我是聪明的新手 我正在工作的两个文件是 browse.php
<?php
include ("include/config.php");
if(isset($_GET['offset']))
$offset=$_GET['offset'];
else
$offset=0;
//**** Set limit record per page
$limit=10;
$num=0;
function dateDiff($dformat, $endDate, $beginDate)
{
return mysql_result(mysql_query("SELECT DATEDIFF('$beginDate', '$endDate')"),0,0);
}
if(isset($_GET[show_length]))
$_SESSION[show_length] = $_GET[show_length];
elseif(!isset($_SESSION[show_length]))
$_SESSION[show_length] = 'all';
if(isset($_GET[show_cat]))
$_SESSION[show_cat] = $_GET[show_cat];
elseif(!isset($_SESSION[show_cat]))
$_SESSION[show_cat] = 'all';
if(isset($_GET[show_category]))
$_SESSION[show_category] = $_GET[show_category];
elseif(!isset($_SESSION[show_category]))
$_SESSION[show_category] = 0;
if(isset($_GET[qry])) { //echo $_GET[qry];
$_SESSION[show_category] = 0;
$_SESSION[show_cat] = 'all';
$_SESSION[show_length] = 'all';
}
$category = '';
if($_SESSION[show_category] != 0)
$category = ' and pi.catid='.$_SESSION[show_category];
$param = " where ";
if ($_SESSION[show_cat] == 'txt_ad')
$param .= " p.ad_type like '%txt_ad' ";
if ($_SESSION['show_cat'] == 'PicText_ad')
$param .= " p.ad_type like '%PicText_ad' ";
elseif ($_SESSION[show_cat] == 'img_ad')
$param .= " p.ad_type like '%img_ad' ";
elseif ($_SESSION[show_cat] == 'peel_ad')
$param .= " p.ad_type like '%peel_ad' ";
elseif ($_SESSION[show_cat] == 'splash_ad')
$param .= " p.ad_type like '%splash_ad' ";
elseif ($_SESSION[show_cat] == 'pop_ad')
$param .= " p.ad_type like '%pop_ad' ";
elseif ($_SESSION[show_cat] == 'vdo_ad')
$param .= " p.ad_type like '%vdo_ad' ";
elseif ($_SESSION[show_cat] == 'pop_under')
$param .= " p.ad_type='pop_under' ";
elseif ($_SESSION[show_cat] == 'pop_up')
$param .= " p.ad_type='pop_up' ";
elseif ($_SESSION[show_cat] == 'full_page')
$param .= " p.ad_type='full_page' ";
elseif ($_SESSION[show_cat] == 'all')
$param .= " p.ad_type<>'inline' AND p.ad_type<>'invideo' ";
if($_SESSION['show_length'] == 'ppc' || $_SESSION['show_length'] == 'ppm'){
if($_SESSION[show_length] == 'ppc'){
$param .= " and p.length='0' and p.ad_type like 'ppc_%' ";
} else $param .= " and p.length='0' and p.ad_type like 'ppm_%' ";
}
elseif ($_SESSION[show_length] != 'all')
$param .= " and p.length='$_SESSION[show_length]' ";
$search = '';
if(isset($_GET[qry]))
$search = " and (pi.keywords like '%$_GET[qry]%' or pi.websitename like '%$_GET[qry]%') ";
$inqry = " select distinct p.pid, p.uid from publishers_adspaces p $param ";
//echo $inqry;
$inq = mysql_query($inqry);
$in_array = array();
while ($inr = mysql_fetch_assoc($inq)){
$get_suspended_uid = mysql_result(mysql_query("select status from users where uid = '$inr[uid]' limit 1 "),0,0);
if($get_suspended_uid == 0) continue;
$in_array[] = $inr[pid];
}
$in_arr_str = implode(',', $in_array);
$ws_qry = "select distinct t.pid, t.member_since, t.websitename, t.url, t.distinct_hits, t.google_page_rank, t.alexa_rank from (
select pi.* from publishersinfo pi inner join publishers_adspaces pa on pi.pid=pa.pid where pi.pid in ($in_arr_str) and pi.status = '1' $category $search order by ad_id desc)
as t";
//echo $ws_qry;
$num = mysql_num_rows(mysql_query($ws_qry));
$ws = mysql_query("$ws_qry limit $offset, $limit");
while($row = @mysql_fetch_assoc($ws)){
$a_cpc = mysql_result(mysql_query("select round(avg(cost),2) from publishers_adspaces where pid='$row[pid]' and length=0"),0,0);
$def_len = $_SESSION[show_length];
$def_ad_type = $_SESSION[show_cat];
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='txt_ad') $def_ad_type = 'ppc_txt_ad';
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='PicText_ad') $def_ad_type = 'ppc_PicText_ad';
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='img_ad') $def_ad_type = 'ppc_img_ad';
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='peel_ad') $def_ad_type = 'ppc_peel_ad';
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='splash_ad') $def_ad_type = 'ppc_splash_ad';
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='pop_ad') $def_ad_type = 'ppc_pop_ad';
if($def_len == 0 && $def_len != 'all' && $def_ad_type=='vdo_ad') $def_ad_type = 'ppc_vdo_ad';
if($_SESSION[show_cat] == 'pop_under') {$def_len = 0; $def_ad_type = 'pop_under';}
if($_SESSION[show_cat] == 'pop_up') {$def_len = 0; $def_ad_type = 'pop_up';}
if($_SESSION[show_cat] == 'full_page') {$def_len = 0; $def_ad_type = 'full_page';}
if(($def_ad_type == 'all') && ($def_len == 'all'))
$cst = mysql_result(mysql_query("select round(min(cost),3) from publishers_adspaces where pid='$row[pid]' "),0,0);
elseif($def_ad_type == 'all')
$cst = mysql_result(mysql_query("select round(min(cost),3) from publishers_adspaces where pid='$row[pid]' and length='$def_len' "),0,0);
elseif($def_len == 'all')
$cst = mysql_result(mysql_query("select round(min(cost),3) from publishers_adspaces where pid='$row[pid]' and ad_type like '%$def_ad_type'"),0,0);
else
$cst = mysql_result(mysql_query("select round(min(cost),3) from publishers_adspaces where pid='$row[pid]' and length='$def_len' and ad_type='$def_ad_type'"),0,0);
// $cst = mysql_result(mysql_query("select round(min(cost),3) from publishers_adspaces where pid='$row[pid]' "),0,0);
$T = ''; $I = ''; $V = ''; $P = ''; $F = ''; $PU = ''; $S = ''; $PA = ''; $PEEL = ''; $PT = '';
$txt = mysql_result(mysql_query("select count(*) from publishers_adspaces where ad_type like '%txt_ad' and pid='$row[pid]' "),0,0);
if ($txt) $T = 'T';
$PicText = mysql_result(mysql_query("select count(*) from publishers_adspaces where ad_type like '%PicText_ad' and pid='$row[pid]' "),0,0);
if ($PicText) $PT = 'PT';
$img = mysql_result(mysql_query("select count(*) from publishers_adspaces where ad_type like '%img_ad' and pid='$row[pid]' "),0,0);
if ($img) $I = 'I';
$peel = mysql_result(mysql_query("select count(*) from publishers_adspaces where ad_type like '%peel_ad' and pid='$row[pid]' "),0,0);
if ($peel) $PEEL = 'PEEL';
$splash = mysql_result(mysql_query("select count(*) from publishers_adspaces where ad_type like '%splash_ad' and pid='$row[pid]' "),0,0);
if ($splash) $S = 'S';
$pop = mysql_result(mysql_query("select count(*) from publishers_adspaces where ad_type like '%pop_ad' and pid='$row[pid]' "),0,0);
if ($pop) $PA = 'PA';
$vdo = mysql_result(mysql_query("select count(*) from publishers_adspaces where (ad_type='vdo_ad' or ad_type like '%_vdo_ad') and pid='$row[pid]' "),0,0);
if ($vdo) $V = 'V';
$popunder = mysql_result(mysql_query("select count(*) from publishers_adspaces where (ad_type='pop_under') and pid='$row[pid]' "),0,0);
if ($popunder) $P = 'P';
$popup = mysql_result(mysql_query("select count(*) from publishers_adspaces where (ad_type='pop_up') and pid='$row[pid]' "),0,0);
if ($popup) $PU = 'PU';
$fullpage = mysql_result(mysql_query("select count(*) from publishers_adspaces where (ad_type='full_page') and pid='$row[pid]' "),0,0);
if ($fullpage) $F = 'F';
// $max_u = mysql_result(mysql_query("SELECT count(distinct ip) as total from hits where pub_id='$row[pid]' group by date order by total desc limit 1"),0,0);
$date_now = date("Y-m-d");
$reg_date = $row[member_since];
$diff = dateDiff("-", $date_now, $reg_date);
if($diff <= 0) $diff = 1;
//$max_u_u = mysql_result(mysql_query("SELECT count(distinct ip) as total from hits where pub_id='$row[pid]' group by date order by total desc limit 1"),0,0); // live
$max_u_u = $row['distinct_hits']; // NOT live
$upvpd = round(($max_u_u / $diff),2);
// if($upvpd >= 1) $upvpd = round($upvpd);
if($upvpd == 0) $upvpd = "";
$realPath = dirname(__FILE__);
$thumbPath = $realPath.'/wwwThumb/thumb_'.$row[pid].'_pic.jpg';
if(file_exists($thumbPath) && filesize($thumbPath) > 0)
$fileName = 'thumb_'.$row[pid].'_pic.jpg';
else
$fileName = 'nothumb.jpg';
$c[] = array ('pid' => $row[pid], 'wname' => $row['websitename'], 'alexa' => $row['alexa_rank'], 'gpr' => $row['google_page_rank'], 'url' => $row['url'], 'thumb' => $fileName, 'daily_users' => $upvpd, 'cpc' => $a_cpc, 'cost' => $cst, 'T' => $T, 'I' => $I, 'V' => $V, 'P' => $P, 'F' => $F, 'PU' => $PU, 'PT' => $PT, 'PA' => $PA, 'S' => $S, 'PEEL' => $PEEL );
// print_r($c);
}
$smarty->assign('winfo', $c);
// Pagination
$TblPagignationClass = new TblPagignationClass('Previous','Next',$limit);
$TblPagignationClass->SetOffset($offset) ;
$TblPagignationClass->SetNumofRows($num) ;
$TblPagignationClass->SetFileName($_SERVER['PHP_SELF']) ;
//$TblPagignationClass->SetIdentifierVariable("orderby=picture_id") ;
$Template_Pagignation_Data=$TblPagignationClass->CreatePagignationData() ;
$smarty->assign('Template_Pagignation_Data', $Template_Pagignation_Data);
$offset=1;
$smarty->assign('offset', $offset);
//
$smarty->assign('cat_menu', get_list('category', 'category'));
$m1 = mysql_result(mysql_query("select max(length) from textad"),0,0);
$m2 = mysql_result(mysql_query("select max(length) from imagead"),0,0);
$m3 = mysql_result(mysql_query("select max(length) from videoad"),0,0);
$max_length = max($m1,$m2,$m3);
for ($i=1; $i<=$max_length; $i++)
$lens[$i] = $i.' Day Ads';
$smarty->assign('len_menu', $lens);
$smarty->assign('right_panel', 'off');
$content = $smarty->fetch('browse.tpl');
$smarty->assign('content',$content);
$smarty->display('master_page.tpl');
?>
和 browse.tpl
<h1>{$_lang.Browse_Websites_To_Advertise_On}</h1>
<div class="types">Types of ads we currently support:
{if $_config.text_ad == 'on'}
<img src="{$template_dir}/images/text_ad.png" alt="{$_lang.Text_Ads}" width="16" height="16" align="absmiddle" /> - {$_lang.Text_Ads}
{/if}
{if $_config.image_ad == 'on'}
<br />
<img src="{$template_dir}/images/img_ad.png" alt="{$_lang.Image_Ads}" width="16" height="16" align="absmiddle" /> - {$_lang.Image_Ads}
{/if}</div><!--types -->
<p>Feel free to browse through our marketplace. You can list the sites based on their categories and types of ads the owners are selling.</p>
<div class="clearfix"></div>
<div class="liner"></div>
<div class="browsing">
<select name="show_category" onchange="javascript: if(this.value != '-1') window.location=location.pathname+'?show_category='+this.value;">
<option value="-1">{$_lang.Choose_Category}</option>
<option value="0">-- {$_lang.All} --</option>
{html_options values=$cat_menu.cid output=$cat_menu.category selected=$smarty.session.show_category}
</select>
<span class="choose">
{if $smarty.session.show_length != 'ppc'}<a href="?show_length=ppc">{/if}Pay-Per-Click Ads{if $smarty.session.show_length != 'ppc'}</a>{/if}
{if $smarty.session.show_length != 'ppm'}<a href="?show_length=ppm">{/if}PPM Ads{if $smarty.session.show_length != 'ppm'}</a>{/if}
{if $smarty.session.show_length != 'all'}<a href="?show_length=all">{/if}{$_lang.Show_All}{if $smarty.session.show_length != 'all'}</a>{/if}
</span>
<span class="choose">
{$_lang.Only_Show}: {if $_config.text_ad == 'on'}{if $smarty.session.show_cat != 'txt_ad'}<a href="?show_cat=txt_ad">{/if}{$_lang.Text_Ads}{if $smarty.session.show_cat != 'txt_ad'}</a>{/if}{/if}
{if $_config.image_ad == 'on'}{if $smarty.session.show_cat != 'img_ad'}<a href="?show_cat=img_ad">{/if}{$_lang.Image_Ads}{if $smarty.session.show_cat != 'img_ad'}</a>{/if}{/if}
{if $smarty.session.show_cat != 'all'}<a href="?show_cat=all">{/if}{$_lang.Show_All}{if $smarty.session.show_cat != 'all'}</a> {/if}
</span>
</div><!-- browsing -->
<div class="liner"></div>
{section name=num loop=$winfo}
<div class="website">
<div class="my-image">
<img src='http://www.bitpixels.com/getthumbnail?code=63848&size=100&url={$winfo[num].url}'/><!--<img src="wwwThumb/{$winfo[num].thumb}" alt="{$winfo[num].wname}" width="60" height="44" />-->
</div>
<div class="adcost">
<strong>{$_lang.Ad_Cost}:</strong> {$CURRENCY}{$winfo[num].cost|string_format:"%.2f"}
<div class="details"><a href="website_page.php?pid={$winfo[num].pid}">{$_lang.More_Info}</a></div>
</div><!--adcost -->
<div class="site-name">
<a href="website_page.php?pid={$winfo[num].pid}">{$winfo[num].wname}</a>
{if $winfo[num].T == 'T'} <img src="{$template_dir}/images/text_ad.png" alt="{$_lang.Text_Ads}" width="16" height="16" align="absmiddle" /> {/if}
{if $winfo[num].I == 'I'} <img src="{$template_dir}/images/img_ad.png" alt="{$_lang.Image_Ads}" width="16" height="16" align="absmiddle" /> {/if}
</div>
<strong>{$_lang.Daily_Unique_Users}:</strong> {if $winfo[num].daily_users == ""}{$_lang.no_data}{else}{$winfo[num].daily_users}{/if}<br/>
<strong>Google Page Rank: </strong> {if $winfo[num].gpr == ""}{$_lang.no_data}{else}{$winfo[num].gpr}{/if}<br/>
<strong>Alexa Rank: </strong> {if $winfo[num].alexa == ""}{$_lang.no_data}{else}{$winfo[num].alexa}{/if}
</div><!-- website -->
{/section}
{$Template_Pagignation_Data}
<div class="liner"></div>
<div class="my-tips">
{$TIP}
</div>
和config.php
<?php
error_reporting(1);
session_start();
ob_start();
error_reporting(0);
$_config = array();
$abs_path = dirname(dirname(__FILE__));
require_once($abs_path . "/include/class.sanitize.php");
require_once($abs_path . "/include/db_connection.php");
require_once($abs_path . "/include/libs/Smarty.class.php");
include($abs_path . "/include/functions.php");
require_once($abs_path . "/include/pagination.php");
$smarty = new Smarty;
if($admin_page == 'Y')
{
$smarty->assign('sel_tmp', $_config['template'] );
$_config['template'] = 'default';
}
$smarty->template_dir = 'templates/'.$_config['template'].'/';
$smarty->compile_dir = 'templates_c/';
$smarty->config_dir = 'configs/';
$smarty->cache_dir = 'cache/';
//$smarty->caching = true;
//$smarty->cache_lifetime = 3600;
$smarty->compile_check = true; //
$smarty->debugging = false; //
$smarty->error_reporting = false;
if(isset($_SESSION['uid'], $_SESSION['lang'])){
if(isset($_POST['mylang'])){
mysql_query("UPDATE users SET lang = '$_POST[mylang]' WHERE uid = '$_SESSION[uid]' ") or die(mysql_error());
$_SESSION['lang'] = $_POST['mylang'];
}
if($_SESSION['lang'] == '') $_SESSION['lang'] = 'English';
$_config['lang'] = $_SESSION['lang'];
}
//die($_config['lang']);
$lang_file = $abs_path . '/include/lang/'.$_config[lang].'.php';
include($lang_file);
$smarty->assign('_lang',$_lang);
$lang_files = array();
if ($handle = opendir($abs_path . '/include/lang/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$lang_files[] = substr($file, 0, -4);
}
}
closedir($handle);
}
$smarty->assign('lang_files', $lang_files);
$smarty->assign('template_dir','templates/'.$_config['template']);
$smarty->assign('CURRENCY',$_config['currency']);
$smarty->assign('_config',$_config);
$scfn = $_SERVER['SCRIPT_FILENAME'];
$t = explode('/', $scfn );
$cp = $t[count($t)-1];
$smarty->assign('cp',$cp);
$tip = mysql_result(mysql_query("select tip from tips order by rand() limit 1"),0,0);
$TIP = '<p align="left" class="post-footer align-left" style="margin-bottom: 10px;">
<span class="tips_body">
<span class="tips">'.$_config[website_name].' '.$_lang[Tip].':</span>
<span id="tips_text">'.
stripslashes($tip);
'</span>
</span>
</p>';
$smarty->assign('TIP',$TIP);
/// Top sites ///
$top_sites_alexa = mysql_query("select distinct publishersinfo.* from publishersinfo, publishers_adspaces, users where publishersinfo.alexa_rank>0 and publishersinfo.status = '1' and publishers_adspaces.pid = publishersinfo.pid and users.status = '1' and users.uid = publishersinfo.uid
order by publishersinfo.alexa_rank limit 5");
$top_sites_gpr = mysql_query("select distinct publishersinfo.* from publishersinfo, publishers_adspaces, users where publishersinfo.google_page_rank>0 and publishersinfo.status = '1' and publishers_adspaces.pid = publishersinfo.pid and users.status = '1' and users.uid = publishersinfo.uid
order by publishersinfo.google_page_rank desc limit 5");
while ($alexa_row = mysql_fetch_assoc($top_sites_alexa)) {
$a[] = array('pid' => $alexa_row['pid'], 'wname' => $alexa_row['websitename'], 'a_rank' => $alexa_row['alexa_rank']);
}
while ($gpr_row = mysql_fetch_assoc($top_sites_gpr)) {
$g[] = array('pid' => $gpr_row['pid'], 'wname' => $gpr_row['websitename'], 'g_rank' => $gpr_row['google_page_rank']);
}
$smarty->assign('alexa_top', $a);
$smarty->assign('google_top', $g);
ob_end_clean();
?>
现在的问题是如何从数据库中提取类别并输出到下拉菜单?
<select name="show_category" onchange="javascript: if(this.value != '-1') window.location=location.pathname+'?show_category='+this.value;">
<option value="-1">{$_lang.Choose_Category}</option>
<option value="0">-- {$_lang.All} --</option>
{html_options values=$cat_menu.cid output=$cat_menu.category selected=$smarty.session.show_category}
</select>
在browse.php中的我看到以下代码,其中cat_menu是asigned
$smarty->assign('cat_menu', get_list('category', 'category'));
但我找不到get_list函数。
我需要有关如何从数据库中提取类别信息的帮助
由于
答案 0 :(得分:1)
我很确定该功能在你的config.php文件中。因此include(“include / config.php”);
答案 1 :(得分:0)
只是一个猜测:因为“get_list”是一个函数,你可以看一下config.php包含的“/include/functions.php”;)