www.gusucode.com > 维六酷博客管理系统 1.1源码程序 > guestbook.asp

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<!--#include file="include.asp"-->
<!--#include file="inc/char.inc"-->
<%
if request("action")="" then response.redirect"Guestbook.asp?action=show"
	if request("action")="post" then
	dim bookname
	dim bookwhere
	dim bookpic
	dim bookface
	dim bookcontent
	dim booktime
	dim bookip

	dim FoundErr,ErrMsg


	bookname=request("name")
	bookwhere=request("where")
	bookpic=request("pic")
	bookface=request("face")
	bookshow=request("show")
	bookcontent=request("content")
	checkcode=Request("checkcode")
	bookip=request.ServerVariables("REMOTE_ADDR")

	if bookname="" then
		Response.Write "<SCRIPT LANGUAGE='JavaScript'>"
		Response.Write "alert('留言昵称不能为空!');"
		Response.Write "history.go(-1);"
		Response.Write "</SCRIPT>"
		Response.End
	end if
	if bookcontent="" then
		Response.Write "<SCRIPT LANGUAGE='JavaScript'>"
		Response.Write "alert('留言内容不能为空!');"
		Response.Write "history.go(-1);"
		Response.Write "</SCRIPT>"
		Response.End
	end if
	if checkcode="" Or checkcode<> Session("checkcode") then
		 Response.Write "<SCRIPT LANGUAGE='JavaScript'>"
		 Response.Write "alert('验证码输错啦!');"
		 Response.Write "history.go(-1);"
		 Response.Write "</SCRIPT>"
			Response.End
	end If
	strArr=split(W_BookWorryNeed,"|")  

	set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from book"
	rs.open sql,conn,1,3
	rs.addnew
		rs("name")=htmlencode(bookname)
		rs("where")=htmlencode(bookwhere)
		rs("pic")=bookpic
		rs("face")="images/face/"&bookface&".gif"
		rs("show")=bookshow
		rs("content")=htmlencode(bookcontent)
		rs("ip")=bookip
		rs("time")=now()
	rs.update
	rs.close
	 Response.Write "<SCRIPT LANGUAGE='JavaScript'>"
	 Response.Write "alert('恭喜您!您已经成功提交了信息!');"
	 Response.Write "window.location.href='Guestbook.asp?i=show'"
	 Response.Write "</SCRIPT>"
	Response.end
end if
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言 - <%=WebName%></title>
<meta name="keywords" content="<%=W_WebSiteKeyword%>">
<meta name="description" content="<%=W_WebSiteIntr%>">
<LINK href="css.css" type="text/css" rel="stylesheet">
</head>

<body>
<!-- #include file="top.asp"-->
<table width="1000" height="559" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="718" valign="top">
      <table width="668"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="100" align="right"><img src="images/about1.gif" width="342" height="76"></td>
        </tr>
        <tr>
          <td><img src="images/book2.gif" width="649" height="108"></td>
        </tr>
        <tr>
          <td height="292" valign="top">
		  
<table width="585"  border="0" cellpadding="5" cellspacing="0">
   <tr> 
			  <td width="50">&nbsp;</td>
			  <td> 

<a href="Guestbook.asp?action=sub"><img src="images/bookb.gif" border="0"></a>
<a href="Guestbook.asp?action=show"><img src="images/booka.gif" border="0"></a>


</td>
</tr> 
              <tr> 
			  <td width="50">&nbsp;</td>
                <td width="515">

<% If Request("action")="show" Then %>
	
	<%
   const MaxPerPage=6   '单独页最大记录数 const 用来申明常量
   dim sql 
   dim rs
   dim totalPut   '总记录
   dim CurrentPage  '当前页次
   dim TotalPages   '总页数
   dim i
   dim id
   
%>
     <%
set rs=server.createobject("adodb.recordset")
If BookExamine=False Then
sql="select * from book order by id desc"
Else
sql="select * from book where bexamine=true order  by id desc"
End If
rs.open sql,Conn,1,1
%>


       <%
 if rs.eof and rs.bof then
 %>

     <table width="522"  border="0" align="center" cellpadding="5" cellspacing="1">
       <tr>
         <td align="center">暂时还没有任何留言!</td>
       </tr>
     </table>
     

        <%
else
%>
        <!-- 分页功能代码块,可独立使用 -->
        <% 
 if not rs.eof then
  rs.MoveFirst  '注意放到前面来,否则到任何页总是在第一个记录上
  end if
  rs.pagesize=MaxPerPage  '设置每页最多显示多少条记录
  If trim(Request("Page"))<>"" then  '如果请求的页次不为空
   If IsNumeric(trim(Request("Page"))) = False Then
		GoError "分页参数错误,请不要试图破坏此系统。"
	End If
	CurrentPage= CLng(request("Page"))   'clng是转换成长整型数据类型,并赋值到当前页次上
	If CurrentPage> rs.PageCount then  '如果当前页次大于总页数,则将最大页次赋值到当前页次上
		CurrentPage = rs.PageCount 
	End If 
Else 
	CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If 


 totalPut=rs.recordcount '将总记录赋值于TOTALPUT
	if CurrentPage<>1 then '如果当前页数不等于第一页
		if (currentPage-1)*MaxPerPage<totalPut then  '如果当前页减一乘以每页最大的记录数小于总记录的话
			rs.move(currentPage-1)*MaxPerPage  '相对当前记录数向后移动
			dim bookmark  '定义书签变量
			bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上
		end if 
	end if

	dim n,k 
	if (totalPut mod MaxPerPage)=0 then  '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
		n= totalPut \ MaxPerPage
	else  
		n= totalPut \ MaxPerPage + 1  
	end if
%>
        <!-- 将RS记录指针指向第一个记录,然后开始判断移动记录时,记录结尾是否为空,如果不为空接着移动指针,把所有数据都读取出来。直到结尾为空时,退出循环 -->
        <%
 id=(totalPut-MaxPerPage*(currentPage-1))+1 
i=0
Do While Not rs.EOF and i<MaxPerPage
id=id-1
%>

      <table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" class="alpha">
        <tr>
          <td width="110" align="center">【第<%=id%>位】</td>
          <td><table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="57">发表于:</td>
                <td align="left"><%=rs("time")%></td>
                <td width="26" align="center"><img src="images/friend.gif" alt="来自:<%=rs("where")%>" width="18" height="18" /></td>
                <td width="30" align="center"><img src="images/ip.gif" alt="IP:<%=rs("ip")%>" width="18" height="18" /></td>
              </tr>
          </table></td>
        </tr>
<tr bgcolor="#666666"> 
				  <td height="1" colspan="3" ></td>
		</tr>
        <tr>
          <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td> </td>
              </tr>
              <tr>
                <td align="center"><img src="<%=rs("pic")%>" width="75" height="75" /></td>
              </tr>
              <tr>
                <td height="35" align="center"><strong><%=rs("name")%></strong></td>
              </tr>
            </table>
          </td>
          <td valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="7%"></td>
                <td width="38%">                  <%if rs("show")=2 then
response.write"此留言内容为悄悄话,只有管理员才可查看!"
%>                  <%else%>                 </td>
              </tr>
              <tr valign="top">
                <td height="60" colspan="2"><%=rs("content")%>                      <%end if%>                </td>
              </tr>
            </table>              <%
		if rs("reply")<>"" then%>
              <table width="80%" border="0" align="right" cellpadding="0" cellspacing="0">
                <tr>
                  <td align="center"><span class="style3">---------------------------------------------</span></td>
                </tr>
                <tr>
                  <td class="style5">站长回复:<%=htmlencode(rs("reply"))%></td>
                </tr>
              </table>              <%end if%>            </td>
        </tr>

      </table>

<% i=i+1
  rs.movenext
  loop
  %>

<table align="center" >
        <tr>
          <td align="center">
		  
		  

		第 <font color="#FF0000"><%=currentpage%>/<%=n%></font> 页 共 <font color="#FF0000"><%=rs.recordcount%></font> 条留言
                  <%k=currentPage
		if k<>1 then
			response.write "[<b>"+"<a href='?action=show&page=1'>首页</a></b>] "
			response.write "[<b>"+"<a href='?action=show&page="&cstr(k-1)&"'>上一页</a></b>] "
		else
			Response.Write "[首页] [上一页]"
		end if
		if k<>n then
			response.write "[<b>"+"<a href='?action=show&page="&cstr(k+1)&"'>下一页</a></b>] "
			response.write "[<b>"+"<a href='?action=show&page="&cstr(n)&"'>尾页</a></b>] "
		else
			Response.Write "[下一页] [尾页]"
		end if
		
		rs.close  
	%>
	
	
          </td>
        </tr>
      </table>
 <%
end if
%> 
<% EnD iF %>

<% If Request("action")="sub" Then %>
  <form action="?action=post" method="post" name="form" id="form">
             <table width="100%" border="0" align="center">

               <tr>
                 <td width="79" height="23" align="right">留言昵称:</td>
               <td colspan="3" align="left">
                 <input name="name" type="text" size="15" class="input2" />
                 * (请使用中文)</td>
               <td width="194" rowspan="2" align="left"><img src="images/face/1.gif" name="iface" width="75" height="75" id="iface" /></td>
               </tr>
               <tr>
                 <td height="26" align="right">来自哪里:</td>
                 <td width="71" align="left"><select name="where" size="1" class="input2" id="select2" style="border: 1px solid #E6E6E6">
                     <option value="未知" selected="selected">保密</option>
                     <option value="北京">北京</option>
                     <option value="上海">上海</option>
                     <option value="天津">天津</option>
                     <option value="重庆">重庆</option>
                     <option value="河北">河北</option>
                     <option value="山西">山西</option>
                     <option value="内蒙古">内蒙古</option>
                     <option value="辽宁">辽宁</option>
                     <option value="吉林">吉林</option>
                     <option value="黑龙江">黑龙江</option>
                     <option value="江苏">江苏</option>
                     <option value="浙江">浙江</option>
                     <option value="安徽">安徽</option>
                     <option value="福建">福建</option>
                     <option value="江西">江西</option>
                     <option value="山东">山东</option>
                     <option value="河南">河南</option>
                     <option value="湖北">湖北</option>
                     <option value="湖南">湖南</option>
                     <option value="广东">广东</option>
                     <option value="广西">广西</option>
                     <option value="海南">海南</option>
                     <option value="四川">四川</option>
                     <option value="贵州">贵州</option>
                     <option value="云南">云南</option>
                     <option value="西藏">西藏</option>
                     <option value="陕西">陕西</option>
                     <option value="甘肃">甘肃</option>
                     <option value="宁夏">宁夏</option>
                     <option value="青海">青海</option>
                     <option value="新疆">新疆</option>
                     <option value="香港">香港</option>
                     <option value="澳门">澳门</option>
                     <option value="台湾">台湾</option>
                     <option value="海外">海外</option>
                   </select>
                 </td>
                 <td width="66" align="left">选择头像:</td>
                 <td width="90" align="left"><select name="pic" size="1" class="input2" style="border: 1px solid #E6E6E6" onchange="document.images ['iface'].src=options[selectedIndex].value;">
                     <option value="images/face/1.gif" selected="selected">NO.  01</option>
                     <%for i=2 to 21%>
                     <option value="images/face/<%=i%>.gif">NO.
                       <%if i<10 then
					response.write "0"&i
					else response.write i
					end if
					%>
                     </option>
                     <%next%>
                 </select></td>
                 </tr>

           
             <tr>
                 <td height="26" align="right">留言性质:</td>
                 <td colspan="4" align="left">
                   <input name="show" type="radio" class="input2" value="1" checked="checked" />
                   公开
                   <input name="show" type="radio" class="input2" value="2" />
                   悄悄话</td>
             </tr>

               <tr>
                 <td align="right" valign="middle">留言内容:<br />
                       <br />
               </td>
                 <td colspan="4" align="left">
                     <textarea name="content" cols="50" rows="4" id="textarea3" class="input2"></textarea>
                </td>
               </tr>
<% 
dim rndnum,checkCode
Randomize
Do While Len(rndnum)<4
	num1=CStr(Chr((57-48)*rnd+48))
	rndnum=rndnum&num1
loop
session("checkCode")=rndnum
%>
             <tr>
                 <td height="26" align="right">验证码:</td>
                 <td colspan="2" align="left">
                   <input name="checkcode" type="text" class="input2" size="4" maxlength="4" />
				   <font color="#FF0000"><%=rndnum%></font>
                   </td>
             </tr>
               <tr>
                 <td colspan="5" valign="middle" align="center">
                     <input name="submit" type="submit" class="input2" id="submit3" value="发表留言" onclick="javascript:return CheckForm();"/>
                   
                 <input type="reset" name="Submit2" value="清除留言" class="input2" />
                   
                 <input type="button" value="返  回" name="cmdExit" onclick=" history.back()" class="input2" />
                 </td>
               </tr>
             </table>
       </form>
<%
EnD iF
%>

		
			
			</td>

              </tr>
            </table>
		  
		  
		  </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="82" align="right"><img src="images/about5.gif" width="162" height="63"></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>