<?
session_start();
error_reporting(0);
include_once 'comm/config.php';
include_once 'comm/Taoapi.php';
include_once 'comm/page.class.php';
include_once 'comm/checkpostandget.php';
$cid=$_GET['cid'];
$start_level=$_GET['start_level'];
$end_level=$_GET['end_level'];
$keyword=trim($_GET['keyword']);

$area=$_GET['area'];
$cpr=$_GET['cpr'];
$type=$_GET['type'];
$px=$_GET['px'];
$subsql='1=1';

if($cid!=''){
	$arrcid=preg_split("/[,]/", $cid);
	$subsql="(";
	for($i=0;$i<count($arrcid);$i++)
	{
		if($i==(count($arrcid)-1)){
			$subsql=$subsql." cid='".$arrcid[$i]."'";
		}else{
			$subsql=$subsql." cid='".$arrcid[$i]."' or ";
		}
	}
	$subsql=$subsql.")";
}

if($start_level!=''&&$end_level=='')
{
	$startlevel=$start_level;
	$endlevel=20;
}elseif($start_level==''&&$end_level!='')
{
	$startlevel=1;
	$endlevel=$end_level;
}
else
{
	$startlevel=$start_level;
	$endlevel=$end_level;
}
if($startlevel>$endlevel)
{
	$temp=$startlevel;
	$startlevel=$endlevel;
	$endlevel=$temp;
}

if($startlevel!='')
{
	$subsql=$subsql." and level>=".$startlevel."";
}
if($endlevel!='')
{
	$subsql=$subsql." and level<=".$endlevel."";
}
if($keyword!='请输入店铺或掌柜名称...'&&$keyword!='')
{
	$subsql=$subsql." and (nick like '%".$keyword."%' or title like '%".$keyword."%')";
}
else{
    $keyword='';
}
if($area!=''){
	$sql_area=str_replace(',','\',\'',$area);
	$subsql=$subsql." and (city in ('".$sql_area."') or state in ('".$sql_area."'))";
}
//if($cpr=='1')
//{
//	$subsql=$subsql." and consumer_protection='true'";
//}
if($type=='1')
{
	$subsql=$subsql." and `type`='B'";
}
if($px=='1'){
	$subsql=$subsql." order by level desc";
}
if($px=='0'){
	$subsql=$subsql." order by level asc";
}
if($px==''){
	$subsql=$subsql." order by tuijian desc,Id desc";
}
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=20;
$frmnum=($page-1)*$pagesize;

$sql="select count(*) as totalnum from ".$BIAOTOU."shop where good>0 and fanxianlv>0 and ".$subsql;
$rsnum = mysql_query($sql);
$rownum = mysql_fetch_array($rsnum);
$total=$rownum["totalnum"];

$sql="select * from ".$BIAOTOU."shop where good>0 and fanxianlv>0 and ".$subsql." limit $frmnum,$pagesize";
$rs=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 0,5";
$rs_mall=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 5,6";
$rs_mall2=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 11,7";
$rs_mall3=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 15,6";
$rs_mall4=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 20,5";
$rs_mall5=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 25,5";
$rs_mall6=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 7,10";
$rs_mall7=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 13,8";
$rs_mall8=mysql_query($sql);
$sql="select * from ".$BIAOTOU."mall where end_time >='".date('Y-m-d')."' order by sort desc limit 17,5";
$rs_mall9=mysql_query($sql);
$tag="shoplist";
include_once 'comm/wjt.php';
include_once 'comm/seo.php';
//引入模板
include 'template/'.MOBAN.'/taodian.tpl.php';
mysql_close($cfg_link);
?>