<?php
require('../class/connect.php');
require('../class/db_sql.php');
require('../class/functions.php');
require('../class/t_functions.php');
require('../data/dbcache/class.php');
require LoadLang('pub/fun.php');
$link=db_connect();
$empire=new mysqlquery();
$add='';
$addorder='id desc';
$search='';
$GLOBALS['navclassid']=0;
$yhid=0;
$yhvar='qlist';
//模型ID
$mid=1;
$tbname='';
$pagetitle='留言反馈-'.$public_r['sitename'];
$pagekey=$public_r['sitename'];
$pagedes=$public_r['sitename'];
$pageecms=1;
$pageclassid=0;
$have_class=1;
//栏目
$trueclassid=0;
$classid=$_GET['classid'];
if($classid)
{
	$classid=RepPostVar($classid);
	if(strstr($classid,','))//多栏目
	{
		$son_r=sys_ReturnMoreClass($classid,1);
		$trueclassid=$son_r[0];
		$add.=' and ('.$son_r[1].')';
	}
	else
	{
		$trueclassid=intval($classid);
		if($class_r[$trueclassid][islast])//终极栏目
		{
			$add.=" and classid='$trueclassid'";
			$have_class=0;
		}
		else
		{
			$add.=' and '.ReturnClass($class_r[$trueclassid][sonclass]);
		}
		$cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid from {$dbtbpre}enewsclass where classid='$trueclassid'");
		//权限
		if($cr['cgroupid'])
		{
			$mgroupid=(int)getcvar('mlgroupid');
			if(!strstr($cr[cgroupid],','.$mgroupid.','))
			{
				printerror('NotLevelToClass','history.go(-1)',1);
			}
		}
		$pagetitle=$class_r[$trueclassid]['classname'];
		$pagekey=$cr['classpagekey'];
		$pagedes=$cr['intro'];
		$classimg=$cr['classimg']?$cr['classimg']:$public_r[newsurl].'e/data/images/notimg.gif';
		$url=ReturnClassLink($trueclassid);
		$pageecms=0;
		$pageclassid=$trueclassid;
		$GLOBALS['navclassid']=$trueclassid;
	}
	if(empty($class_r[$trueclassid][tbname]))
	{
		printerror('ErrorUrl','',1);
	}
	if(empty($tbname))
	{
		$tbname=$class_r[$trueclassid][tbname];
		$mid=$class_r[$trueclassid][modid];
		$yhid=$class_r[$trueclassid][yhid];
	}
	if($class_r[$trueclassid][reorder])
	{
		$addorder=$class_r[$trueclassid][reorder];
	}
	$search.='&classid='.$classid;
}

//每页显示记录数
$line=48;
//列表模板
$tempid=1;

$tempr=$empire->fetch1("select tempid,temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewslisttemp")." where tempid='$tempid'");


$page=(int)$_GET['page'];
$start=0;
$page_line=16;//每页显示链接数
$offset=$page*$line;//总偏移量
//系统模型
$ret_r=ReturnReplaceListF($mid);
//优化
$yhadd='';
if($yhid)
{
	$yhadd=ReturnYhSql($yhid,$yhvar);
}

$dorder=$_GET['dorder'];
if($dorder=='') $dorder='id';
if($dorder=='id'){
$ordertemp='<span class="orderNav"><em>排序：</em> <a href="index.html" title="添加时间" class="on">添加时间</a> | <a href="update.html" title="更新时间">更新时间</a> | <a href="view.html" title="点击次数">点击次数</a></span>';
$filename='index';
}
if($dorder=='newstime'){
$ordertemp='<span class="orderNav"><em>排序：</em> <a href="index.html" title="添加时间">添加时间</a> | <a href="update.html" title="更新时间" class="on">更新时间</a> | <a href="view.html" title="点击次数">点击次数</a></span>';
$filename='update';
}
if($dorder=='onclick'){
$ordertemp='<span class="orderNav"><em>排序：</em> <a href="index.html" title="添加时间">添加时间</a> | <a href="update.html" title="更新时间">更新时间</a> | <a href="view.html" title="点击次数" class="on">点击次数</a></span>';
$filename='view';
}


//总数
$totalnum=(int)$_GET['totalnum'];
if($totalnum<1)
{
	$totalquery="select count(*) as total from {$dbtbpre}movie_gbook where  checked=1";
	$num=$empire->gettotal($totalquery);
}
else
{
	$num=$totalnum;
}
$search.='&totalnum='.$num;
$query="select * from {$dbtbpre}movie_gbook where checked=1 order by $dorder desc limit $offset,$line";
$sql=$empire->query($query);
//分页
$search=$ar;
$templistpage=dtlistpage($num,$line,$page,$file);
//页面支持标签
if($public_r['dtcanbq'])
{
	$tempr[temptext]=DtNewsBq('gbook'.$tempid,$tempr[temptext],0);
}
else
{
	if($public_r['searchtempvar'])
	{
		$tempr[temptext]=ReplaceTempvar($tempr[temptext]);
	}
}
$listtemp=$tempr[temptext];
$rownum=$tempr[rownum];
if(empty($rownum))
{$rownum=1;}
$formatdate=$tempr[showdate];
$subnews=$tempr[subnews];
$subtitle=$tempr[subtitle];
$docode=$tempr[docode];
$modid=$tempr[modid];
$listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[listvar]);
//公共
$listtemp=Class_ReplaceSvars($listtemp,$url,$pageclassid,$pagetitle,$pagekey,$pagedes,$classimg,$addr,$pageecms);
$listtemp=str_replace('[!--page.stats--]','',$listtemp);
$listtemp=str_replace('[!--dt.listpage--]',$templistpage,$listtemp);
//取得列表模板
$list_exp="[!--empirenews.listtemp--]";
$list_r=explode($list_exp,$listtemp);
$listtext=$list_r[1];
$no=$offset+1;
$changerow=1;
while($r=$empire->fetch($sql))
{
	//替换列表变量
	$repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);
	$listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
	$changerow+=1;
	//超过行数
	if($changerow>$rownum)
	{
		$changerow=1;
		$string.=$listtext;
		$listtext=$list_r[1];
	}
	$no++;
}
//多余数据
if($changerow<=$rownum&&$listtext<>$list_r[1])
{
	$string.=$listtext;
}
$string=$list_r[0].$string.$list_r[2];
echo stripSlashes($string);
db_close();
$empire=null;
?>