前些日子整理的代码
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
'程序出处 :VA GuestBook System By Vanery
'版 本 :Version 1.16单用户精简版 (新版本研究中)
'QQ :296338925
'Email :[email protected]
'声 明 :本程序仅供ASP编程爱好者参考学习,所有代码均开源提供。
'发布日期 :2007年9月19日
'作 者 :阿威
'官网地址 :jaker.137.tofor.com
'初始帐号 :admin 密码:123465
'
'-----------------------------------------------------------------------------------连接数据库
Dim Conn,Connstr,uip,SiteName,wtime,StartTime
StartTime = Timer()
SiteName="VA GuestBook System" '-------------------留言本名字
wtime=now()
Set Conn=Server.CreateObject("ADODB.Connection")
DB="Images/#data.mdb"
Connstr="DBQ="+server.mappath(DB)+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
on error resume next
Conn.open Connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
'--------------------------------------------------------------------------------------获取IP
uip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If uip = "" Then uip = Request.ServerVariables("REMOTE_ADDR")
'-----------------------------------------------------------------------------------定义文字内容规范
Function MyReplace(sMsg)
sMsg = Trim(sMsg)
sMsg = Replace(sMsg, "<", "<")
sMsg = Replace(sMsg, ">", ">")
sMsg = Replace(sMsg, Chr(13) & Chr(10), "
") '回车换行
sMsg = Replace(sMsg, Chr(32), " ") '空格
sMsg = Replace(sMsg, Chr(34), """) ' " 双引号
sMsg = Replace(sMsg, Chr(9), " ") 'Tab
MyReplace = sMsg
End Function
'------------------------------------------------------------------------------------------
%>
<%=SiteName%> 首 页|<%If Session("admin")="" then%>管理员登陆<%Else%> 注销登陆|修改密码|当前操作员:<%=Session("admin")%><%End If%> |
<% Dim Action,Admin Set Rs = Server.CreateObject("ADODB.Recordset") Action = Request.QueryString("Action") Admin = "$Admin001" Select Case Action Case "Add" '-------------------------------------------------添加留言 title=MyReplace(request.Form("title")) if session("admin")="" Then nam=Replace(request.Form("nam"),Chr(32),"") if nam="管理员" then nam="猪头三" if nam="admin" then nam="猪头三" nam=MyReplace(request.Form("nam")) else nam="admin" msg = Replace(request.Form("msg"), Chr(13) & Chr(10), " ") end if msg=MyReplace(request.Form("msg")) sex=request.Form("sex") email=MyReplace(request.Form("email")) conn.execute "insert into Content (Title,Wname,Wsex,Msg,Wtime,WIP) values ('"&title&"','"&nam&"','"&sex&"','"&msg&"','"&Wtime&"','"&uip&"')" set title=nothing set nam=nothing set sex=nothing set msg=nothing set email=nothing response.write "" response.redirect "GuestBook.asp" Case "Delete" '-----------------------------------------------删除留言 if request("id")<>empty then if session("admin")="" then response.redirect ("login.asp") end if conn.Execute("delete * from Content where gid="&trim(request("id"))) end if response.redirect "GuestBook.asp" Case "Seta" '-----------------------------------------------置顶留言 if request("id")<>"" then if session("admin")="" then response.redirect ("login.asp") end if conn.Execute("update Content set Sets=1 where gid="&trim(request("id"))) end if response.redirect "GuestBook.asp" Case "Setat" '-----------------------------------------------解除置顶留言 if request("id")<>"" then if session("admin")="" then response.redirect ("login.asp") end if conn.Execute("update Content set Sets=0 where gid="&trim(request("id"))) end if response.redirect "GuestBook.asp" Case "Revert" '------------------------------------------------显示回复表单 if session("admin")="" then response.redirect ("login.asp") end if Sql = "Select * From Content Where GID="&trim(request("id")) rs.open sql,conn,1,1 %> <% set sql=nothing set Rs=nothing response.Write(" |
<%
Case "SaveEdit" '------------------------------------------------保存编辑
if request("id")<>empty then
if session("admin")="" then
response.redirect ("login.asp")
end if
conn.Execute("update Content set msg='"&(request.Form("gmhuifu"))&"' where gid="&trim(request("id")))
end if
response.redirect "GuestBook.asp"
Case "SaveRevert" '------------------------------------------------保存回复
if request("id")<>empty then
if session("admin")="" then
response.redirect ("login.asp")
end if
conn.Execute("update Content set RConten='"&MyReplace(request.Form("gmhuifu"))&"' where gid="&trim(request("id")))
end if
response.redirect "GuestBook.asp"
Case "Login" '------------------------------------------------登进
If Session("Admin")="" then
If Request.ServerVariables("Request_Method")="GET" then
response.write("
Sql = "Select * From Content Order BY Sets desc , Gid Desc"
Rs.Open Sql,conn,1,1
IF Rs.Eof or rs.bof Then
Response.Write "
目前还没有任何信息"
else
totalrecord=rs.recordcount
IF Request("s")="" Then
ShowNum=10
Else
ShowNum=Request("s")
End IF
rs.pagesize=ShowNum
maxpage=rs.pagecount
requestpage=clng(request("p"))
if requestpage="" or requestpage=0 then
requestpage=1
end if
if resquestpage>maxpage then
resquestpage=maxpage
end if
if not requestpage=1 then
rs.move (requestpage-1)*rs.pagesize
end if
for i=1 to rs.pagesize and not rs.bof
%>
<% If Rs("wname")="admin" then %>管理员<%else%><%=Rs("wname")%><%end if%> .jpg" border="0"> |
|