<!--#include file="../conn.asp" -->
<%
uid=cint(request.QueryString("uid"))
user=request.QueryString("user")

if uid="" then 
response.write("<script>alert('留言参数失败，请重试！');</script>")
response.Redirect("/index.asp")
response.end
end if
'response.write("<script>alert('"&user&"');</script>")
ac=request.QueryString("ac")
if ac="add" then
face=request.form("p1")+request.form("p2")
if request.form("p1")="" or request.form("p2")="" then
face="m01"
end if
name=htmlencode(request.form("name"))
if name="" then
name="过客"
end if
'email=request.form("email")
title=request.form("url")
if title="" then
title="无题"
end if
ly=htmlencode(request.form("ly"))
yz=htmlencode(request.form("yz"))
yz1=Session("bookSafeCode")
'**********检查是否填写了所有项，如果不是侧自动返回申请页面
if ly="" then
errmsg=errmsg & "△ 请填写留言[内容]！\n"
end if
if yz="" then
errmsg=errmsg & "△ 错误的验证码！\n"
else
if  int(yz1)=int(yz) or yz="" then
else
errmsg=errmsg & "△ 错误的验证码！\n"
end if
end if
'if request.cookies("ly")=ly then
'errmsg=errmsg & "△ 请不要重复提交相同的留言！\n"
'end if
'response.cookies("ly")=ly
if errmsg<>"" then
    Conn.Close
    Set conn = nothing
    Set rsc = nothing
    response.write("<script>alert('" & errmsg & "');history.go(-1)</script>")
    response.end
end if
ly=stripHTML(ly)
name=stripHTML(name)
title=stripHTML(title)
'**********检查结束**********

set rs=server.createobject("adodb.recordset")
sql="select * from book" 

rs.open sql,conn,1,3
rs.addnew
rs("userid")=uid
rs("bookuser")=user
rs("name")=name
rs("face")=face
'rs("email")=email
rs("title")=title
rs("ly")=ly
rs.update

rs.close
set rs=nothing  
'conn.close     
'set conn=nothing
response.write("<script>alert('您已经成功提交留言！');</script>")
end if

set rs=server.createobject("adodb.recordset")
sql="Select * From diaryuser where userid="&uid&""

rs.open sql,conn,1,1
user=rs("username")
bookname=rs("bookname")
showbook=rs("showbook") 
    'Conn.Close
    'Set conn = nothing
    Set rs = nothing
%>
<%
   if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
   end if

   MaxPerPage=10 '###每页显示条数

   dim totalPut
   dim CurrentPage
   dim TotalPages
   dim i,j
   
   '###验证码
   		Dim zNum
		Randomize timer
		zNum = cint(8999*Rnd+1000)
		Session("bookSafeCode") =""
		Session("bookSafeCode") = zNum
		Result = Session("bookSafeCode")
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=title1%></title>
<style type="text/css">
td        { font-size: 9pt; line-height: 12pt}
a:link    {color: #0080FF; text-decoration: none }
a:visited {color: #0080FF; text-decoration: none }
a:hover   {color: #ee9c00; text-decoration: underline }
}
</style>
<script language="javascript">
	function SwitchCover(nCover,nBookID,sImageType)
	{
			document.guestf.gpreview.src="<%=alltubg%>gface/"+sImageType+nCover+".gif"
	}
</script>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0">
<table class=td width="220" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>                                                       
        <table border="0" width="100%" cellpadding="0" align="center" cellspacing="0">
          <tr>                                                                  
    <td bgcolor="#EBEBEB" height="1" colspan="2"></td>                                                                            
  </tr>                                                                            
  <tr>                                                                  
            <td width="74%" height="23" valign="bottom" nowrap><a href="/?i=<%=uid%>" target="_blank"><%=bookname%></a> 
              <%if request("page")<>"" then%>
              &gt;&gt; 第<%=request("page")%>页 
              <%end if%>
            </td>                                                                             
                                                                      
            <td height="23">		
			<span id=qianxie style="display:block"><a href="#" target="_self" onClick="gf.style.display='block';qianxie.style.display='none';qianxie1.style.display='block';">↓签写</a></span>
			<span id=qianxie1 style="display:none"><a href="#" target="_self" onClick="gf.style.display='none';qianxie.style.display='block';qianxie1.style.display='none';">↑隐藏</a></span>
</td>                                                                                
  </tr>                                                                                
                                                                     
                                                                   
  <tr>                                                                                
    <td colspan="2">                                                                                
      <hr SIZE="1">                                                                               
    </td>                                                                               
  </tr>                                                                               
</table>                                                                                                                                
<%dim rsu,sqlu                                                          
                                                        
sqlu="select * from book where userid="&uid&" order by ID desc"                                 
Set rsu= Server.CreateObject("ADODB.Recordset") 
rsu.open sqlu,conn,1,1                                                          
%>
<%totalPut=rsu.recordcount                                                          
        if currentpage<1 then                                                          
          currentpage=1                                                          
      end if                                                          
      if (currentpage-1)*MaxPerPage>totalput then                                                          
	   if (totalPut mod MaxPerPage)=0 then                                                          
	     currentpage= totalPut \ MaxPerPage                                                          
	   else                                                          
	      currentpage= totalPut \ MaxPerPage + 1                                                          
	   end if                                                          
      end if                                                          
       if currentPage=1 then                                                          
           showpage totalput,MaxPerPage,"index.asp"                                                          
            showContent                                                          
            showpage totalput,MaxPerPage,"index.asp"                                                          
       else                                                          
          if (currentPage-1)*MaxPerPage<totalPut then                                                          
            rsu.move  (currentPage-1)*MaxPerPage                                                          
            dim bookmark                                                          
            bookmark=rsu.bookmark                                                          
           showpage totalput,MaxPerPage,"index.asp"                                                          
            showContent                                                          
             showpage totalput,MaxPerPage,"index.asp"                                                          
        else                                                          
	        currentPage=1                                                          
           showpage totalput,MaxPerPage,"index.asp"                                                          
           showContent                                                          
           showpage totalput,MaxPerPage,"index.asp"                                                          
	      end if                                                          
	   end if                                                          
	sub showContent                                                          
       dim i                                                          
       i=0                                                          
end sub                                                        
function showpage(totalnumber,maxperpage,filename)                                                       
end function                                                       
  dim n                                                        
  if totalnumber mod maxperpage=0 then                                                        
     n= totalnumber \ maxperpage                                                        
  else                                                        
     n= totalnumber \ maxperpage+1                                                        
  end if                                                                                                                                 %>
<%if rsu.eof and rsu.bof then%>
      <table align="center" width="100%" cellspacing="0" cellpadding="0" border="0">
        <tr>                                                          
          <td align="center" colspan="5" height="100"> 
            还没有留言！
          </td>                                                          
  </tr>                                                        
</table>                                                          
<%else%>                                                                                                                                 <%                           
k=(totalPut-MaxPerPage*(currentPage-1))+1                           
do while not rsu.eof                           
k=k-1%>                                                                              
      <table border="0" width="100%" cellpadding="0" align="center" cellspacing="0">
        <tr> 
          <td width="*" valign="top" height="16"><img border="0" src="<%=alltubg%>gface/foot.gif" width="16" height="16"> 
            网友:<%=rsu("name")%></td>
          <td valign="top"></td>
          <td width="40" rowspan="2" valign="top"> 
<img border="0" src="<%=alltubg%>gface/<%=rsu("face")%>.gif" width="40" height="50">
          </td>
        </tr>
        <tr> 
          <td colspan="2" valign="top"><%=rsu("ly")%> 
            <%if rsu("re")<>"" then%>
            <br>
            <img border="0" src="<%=alltubg%>gface/dot.gif" width="10" height="10"> 
            <%=user%> 回复：<br>
            <font color="#FF8000"><%=rsu("re")%></font>
            <%end if%>
          </td>
        </tr>
        <tr> 
          <td valign="bottom" colspan="2"> <font color="#000000">[<%=rsu("booktime")%>]</font> 
          </td>
          <td width="40" valign="top">NO.<font color="#FF0000"><%=k%></font></td>
        </tr>
        <tr> 
          <td colspan="3"> 
            <hr SIZE="1">
          </td>
        </tr>
      </table>

                                                                          
<% i=i+1                                                      
 if i>=MaxPerPage then exit do                                                      
 rsu.movenext                                                                                                                                         
loop                                                                                                                                         
%>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
                <tr>                                                     
    <td height="23">                               
      <p align="center">分页:<%                                                    
    pageno=request("page")                                                    
    if MaxPerPage="" or isempty(MaxPerPage) or MaxPerPage<1 then                                                    
        MaxPerPage=15                                                    
    end if                                                    
    rsu.pagesize=MaxPerPage '得到每页数                                                    
    mpage=rsu.pagecount     '得到总页数                                                    
    if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then                                                    
        pageno=1                                                    
    end if                                                    
for pno=1 to mpage                                                    
  if pno=cint(pageno) then%><font color="#C0C0C0">[<font color="#FF0000"><b><%=pno%></b></font>]</font><%else%><font color="#C0C0C0">[<a href=index.asp?user=<%=user%>&page=<%=pno%> target="_self"><%=pno%></a>]</font><%end if%><%next%></p>                              
    </td>                                                    
  </tr>                                                    
</table>                                                                                                                      
                                                                  
<%end if%></td>
  </tr>
</table>
<% 
rsu.close 
set rsu=nothing    
conn.close      
set conn=nothing%> 
 <div id="gf" style="display:none;background:#ddd;z-index:300;position:absolute;left:0px;top:30px;margin-left:15px">     
      <table border="0" width="220" cellspacing="0" cellpadding="0" align=center>	
        <form method="post" name="guestf" action="guest.asp?ac=add&uid=<%=uid%>&user=<%=user%>" target="_self">
          <tr> 
            <td height="24">&nbsp;昵称:<input maxlength="20" name="name" size="15" style="width:70px;border: 1 solid #808080">&nbsp;<select id="p2" onChange="SwitchCover(this.value,6913,document.guestf.p1.value)" class="stbtm" name="p2" size="1" style="BACKGROUND-COLOR: #f5f5f5; FONT-SIZE: 9pt">
                <option selected value="01">好开心</option>
                <option value="02">没办法</option>
                <option value="03">不满意</option>
                <option value="04">平常心</option>
                <option value="05">忙死了</option>
                <option value="06">动脑筋</option>
                <option value="07">好感动</option>
                <option value="08">好生气</option>
                <option value="09">要坚持</option>
                <option value="10">好可怜</option>
                <option value="11">要唱歌</option>
                <option value="12">好伤心</option>
                <option value="13">棒极了</option>
                <option value="14">哇好靓</option>
                <option value="15">我抗议</option>
                <option value="16">好害怕</option>
              </select>&nbsp;<select id="p1" name="p1" size="1" style="BACKGROUND-COLOR: #f5f5f5; FONT-SIZE: 9pt">
                <option selected value="m">男</option>
                <option value="w">女</option>
              </select>
              <input type="hidden" maxlength="20" value="给<%=user%>留言" name="url" size="15" style="border: 1 solid #808080">
            </td>
          </tr>
          <tr> 
            <td>  
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr> 
                    
              <td align="center">
<textarea name="ly" rows="6" wrap="hard" style="width:160px;border: 1 dotted #808080"><%=user%>:</textarea>
              </td>
                    <td width="40" align="center"><img src="/diary/gface/m01.gif" id="gpreview" name="gpreview" width="35" height="40"> 
                      <input name="yz" style="width:35px;height:18px;" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                      <%=Result%> 
                      <input type="submit" value="提交" style="width:33px;height:18px;background-color: #FFFFFF; border:1 solid #808080" name="submit">
                    </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td width="40" align="center">&nbsp;</td>
                  </tr>
                </table>
            </td>
          </tr>
          <tr> 
        </form>
      </table>
</div>      
</body>                             
</html> 
