<!--#include file="../tgzcm.Conn.asp"-->
<!--#include file="../tgzcm.Cache/tgzcm.Admin.asp"-->
<!--#include file="tgzcm.Security.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=PE_CLng(Request("gb_id"))
Page=PE_CLng(Request("page")) : If Page<1 Then page=1
If Action="addsave" Then'新加
	Gb_user=Left(FilterDirty(Bad_Url(NoSqlHack(Request.Form("gb_user")))),50)
	Gb_oicq=PE_CLng(Trim(Request.Form("gb_oicq")))
	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 tgzcm_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 [tgzcm_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 [tgzcm_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 [tgzcm_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 [tgzcm_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 [tgzcm_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 tgzcm_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=PE_CLng(tgzcmId(8))'每页数量
		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("<ul><li class='gb_user'>访客:"&rs("gb_user")&"</li>")
			Response.Write("<li class='gb_lastdate'>"&rs("gb_lastdate")&"</li>")
			Response.Write("<li class='gb_content'>"&server.htmlencode(rs("gb_content"))&"</li>")
			If rs("gb_intro")<>"" Then
			Response.Write("<li class='gb_intro'>"&rs("gb_intro")&"</li>")
			Else
			Response.Write("<li class='gb_intro' style='display:none' id='"&rs("gb_id")&"'></li>")
			End If
			If Checktgzcm=True 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("</ul>")	
		    rs.movenext
		    If rs.eof Then Exit For
		Next
		Call GbookPage
	Else
		Response.Write("暂时没有网友留言")
	End If
	rs.close
	Set rs=nothing
	If Checktgzcm=True Then Session("Gbadmin")=Checktgzcm 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=""tgzcmGbook(1);return false;"" >首页</a> <a href=""javascript:"" onclick=""tgzcmGbook("&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=""tgzcmGbook("&m&");return false;"">"&m&"</a>"
	Next
	Response.Write " <a onclick=""tgzcmGbook("&page+1&");"" href=""javascript:"">下一页</a> <a onclick=""tgzcmGbook("&pageall&")"" href=""javascript:"">尾页</a>"
	Response.Write "</div>"
End Sub

Call CloseConn()
%>