<?php
include("qs.php");
require( '../data/config.php');
$conn=mysql_connect($db_host,$db_user,$db_pass);
mysql_query("set names 'utf8'");
mysql_select_db($db_name);
if (PHP_VERSION >= '5.1' && !empty($timezone))
{
    date_default_timezone_set($timezone);
}
$qs=explode(",",$_SESSION["tm_qs"]);
if($qs[0]==0)
   {
   echo "<script>location.href='main.php';</script>";
   exit();
   }
$title=_get('title');
if($title=="")
$title=_post('title');
$classfile=array();
$sql="select * from tm_art_class order by px";
		  $rsql=mysql_query($sql);
		  while($rs=mysql_fetch_object($rsql))
		  {
		  $classfile[$rs->art_id]=$rs->filename;
		  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META http-equiv="Pragma" content="no-cache" />
<LINK href="css/general.css" rel="stylesheet" type="text/css" />
<LINK href="css/main.css" rel="stylesheet" type="text/css" />
<style>
#Loading { margin-top:60px; padding-top:10px; padding-right:10px; padding-left:10px; position:absolute;z-index:10;left:10px;top:10px;border:1px #666666 solid;background:#eeeeee;width:500px;height:200px; word-wrap: break-word; word-break: normal;}
</style>
<script LANGUAGE="JavaScript"> 
<!-- 
function $(){return document.getElementById?document.getElementById(arguments[0]):eval(arguments[0]);}
var OverH,OverW,ChangeDesc,ChangeH=50,ChangeW=50;
function OpenDiv(_Dw,_Dh,_Desc) {
$("Loading").innerHTML="";
OverH=_Dh;OverW=_Dw;ChangeDesc=_Desc;
$("Loading").style.display='';
if(_Dw>_Dh){ChangeH=Math.ceil((_Dh-10)/((_Dw-10)/50))}else if(_Dw<_Dh){ChangeW=Math.ceil((_Dw-10)/((_Dh-10)/50))}
$("Loading").style.top=(document.documentElement.clientHeight-10)/2+"px";
$("Loading").style.left=(document.documentElement.clientWidth-10)/2+"px";
OpenNow()
}
var Nw=10,Nh=10;
function OpenNow() {
if (Nw>OverW-ChangeW)ChangeW=2;
if (Nh>OverH-ChangeH)ChangeH=2;
Nw=Nw+ChangeW;Nh=Nh+ChangeH;

if(OverW>Nw||OverH>Nh) {
	if(OverW>Nw) {
	$("Loading").style.width=Nw+"px";
	$("Loading").style.left=(document.documentElement.clientWidth-Nw)/2+"px";
	}
	if(OverH>Nh) {
	$("Loading").style.height=Nh+"px";
	$("Loading").style.top=(document.documentElement.clientHeight-Nh)/2+"px"
	}
	window.setTimeout("OpenNow()",10)
	}else{
	Nw=10;Nh=10;ChangeH=50;ChangeW=50;
	$("Loading").innerHTML=ChangeDesc;
	}
}
//-->
</script> 
</HEAD><BODY>
<div class="h2">系统管理 >> 日志评论管理</div>
<div class="list-div">

<table cellspacing='1' cellpadding='3'>
<tr>
  <th align='left'><table width="100" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="left">&nbsp;&nbsp;日志评论管理</div></td>
        <td width="150">&nbsp;</td>
      </tr>
    </table></th>
</tr>
<tr><td align="left" valign="top" style="background:#F5F5F5;padding-bottom:8px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form id="form1" name="form1" method="post" action="ret.php" onsubmit="return checkform(this);">
<TR BORDER="0" WIDTH="100%">
                <TD style="PADDING-LEFT: 8px; PADDING-TOP: 8px" vAlign=top 
                align=left bgColor=#ffffff height=30 colspan="8">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="90">输入搜索发布者:</td>
    <td width="160"><input name="title" type="text" id="title" value="<?php echo $title;?>" /></td>
    <td width="30">&nbsp;</td>
	  <td><div align="left">
	    <input type="submit" name="dosubmit" value="搜索" class="btn">
	    </div></td>
  </tr>
</table>

				</TD>
</TR>
</form>	
</table>
<TABLE cellSpacing=0 cellPadding=0 width="97.5%" border=0 CALLPADDING="0">
			  <form id="form2" name="form2" method="post" action="ret_w.php">
			  <tr>
                <td height="20" bgcolor="#C2C2C2" style="PADDING-LEFT: 8px; PADDING-TOP: 8px"><input type="checkbox" name="selall" title="全選"  onClick="select_all('form2','chkkindid[]',this.name)">&nbsp;</td>
                    <td width="21%" bgcolor="#C2C2C2" style="PADDING-LEFT: 8px; PADDING-TOP: 8px"><span class="STYLE1">内容</span></td>
				<td width="15%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">发布者</div></td>
				<td width="10%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">邮箱</div></td>
				<td width="10%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">网址</div></td>
                <td width="10%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">IP</div></td>
                <td width="15%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">评论日期</div></td> 
                <td width="10%" bgcolor="#C2C2C2"><div align="center">操作</div></td>
			  </tr>
				<?php 
$sql="select count(*) from tm_art_re";
if($title<>"")
$sql.=" where re_name like '%".$title."%'";
$resultc=mysql_query($sql) or die(mysql_error());
$rsc=mysql_fetch_array($resultc);
$num=$rsc[0];
$pagesize=12; 
if(_get('page')<>"")
   {
   $page=_get('page')-1;
   if($page<0)$page=0;
   if($page>(intval($num/$pagesize)))$page=intval($num/$pagesize);
   }
else
	$page=0;
		  $sql="select tm_art_re.*,tm_art.art_class,tm_art.art_date from tm_art_re left join tm_art on tm_art_re.re_artid=tm_art.art_id";
if($title<>"")
$sql.=" where tm_art_re.re_name like '%".$title."%'";
$sql.=" order by tm_art_re.re_id desc limit ".$pagesize*$page.",".$pagesize;
		  $rsql=mysql_query($sql);
		  while($rs=mysql_fetch_object($rsql))
		  {
		  ?>
<TR BORDER="0" WIDTH="100%" bgcolor="#EEEEEE" onmousemove="this.style.color='#000000';this.style.backgroundColor='#D5D5D5'" onmouseout="this.style.backgroundColor='#EEEEEE';this.style.color='#000000'">
                <TD width="6%"  height=20 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px; border-bottom:#666666 dotted 1px;"><input name="chkkindid[]" type="checkbox" id="chkkindid[]" value="<?php echo $rs->re_id;?>" /></TD>
                <TD   height=20 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px; border-bottom:#666666 dotted 1px;">
                <?php if(strlen($rs->re_cont)>40) echo "<a href=\"javascript:OpenDiv(500,200,'".$rs->re_cont."<br /><br /> 双击关闭')\">".mb_substr($rs->re_cont,0,20,"utf-8")."…</a>"; else echo $rs->re_cont."&nbsp;";?></TD>
                <TD  
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php echo $rs->re_name;?>
              </div></TD>
			  <TD  
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php echo $rs->re_email;?>&nbsp;
              </div></TD>
			  <TD  
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php echo $rs->re_url;?>&nbsp;
              </div></TD>
				<TD  
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;">
                  
                  <div align="center"><a href="http://www.wztm.net/ip.php?id=<?php echo $rs->ip;?>" target="_blank"><?php echo $rs->ip;?></a>
                  </div></TD>
                <TD  
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php echo $rs->re_date;?>
              </div></TD>
                <TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center"><a href="../<?php echo $classfile[$rs->art_class];?>/<?php echo substr(ereg_replace('-',"",$rs->art_date),0,6);?>/<?php echo ereg_replace('-',"",$rs->art_date).$rs->re_artid;?>.html" target="_blank">详细</a> </div></TD>
              </TR>
		  <?php }?>
			<TR BORDER="0" >
              <TD height="30"  colspan="8">&nbsp;&nbsp;
                <input type="image" src="images/del.gif" align="absmiddle" border="0" name="del" onclick="javascript:return chkform(form2.name,'确定刪除吗？','del');" />
                <input name="action" type="hidden" id="action" />
              </TD>
			</TR>
		  </form>
<div id="Loading" style="display:none" ondblclick="this.style.display='none'"></div>
<TR BORDER="0" >
			  <TD height="30"  colspan="8">
			  <div class="page">
		 总数：<?php echo $num;?>篇,每页显示<?php echo $pagesize;?>篇，共<?php echo ceil($num/$pagesize);?>页，共<?php echo ceil($num/$pagesize);?>页
		 共<?php echo ceil($num/$pagesize);?>页
	      <a href="ret.php?page=1&title=<?php echo urlencode($title);?>">首页</a><?php if($page>0) echo " <a href='ret.php?page=".$page."&title=".urlencode($title)."'>上一页</a> ";
for($i=($page>4?($page-3):1);$i<=($page<(ceil($num/$pagesize)-4)?(($page>=5?($page-3):1)+8):ceil($num/$pagesize));$i++)
    {
	if(($page+1)==($i))
	echo "&nbsp;".$i."&nbsp;";
	else
	echo "<a href=ret.php?page=".$i."&title=".urlencode($title).">[".($i)."]</a>";
	}
	?><?php if($page<ceil($num/$pagesize)-1) echo " <a href='ret.php?page=".($page+2)."&title=".urlencode($title)."'>下一页</a> ";?><a href="ret.php?page=<?php echo round(ceil($num/$pagesize));?>&title=<?php echo urlencode($title);?>">末页</a>
		  </div>
			  </TD>
		  </TR>
      </TABLE>
</td>
</tr></table></div>

<?php include "boot.php";?>
</body></html>
<script language="JavaScript" >

function chkform(theForm,msg,action){
	if (confirm(msg)){

		document.forms[theForm].action.value = action;
		document.forms[theForm].submit();
		return true;
	}else{
		return false;
	}
}

// -------- 全選或取消 checkbox 方塊
<!--
function select_all(formName, elementName, selectAllName) {
	if(document.forms[formName].elements[selectAllName].checked) {
		
		if(document.forms[formName].elements[selectAllName].length = 1 &&
		    typeof(document.forms[formName].elements[elementName]) != "undefined" ) {
		
			document.forms[formName].elements[elementName].checked = true;

		    for(var i = 0; i < document.forms[formName].elements[elementName].length; i++)
			document.forms[formName].elements[elementName][i].checked = true;
		}
	}
	else {
		if(document.forms[formName].elements[selectAllName].length = 1 &&
		    typeof(document.forms[formName].elements[elementName]) != "undefined" ) {
			document.forms[formName].elements[elementName].checked = false;

		    for(var i = 0; i < document.forms[formName].elements[elementName].length; i++)
				document.forms[formName].elements[elementName][i].checked = false;
		}
	}
}
//-->
</script>
<script language="javascript">
function checkform(theform)
{
if(theform.title.value=="")
  {
  alert("搜索发布者不能为空！");
  theform.title.focus();
  return false;
  }
return true;
}
</script>