<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%
if session("admin")="" then
  response.redirect "admin_login.asp"
end if

'07 访客留言管理
if not checkflag("07") then
  call mb("对不起，您没有管理访客留言的权限！","",0)
end if

dim action
dim totalpage,maxperpage,totalrecords,i,currentpage
action=request("action")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言本管理相关</title>
<script language=javascript src="mouse_up.js"></script>
<link href="admin.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="5" topmargin="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#000000" vspace="0" hspace="0">
  <tr bgcolor="#EFEBEF"> 
    <td height="27"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="86%"><font color="#FF3000">.:: 您可以在这里进行[访客留言管理]相关操作</font></td>
          <td width="14%" height="20" align="center"><a href="javascript:this.location.reload()"><img src="images/refresh.gif" alt="刷新" width="40" height="12" border="0"></a></td>
        </tr>
      </table></td>
  </tr>
  <tr > 
    <td height="1" bgcolor="#000000"></td>
  </tr>
</table>
<%
select case action
  case "reply"
    call reply()
  case "replysave"
    call replysave()
  case "replyedit"
    call replyedit()
  case "del"
    call del
  case else
    call main()
end select

sub main()

response.expires=0
currentpage=request("page")
if not isinteger(currentpage) then
  currentpage=1
else
  currentpage=clng(currentpage)
end if

maxperpage=15
totalrecords=0
totalpage=1
i=1

set rs=server.createobject("adodb.recordset")
sql="select * from guestbook order by id desc"
rs.open sql,conn,1,1

if not(rs.bof and rs.eof) then
  rs.pagesize=maxperpage
  rs.absolutepage=currentpage
  totalpage=rs.pagecount
  totalrecords=rs.recordcount
end if
%>
<br>
<br>
<form name="form1" method="post" action="">
  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr align="center" bgcolor="#EFEBEF"> 
      <td width="3%" height="23"><font color="#000000">ID</font></td>
      <td width="27%" height="23"><font color="#000000">留言主题</font></td>
      <td width="25%" height="23"><font color="#000000">网友姓名</font></td>
      <td width="21%" height="23"><font color="#000000">留言日期</font></td>
      <td width="11%" height="23"><font color="#000000">是否回复</font></td>
      <td width="13%" height="23"><font color="#000000">删　除</font></td>
    </tr>
    <%do until rs.eof or i>maxperpage%>
    <tr bgcolor="#FFFFFF"> 
      <td height="23">&nbsp;<%=rs("id")%></td>
      <td height="23">&nbsp;<a href="" target=_blank><%=rs("g_topic")%></a></td>
      <td height="23">&nbsp; <%=rs("g_name")%> </td>
      <td height="23">&nbsp; <%=rs("g_dateandtime")%> </td>
      <td height="23" align="center">&nbsp; 
        <%
	  if rs("g_reply")<>"" then
	     response.write "[<a href='admin_guestbook.asp?action=replyedit&id="&rs("id")&"' title='修改此留言的回复内容...'>修改回复</a>]"
	  else
	     response.write "[<a href='admin_guestbook.asp?action=reply&id="&rs("id")&"' title='回复此条留言...'><font color=red>回复留言</font></a>]"
	  end if
	  %>
      </td>
      <td height="23" align="center"><a href="?action=del&id=<%=rs("id")%>" onclick="javascript:if(confirm('是否真的要删除此条留言？')){return true;}else{return false;}">删除</a> 
      </td>
    </tr>
    <%rs.movenext
   i=i+1
   loop
  %>
    <tr bgcolor="#FFFFFF"> 
      <td height="23" colspan="6"> 
        <%if totalrecords>0 then call showpage("admin_link.asp",totalrecords,maxperpage,true,true,"条留言")%>
      </td>
    </tr>
  </table>
</form>
<%
rs.close
set rs=nothing
end sub

sub reply()

dim id,g_content

id=request("id")
 
if not isinteger(id) then
  call mb("请指定要回复的留言！","",0)
end if

set rs=conn.execute("select * from guestbook where id="&id)

if rs.bof and rs.eof then
  call mb("找不到要回复的留言，请确认是否已经被删除！","",0)
end if

g_content=rs("g_content")
g_content=replace(g_content,chr(13),"<br>")
g_content=replace(g_content," ","&nbsp;")

%>
<form action="?action=replysave" method="post" name="reply" id="reply">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr align="center" bgcolor="#EFEBEF" > 
      <td height="22" colspan="2"　background="images/admin/menu_bg.gif"><font color="#000000">留 
        言 管 理 - 修 改 回 复</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="104" height="22" align="center">留言主题：</td>
      <td width="393" height="22">&nbsp;<b><%=rs("g_topic")%></b></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">网友大名：</td>
      <td height="22">&nbsp;<%=rs("g_name")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">留言时间：</td>
      <td height="22">&nbsp;<%=rs("g_dateandtime")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">留言内容：</td>
      <td height="22">&nbsp;<%=g_content%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">回复留言：</td>
      <td height="22">&nbsp; 
        <textarea name="g_reply" cols="40" rows="10" class="input" id="g_reply"></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="30" colspan="2" align="center"> 
        <input name="id" type="hidden" id="id" value="<%=id%>"> 
        <input name="Submit" type="submit" class="button" value=" 确定回复 ">
        　 <input name="Submit2" type="reset" class="button" value=" 重新填写 ">
      </td>
    </tr>
  </table>
</form>
<%
rs.close
set rs=nothing

end sub

sub replysave()

dim g_reply,id
g_reply=checkstr(trim(request.form("g_reply")))
id=request("id")
if not isinteger(id) then
  call mb("请指定要回复的留言！","",0)
end if

if g_reply="" then
 call mb("请输入回复内容！","",0)
end if

set rs=server.createobject("adodb.recordset")
sql="select * from guestbook where id="&id
rs.open sql,conn,1,3

if rs.bof and rs.eof then
  call mb("找不到要回复的留言，请确定是否已经被删除！","",0)
else
  rs("g_reply")=g_reply
  rs("g_replydate")=now()
  rs.update
end if

rs.close
set rs=nothing

call mb("回复成功！","admin_guestbook.asp",1)

end sub


sub replyedit()

dim id,g_content,g_reply

id=request("id")
 
if not isinteger(id) then
  call mb("请指定要修改的留言的回复！","",0)
end if

set rs=conn.execute("select * from guestbook where id="&id)

if rs.bof and rs.eof then
  call mb("找不到信息，请确认是否已经被删除！","",0)
end if

g_content=rs("g_content")
g_content=replace(g_content,chr(13),"<br>")
g_content=replace(g_content," ","&nbsp;")

g_reply=rs("g_reply")
'g_reply=replace(g_reply,chr(13),"<br>")
'g_reply=replace(g_reply," ","&nbsp;")

%>
<form action="?action=replysave" method="post" name="replyedit" id="replyedit">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr align="center" bgcolor="#EFEBEF"> 
      <td height="23" colspan="2"><font color="#000000">留 言 管 理 - 回 复 留 言</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="104" height="22" align="center">留言主题：</td>
      <td width="393" height="22">&nbsp;<b><%=rs("g_topic")%></b></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">网友大名：</td>
      <td height="22">&nbsp;<%=rs("g_name")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">留言时间：</td>
      <td height="22">&nbsp;<%=rs("g_dateandtime")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">留言内容：</td>
      <td height="22">&nbsp;<%=g_content%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="22" align="center">回复留言：</td>
      <td height="22">&nbsp; 
        <textarea name="g_reply" cols="40" rows="10" class="input" id="g_reply"><%=g_reply%></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="30" colspan="2" align="center"> 
        <input name="id" type="hidden" id="id" value="<%=id%>"> 
        <input name="Submit" type="submit" class="button" value=" 确定修改 ">
        　 <input name="Submit2" type="reset" class="button" value=" 重新填写 ">
      </td>
    </tr>
  </table>
</form>
<%
rs.close
set rs=nothing

end sub

sub del()

id=request("id")

if not isinteger(id) then
 call mb("请指定要删除的留言！","",0)
end if

sql="delete from guestbook where id="&id
conn.execute(sql)

call mb("删除留言成功！","admin_guestbook.asp",1)

end sub
%>
</body>
</html>
