<!--#include file="inc.asp"-->
<!--#include file="check.asp"-->
<%
username=request("username")
page=request("page")
if page="" then
page="1"
end if
if page="1" then
pagen="0"
else
pagen=page
end if
act=request("act")
if act<>"" then
if act="add" then
call addgbook()
response.end
elseif act="save" then
set rs=server.createobject("adodb.recordset") 
sql="select * from gbook where id="&request("id")
rs.open sql,userconn,1,3
rs("reply")=request.form("content")
rs("replytime")=now()
rs("ifrp")=true
rs.update
rs.close
set rs=nothing
response.redirect "?userid="&request("userid")&"&username="&username
response.end
elseif act="del" then
userconn.execute("delete * from [gbook] where id="&request("id")&"")
Response.write "<SCRIPT language=JavaScript>alert('删除成功！');window.location.href='?userid="&request("userid")&"&username="&username&"&page="&page&"';</SCRIPT>"
response.end
end if
end if%>
<SCRIPT LANGUAGE="JavaScript">
<!--//
function check()
{if (isNaN(go2to.page.value))alert("请正确填写转到页数！");
   else if (go2to.page.value==""){alert("请输入转到页数！");}
   else
	go2to.submit();
}
//--></SCRIPT>
<link href="../user/images/style.css" type="text/css" rel="stylesheet" />
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<table width="678"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
        <tr>
          <table border="0" align=center cellpadding="2" cellspacing="1" width="95%" bgcolor="#c6c6c6">
                      <tr bgcolor="#ffffff">
                       <td width="90%" height="13"><div align="center"> [<a href="?userid=<%=request("userid")%>&username=<%=username%>&reply=n"><b><%=username%></b>未回复留言</a>] &nbsp;&nbsp;&nbsp; [<a href="?userid=<%=request("userid")%>&username=<%=username%>&reply=y"><b><%=username%></b>已回复留言</a>] &nbsp;&nbsp;&nbsp; [<a href="?userid=<%=request("userid")%>&username=<%=username%>"><b><%=username%></b>所有留言</a>] &nbsp;&nbsp;&nbsp;<%if username<>"" then%> [<a href="?">所有留言</a>] &nbsp;&nbsp;&nbsp;<%end if%> </div></td>
                      </tr>
                    </table>
        </tr>
      </table>

<%sub addgbook%>
<br>
                   <table border="0" align=center cellpadding="4" cellspacing="1" width="95%" bgcolor="#c6c6c6">
                      <form action="?id=<%=request("id")%>&userid=<%=request("userid")%>&username=<%=username%>&act=save" method="post" name="form1">
                        <TR bgColor=#ffffff>
                          <TD bgcolor="#F7F7F7" style="color:#000000">内 容：</TD>
                          <TD bgcolor="#FFFFFF"><TEXTAREA  name=content rows=7 cols=50><%=request.form("content")%></TEXTAREA></TD>
                        </TR>
                        <TR bgColor=#ffffff>
                          <TD colSpan=2><DIV align=center>
                              <input type="submit" name="Submit" value=" 提交回复 " class=bt2>
                              <input type="RESET" name="Reset2" value=" 重新填写 " class=bt2>
                          </DIV></TD>
                        </TR>
                      </form>
                  </TABLE>
<%end sub%>
<% set rs=server.createobject("adodb.recordset") 
              if not isempty(request("page")) then   
	          pagecount=cint(request("page"))   
              else   
	          pagecount=1   
              end if
	userid=request("userid")
	if request("reply")="n" then
	   if userid<>"" then
              sql="select * from gbook where userid="&userid&" and ifrp=false order by id desc"
	   else
              sql="select * from gbook where ifrp=false order by id desc"
	   end if
	elseif request("reply")="y" then
	   if userid<>"" then
              sql="select * from gbook where userid="&userid&" and ifrp=true order by id desc"
	   else
              sql="select * from gbook where ifrp=true order by id desc"
	   end if
	else
	   if userid<>"" then
              sql="select * from gbook where userid="&userid&" order by id desc"
	   else
              sql="select * from gbook order by id desc"
	   end if
	end if
              rs.open sql,userconn,1,1
			  rs.pagesize=5
              if pagecount>rs.pagecount or pagecount<=0 then              
              pagecount=1              
              end if               
              %>
			  <% if rs.eof and rs.bof then %>
             <font size=2><br>
             <br>
            <center> 还没有任何留言!</font> 
    <%else
              rs.AbsolutePage=pagecount%>
    <TABLE width=95% border=0 align="center" cellPadding=0 cellSpacing=0>
      <TBODY>
        <% do while not rs.eof
	if userid="" then%>
	<TR>
          <TD width="85%">&nbsp;&nbsp;&nbsp;<%=rs.pagesize*pagen+i+1%>. &nbsp;&nbsp;&nbsp;留言会员：<a href="?userid=<%=rs("userid")%>&username=<%=rs("username")%>" title=查看该会员所有留言><%=rs("username")%></a></TD>
        </TR><%end if%>
        <TR>
          <TD vAlign=top height=2></TD>
        </TR>
        <TR>
          <TD width="85%" align="left" vAlign=center><%if userid<>"" then%>&nbsp;&nbsp;<%=i+1%>.<%end if%>&nbsp;&nbsp;<%=rs("body")%></TD>
        </TR>
        <TR>
          <TD height=30 align=right><font color="#D0D0D0">(<%=rs("dateandtime")%>)&nbsp;&nbsp;</font></FONT><a href=?userid=<%=rs("userid")%>&username=<%=rs("username")%>&id=<%=rs("id")%>&act=del&page=<%=page%>>删除</a>&nbsp;&nbsp;</TD>
        </TR>
		<% if rs("reply")<>"" then %>
        <TR><form name=form1 method="POST" action="?id=<%=rs("id")%>&act=add&userid=<%=rs("userid")%>&username=<%=rs("username")%>">
          <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class=input type="submit" value="回 复" name="cmdok2" title=修改回复内容>：&nbsp;<font color="green">
              <%=rs("reply")%></font><font color="#D0D0D0">(<%=rs("replytime")%>)</font><input name=content type=hidden value="<%=rs("reply")%>"></TD></form>
          </TR><%else%><TR><TD align=right><a href=?id=<%=rs("id")%>&act=add&userid=<%=rs("userid")%>&username=<%=rs("username")%>><font color="green"><B>回 复</B></font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
          </TR><%end if%>
        <TR vAlign=center align=middle>
          <TD height=1><hr width="98%" size="1" color="#0000FF" style="border: 1 dotted #3399CC"></TD>
        </TR>
		
        <% i=i+1                                                                                                  
          rs.movenext                                                                                                  
          if i>=rs.PageSize then exit do 
		  loop                                                                    
         %>
      </TBODY>
    </TABLE>
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr align="right">
        <% if rs.pagecount=1 then %>
        <td height="30" colspan="2">共 <strong><font color="#ff0000"><%=rs.recordcount%></font></strong> 条留言</td>
      </tr>
      <tr>
        <%else%>
        <td width="41%" height="30" align="center" valign="middle"><font color="#000000">
          <% page_start=(pagecount-1)*rs.pagesize
            if pagecount=1 then page_start=1
		    page_end=rs.pagesize*pagecount
		    if pagecount*rs.pagesize=>rs.recordcount then page_end=rs.recordcount end if%>
          共 <strong><font color="#ff0000"><%=rs.recordcount%></font></strong> 条 &nbsp;&nbsp; 第 <strong><font color=ffoooo><%=pagecount%></font></strong> 页 / 共 <strong><font color=ffoooo><%=rs.pagecount%></font></strong> 页</font></td>
        <td width="59%" height="30" align="right" valign="middle"><font color="#000000">
          <% response.write"<form name=go2to form method=Post action='?userid="&userid&"&username="&username&"'>"                                             
		     if pagecount=1 then                                                        
			 response.write "<font color='#000064'>首页 上一页</font>&nbsp;"
			 else                                                        
             response.write "<a href=?page=1&userid="&userid&"&username="&username&"><font color='0000BE'>首页</font></a>&nbsp;" 
	         response.write "<a href=?userid="&userid&"&username="&username&"&page="+cstr(pagecount-1)+"><font color='0000BE'>上一页</font></a>&nbsp;"
			 end if                                        
             if rs.PageCount-pagecount<1 then                                                        
             response.write "<font color='#000064'>下一页 尾页</font>"                                                    
			 else                                                        
             response.write "<a href=?userid="&userid&"&username="&username&"&page="+cstr(pagecount+1)+"><font color='0000BE'>下一页</font></a>&nbsp;"
			 response.write "<a href=?userid="&userid&"&username="&username&"&page="+cstr(rs.PageCount)+"><font color='0000BE'>尾页</font></a>"           
             end if 
			response.write "<font color='000064'> 转到<input type='text' name='page' size=2 maxLength=3 style='font-size: 9pt; color:#0E96DF; position: relative; height: 18' value="&PageCount&">页</font>&nbsp;"                               
			response.write "<INPUT style='CURSOR: hand' type='image' onclick=check() height='15' width='24' src='../bzmtv-inc/images/search.gif' name='Image'>" %>
        </font></td>
      <tr>
        <td height="6" colspan="4" valign="bottom"><font color="#000000">&nbsp; </font></td>
      </tr>
      <% end if %>
    </table>
    <%end if%></td>
  </tr>
</table>
<%
rs.close
set rs=nothing
userconn.close
set userconn=nothing
%>  </body></html>