Auto Buyers News:





   Copyright © 2005 Wellingborough England directory | | The Initial Developer of the Original Code is Ruslan R. Fazliev. | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2002 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: categories.php,v 1.43 2002/11/14 07:58:18 zorg Exp $ # # # For users some categories may be disabled # #for increase speed $enable_subcategories_count = $config["General"]["count_products"]=="Y"?1:0; if ($current_area == "C") { $membership_condition = " AND ($sql_tbl[categories].membership='$user_account[membership]' OR $sql_tbl[categories].membership='') "; } else { $membership_condition = ""; } $categories_data = func_query("select $sql_tbl[categories].*, 0 as product_count from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category")); # # Put all categories into $all_categories array and find current_category # by categoryid stored in $cat # if(!$categories_data) $categories_data = array(); $all_categories = $categories_data; foreach($categories_data as $category_data) { if ($category_data["categoryid"]==$cat) { $current_category = $category_data; $current_category["product_count"] = array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[products] WHERE (categoryid=$category_data[categoryid] OR categoryid1=$category_data[categoryid] OR categoryid2=$category_data[categoryid] OR categoryid3=$category_data[categoryid]) and $sql_tbl[products].forsale='Y'")); } } # # Put all root categories to $categories array # Put all subcategories of current_category to $categories array # foreach($all_categories as $all_category) { $category=$all_category["category"]; $cur_dir_len = strlen($current_category["category"]); if(!strstr($category,"/")) { $categories[]=$all_category; if(empty($current_category)) { if($enable_subcategories_count) $all_category["product_count"]=array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[products] WHERE $sql_tbl[products].forsale='Y' and (categoryid='$all_category[categoryid]' OR categoryid1='$all_category[categoryid]' OR categoryid2='$all_category[categoryid]' OR categoryid3='$all_category[categoryid]')")); $subcategories[]=$all_category; } } if(substr($category,0,$cur_dir_len+1) == $current_category["category"]."/" and $category!=$current_category["category"]) if(!strstr(substr($category,$cur_dir_len+1),"/")) { if($enable_subcategories_count) $all_category["product_count"]=array_pop(func_query_first("select count(*) from $sql_tbl[products] where $sql_tbl[products].forsale='Y' and (categoryid='$all_category[categoryid]' OR categoryid1='$all_category[categoryid]' OR categoryid2='$all_category[categoryid]' OR categoryid3='$all_category[categoryid]')")); $all_category["category"]=ereg_replace("^.*/","",$all_category["category"]); $subcategories[]=$all_category; } } # # Put subcategory_count to $subcategories array # if ($subcategories) foreach($subcategories as $key =>$subcategory) { $subcategory["subcategory_count"]=0; foreach($all_categories as $all_category) { if ($all_category["categoryid"]==$subcategory["categoryid"]) { $cur_dir_len = strlen($all_category["category"]); $current_subcategory=$all_category["category"]; } } foreach($all_categories as $all_category) { $category=$all_category["category"]; if(substr($category,0,$cur_dir_len+1) == $current_subcategory."/" and $category!=$current_subcategory) if(!strstr(substr($category,$cur_dir_len+1),"/")) $subcategory["subcategory_count"]++; } $subcategories[$key]["subcategory_count"]=$subcategory["subcategory_count"]; } # # Generate category sequence, i.e. # Books, Books/Poetry, Books/Poetry/Philosophy ... # $current_category_array = explode("/",$current_category["category"]); $prev = $current_category_array[0]; list($key,$val)=each($current_category_array); $new_array = array($val); while(list($key,$val)=each($current_category_array)) { $new_array[] = $prev."/".$val; $prev = $prev."/".$val; } unset($current_category_array); # # Generate array for displaying categories sequence in location # $category_location=array(); reset($all_categories); $my_cats = array (); foreach($all_categories as $all_category) { $categoryid=$all_category["categoryid"]; $category=$all_category["category"]; $my_cats [$categoryid] = $category; } asort ($my_cats); foreach ($my_cats as $categoryid => $category) { reset ($new_array); while(list($key,$val)=each($new_array)) if ($val==$category) $category_location[]=array(ereg_replace(".*/","",$val),"home.php?cat=".$categoryid); } # # Assign Smarty variables # $cat_cnt = func_query("select count(*),categoryid from $sql_tbl[products] group by categoryid order by categoryid"); $n = count($cat_cnt); for($i=0; $i<$n; $i++) { for($j=0; $j=".$date_tod." and "."date<=".$date_tom); $row=mysql_fetch_array($res); $orders_count = $row[0]; $res = mysql_query("select count(*) from xcart_customers where ". "first_login>=".$date_tod." and first_login<=".$date_tom); $row=mysql_fetch_array($res); $users_total = $row[0]; $res = mysql_query("select sum(amount) from xcart_order_details,xcart_orders where ". "date>=".$date_tod." and "."date<=".$date_tom. " and xcart_orders.orderid=xcart_order_details.orderid"); $row=mysql_fetch_array($res); $orders_cds = $row[0]; $current_date = date("d", time()+3*60*60).".".date("m", time()+3*60*60).".".date("Y", time()+3*60*60); ///====================================== $smarty->assign("orders_count",$orders_count); //$smarty->assign("orders_total",$orders_total); $smarty->assign("users_total",$users_total); $smarty->assign("orders_cds",$orders_cds); $smarty->assign("current_date",$current_date); // number of clips $nclips = func_query("SELECT COUNT(*) FROM xcart_clips"); $nclips = $nclips[0][0]; $smarty->assign("nclips",$nclips); ///====================================== $smarty->assign("allcategories",$all_categories); $smarty->assign("categories",$categories); $smarty->assign("subcategories",$subcategories); //$smarty->assign("counts",$counts); $smarty->assign("current_category",$current_category); $smarty->assign("enable_subcategories_count",$enable_subcategories_count); $smarty->assign("cat",$cat); ?>