require_once "./global.php";
######
$rows="";
function catelist_rows($cateid="0",$level=1) {
global $cachesorts,$rows,$db;
if (isset($cachesorts[$cateid])) {
foreach($cachesorts[$cateid] AS $key => $cats){
$product_amount=$db->get_col("SELECT COUNT(id) FROM product WHERE cateid=$cats[cateid]",0);
$product_amount=empty($product_amount[0])?0:$product_amount[0];
$rows.="
\n";
if($level>1) {
$rows.= str_repeat(" ", $level-1)."\n";
}
$rows.= " ".$cats['catename']." ($product_amount)\n ";
$rows.= "\n |
\n";
catelist_rows($cats['cateid'], $level+1);
}
}
return $rows;
}
######
$cachesorts=cachesorts();
$cates_rows=catelist_rows();
$tpl->assign("cates_rows",$cates_rows);
unset($cachesorts,$cates_rows);
//Total Products
$product_amount=$db->get_col("SELECT COUNT(id) FROM product",0);
$product_amount=$product_amount[0];
$tpl->assign("total",$product_amount);
unset($product_amount);
######
//Newest Products List Data
$qry="SELECT id,name,addtime,image,tradeprice FROM product ORDER BY addtime DESC LIMIT 0,15";
$id=$db->get_col($qry,0);
$name=$db->get_col(null,1);
$addtime=$db->get_col(null,2);
$image=$db->get_col(null,3);
$tradeprice=$db->get_col(null,4);
if(is_array($comments)) foreach($comments as $key=>$result) $comments[$key]=substr($result,0,30);
if(is_array($addtime)) foreach($addtime as $key=>$result) $addtime[$key]=date("m/d/Y",$result);
if(is_array($image)) foreach($image as $key=>$result) {
if($result) resizeimg($product_img_dir.$result,$thumb_dir.$result,75,75);
}
$tpl->assign("N_product_id",$id);
$tpl->assign("N_product_name",$name);
$tpl->assign("N_addtime",$addtime);
$tpl->assign("N_product_image",$image);
$tpl->assign("N_tradeprice",$tradeprice);
unset($id,$cateid,$name,$comments,$addtime,$image,$tradeprice,$result);
//Special Price
$qry="SELECT id,name,specialcost FROM product WHERE specialcost != '0.00' ORDER BY addtime DESC LIMIT 0,$special_qty";
$sp_id=$db->get_col($qry,0);
$sp_name=$db->get_col(null,1);
$sp_price=$db->get_col(null,2);
$tpl->assign("sp_id",$sp_id);
$tpl->assign("sp_name",$sp_name);
$tpl->assign("sp_price",$sp_price);
unset($sp_id,$sp_name,$sp_price);
######
//image banner
$tpl->assign("img","product.jpg");
//ad
right_col(2);
/*
$tpl_vars = $tpl->get_template_vars();
print_rr($tpl_vars);
*/
$output=$tpl->fetch("catelist_,ahp2004.htm");
echo str_replace($tpl_imgdir_name, $tpl->template_dir.$tpl_imgdir_name,$output);
?>