<?php
$zimu=strip_tags($_GET[zimu])?strip_tags($_GET[zimu]):'0';
$diqu=(int)$_GET[diqu];
$year=(int)$_GET[year];
$classtype=strip_tags($_GET[classtype])?strip_tags($_GET[classtype]):'0';
$language=(int)$_GET[language];
$classid=(int)$_GET[classid];
$order=$_GET[order];
$hour=60*60;
$cachetime=$hour*12;
$mulu='list';
$tpage=(int)$_GET['page'];
$page=$tpage-1;
if($page<0) $page=0;
if($tpage==0) $tpage=1;
$iscache=0;
if($iscache){
$cachefilename=$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'-'.$order.'-'.$page.'.html';
//判断缓存
    
    if(file_exists('cache/'.$mulu.'/'.$cachefilename)&&filemtime('cache/'.$mulu.'/'.$cachefilename)+$cachetime>time()){
    echo file_get_contents('cache/'.$mulu.'/'.$cachefilename);
    exit;
    }
ob_start();
}
require('../e/class/connect.php');
require('../e/class/db_sql.php');
require('../e/class/functions.php');
require('../e/class/t_functions.php');
require('../e/data/dbcache/class.php');
$link=db_connect();
$empire=new mysqlquery();
$search='';
$GLOBALS['navclassid']=0;
$yhid=0;
$yhvar='qlist';
//模型ID


$tempid=4;
$mid=1;
$tbname='movie';
$pagetitle=$public_r['sitename'];
$pagekey=$public_r['sitename'];
$pagedes=$public_r['sitename'];
$pageecms=1;
$pageclassid=0;
$have_class=1;
//栏目

//系统模型
$ret_r=ReturnReplaceListF($mid);
if(!$classid&&!$year&&!$diqu&&!$zimu&&!$classtype&&!$language){
	$titletemp='所有影片';
}

if(!$order) $order='id';
if($order=='id'||$order=='index'){ $dorder='id';  $fileorder='index';}
elseif($order=='click'||$order=='hot'||$order=='top'){ $dorder='onclick';  $fileorder='top';}
elseif($order=='newstime') { $dorder='newstime'; }
else { $order='id'; $dorder='id'; $fileorder='index';}


/////////////////////////////////////////////year start 
$yearstr='2013|2012|2011|2010|2009|2008|2007|2006|2005-2009|2000-2004|70年代|80年代|90年代|更早';
$yearnum='2013|2012|2011|2010|2009|2008|2007|2006|20052009|20002004|19701979|19891990|19901999|19001969';
if($year){
if(strlen($year)>4){
$yearr=str_split($year,4);
$yearsql='and year>'.$yearr[0].' and year<'.$yearr[1];
$titletemp=$yearr[0].'-'.$yearr[1].'年 ';
}
else{
$yearsql='and year='.$year.' ';
$titletemp=$year.'年 ';
}
$yeartemp='<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-0-'.$language.'/" >全部年份</a><em>|</em></dt><dd>';
}
else{ $yeartemp='<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-0-'.$language.'/" class="cur">全部年份</a><em>|</em></dt><dd>'; }
$yr=explode('|',$yearstr);
$ynr=explode('|',$yearnum);
$yclass='';

for($i=0;$i<count($yr);$i++){
	$thisyname=$yr[$i];
	$thisynum=$ynr[$i];
	$thisyurl='/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$thisynum.'-'.$language.'/';
	$yclass=$thisynum==$year?'class="cur"':'';
	$yeartemp.='<a href="'.$thisyurl.'" target="_self" '.$yclass.'>'.$thisyname.'</a><em>|</em>';
}
$yeartemp.='</dd>';

$titletemp.=$class_r[$classid][bname];//增加栏目

///////////////////////////////////////////////////year end
//$thisyurl='/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/';
/////////////////////////////////////////////////classtyep start
if($classid==0) $cclassid=0; else {
 if($classid!=3&$classid!=4){
   $cclassid=$class_r[$classid][bclassid];
 }
 else $cclassid=$classid;
}
if($cclassid){
$classtypestr=str_replace("\r\n",'|',$public_r['add_classtype_'.$cclassid]);
}
else{
$classtypestr='喜剧|惊悚|武侠|战争|古装|历史|神话|偶像|爱情|伦理|动作|都市|警匪|穿越|谍战|抗日|家庭|悬疑|农村|儿童|经典|枪战|剧情';
}
$cr=explode('|',$classtypestr);
$classtypeselect='';
$classtypetemp=$classtype?'<dt><a target="_self" href="/list/0-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/">全部类型</a><em>|</em></dt><dd>':'<dt><a target="_self" href="/list/0-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/" class="cur" >全部类型</a><em>|</em></dt><dd>';
$tname='';
$classtypeclass='';
for($i=0;$i<count($cr);$i++){
		$thiscname=$cr[$i];
		$thispname=ReturnPinyinFun($thiscname);
		$thisyurl='/list/'.$thispname.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/';
		if($thispname==$classtype) { $classtypeselect=$thiscname; }
		if($thispname==$classtype) { $tname=$thiscname; }
          $classtypeclass=$thispname==$classtype?' class="cur" ':'';
		$classtypetemp.='<a href="'.$thisyurl.'" target="_self" '.$classtypeclass.'>'.$thiscname.'</a><em>|</em>';


}
$classtypetemp.='</dd>';
$classtypesql=$classtypeselect?' and classtype like \'%'.$classtypeselect.'%\' ':'';
$titletemp.=' '.$tname;

////////////////////////////////////////////diqu start

$diqutemp=$diqu?'<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-0-'.$zimu.'-'.$year.'-'.$language.'/">全部地区</a><em>|</em></dt><dd>':'<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-0-'.$zimu.'-'.$year.'-'.$language.'/" class="cur" >全部地区</a><em>|</em></dt><dd>';
$diqustr=$public_r[add_moviediqu];
$dr=explode("\r\n",$diqustr);
$diquselect='';
$tname='';
for($i=0;$i<count($dr);$i++){
$thisdiqui=$i+1;
$thisname=$dr[$i];

		if($thisdiqui==$diqu) { $diquselect=$thisname; }
		if($thisdiqui==$diqu) { $tname=$thisname; }
		$aclass=$thisdiqui==$diqu?' class="cur" ':'';
		$thisyurl='/list/'.$classtype.'-'.$classid.'-'.$thisdiqui.'-'.$zimu.'-'.$year.'-'.$language.'/';
		$diqutemp.='<a href="'.$thisyurl.'" target="_self" '.$aclass.'>'.$thisname.'</a><em>|</em>';
		

}
$diqutemp.='</dd>';
$titletemp.=' '.$tname;
$diqusql=$diquselect?' and area=\''.$diquselect.'\' ':'';

/////////////////////////////////////////language start
$lstr='普通话|国语|粤语|英语|日语|韩语|泰语|俄语|德语|法语';
$lr=explode('|',$lstr);
$languageselect='';

$languagetemp=$language?'<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-0/">全部语言</a><em>|</em></dt><dd>':'<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-0/" class="cur" >全部语言</a><em>|</em></dt><dd>';
$tname='';
for($i=0;$i<count($lr);$i++){
		$thisi=$i+1;
		$thisyurl='/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$thisi.'/';
		$thisname=$lr[$i];
		$aclass=$thisi==$language?' class="cur" ':'';
		$languagetemp.='<a href="'.$thisyurl.'" target="_self" '.$aclass.'>'.$thisname.'</a><em>|</em>';
		if($thisi==$language) { $languageselect=$thisname; }
		if($thisi==$language) { $tname=$thisname; }
}

$languagetemp.='</dd>';
$titletemp.=' '.$tname;
$languagesql=$languageselect?' and language=\''.$languageselect.'\' ':'';
////////////////////////////////////////////infozm

$zimutemp=$zimu?'<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-'.$diqu.'-0-'.$year.'-'.$language.'/">全部字母</a><em>|</em></dt><dd>':'<dt><a target="_self" href="/list/'.$classtype.'-'.$classid.'-'.$diqu.'-0-'.$year.'-'.$language.'/" class="cur" >全部字母</a><em>|</em></dt><dd>';
$zmstr='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$zr=str_split($zmstr,1);

$zmtemp='';
$zmselect='';
$tname='';
for($i=0;$i<count($zr);$i++){
	$thisname=$zr[$i];
	$thisyurl='/list/'.$classtype.'-'.$classid.'-'.$diqu.'-'.$thisname.'-'.$year.'-'.$language.'/';
	$aclass=$thisname==$zimu?' class="cur" ':'';
	
	$zimutemp.='<a href="'.$thisyurl.'" target="_self" '.$aclass.'>'.$thisname.'</a><em>|</em>';
	

}
$zimutemp.='</dd>';
if($zimu){ $zimusql='and infozm=\''.$zimu.'\' '; $titletemp.=' 首字母'.$zimu;} else {$zimusql='';}

//------------------classid
$classidtemp=$classid?'<dt><a target="_self" href="/list/'.$classtype.'-0-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/">全部分类</a><em>|</em></dt><dd>':'<dt><a target="_self" href="/list/'.$classtype.'-0-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/" class="cur" >全部分类</a><em>|</em></dt><dd>';
$cquery=$empire->query("select classid,bclassid from {$dbtbpre}enewsclass where classid='3' or classid='4' or bclassid='1' or bclassid='2' order by classid asc ");
if($classid==1||$classid==2){
$classidtemp='<dt><a target="_self" href="/list/'.$classtype.'-0-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/" class="cur" >全部分类</a><em>|</em></dt><dd>';
}
while($ccr=$empire->fetch($cquery)){
	$thisclassid=$ccr[classid];
	$thisname=$class_r[$thisclassid][bname];
	$aclass=$thisclassid==$classid?' class="cur" ':'';
	$thisyurl='/list/'.$classtype.'-'.$thisclassid.'-'.$diqu.'-'.$zimu.'-'.$year.'-'.$language.'/';
	$classidtemp.='<a href="'.$thisyurl.'" target="_self" '.$aclass.'>'.$thisname.'</a><em>|</em>';

}
$classidtemp.='</dd>';

if($classid==1||$classid==2){
$sonclassid=$class_r[$classid][sonclass];
$sonclassr=explode('|',$sonclassid);
$sonnum=count($sonclassr);
$sonclasstemp='';
for($u=0;$u<$sonnum;$u++){
if($sonclassr[$u]!=''){
		$sonclasstemp.="'$sonclassr[$u]',";
}
}
$sonclasstemp=substr($sonclasstemp,0,strlen($sonclasstemp)-1);	
$classidsql=" and classid in ( $sonclasstemp ) ";
}
else
$classidsql=$classid?' and classid=\''.$classid.'\' ':' ';
if(!$classid&&!$year&&!$diqu&&!$zimu&&!$classtype&&!$language){
	$titletemp='所有影片';
}
else{
$titletemp.='的影片 ';
}
//---排序 ---------------------

if($fileorder=='index'){
$ordertemp='<a href="index.html" class="on" >更新</a><a href="top.html">点击</a>';

}

if($fileorder=='top'){
$ordertemp='<a href="index.html">更新</a><a href="top.html" class="on" >点击</a>';
}




//每页显示
$lenth=20;
$line=$lenth;
//列表模板

$tempr=$empire->fetch1("select * from ".GetTemptb("enewslisttemp")." where tempid=$tempid");
$start=0;
$page_line=5;//每页显示链接数
$offset=$page*$line;//总偏移量


$fsql="select * from {$dbtbpre}ecms_".$tbname." where isurl=0 ";
$tsql=" order by $dorder desc limit $offset,$line";
$ssql=$classidsql.$classtypesql.$diqusql.$zimusql.$yearsql.$languagesql;
$totalquery="select count(*) as total from {$dbtbpre}ecms_".$tbname." where isurl=0 $ssql ";
$num=$empire->gettotal($totalquery);

$search=$num;
$query=$fsql.$ssql.$tsql;
//echo $query;
$sql=$empire->query($query);
$pageurl='?infozm='.$infozm.'&tagid='.$tagid.'&diqu='.$diqu.'&type='.$type.'&year='.$yaar.'&order='.$order;
//分页
$showlistpage=user_dtShowListPage($num,$tpage,$dolink,$type,$totalpage,$line,$ok,$fileorder);
$sqlyuju=$query;
$title='动画检索';
$pagetitle=$title;
//页面支持标签
if($public_r['dtcanbq'])
{
	$tempr[temptext]=DtNewsBq('templist'.$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]);
//公共
$maxpage=ceil($num/$line);

$listtemp=Class_ReplaceSvars($listtemp,$url,$pageclassid,$pagetitle,$pagekey,$pagedes,$classimg,$addr,$pageecms);
$listtemp=str_replace('[!--page.stats--]','',$listtemp);

$listtemp=str_replace('[!--ordertemp--]',$ordertemp,$listtemp);
$listtemp=str_replace('[!--show.listpage--]',$showlistpage,$listtemp);
$listtemp=str_replace('[!--classidtemp--]',$classidtemp,$listtemp);
$listtemp=str_replace('[!--zimutemp--]',$zimutemp,$listtemp);
$listtemp=str_replace('[!--classtypetemp--]',$classtypetemp,$listtemp);
$listtemp=str_replace('[!--diqutemp--]',$diqutemp,$listtemp);
$listtemp=str_replace('[!--languagetemp--]',$languagetemp,$listtemp);
$listtemp=str_replace('[!--ordertemp--]',$ordertemp,$listtemp);
$listtemp=str_replace('[!--titletemp--]',$titletemp,$listtemp);
$listtemp=str_replace('[!--yeartemp--]',$yeartemp,$listtemp);
$listtemp=str_replace('[!--sql--]','',$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);
if($iscahce){
$cache_html=ob_get_contents();
file_put_contents('cache/'.$mulu.'/'.$cachefilename,$cache_html);
}
db_close();
$empire=null;
?>