<!--#include file="../Conn.asp"-->
<!--#include file="../Cache/QvodCms.Admin.asp"-->
<!--#include file="QvodCms.Security.asp"-->
<!--#include file="QvodCms.Fun.asp"-->
<%Response.Charset="gb2312"
Dim Action,Gb_user,Gb_oicq,Gb_content,Gb_intro,Gb_id,Gb_code,Page,GbPage
Action=Trim(Request.QueryString("action"))
Gb_id=QvodCms_CLng(Request("gb_id"))
Page=QvodCms_CLng(Request("page")) : If Page<1 Then page=1
Call OpenConn()
If Action="addsave" Then'新加
	Gb_user=Left(FilterDirty(Bad_Url(NoSqlHack(Request.Form("gb_user")))),50)
	'Gb_oicq=QvodCms_CLng(Trim(Request.Form("gb_oicq")))
	Gb_oicq="1000"
	Gb_content=FilterDirty(Bad_Url(NoSqlHack(Request.Form("gb_content"))))
	Gb_code=Trim(Request.form("gb_code"))
	If Trim(Session("CheckCode")) = "" Then
	    Response.Write "err1"
	ElseIf Gb_code <> Session("CheckCode") Then
	    Response.Write "err2"
	ElseIf GetTimeSpan("LastGbTime")<40 Then 
        Response.Write "wait"		
	Else
		 Conn.Execute("Insert Into qvodcms_gb (gb_id,gb_user,gb_oicq,gb_content,gb_lastdate,gb_top) values ('"&Max_id("gb")&"','"&ReplaceHtml(Gb_user)&"',"&Gb_oicq&",'"&ReplaceHtml(Gb_content)&"','"&now()&"',0)")
		Response.Write "ok"
	    SetSessionTime "LastGbTime",Now()
	End If
ElseIf Action="comment" Then'置顶
	If Session("Gbadmin")=True Then Conn.Execute(" Update [qvodcms_gb] Set gb_top=1 Where gb_id="&Gb_id&" ")
	Response.Write"ok"
ElseIf Action="recomment" Then'取消置顶
    If Session("Gbadmin")=True Then Conn.Execute(" Update [qvodcms_gb] Set gb_top=0 Where gb_id="&Gb_id&" ")
	Response.Write"ok"
ElseIf Action="del" Then'删除留言
	If Session("Gbadmin")=True Then Conn.Execute(" Delete from [qvodcms_gb] Where gb_id="&Gb_id&" ")
	Response.Write"ok"
ElseIf Action="regb" Then'回复留言
    Gb_intro=FilterDirty(NoSqlHack(Request.Form("gb_intro")))
	If Session("Gbadmin")=True Then Conn.Execute(" Update [qvodcms_gb] Set gb_intro='"&Gb_intro&"' Where gb_id="&Gb_id&" ")
	Response.Write"ok"
ElseIf Action="delregb" Then'删除回复
	If Session("Gbadmin")=True Then Conn.Execute(" Update [qvodcms_gb] Set gb_intro='' Where gb_id="&Gb_id&" ")
	Response.Write"ok"						
Else
	Set rs = Server.CreateObject("adodb.recordset")
	sql="select gb_id,gb_user,gb_oicq,gb_content,gb_intro,gb_lastdate,gb_top from qvodcms_gb order by gb_top desc,gb_lastdate desc"
	rs.Open sql, Conn, 1, 1
	If Not(rs.bof And rs.eof) Then
	    rs.pagesize=QvodCms_CLng(AdminId(18))'分页大小
		pageall=rs.pagecount   '总页数
	    rscount=rs.recordcount '总记录数
		If page>rs.PageCount Then page=rs.PageCount
		rs.absolutepage=page
		For i=1 to rs.pagesize
		    Response.Write "<table width=""100%"" class=gb_box border=""0"" cellspacing=""0"" cellpadding=""0"">"
			Response.Write "<tr class=gb_user><td class='gb_ufont' width=93% height=22>&nbsp;&nbsp;访客:"&rs("gb_user")&" 留言于："&rs("gb_lastdate")&"</td><td width=""7%"" class='gb_lou'>第"&rscount-(page-1)*QvodCms_CLng(AdminId(23))-(i-1)&"楼</td></tr>"
            Response.Write("<tr><td class='gb_content' colspan=""2"">"&server.htmlencode(rs("gb_content"))&"</td></tr>")
			If rs("gb_intro")<>"" Then
			Response.Write("<tr><td class='gb_intro' colspan=""2"">"&rs("gb_intro")&"</td></tr>")
			Else
			Response.Write("<tr class='gb_intro' style='display:none' id='"&rs("gb_id")&"'><td class='gb_intro' colspan=""2""></td></tr>")
			End If
			If CheckJaJa=True and Session("QvodCms")="qvodcms.com" Then'管理员权限
			    Response.Write("<li class='gb_admin'>")
			    If rs("gb_top")=1 Then
			    Response.Write("<a href=""javascript:"" onclick=""GbookList("&rs("gb_id")&","&page&",'recomment');"">取消置顶</a> ")
				Else
				Response.Write("<a href=""javascript:"" onclick=""GbookList("&rs("gb_id")&","&page&",'comment');"">置顶</a> ")
				End If
			    If rs("gb_intro")<>"" Then
				Response.Write("<a href=""javascript:"" class='delregb' onclick=""GbookList("&rs("gb_id")&","&page&",'delregb');"">删除回复</a> ")
				Else
				Response.Write("<a href=""javascript:"" class='regb' onclick=""ReGbook("&rs("gb_id")&","&page&");"">回复</a> ")
				End If				
				Response.Write("<a href=""javascript:"" class='del' onclick=""GbookList("&rs("gb_id")&","&page&",'del');"">删除</a> ")
				'Response.Write("<a target=blank href='tencent://message/?uin="&rs("gb_oicq")&"&Site=留言回复&Menu=yes' title='"&rs("gb_oicq")&"'>QQ留言</a> ")
				Response.Write("</li>")
			End If
			Response.Write("</table>")	
		    rs.movenext
		    If rs.eof Then Exit For
		Next
		Call GbookPage
	Else
		Response.Write("暂时没有网友留言")
	End If
	rs.close
	Set rs=nothing
	If CheckJaJa=True Then Session("Gbadmin")=CheckJaJa Else Session("Gbadmin")=""	
End If

Sub GbookPage
    Dim m,x,y:x=page-5:y=page+5:if x<1 then x=1
	if y>pageall then y=pageall
    Response.Write "<div class=""gb_page"">"&chr(10)
	Response.Write "共"&pageall&"页 <a href=""javascript:"" onclick=""JaJaGbook(1);return false;"" >首页</a> <a href=""javascript:"" onclick=""JaJaGbook("&page-1&");return false;"">前一页</a>"
	For m=x to y
		If page=m Then Response.Write" <font color=""#FF0000"">"&m&"</font>" Else Response.Write " <a href=""javascript:"" onclick=""JaJaGbook("&m&");return false;"">"&m&"</a>"
	Next
	Response.Write " <a onclick=""JaJaGbook("&page+1&");"" href=""javascript:"">下一页</a> <a onclick=""JaJaGbook("&pageall&")"" href=""javascript:"">尾页</a>"
	Response.Write "</div>"
End Sub

Call CloseConn()
%>