<?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);
$classid=(int)$_GET['classid'];
$bclassid=(int)$_GET['bclassid'];
$id=(int)$_GET['id'];
//验证权限
CheckLevel($logininid,$loginin,$classid,"news");
$keyboard=$_GET['keyboard'];
$keyboard=addslashes(stripSlashes($keyboard));
$start=(int)$_GET['start'];
$page=(int)$_GET['page'];
$line=15;//每行显示
$page_line=15;
$offset=$start+$page*$line;
$search="&bclassid=$bclassid&classid=$classid&id=$id&keyboard=$keyboard";
$query="select plid,username,saytime,saytext,sayip,checked,zcnum,fdnum,userid,isgood from {$dbtbpre}enewspl where id='$id' and classid='$classid'";
//搜索
if($keyboard)
{
	$query.=" and (saytext like '%".$keyboard."%' or username like '%".$keyboard."%' or sayip like '%".$keyboard."%')";
}
$num=$empire->num($query);//取得总条数
$query.=" order by plid desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page1($num,$line,$page_line,$start,$page,$search);
//位置
$n_r=$empire->fetch1("select title from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id'");
$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;".$n_r[title]."&nbsp;->&nbsp;管理评论";
//风格
$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">
<title>管理评论</title>
<link href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<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="98%%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>位置:<?=$url?></td>
  </tr>
</table>

  <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <form name="form2" method="get" action="ListPl.php">
    <tr>
      <td>关键字： 
        <input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>"> 
        <input type="submit" name="Submit2" value="搜索评论">
        <input name=id type=hidden id="id" value=<?=$id?>>
        <input name=classid type=hidden id="classid" value=<?=$classid?>>
        <input name=bclassid type=hidden id="bclassid" value=<?=$bclassid?>></td>
    </tr>
	</form>
  </table>

<form name="form1" method="post" action="enews.php">
<input type=hidden name=bclassid value=<?=$bclassid?>>
<input type=hidden name=classid value=<?=$classid?>>
<input type=hidden name=id value=<?=$id?>>
  <input name="isgood" type="hidden" id="isgood" value="1">
  <table width="98%%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header"> 
      <td width="16%" height="25"><div align="center">网名</div></td>
      <td width="49%" height="25"><div align="center">评论内容</div></td>
      <td width="14%" height="25"><div align="center">发表时间</div></td>
      <td width="13%" height="25"><div align="center">IP</div></td>
      <td width="8%" height="25"><div align="center">删除</div></td>
    </tr>
	<?
	while($r=$empire->fetch($sql))
	{
		if(!empty($r[checked]))
		{$checked=" title='未审核' style='background:#99C4E3'";}
		else
		{$checked="";}
		if($r['userid'])
		{
			$r['username']="<a href='member/AddMember.php?enews=EditMember&userid=$r[userid]' target='_blank'><b>$r[username]</b></a>";
		}
		if(empty($r['username']))
		{
			$r['username']='匿名';
		}
		if($r[isgood])
		{
			$r[saytime]='<color=red>'.$r[saytime].'</font>';
		}
	?>
    <tr bgcolor="#FFFFFF" id=pl<?=$r[plid]?>> 
      <td height="25" valign="top"><div align="center"><?=$r[username]?></div></td>
      <td height="25" valign="top"><?=$r[saytext]?></td>
      <td height="25" valign="top"><div align="center"><?=$r[saytime]?></div></td>
      <td height="25" valign="top"><div align="center"><?=$r[sayip]?></div></td>
      <td height="25" valign="top"><div align="center"> 
          <input name="plid[]" type="checkbox" id="plid[]" value="<?=$r[plid]?>" onclick="if(this.checked){pl<?=$r[plid]?>.style.backgroundColor='#DBEAF5';}else{pl<?=$r[plid]?>.style.backgroundColor='#ffffff';}"<?=$checked?>>
        </div></td>
    </tr>
	<?
	}
	db_close();
	$empire=null;
	?>
    <tr bgcolor="#FFFFFF">
      <td height="25" colspan="5">
        <?=$returnpage?>
        &nbsp;&nbsp; <input type="submit" name="Submit" value="审核评论" onClick="document.form1.enews.value='CheckPl_all';">
        &nbsp;&nbsp;&nbsp; 
		<input type="submit" name="Submit3" value="推荐评论" onClick="document.form1.enews.value='DoGoodPl_all';document.form1.isgood.value='1';"> 
        &nbsp;&nbsp;&nbsp; 
		<input type="submit" name="Submit4" value="取消推荐评论" onClick="document.form1.enews.value='DoGoodPl_all';document.form1.isgood.value='0';"> 
        &nbsp;&nbsp; &nbsp;
        <input type="submit" name="Submit" value="删除" onClick="document.form1.enews.value='DelPl_all';"> 
        <input name="enews" type="hidden" id="enews" value="DelPl_all">&nbsp;<input type=checkbox name=chkall value=on onclick=CheckAll(this.form)>选中全部</td>
    </tr>
  </table>
</form>
</body>
</html>
