<?php
require("../class/connect.php");
include("../class/db_sql.php");
include("../class/config.php");
include("../class/class.php");
include("../class/user.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);
$mid=(int)$_GET[mid];
if(empty($mid))
{
	printerror("ErrorUrl","history.go(-1)");
}
$mr=$empire->fetch1("select mid,tbname,sonclass from {$dbtbpre}enewsmod where mid='$mid'");
if(empty($mr[mid])||empty($mr[tbname]))
{
	printerror("ErrorUrl","history.go(-1)");
}
$start=(int)$_GET['start'];
$page=(int)$_GET['page'];
$search="&mid=$mid";
//取得相应的新闻
$user_r=$empire->fetch1("select groupid,adminclass from {$dbtbpre}enewsuser where userid='$logininid'");
//取得用户组
$gr=$empire->fetch1("select doall from {$dbtbpre}enewsgroup where groupid='$user_r[groupid]'");
//管理员
if($gr[doall])
{
	$where="(".ReturnClass($mr[sonclass]).")";
}
else
{
	$a=explode("|",$user_r[adminclass]);
	for($i=1;$i<count($a)-1;$i++)
	{
		if(!strstr($mr[sonclass],"|".$a[$i]."|"))
		{continue;}
		$where.="classid='".$a[$i]."' or ";
	}
	//去掉最后四个字符
	$where="(".substr($where,0,strlen($where)-4).")";
}
if(empty($where)||$where=="()")
{$where="id=0";}
$url="<a href=CheckNews.php?mid=".$mid.">审核信息</a>";
$line=25;//每行显示
$page_line=21;
$offset=$start+$page*$line;
$add="";
//搜索
$sear=$_POST['sear'];
if(empty($sear))
{$sear=$_GET['sear'];}
if($sear)
{
	$keyboard=$_POST['keyboard'];
	if(empty($keyboard))
	{$keyboard=$_GET['keyboard'];}
	$keyboard=addslashes(stripSlashes($keyboard));
	$show=$_POST['show'];
	if(empty($show))
	{$show=$_GET['show'];}
	//搜索全部
	if($show==0)
	{
		$add=" and (title like '%$keyboard%' or username like '%$keyboard%')";
	}
	//搜索标题
	elseif($show==1)
	{
		$add=" and (title like '%$keyboard%')";
	}
	else
	{
		$add=" and (username like '%$keyboard%')";
	}
	$search.="&sear=1&keyboard=$keyboard&show=$show";
}
$totalquery="select count(*) as total from {$dbtbpre}ecms_".$mr[tbname]." where checked=0 and ".$where.$add;
$num=$empire->gettotal($totalquery);//取得总条数
$query="select * from {$dbtbpre}ecms_".$mr[tbname]." where checked=0 and ".$where.$add;
$query.=" order by id desc 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,"|-",0,0);}
$phpmyself=urlencode($_SERVER['PHP_SELF']."?".$_SERVER["QUERY_STRING"]);
//风格
$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>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>位置：<?=$url?></td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  <form name="form2" method="GET" action="CheckNews.php">
  <tr> 
      <td class="header">&nbsp;&nbsp; <input type="button" name="Submit" value="刷新首页" onclick="self.location.href='enews.php?enews=ReIndex'">
        &nbsp;&nbsp; <input type="button" name="Submit4" value="刷新所有信息JS" onclick="window.open('enews.php?enews=ReAllNewsJs&from=<?=$phpmyself?>','','');"> 
      </td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF">
<div align="right">[<a href=../../ target=_blank>预览首页</a>]&nbsp;&nbsp;&nbsp;&nbsp;搜索： 
          <input name="keyboard" type="text" id="keyboard">
          <input name="show" type="radio" value="0" checked>
          不限 
          <input type="radio" name="show" value="1">
          标题 
          <input type="radio" name="show" value="2">
          发布者 
          <input type="submit" name="Submit2" value="搜索">
          <input name="mid" type="hidden" id="mid" value="<?=$mid?>">
          <input name="sear" type="hidden" id="sear" value="1">
        </div></td>
  </tr></form>
</table>
<form name="listform" method="post" action="enews.php" onsubmit="return confirm('确认要执行此操作？');">
  <input type=hidden name=enews value=DelNews_all>
  <input name=mid type=hidden id="mid" value=<?=$mid?>>
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header"> 
      <td width="5%" height="25"><div align="center">ID</div></td>
      <td width="37%" 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">点击</div></td>
      <td width="17%" height="25"> 
        <div align="center">发布时间</div></td>
      <td width="22%" height="25"> 
        <div align="center">操作</div></td>
    </tr>
    <?
	while($r=$empire->fetch($sql))
	{
		$oldtitle=$r[title];
		$r[title]=stripSlashes(sub($r[title],0,30,false));
		if(empty($r[checked]))
		{$checked=" title='未审核' style='background:#99C4E3'";}
		else
		{$checked="";}
		//会员投稿
		if($r[ismember])
		{
					//取得用户邮箱
		$email=GetUserEmail($r[userid],$r[username]);
			$r[username]="<a href=mailto:".$email."><font color=red>".$r[username]."</font></a>";
			}
		//取得类别名
		$do=$r[classid];
		$dob=$class_r[$r[classid]][bclassid];
				//文件类别
		$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=360,height=520,scrollbars=yes');\">".$qf."</a>";
		}
	?>
    <tr bgcolor="#FFFFFF"> 
      <td height="25"> <div align="center">
          <?=$r[id]?>
        </div></td>
      <td height="25"> <div align="left"><a href='<?=$titleurl?>' target=_blank title="<?=$oldtitle?>">
          <?=$r[title]?><?=$qf?>
          </a><br>
          <font color=red>栏目:</font><a href='ListNews.php?bclassid=<?=$class_r[$r[classid]][bclassid]?>&classid=<?=$r[classid]?>'> 
          <?=$class_r[$dob][classname]?>
          </a>-><a href='ListNews.php?bclassid=<?=$class_r[$r[classid]][bclassid]?>&classid=<?=$r[classid]?>'> 
          <?=$class_r[$r[classid]][classname]?>
          </a></div></td>
      <td height="25"> <div align="center">
          <?=$r[username]?>
        </div></td>
      <td height="25"> <div align="center">
          <?=$r[onclick]?>
        </div></td>
      <td height="25"> <div align="center">
          <?=$r[newstime]?>
        </div></td>
      <td height="25"> <div align="center">[<a href="ListPl.php?id=<?=$r[id]?>&classid=<?=$r[classid]?>&bclassid=<?=$class_r[$r[classid]][bclassid]?>">评论</a>]&nbsp; 
          <a href="AddNews.php?enews=EditNews&id=<?=$r[id]?>&classid=<?=$r[classid]?>&bclassid=<?=$class_r[$r[classid]][bclassid]?>"><img src=../data/images/EditNews.png alt='修改' title='修改信息' border=0></a>&nbsp; 
          <a href="enews.php?enews=DelNews&id=<?=$r[id]?>&classid=<?=$r[classid]?>&bclassid=<?=$class_r[$r[classid]][bclassid]?>" onclick="return confirm('确认要删除？');"><img src=../data/images/DelNews.png alt='删除' title='删除信息' border=0></a>&nbsp; 
          <input name="id[]" type="checkbox" id="id[]" value="<?=$r[id]?>"<?=$checked?>>
        </div></td>
    </tr>
    <?
	}
	?>
	<input type=hidden name=classid value=<?=$do?>>
	<input type=hidden name=bclassid value=<?=$dob?>>
    <tr bgcolor="#FFFFFF">
      <td height="25" colspan="6"><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';">
          <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="to_classid">
            <option value=0>选择要移动/复制的目标栏目</option>
			<?=$do_class?>
          </select>
          <input type="submit" name="Submit5" value="移动" onclick="document.listform.enews.value='MoveNews_all';">
          <input type="submit" name="Submit6" value="复制" onclick="document.listform.enews.value='CopyNews_all';">
		  &nbsp;<input type=checkbox name=chkall value=on onclick=CheckAll(this.form)>选中全部
        </div></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="6"> 
        <?=$returnpage?>
        　 </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="6"> 备注：多选框为蓝色代表未审核信息，置顶级别越高越前面，会员投稿作者为红色,签发信息标题后有说明．</td>
    </tr>
  </table>
</form>
</body>
</html>
<?
db_close();
$empire=null;
?>
