<!--#include file="../inc.asp"-->
<!--#include file="../ydzq.asp"-->
<!--#include file="conn.asp"-->

<%
dim IP,winText
call head()
TP=request("TP")
winText=ubb(request("winText"))
if TP="ok" then

Call saycarda("发表评论")

if winText="" then
  Call Error("评论内容不能为空！")
  end if
if len(winText)>100 then
  Call Error("评论内容最多100字！")
  end if

set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from winbbs where writetime >= DateAdd('s', -20, Now()) and usid="&myid,ydzqconn,1,3

if not rs.eof then
  Call Error("操作太快，请等待20秒再发表评论！")
  end if
  
rs.addnew
rs("winText")=winText
rs("usid")=myid
rs("writetime")=now()
rs.update
rs.close
set rs=nothing

response.write"发表成功！<br/>"
response.write"<a href=""winbbs.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&""">返回上级</a><br/>"
call headsay()
response.end
end if

Call saycarda("评论列表")
  If saytk>1 then
%>
<form name="form" method="post" action="winbbs.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">
<%End if
response.write"<input type=""text"" name=""winText"" maxlength=""100""/><br/>"
  If saytk>1 Then
  response.write "<input type=""hidden"" name=""tp"" value=""ok""/>"
  response.write "<input type=""submit"" name=""Submit"" value=""发表""></form><br/>"
  else
response.write"<anchor>发表"
response.write"<go method=""post"" href=""winbbs.asp?sid="&sid&"&amp;saytk="&saytk&""">"
response.write"<postfield name=""winText"" value=""$(winText)""/>"
response.write"<postfield name=""TP"" value=""ok""/>"
response.write"</go></anchor><br/>"
End if
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select  winText,usid,writetime from winbbs order by id desc",ydzqconn,1,1
If Not rs.eof	Then
	Dim PageSize,i
	PageSize=10						
	Dim Count,page,pagecount,gopage			
	gopage="winbbs.asp?sid="&sid&"&amp;saytk="&saytk&"&amp;"
	Count=rs.recordcount	
	page=int(request.QueryString ("page"))
	if page<=0 or page="" then page=1		
	pagecount=(count+pagesize-1)\pagesize	
        if page>pagecount then page=pagecount
	rs.move(pagesize*(page-1))
	For i=1 To PageSize     						
	If rs.eof Then Exit For

Response.write ""&i+(page-1)*PageSize&"."
  if rs("usid")<>0 then
  response.write"<a href=""../uinfo.asp?ID="&rs("usid")&"&amp;sid="&sid&"&amp;saytk="&saytk&""">"&uname(rs("usid"))&"</a>说:"&ubb(rs("winText"))&"("&fordate2(rs("writeTime"))&")<br/>"
  else
  response.write"(系统)"&ubb(rs("winText"))&"("&fordate2(rs("writeTime"))&")<br/>"
  end if
	rs.moveNext
 	Next
	if page-pagecount<0 then response.write "<a href="""&gopage&"page="&page+1&""">下页</a>"
	if page>1 then response.write "<a href="""&gopage&"page="&page-1&""">上页</a>"
	if pagecount>1 then response.write "<br/><b>"&page&"</b>/"&pagecount&"页<input name=""page"" format=""*N"" value="""&page&""" type=""text"" maxlength=""5"" emptyok=""true"" size=""3""/><a href="""&gopage&"page=$(page)"">跳转</a><br/>"
Else
   Response.write "暂无相关记录！<br/>"
end if
rs.close
set rs=nothing
  function uname(fid)
 dim ru
 Set ru = Server.CreateObject("ADODB.Recordset")
 ru.Source ="SELECT name from users Where ID="&fid
 ru.open ru.Source,Conn,1,1
 if not ru.eof then
  uname=ru("name")
 else
 uname="用户不存在"
 end if
 ru.close
 set ru=nothing
 end function

ydzqconn.close
set ydzqconn=nothing
conn.close
set conn=nothing
%>
-------------
<!--#include file="fanhui.asp"-->
<%Call headsay()%>  