<?php
require("../class/connect.php");
include("../class/db_sql.php");
include("../class/config.php");
include("../class/class.php");
include("../class/functions.php");
include LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
is_login($logininid,$loginin,$loginrnd);
$totalnum=(int)$_GET['totalnum'];
$start=(int)$_GET['start'];
$page=(int)$_GET['page'];
$classid=(int)$_GET['classid'];
$bclassid=(int)$_GET['bclassid'];
$bclassid=(int)$class_r[$classid]['bclassid'];
//验证权限
$doselfinfo=CheckLevel($logininid,$loginin,$classid,"news");
//取得栏目名
if(!$class_r[$classid][classid]||!$class_r[$classid][tbname])
{printerror("ErrorUrl","history.go(-1)");}
//取得模型表
$fieldexp="<!--field--->";
$recordexp="<!--record-->";
//返回搜索字段列表
function ReturnSearchOptions($enter,$field,$record)
{
	$r=explode($record,$enter);
	$count=count($r);
	for($i=0;$i<$count-1;$i++)
	{
		if($i==0)
		{
			$or="";
		}
		else
		{
			$or=" or ";
		}
		$r1=explode($field,$r[$i]);
		if($r1[1]=="special.field")
		{
			continue;
		}
		$sr['searchallfield'].=$or.$r1[1]." like '%[!--key--]%'";
		$sr['select'].="<option value=\"".$r1[1]."\">".$r1[0]."</option>";
	}
	return $sr;
}
$modid=(int)$class_r[$classid][modid];
$infomod_r=$empire->fetch1("select enter,tbname from {$dbtbpre}enewsmod where mid=".$modid);
if(empty($infomod_r['tbname']))
{
	printerror("ErrorUrl","history.go(-1)");
}
$searchoptions_r=ReturnSearchOptions($infomod_r['enter'],$fieldexp,$recordexp);
$url="<a href=ListNews.php?bclassid=$bclassid&classid=$classid>".$class_r[$bclassid][classname]."</a>&nbsp;->&nbsp;<a href=ListNews.php?bclassid=$bclassid&classid=$classid>".$class_r[$classid][classname]."</a>&nbsp;->管理信息&nbsp;&nbsp;(<a href='AddNews.php?enews=AddNews&bclassid=$bclassid&classid=$classid'>增加信息</a>)";
$line=25;//每行显示
$page_line=12;
$offset=$start+$page*$line;
$search="&bclassid=$bclassid&classid=$classid";
$add="";
//搜索
$sear=$_GET['sear'];
if($sear)
{
	$keyboard=addslashes(stripSlashes($_GET['keyboard']));
	$show=$_GET['show'];
	//审核
	$schecked=$_GET['schecked'];
	//关键字
	if($keyboard)
	{
		//搜索全部
		if(!$show)
		{
			$add=" and (".str_replace("[!--key--]",$keyboard,$searchoptions_r['searchallfield']).")";
		}
		//搜索字段
		elseif($show&&strstr($infomod_r['enter'],"<!--field--->".$show."<!--record-->"))
		{
			$add=" and (".$show." like '%$keyboard%')";
			$searchoptions_r['select']=str_replace(" value=\"".$show."\">"," value=\"".$show."\" selected>",$searchoptions_r['select']);
		}
		else
		{}
	}
	//审核
	if($schecked==2)
	{
		$add.=" and checked=0";
	}
	elseif($schecked==1)
	{
		$add.=" and checked=1";
	}
	else
	{}
	//专题
	$ztid=$_GET['ztid'];
	if($ztid)
	{
		$add.=" and ztid like '%|".$ztid."|%'";
	}
	$search.="&sear=1&keyboard=$keyboard&show=$show&schecked=$schecked&ztid=$ztid";
}
//显示重复标题
if($_GET['showretitle']==1)
{
	$search.="&showretitle=1&srt=".$_GET['srt'];
	$addsrt="";
	$srtid="";
	$first=1;
	$srtsql=$empire->query("select id,title from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid' group by title having(count(*))>1");
	while($srtr=$empire->fetch($srtsql))
	{
		if($first==1)
		{
			$addsrt.="title='".$srtr['title']."'";
			$srtid.=$srtr['id'];
			$first=0;
		}
		else
		{
			$addsrt.=" or title='".$srtr['title']."'";
			$srtid.=",".$srtr['id'];
		}
	}
	if(!empty($addsrt))
	{
		if($_GET['srt']==1)
		{
			$add.=" and (".$addsrt.") and id not in (".$srtid.")";
		}
		else
		{
			$add.=" and (".$addsrt.")";
		}
	}
}
//只能编辑自己的信息
if($doselfinfo['doselfinfo'])
{
	$add.=" and userid='$logininid' and ismember=0";
}
$query="select id,title,checked,ismember,username,plnum,checkuser,returncheck,docheckuser,classid,totaldown,onclick,newstime,titleurl,groupid,newspath,filename,titlepic,havehtml,truetime,lastdotime,istop,isgood,firsttitle from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid'".$add;
$totalquery="select count(id) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid'".$add;
if(empty($totalnum))
{
	$num=$empire->gettotal($totalquery);//取得总条数
}
else
{
	$num=$totalnum;
}
//排序
$myorder=$_GET['myorder'];
//时间
if($myorder==1)
{$doorder="newstime desc";}
//评论数
elseif($myorder==2)
{$doorder="plnum desc";}
//人气
elseif($myorder==3)
{$doorder="onclick desc";}
//ID号
elseif($myorder==4)
{$doorder="id desc";}
//默认排序
else
{
	$thisclassr=$empire->fetch1("select listorderf,listorder from {$dbtbpre}enewsclass where classid='$classid'");
	if(empty($thisclassr[listorderf]))
	{
		$doorder="id desc";
	}
	else
	{
		$doorder=$thisclassr[listorderf]." ".$thisclassr[listorder];
	}
}
$search.="&totalnum=$num";
$search1=$search;
$search.="&myorder=$myorder";
$query.=" order by ".$doorder." limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page1($num,$line,$page_line,$start,$page,$search);
//--------------------操作的栏目
$fcfile="../data/fc/ListEnews.php";
$do_class="<script src=../data/fc/cmsclass.js></script>";
if(!file_exists($fcfile))
{$do_class=ShowClass_AddClass("","n",0,"|-",$modid,4);}
$phpmyself=urlencode($_SERVER['PHP_SELF']."?".$_SERVER["QUERY_STRING"]);
//取得专题
$ztclass="";
$doztclass="";
$ztwhere=ReturnClass($class_r[$classid][featherclass]);
$z_sql=$empire->query("select ztname,ztid,tbname from {$dbtbpre}enewszt where classid=0 or classid='$classid' or (".$ztwhere.")");
while($z_r=$empire->fetch($z_sql))
{
	//不同表
	if($class_r[$classid][tbname]!=$z_r[tbname])
	{continue;}
	$selected="";
	if($z_r[ztid]==$ztid)
	{
		$selected=" selected";
	}
	$ztclass.="<option value='".$z_r[ztid]."'".$selected.">".$z_r[ztname]."</option>";
	$doztclass.="<option value='".$z_r[ztid]."'>".$z_r[ztname]."</option>";
}
//栏目链接
$getcurlr['classid']=$classid;
$classurl=sys_ReturnBqClassname($getcurlr,9);
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" type="text/css">
<title>管理信息</title>
<script>
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }
</script>
<script src=editor/setday.js></script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td width="55%">位置： 
      <?=$url?>
    </td>
    <td width="45%">
<div align="center">[<a href="file/ListFile.php?type=9&classid=<?=$classid?>">附件管理</a>]&nbsp;&nbsp;[<a href=ReHtml/ChangeData.php target=_blank>更新数据</a>]&nbsp;&nbsp;[<a href=../../ target=_blank>预览首页</a>]&nbsp;[<a href="<?=$classurl?>" target=_blank>预览栏目</a>]&nbsp;&nbsp;[<a href="ListInfoDoc.php?bclassid=<?=$bclassid?>&classid=<?=$classid?>">管理归档</a>]</div></td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <form name="form2" method="GET" action="ListNews.php">
    <tr> 
      <td><table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableborder">
          <tr class="header"> 
            <td><div align="center"> 
                <input type=button name=button value=增加信息 onClick="self.location.href='AddNews.php?enews=AddNews&bclassid=<?=$bclassid?>&classid=<?=$classid?>'">
              </div></td>
            <td><div align="center"> 
                <input type="button" name="Submit" value="刷新首页" onclick="self.location.href='enews.php?enews=ReIndex'">
              </div></td>
            <td><div align="center">
                <input type="button" name="Submit222" value="刷新父栏目" onclick="self.location.href='enews.php?enews=ReListHtml&classid=<?=$bclassid?>'">
              </div></td>
            <td><div align="center"> 
                <input type="button" name="Submit22" value="刷新本栏目" onclick="self.location.href='enews.php?enews=ReListHtml&classid=<?=$classid?>'">
              </div></td>
            <td><div align="center"> 
                <input type="button" name="Submit4" value="刷新所有信息JS" onclick="window.open('enews.php?enews=ReAllNewsJs&from=<?=$phpmyself?>','','');">
              </div></td>
            <td><div align="center"> 
                <input type="button" name="Submit10" value="栏目设置" onclick="self.location.href='AddClass.php?enews=EditClass&classid=<?=$classid?>'">
              </div></td>
            <td><div align="center"> 
                <input type="button" name="Submit102" value="增加采集" onclick="self.location.href='AddInfoClass.php?enews=AddInfoClass&newsclassid=<?=$classid?>'">
              </div></td>
            <td><div align="center"> 
                <input type="button" name="Submit103" value="管理采集" onclick="self.location.href='ListInfoClass.php'">
              </div></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td><div align="right">[<a href="ListNews.php?bclassid=<?=$bclassid?>&classid=<?=$classid?>&showretitle=1&srt=1" title="查询重复标题，并保留一条信息">查询重复标题A</a>]&nbsp;[<a href="ListNews.php?bclassid=<?=$bclassid?>&classid=<?=$classid?>&showretitle=1&srt=0" title="查询重复标题的信息(不保留信息)">查询重复标题B</a>]&nbsp;[<a href="enews.php?bclassid=<?=$bclassid?>&classid=<?=$classid?>&enews=SetAllCheckInfo" title="本栏目所有信息全设为审核状态" onclick="return confirm('确认要操作?');">审核本栏目全部信息</a>]&nbsp;搜索: 
          <input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>" size="16">
          <select name="show">
		  <option value="0" selected>不限字段</option>
		  <?=$searchoptions_r['select']?>
          </select>
          <select name="schecked" id="schecked">
            <option value="0">不限</option>
            <option value="1">审核</option>
            <option value="2">未审核</option>
          </select>
          <select name="ztid" id="ztid">
            <option value="0">所有专题</option>
            <?=$ztclass?>
          </select>
          <input type="submit" name="Submit2" value="搜索">
          <input name="sear" type="hidden" id="sear" value="1">
          <input name="bclassid" type="hidden" id="bclassid" value="<?=$bclassid?>">
          <input name="classid" type="hidden" id="classid" value="<?=$classid?>">
        </div></td>
    </tr>
  </form>
</table>
<form name="listform" method="post" action="enews.php" onsubmit="return confirm('确认要执行此操作？');">
<input type=hidden name=classid value=<?=$classid?>>
<input type=hidden name=bclassid value=<?=$bclassid?>>
<input type=hidden name=enews value=DelNews_all>
<input type=hidden name=isgood value=0>
<input type=hidden name=doing value=0>
  <input name="ecmsdoc" type="hidden" id="ecmsdoc" value="2">
  <input name="docfrom" type="hidden" id="docfrom" value="<?=$phpmyself?>">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header"> 
      <td width="7%" height="25"><div align="center"><a href='ListNews.php?<?=$search1?>&myorder=4'><u>ID</u></a></div></td>
      <td width="39%" height="25"> 
        <div align="center">标题</div></td>
      <td width="13%" height="25"><div align="center">发布者</div></td>
      <td width="7%" height="25"><div align="center"><a href='ListNews.php?<?=$search1?>&myorder=3'><u>点击</u></a></div></td>
      <td width="18%" height="25"> 
        <div align="center"><a href='ListNews.php?<?=$search1?>&myorder=1'><u>发布时间</u></a></div></td>
      <td width="7%"><div align="center"><a href='ListNews.php?<?=$search1?>&myorder=2'><u>评论</u></a></div></td>
      <td width="9%" height="25"> 
        <div align="center">操作</div></td>
    </tr>
    <?
	while($r=$empire->fetch($sql))
	{
		//置顶
		$istop="";
		if($r[istop])
		{
			$istop="<font color=red>[顶".$r[istop]."]</font>";
		}
		//推荐
		$isgood="";
		if($r[isgood])
		{
			$isgood="<font color=red>[推]</font>";
		}
		//头条
		$firsttitle="";
		if($r[firsttitle])
		{
			$firsttitle="<font color=red>[头]</font>";
		}
		//时间
		$truetime=date_time($r[truetime],"Y-m-d H:i:s");
		$lastdotime=date_time($r[lastdotime],"Y-m-d H:i:s");
		$oldtitle=$r[title];
		$r[title]=stripSlashes(sub($r[title],0,50,false));
		if(empty($r[checked]))
		{$checked=" title='未审核' style=background-color:4791C5";}
		else
		{$checked="";}
				//会员投稿
		if($r[ismember])
		{$r[username]="<font color=red>".$r[username]."</font>";}
		//评论个数
		$plnum=$r[plnum];
		//文件类别
		$titleurl=sys_ReturnBqTitleLink($r);
		//签发
		$qf="";
		if($r[checkuser])
		{
			if($r[returncheck])
			{$qf="(<font color=red>已退稿</font>)";}
			elseif(strlen($r[checkuser])==strlen($r[docheckuser]))
			{$qf="(<font color=red>已签发</font>)";}
			else
			{$qf="(<font color=red>签发中</font>)";}
			$qf="<a href=#ecms onclick=\"window.open('DoNewsQf.php?classid=$r[classid]&id=$r[id]','','width=600,height=520,scrollbars=yes');\">".$qf."</a>";
		}
		//标题图片
		$showtitlepic="";
		if($r[titlepic])
		{
			$showtitlepic="<a href='".$r[titlepic]."' title='预览标题图片' target=_blank><img src='../data/images/showimg.gif' border=0></a>";
		}
		//未生成
		$myid=$r['id'];
		if(empty($r[havehtml]))
		{
		$myid="<a title='未生成'><b>".$r[id]."</b></a>";
		}
	?>
    <tr bgcolor="#FFFFFF" id=news<?=$r[id]?>> 
      <td height="25"> <div align="center"> 
          <?=$myid?>
        </div></td>
      <td height="25"> <div align="left"><?=$istop.$firsttitle.$isgood?><?=$showtitlepic?><a href='<?=$titleurl?>' target=_blank title="<?=$oldtitle?>"> 
          <?=$r[title]?>
          </a><?=$qf?></div></td>
      <td height="25"> <div align="center"> 
          <?=$r[username]?>
        </div></td>
      <td height="25"> <div align="center"> 
          <a title="下载次数:<?=$r[totaldown]?>"><?=$r[onclick]?></a>
        </div></td>
      <td height="25"> <div align="center"> 
          <a href="AddNews.php?enews=EditNews&id=<?=$r[id]?>&classid=<?=$classid?>&bclassid=<?=$bclassid?>" title="<? echo"增加时间：".$truetime."\r\n最后修改：".$lastdotime;?>"><?=$r[newstime]?></a>
        </div></td>
      <td><div align="center"><a href="ListPl.php?id=<?=$r[id]?>&classid=<?=$classid?>&bclassid=<?=$bclassid?>" title="管理评论"><u>
          <?=$plnum?>
          </u></a></div></td>
      <td height="25"> <div align="center"> <a href="AddNews.php?enews=EditNews&id=<?=$r[id]?>&classid=<?=$classid?>&bclassid=<?=$bclassid?>"><img src=../data/images/EditNews.png alt='修改' title='修改' border=0></a>&nbsp; 
          <a href="enews.php?enews=DelNews&id=<?=$r[id]?>&classid=<?=$classid?>&bclassid=<?=$bclassid?>" onClick="return confirm('确认要删除？');"><img src=../data/images/DelNews.png alt='删除' title='删除' border=0></a>&nbsp; 
          <input name="id[]" type="checkbox" id="id[]" onClick="if(this.checked){news<?=$r[id]?>.style.backgroundColor='#DBEAF5';}else{news<?=$r[id]?>.style.backgroundColor='#ffffff';}" value="<?=$r[id]?>"<?=$checked?>>
        </div></td>
    </tr>
    <?
	}
	?>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="7"><div align="right"> 
          <input type="submit" name="Submit3" value="删除" onClick="document.listform.enews.value='DelNews_all';">
          <input type="submit" name="Submit8" value="审核" onClick="document.listform.enews.value='CheckNews_all';">
          <input type="submit" name="Submit9" value="取消审核" onClick="document.listform.enews.value='NoCheckNews_all';">
          <input type="submit" name="Submit82" value="推荐" onClick="document.listform.enews.value='GoodInfo_all';document.listform.isgood.value='1';document.listform.doing.value='0';">
          <input type="submit" name="Submit822" value="取消推荐" onClick="document.listform.enews.value='GoodInfo_all';document.listform.isgood.value='0';document.listform.doing.value='0';">
          <input type="submit" name="Submit823" value="头条" onClick="document.listform.enews.value='GoodInfo_all';document.listform.isgood.value='1';document.listform.doing.value='1';">
          <input type="submit" name="Submit8222" value="取消头条" onClick="document.listform.enews.value='GoodInfo_all';document.listform.isgood.value='0';document.listform.doing.value='1';">
          <select name="istop" id="istop">
            <option value="0">0级置顶</option>
            <option value="1">1级置顶</option>
            <option value="2">2级置顶</option>
            <option value="3">3级置顶</option>
            <option value="4">4级置顶</option>
            <option value="5">5级置顶</option>
            <option value="6">6级置顶</option>
          </select><input type="submit" name="Submit7" value="置顶" onClick="document.listform.enews.value='TopNews_all';">
          <select name="ztid" id="ztid">
            <option value="0">选择专题</option>
            <?=$doztclass?>
          </select><input type="submit" name="Submit52" value="转移" onClick="document.listform.enews.value='DoZtNews_all';">&nbsp;<input type="submit" name="Submit11" value="归档" onClick="document.listform.enews.value='InfoToDoc';document.listform.doing.value='0';">
          <input type=checkbox name=chkall value=on onClick=CheckAll(this.form)>选中全部 </div></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="7"> 
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="64%"> 
              <?=$returnpage?>
            </td>
            <td width="36%"> <div align="center">
                <select name="to_classid">
                  <option value=0>选择要移动/复制的目标栏目</option>
                  <?=$do_class?>
                </select>
                <input type="submit" name="Submit5" value="移动" onClick="document.listform.enews.value='MoveNews_all';">&nbsp;<input type="submit" name="Submit6" value="复制" onClick="document.listform.enews.value='CopyNews_all';">
              </div></td>
          </tr>
        </table></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="7"> 备注：多选框为蓝色代表未审核信息,置顶级别越高越前面,会员投稿作者为红色,签发信息标题后有说明,未生成的信息ID为粗体.</td>
    </tr>
  </table>
</form>
</body>
</html>
<?
db_close();
$empire=null;
?>
