<?php
require("../../class/connect.php");
if(!defined('InEmpireCMS'))
{
	exit();
}
require("../../class/db_sql.php");
require("../../class/q_functions.php");
require "../".LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
eCheckCloseMods('gb');//关闭模块
//分类id
$bid=(int)$_GET['bid'];
$gbr=$empire->fetch1("select bid,bname,groupid from {$dbtbpre}enewsgbookclass where bid='$bid'");
if(empty($gbr['bid']))
{
	printerror("EmptyGbook","",1);
}
//权限
if($gbr['groupid'])
{
	include("../../member/class/user.php");
	$user=islogin();
	include("../../data/dbcache/MemberLevel.php");
	if($level_r[$gbr[groupid]][level]>$level_r[$user[groupid]][level])
	{
		echo"<script>alert('您的会员级别不足(".$level_r[$gbr[groupid]][groupname].")，没有权限提交信息!');history.go(-1);</script>";
		exit();
	}
}
esetcookie("gbookbid",$bid,0);
$bname=$gbr['bname'];
$search="&bid=$bid";
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$line=$public_r['gb_num'];//每页显示条数
$page_line=10;//每页显示链接数
$offset=$start+$page*$line;//总偏移量
$totalnum=(int)$_GET['totalnum'];
if(!$public_r['usetotalnum'])
{
	$totalnum=0;
}
if($totalnum>0)
{
	$num=$totalnum;
}
else
{
	$totalquery="select count(*) as total from {$dbtbpre}enewsgbook where bid='$bid' and checked=0";
	$num=$empire->gettotal($totalquery);//取得总条数
}
if($public_r['usetotalnum'])
{
	$search.="&totalnum=$num";
}
//checkpageno
eCheckListPageNo($page,$line,$num);
$query="select lyid,name,email,`mycall`,lytime,lytext,retext from {$dbtbpre}enewsgbook where bid='$bid' and checked=0";
$query=$query." order by lyid desc limit $offset,$line";
$sql=$empire->query($query);
$listpage=page1($num,$line,$page_line,$start,$page,$search);
$url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$fun_r['saygbook'];
?>
<!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" />
<title>在线留言咨询</title>
<style type="text/css">
<!--
*{ margin:0; padding:0;}
body,td,th {
	font-size: 12px;
	color:#333;
}
body {
	margin: 0px;
}
.guesttable{ margin-bottom:15px;}
.tdtitle{width:656px; border:1px solid #0f3c8d; border-bottom:none;height:24px; background:#0f3c8d; color:#fff; text-indent:10px; line-height:24px; font-size:12px;}
.tdcon{width:636px; padding:10px; border:1px solid #0f3c8d; border-top:none; background:#fff;font-size:12px; line-height:20px;}
.huifu{ width:624px; padding:5px; margin-top:5px; border:1px dashed #cc0000; color:#c00;}
.tdpage{ width:658px; height:20px; line-height:20px; font-size:14px;}
.tdpage a{ font-size:14px;}
input.leftin{ width:150px; height:20px; line-height:20px; background:#fff; border:1px solid #666}
textarea.rightin{ width:415px; height:80px; padding:5px; background:#fff; border:1px solid #666;}
input.button{ width:80px; height:24px; background:#CCC; border:1px solid #999; text-align:center; line-height:18px;}
a:link {
	color: #273981;
}
a:visited {
	color: #273981;
}
a:hover {
	color: #cc0000;
}
a:active {
	color: #cc0000;
}
-->
</style>
<script language="javascript">
function checkform()
{
   if(document.form1.call.value.length!=11)
   {  
    //验证手机号为11位
    alert("您的手机号不正确哦！")
    document.form1.call.focus();
    return false;
   }
   var call=document.form1.call.value;
   var reg0=/^13\d{5,9}$/; //130--139。至少7位
   var reg1=/^15\d{5,9}$/; //15至少7位
   var reg2=/^18\d{5,9}$/; //18
  
   var my=false;
   if (reg0.test(call))my=true;
   if (reg1.test(call))my=true;
   if (reg2.test(call))my=true;
  
   if (!my){
    alert("您的手机号不正确哦")
    document.form1.call.focus();
    return false;
   }
}
</script>
</head>

<body>
<form action="../../enews/index.php" method="post" name="form1" id="form1"  onsubmit="return checkform()">
<table width="658" border="0" cellspacing="0" cellpadding="0" class="guesttable">
  <tr>
    <td class="tdtitle">请您留言</td>
  </tr>
<tr>
<td class="tdcon">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="220" height="30">姓名：<input name="name" type="text" id="name" class="leftin" /> *</td>
    <td rowspan="3"><textarea name="lytext" cols="50" rows="8" id="lytext" class="rightin"></textarea></td>
  </tr>
  <tr>
    <td height="30">手机：<input name="call" type="text" id="call" class="leftin" /> *</td>
    </tr>
  <tr>
    <td  height="30">邮箱：<input name="email" type="text" id="email" class="leftin" /> </td>
    </tr>
  <tr>
    <td colspan="2" align="center" height="40"><input type="submit" name="Submit3" value="提交" class="button" />
											<input type="reset" name="Submit22" value="重置" class="button" />
											<input name="enews" type="hidden" id="enews" value="AddGbook" /></td>
    </tr>
</table>

</td>
</tr>
</table></form>

<?
while($r=$empire->fetch($sql))
{
	$r['retext']=nl2br(stripSlashes($r[retext]));
	$r['lytext']=nl2br(stripSlashes($r[lytext]));
?>

<table width="658" border="0" cellspacing="0" cellpadding="0" class="guesttable">
  <tr>
    <td class="tdtitle"><?=stripSlashes($r[name])?> 于 <?=$r[lytime]?> 留言咨询</td>
  </tr>
  <tr>
    <td class="tdcon"><?=$r[lytext]?>
<?
if($r[retext])
{
?>
<div class="huifu">管理员回复：<?=$r[retext]?></div>
<?
}
?></td>
  </tr>
</table>

<?
}
?>

<table width="658" border="0" cellspacing="0" cellpadding="0" class="guesttable">
<tr>
<td class="tdpage">分页：<?=$listpage?></td>
</tr>
</table>
</body>
</html>

<?php
db_close();
$empire=null;
?>