$now GROUP BY business_id ORDER BY `num` DESC LIMIT 0 , 1";
$rc=mysql_query($query);
$row=mysql_fetch_array($rc);
$rc=mysql_query("select * from `business` where business_id='$row[business_id]' and `approved`=1 limit 0,1");
$row=mysql_fetch_array($rc);
$var_hotbusiness['picurl']= 'b_'.$row['photo_url'];
$var_hotbusiness['bizname']=utf_substr($row['business_name'],25);
if($row['starbiz']) $var_hotbusiness['starbiz']="";
$var_hotbusiness['ratingmod']=get_rating_img($row['rating']);
$var_hotbusiness['catid']=$row['cat_id'];
$var_hotbusiness['catname']=get_biz_cat_translated($row['cat_id']);
$var_hotbusiness['catpermalink']=get_biz_cat_permalink($row['cat_id']);
$var_hotbusiness['subcatid']=$row['sub_cat_id'];
$var_hotbusiness['subcatname']=get_biz_subcat_translated($row['sub_cat_id']);
$var_hotbusiness['subcatpermalink']=get_biz_subcat_permalink($row['sub_cat_id']);
$var_hotbusiness['catid2']=$row['cat_id2'];
$var_hotbusiness['catname2']=get_biz_cat_translated($row['cat_id2']);
$var_hotbusiness['cat2permalink']=get_biz_cat_permalink($row['cat_id2']);
$var_hotbusiness['subcatid2']=$row['sub_cat_id2'];
$var_hotbusiness['subcatname2']=get_biz_subcat_translated($row['sub_cat_id2']);
$var_hotbusiness['subcat2permalink']=get_biz_subcat_permalink($row['sub_cat_id2']);
$var_hotbusiness['catid3']=$row['cat_id3'];
$var_hotbusiness['catname3']=get_biz_cat_translated($row['cat_id3']);
$var_hotbusiness['cat3permalink']=get_biz_cat_permalink($row['cat_id3']);
$var_hotbusiness['subcatid3']=$row['sub_cat_id3'];
$var_hotbusiness['subcatname3']=get_biz_subcat_translated($row['sub_cat_id3']);
$var_hotbusiness['subcat3permalink']=get_biz_subcat_permalink($row['sub_cat_id3']);
$var_hotbusiness['add1']=utf_substr($row['business_add1'],50);
$var_hotbusiness['add2']=utf_substr($row['business_add2'],25);
$var_hotbusiness['phone']=utf_substr($row['business_phone'],20);
$var_hotbusiness['bizurl']=advanced_biz_name($row['business_id']);
if(!biz_existed($row[business_id])) unset($var_hotbusiness);
/////1-2 OTHER HOT BUSINESS
$rc="SELECT count( * ) AS num, business_id FROM bookmark where 1=1 and bookmark_date>$now GROUP BY business_id ORDER BY `num` DESC LIMIT 1 , 6";
$rc=mysql_query($rc);
while($row=mysql_fetch_array($rc))
{
$krc=mysql_query("select * from `business` where business_id='$row[business_id]' and `approved`=1 limit 0,1");
$krow=mysql_fetch_array($krc);
if(biz_existed($krow[business_id]))
$var_hotbusiness['otherhotbusiness_li'].='
'.utf_substr($krow[business_name],20).'';
}
///2-1 BEST OF
$rc = mysql_query("SELECT count( * ) AS num, r.cat_id as cat_id, c.cat_name as cat_name FROM business_category as c , business_reviews as r where c.cat_id=r.cat_id GROUP BY r.cat_id ORDER BY `num` DESC LIMIT 0 , 4 ");
$k=0;
$var_bestof=array();
while($row=mysql_fetch_array($rc))
{
$k+=1;
$var_bestof[$k]['catid']=$cur_cat=$row['cat_id']; //current cat id
$var_bestof[$k]['reviewnum']=$row['num'];//current num
$var_bestof[$k]['catname']=l($row['cat_name']);
$var_bestof[$k]['catpermalink']=get_biz_cat_permalink($row['cat_id']);
//curr cat TOP 5 biz
// comment top 10 then rating top 5
$inrc = mysql_query("SELECT * FROM `business` where cat_id='$cur_cat' and `approved`=1 ORDER BY `reviews_num` DESC, `rating` DESC limit 0,10 ");
$i=0;
while($inrow=mysql_fetch_array($inrc))
{
$i+=1;
$b_rating[$i]=$inrow[rating];
$b_id[$i]=$inrow[business_id];
$b_name[$i]=$inrow[business_name];
$b_photo_url[$i]=$inrow[photo_url];
}
// sort by review number, then now order by rating in the top 10
for($s=1; $s<=($i-1);$s++)
{
for($j=($s+1); $j<=$i; $j++)
{
if($b_rating[$s]<$b_rating[$j])
{
$temp_rating=$b_rating[$s];
$temp_id=$b_id[$s];
$temp_name=$b_name[$s];
$temp_photo_url=$b_photo_url[$s];
$b_rating[$s]=$b_rating[$j];
$b_id[$s]=$b_id[$j];
$b_name[$s]=$b_name[$j];
$b_photo_url[$s]=$b_photo_url[$j];
$b_rating[$j]=$temp_rating;
$b_id[$j]=$temp_id;
$b_name[$j]=$temp_name;
$b_photo_url[$j]=$temp_photo_url;
}
}
}
$var_bestof[$k]['picurl']='b_'.$b_photo_url[1]; // top 1 biz's pic as the category's
for($i=1;$i<=5;$i++)
{$var_bestof[$k]['bizli'].=" ".utf_substr($b_name[$i],15)."";
unset($b_rating[$i]); unset($b_id[$i]); unset($b_name[$i]);
}
}
// 2-2 CATEGORIES
//////////////////////get biz cat list//////
function get_biz_cat_list($path)
{
$rc = mysql_query("select * from `business_category` ORDER BY `cat_name` ASC");
while($row=mysql_fetch_array($rc))
{
$displayName=l($row[cat_name]);
$t.= "";
//$t.= "";
$t.= "$displayName";
$t.= "";
}
return $t;
}
$var_category_li= get_biz_cat_list("./"); // between ul and /ul
// 3-1 TOP EVENTS
////not end ////if no end time, not end
$now=date(YmdHis);
$query="select * from `event` where (date_to>=$now or date_from>=$now) and `approved`=1 ORDER BY `reviews_num` DESC LIMIT 0 , 4";
$up=mysql_query($query) ;
$i=0;
$var_topevents=array();
while($row=mysql_fetch_array($up))
{
$var_topevents[$i]['picurl']=$row['photo_url'];
$var_topevents[$i]['id']=$row['id'];
$var_topevents[$i]['name']=utf_substr($row['event_name'],23);
$var_topevents[$i]['time']=event_time($row['date_from'],$row['date_to']);
$i+=1;
}
// 3-1 TOP PRODUCTS
$top_prod_query = mysql_query("
SELECT DISTINCT p.product_name, p.photo_url, p.product_id, p.rating, p.reviews_num
FROM `product` AS p
WHERE p.approved=1
ORDER BY CAST(`rating` AS DECIMAL(10,2)) DESC, `reviews_num` DESC, `product_id` DESC
LIMIT 0 , 4");
$i=0;
$var_top_products=array();
while($row=mysql_fetch_array($top_prod_query))
{
if($row['starbiz']) $var_top_products[$i]['starbiz']="";
$var_top_products[$i]['picurl'] = 'b_'.$row['photo_url'];
$var_top_products[$i]['name'] = $row['product_name'];
$var_top_products[$i]['url'] = advanced_prodz_name($row['product_id']);
$var_top_products[$i]['ratingmod'] = get_rating_img($row['rating']);
$i+=1;
}
// 4-1 RECENT PRODUCT REVIEWS
$recent_prod_query = mysql_query("
SELECT * FROM `product_reviews` AS pr ,`product` AS p WHERE pr.product_id=p.product_id AND p.approved=1
ORDER BY `review_date` DESC LIMIT 0 , 4");
$i=0;
$var_recent_products=array();
while($row=mysql_fetch_array($recent_prod_query))
{
if($row['starbiz']) $var_recent_products[$i]['starbiz']="";
$var_recent_products[$i]['picurl']='b_'.$row['photo_url'];
$var_recent_products[$i]['name']=$row[product_name];
$var_recent_products[$i]['url']=advanced_prodz_name($row[product_id]);
$var_recent_products[$i]['ratingmod']=get_rating_img($row['rating']);
$var_recent_products[$i]['reviewdate']=turn_date($row[review_date],ftimeordate);
$var_recent_products[$i]['reviewdesc']=utf_substr(str_replace("
"," ",$row[review_desc]),70);
$i+=1;
}
// 4-1 RECENT BUSINESS REVIEWS
$recent_biz_query = mysql_query("
SELECT * FROM `business_reviews` AS pr ,`business` AS p WHERE pr.business_id=p.business_id AND p.approved=1
ORDER BY `review_date` DESC LIMIT 0 , 4");
$i=0;
$var_recent_business=array();
while($row=mysql_fetch_array($recent_biz_query))
{
if($row['starbiz']) $var_recent_business[$i]['starbiz']="";
$var_recent_business[$i]['picurl']='b_'.$row['photo_url'];
if (!$row['photo_url']){
$var_recent_business[$i]['picurl'] = 'home_no_img';
}
$var_recent_business[$i]['name']=$row[business_name];
$var_recent_business[$i]['url']=advanced_biz_name($row[business_id]);
$var_recent_business[$i]['ratingmod']=get_rating_img($row['rating']);
$var_recent_business[$i]['reviewdate']=turn_date($row[review_date],ftimeordate);
$var_recent_business[$i]['reviewdesc']=utf_substr(str_replace("
"," ",$row[review_desc]),70);
$i+=1;
}
// 4-1 Popular Events This Week
$now=date(Ymd);
$wd=date(N);
$nowf=$now-($wd-1);
$nowt=$now+(7-$wd);
$nowF=$nowf."000000";
$nowT=$nowt."240000";
$up=mysql_query("select * from `event` where ((date_from>='$nowF' and date_from<='$nowT') or (date_to>='$nowF' and date_to<='$nowT') or (date_from<='$nowF' and date_to>='$nowT')) and `approved`=1 ORDER BY `reviews_num` DESC LIMIT 0 , 6");
$i=0;
$var_popevents=array();
while($row=mysql_fetch_array($up))
{
$var_popevents[$i]['picurl']=$row['photo_url'];
$var_popevents[$i]['id']=$row['id'];
$var_popevents[$i]['name']=utf_substr($row['event_name'],50);
$var_popevents[$i]['time']=event_time($row['date_from'],$row['date_to']);
$i+=1;
}
/////////////////////////////////RIGHT//////////////////////////////////////////////
//6-1 Latest Reviewer
$query=mysql_query("SELECT distinct user_id FROM `business_reviews` ORDER BY `review_date` DESC limit 2");
$i=0;
$var_lastreviewer=array();
while($row=mysql_fetch_array($query))
{
$var_lastreviewer[$i]['uid']=$user_id=$row['user_id'];
$var_lastreviewer[$i]['picurl']=get_user_data(photo_url,$user_id);
$var_lastreviewer[$i]['name']=get_user_data(nameORemail,$user_id);
$var_lastreviewer[$i]['fb_user_id']=get_user_data(fb_user,$user_id);
$var_lastreviewer[$i]['location']=get_city_name(get_user_data(city,$user_id));
$var_lastreviewer[$i]['regdate']=turn_date(get_user_data('reg_date',$user_id),fdate);
if(!user_existed($user_id))
unset($var_lastreviewer[$i]);
else
$i+=1;
}
//7-1 Hot Business - the most reviewed business in past 7 days
$nowF=date(Ymd)-7;
$nowF.="000000";
$query="SELECT count( * ) AS num, business_id FROM business_reviews WHERE review_date >$nowF and 1=1 GROUP BY business_id ORDER BY `num` DESC LIMIT 0 , 1";
$row=mysql_fetch_array(mysql_query($query));
$var_hotbiz['reviewnumrecent']=$row['num']; // reviews number in 7 days
$queryin="SELECT * FROM business WHERE business_id=$row[business_id] and `approved`=1 LIMIT 0 , 1";
if(!empty($row[business_id]))// or produce an error
{
$row=mysql_fetch_array(mysql_query($queryin));
$var_hotbiz['bizurl']=advanced_biz_name($row['business_id']);
if($row['starbiz']) $var_hotbiz['starbiz']="";
$var_hotbiz['picurl']='b_'.$row['photo_url'];
$var_hotbiz['bizname']=utf_substr($row['business_name'],25);
$var_hotbiz['ratingmod']=get_rating_img($row['rating']);
$var_hotbiz['catid']=$row['cat_id'];
$var_hotbiz['catname']=get_biz_cat_translated($row['cat_id']);
$var_hotbiz['catpermalink']=get_biz_cat_permalink($row['cat_id']);
$var_hotbiz['subcatid']=$row['sub_cat_id'];
$var_hotbiz['subcatname']=get_biz_subcat_translated($row['sub_cat_id']);
$var_hotbiz['subcatpermalink']=get_biz_subcat_permalink($row['sub_cat_id']);
$var_hotbiz['catid2']=$row['cat_id2'];
$var_hotbiz['catname2']=get_biz_cat_translated($row['cat_id2']);
$var_hotbiz['cat2permalink']=get_biz_cat_permalink($row['cat_id2']);
$var_hotbiz['subcatid2']=$row['sub_cat_id2'];
$var_hotbiz['subcatname2']=get_biz_subcat_translated($row['sub_cat_id2']);
$var_hotbiz['subcat2permalink']=get_biz_subcat_permalink($row['sub_cat_id2']);
$var_hotbiz['catid3']=$row['cat_id3'];
$var_hotbiz['catname3']=get_biz_cat_translated($row['cat_id3']);
$var_hotbiz['cat3permalink']=get_biz_cat_permalink($row['cat_id3']);
$var_hotbiz['subcatid3']=$row['sub_cat_id3'];
$var_hotbiz['subcatname3']=get_biz_subcat_translated($row['sub_cat_id3']);
$var_hotbiz['subcat3permalink']=get_biz_subcat_permalink($row['sub_cat_id3']);
$var_hotbiz['add1']=utf_substr($row['business_add1'],50);
$var_hotbiz['add2']=utf_substr($row['business_add2'],25);
$var_hotbiz['phone']=utf_substr($row['business_phone'],20);
$var_hotbiz['zip']=$row[zip]!=0?$row[zip]:"";
$var_hotbiz['location']=get_city_name($row[city_id]);
$var_hotbiz['reviewnum']=$row[reviews_num];
$var_hotbiz['click']=$row[click];
}
//8-0 New Special Offers
$offerObj= new MP_SpecialOffers();
$offerObj->displayNum=3;
$offerObj->offset=0;
$rows=0;
$pagerows=0;
$var_newoffers=$offerObj->getList($rows,$pagerows);
//8-1 New Lists
$query=mysql_query("SELECT * FROM `list` ORDER BY `id` DESC limit 0,5");
$i=0;
$var_newlists=array();
while($row=mysql_fetch_array($query))
{
$tempquery=mysql_query("SELECT * FROM `list_item` where list_id='$row[id]' limit 1 ") ;
$inrow=mysql_fetch_array($tempquery);
$tempquery=mysql_query("SELECT * FROM `business` where business_id='$inrow[business_id]' and `approved`=1 limit 1 ") ;
$inrow=mysql_fetch_array($tempquery);
$var_newlists[$i]['picurl']=get_user_data(photo_url,$row[user_id]);
$var_newlists[$i]['uid']=$row[user_id];
$var_newlists[$i]['id']=$row[id];
$var_newlists[$i]['name']=utf_substr($row[list_name],30);
$var_newlists[$i]['desc']=utf_substr($row[list_desc],50);
$i+=1;
}
//9-1 New Forums
$rc = mysql_query("SELECT * FROM `talk` ORDER BY `reply_time` DESC LIMIT 0 , 5 ");
$i=0;
$var_newchatters=array();
while($row=mysql_fetch_array($rc))
{
$var_newchatters[$i]['uid']=$user_id=$row['user_id'];
$var_newchatters[$i]['picurl']=get_user_data(photo_url,$user_id);
$var_newchatters[$i]['uname']=get_user_data(nameORemail,$user_id);
$var_newchatters[$i]['replytime']=turn_date($row[reply_time],ftimeordate);
$var_newchatters[$i]['tid']=$row[topic_id];
$var_newchatters[$i]['tname']=utf_substr($row[topic_name],25);
$i+=1;
}
//$var_otherhotbusiness['li']=$var_hotbusiness['otherhotbusiness_li']; // FIX 2.1 sp1
$smarty->assign("page_title",$page_title);
$smarty->assign("var_hotbusiness",$var_hotbusiness); //arr
//$smarty->assign("var_otherhotbusiness",$var_otherhotbusiness); //FIX 2.1 sp1
$smarty->assign("var_bestof",$var_bestof); //arr
$smarty->assign("var_top_products",$var_top_products); //arr
$smarty->assign("var_recent_products",$var_recent_products); //arr
$smarty->assign("var_recent_business",$var_recent_business); //arr
$smarty->assign("var_category_li",$var_category_li);
$smarty->assign("var_topevents",$var_topevents); //arr
$smarty->assign("var_popevents",$var_popevents); //arr
$smarty->assign("var_lastreviewer",$var_lastreviewer); //arr
$smarty->assign("var_hotbiz",$var_hotbiz); //arr
$smarty->assign("var_newoffers",$var_newoffers); //arr
$smarty->assign("var_newlists",$var_newlists); //arr
$smarty->assign("var_newchatters",$var_newchatters); //arr
$smarty->display('index.tpl');
?>