<?
exit();
@require("../../class/connect.php");
if(!defined('InEmpireCMS'))
{
	exit();
}
include("../../class/db_sql.php");
include("../../class/config.php");
include("../../class/class.php");
include("../../class/q_functions.php");
include "../".LoadLang("pub/fun.php");
$editor=1;
$link=db_connect();
$empire=new mysqlquery();
//搜索结果
$searchid=(int)$_GET['searchid'];
if(empty($searchid))
	{printerror("SearchNotRecord","history.go(-1)");}
$page=$_GET['page'];
$start=$_GET['start'];
if(empty($page))
{$page=0;}
if(empty($start))
{$start=0;}
$search="&searchid=".$searchid;
$page_line=$public_r[search_pagenum];//每页显示链接数
$line=$public_r[search_num];//每页显示记录数
$offset=$start+$page*$line;//总偏移量
$search_r=$empire->fetch1("select searchid,keyboard,result_num,classid,searchclass,orderby,myorder,starttime,endtime,startprice,endprice from phome_enewssearch where searchid='$searchid'");
if(empty($search_r[searchid]))
	{printerror("SearchNotRecord","history.go(-1)");}
//时间范围
if($search_r[endtime]!="0000-00-00")
{
	$starttime=$search_r[starttime]." 00:00:00";
	$endtime=$search_r[endtime]." 11:59:59";
	$add=" and newstime>='$starttime' and newstime<='$endtime'";
}
//价格
if($search_r[endprice])
{
	$add.=" and price>=".$search_r[startprice]." and price<=".$search_r[endprice];
}
	$have_class=1;
if($search_r[classid])
	{
		//终极类别
		if($class_r[$search_r[classid]][islast])
		{
			$add=" and classid='$search_r[classid]'";
			$have_class=0;
		}
		else
		{
			$where=ReturnClass($class_r[$search_r[classid]][sonclass]);
			if(empty($where))
			{$where="classid=0";}
			$add.=" and (".$where.")";
		}
	}
	//搜索字段
	$fr=explode(",",$search_r[searchclass]);
	$searchfield=$search_r[searchclass];
		for($j=0;$j<count($fr);$j++)
		{
			if($j==0)
			{$or="";}
			else
			{$or=" or";}
			$sf.=$or.$fr[$j]." like '%[!--key--]%'";
		}
	//---------------多个关键字
	$kr=explode(" ",$search_r[keyboard]);
	$keyboard=$search_r[keyboard];
	for($i=0;$i<count($kr);$i++)
	{
		if(empty($kr[$i]))
		{continue;}
		$add.=" and (".str_replace("[!--key--]",$kr[$i],$sf).")";
	}
if($search_r[orderby]==1)//新闻ID
{$myorder="newsid";}
elseif($search_r[orderby]==2)//评论数
{$myorder="plnum";}
elseif($search_r[orderby]==3)//点击率
{$myorder="onclick";}
elseif($search_r[orderby]==4)//下载数
{$myorder="totaldown";}
else//时间
{$myorder="newstime";}
if(empty($search_r[myorder]))
{$myorder.=" desc";}
//当前时间
$todaytime=date("Y-m-d H:i:s");
$query="select * from phome_enewsnews where checked<>0 and (opentime=0 or (opentime=1 and '$todaytime'>starttime and '$todaytime'<endtime)".$add;
$num=$search_r[result_num];
$query.=" order by ".$myorder." limit $offset,$line";
$sql=$empire->query($query);
$listpage=page1($num,$line,$page_line,$start,$page,$search);
//取得模板
if(empty($class_r[$search_r[classid]][searchtempid]))
{
	$tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid from phome_enewssearchtemp where isdefault=1 limit 1");
}
else
{
	$tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid from phome_enewssearchtemp where tempid='".$class_r[$search_r[classid]][searchtempid]."' limit 1");
}
$listtemp=str_replace("[!--show.page--]",$listpage,$tempr[temptext]);
$rownum=$tempr[rownum];
if(empty($rownum))
	{$rownum=1;}
$formatdate=$tempr[showdate];
$subnews=$tempr[subnews];
$modid=$tempr[modid];
$listvar=$tempr[listvar];
//字段
$ret_r=ReturnAddF($tempr[modid],2);
$field=$ret_r[0];
//取得列表模板
$list_exp="[!--empirenews.listtemp--]";
$list_r=explode($list_exp,$listtemp);
$listtext=$list_r[1];
$no=$offset;
$changerow=1;
while($r=$empire->fetch($sql))
{
//替换列表变量
	$repvar=ReplaceListVars($no,$listvar,$subnews,$formatdate,$url,$have_class,$r,$field);
	$listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
	$changerow+=1;
		//超过行数
	if($changerow>$rownum)
	{
		$changerow=1;
		$string.=$listtext;
		$listtext=$list_r[1];
	}
	$no++;
}
db_close();
$empire=null;
//多余数据
    if($changerow<=$rownum&&$listtext<>$list_r[1])
	{
	$string.=$listtext;
    }
    $string=$list_r[0].$string.$list_r[2];
echo $string;
?>