<?php
error_reporting(0);
//加载常用函数
include_once("../include/common.php");
//加载分页函数
include_once("../include/page.inc.php");
session_start();
islogin();
$url=$_POST["url"] ? $_POST["url"] : $_GET["url"];
$id=$_POST["id"] ? $_POST["id"] : $_GET["id"];
?>
<!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" />
<link rel="stylesheet" type="text/css" href="style/index.css" />
<title>无标题文档</title>
<style type="text/css">
<!--
.borderbottom {border-bottom:#CCC 1px solid; font-size:12px; color:#666}
.normal{font-size:12px; color:#666; padding-top:10px; line-height:20px;}
-->
</style>
<script language="javascript">
function checkform()
{
	if(document.getElementById("content").value=="")
	{
		alert("填写内容");
		return false;
	}
	return true;
}
</script>
</head>

<body>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder">
  <tr>
    <td height="30px" colspan="3" align="center" class="title">留言管理</td>
  </tr>
  <?
//分页数
$pageid=intval($_GET["pageid"]);

$pagesize=6;

$pageurl=$_SERVER["PHP_SELF"]."?";

if(!$pageid)
{
	$pageid=1;
}
$offset=($pageid-1)*$pagesize;
if($offset<=0)
{
	$offset=0;
}

$total=$mysql->rownums("select * from feedback");

$mysql->query("select * from feedback order by id desc limit $offset,$pagesize");

while($arr=$mysql->fetcharray())
{
?>
  <tr>
    <td height="10px" colspan="3"></td>
  </tr>
  <tr class="borderbottom">
    <td width="360" height="18" align="left" bgcolor="#F2F2F2" class="borderbottom">&nbsp; <font color="#F47964">
      <?=$arr["user"]?>
    </font> &nbsp;说:</td>
    <td width="321" align="right" bgcolor="#F2F2F2" class="borderbottom">&nbsp;IP:
      <?=$arr["ip"]?>
      &nbsp;&nbsp;时间:&nbsp;
      <?=date("Y-m-d H:i:s",$arr['time']+8*3600)?>
      &nbsp;</td>
    <td width="249" align="center" bgcolor="#F2F2F2" class="borderbottom"><a href="func/dofeedback.php?action=del&id=<?=$arr['id']?>" onclick="return confirm('是否要删除此留言');">删除</a> - <a href="feedback.php?url=reply&id=<?=$arr['id']?>">回复</a></td>
  </tr>
  <tr class="borderbottom">
    <td height="51" colspan="3" align="left" class="normal" style="font-size:13px;">
	<?=$arr["feedback"]?>
	<? 
	if($arr["reply"]!="")
	{
		echo "<p><font color='red'>管理员回复</font>:<br>".$arr['reply']."</p>";
	}
	?>
    </td>
  </tr>
  <? }?>
  <tr class="borderbottom">
    <td height="20" colspan="3" align="center"><? echo page($total,$pagesize,$pageurl); ?></td>
  </tr>
</table>
<?
if($url=="reply")
{
$mysql->query("select * from feedback where id=$id");
$arr=$mysql->fetcharray();
print<<<EOT
<form id="form1" name="form1" method="post" action="func/dofeedback.php?action=reply" onsubmit="return checkform()">
  <table width="90%" border="0" align="center" cellspacing="0">
    <tr>
      <td colspan="2" class="borderbottom">管理员回复:</td>
    </tr>
    <tr>
      <td height="5" colspan="2"><input name="id" type="hidden" value="{$id}" /></td>
    </tr>
    <tr>
      <td width="48%" height="92"><label>
        <textarea name="content" id="content" cols="45" rows="5">{$arr['reply']}</textarea>
      </label></td>
      <td width="52%"><label>
        <input type="submit" name="button" id="button" value="回复留言" />
      </label></td>
    </tr>
  </table>
</form>
EOT;
}
?>
</body>
</html>