?? gbook.asp
字號:
<!--#include file="admin_conn.asp"-->
<%
if session("admin_name")="" then
response.redirect"admin.asp"
end if
'-----------------------------------------------------------------------
function encodestr(str)
dim i
str=trim(str)
str=replace(str,"'","""")
str=replace(str,vbCrLf&vbCrlf,"</p><p>")
encodestr=replace(str,vbCrLf,"<br>")
end function
Function uni(Chinese)
For j = 1 to Len (Chinese)
a=Mid(Chinese, j, 1)
uni= uni & "&#x" & Hex(Ascw(a)) & ";"
next
End Function
'------------------------------------------------------------
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>STONE空間 flash留言本 后臺管理</title>
<meta name="keywords" content="STONE,STONE空間 flash留言本">
<meta http-equiv="STONE空間 flash留言本" content="http://stone-stone.vip.sina.com">
<meta name="description" content="本程序由 STONE 設計編寫!程序有問題請到 STONE空間 flash留言本 提出,謝謝!">
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<!--#include file="top.asp" -->
<br>
<%
select case request("action")
case "gopage"
call manage()
case "gmhuifu"
call gmhuifu()
case "manage"
call manage()
case "view"
call view()
case "del"
call del()
case "huifu"
call huifu()
case "designup"
call designup()
case "designdown"
call designdown()
end select
sub gmhuifu()
set rs=server.CreateObject("adodb.recordset")
sql="select * from gbook where id in("&request("id")&")"
rs.open sql,conn,3,2
rs("name")=trim(request.form("name"))
if trim(request.form("blog"))="" then
rs("blog")=null
else
rs("blog")=trim(request.form("blog"))
end if
if trim(request.form("homepage"))="" then
rs("homepage")=null
else
rs("homepage")=trim(request.form("homepage"))
end if
if trim(request.form("qq"))="" then
rs("qq")=null
else
rs("qq")=trim(request.form("qq"))
end if
if trim(request.form("email"))="" then
rs("email")=null
else
rs("email")=trim(request.form("email"))
end if
rs("title")=trim(request.form("title"))
rs("content")=encodestr(trim(request.form("content")))
if trim(request.form("gmcontent"))<>"" then
rs("gmcontent")=encodestr(trim(request.form("gmcontent")))
rs("gmdate")=date()
else
rs("gmcontent")=null
rs("gmdate")=null
end if
rs.update
rs.close
set rs=nothing
response.write"<script language='javascript'>alert('編輯成功!');location.href('?action=manage');</script>"
end sub
sub del()
set rs=server.CreateObject("adodb.recordset")
sql="select * from gbook where id="&request("id")&""
rs.open sql,conn,3,2
rs.delete
rs.close
set rs=nothing
response.write"<script language='javascript'>alert('刪除成功!');location.href('?action=manage');</script>"
end sub
sub designup()
'排序向上
set rs=server.createobject("adodb.recordset")
sql="select pxid from gbook where id in("&request("id")&")"
rs.open sql,conn,3,2
rs(0)=rs(0)+1
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript>alert('編輯成功!');location.href('?action=manage');</script>"
end sub
'排序向下
sub designdown()
set rs=server.createobject("adodb.recordset")
sql="select pxid from gbook where id in("&request("id")&")"
rs.open sql,conn,3,2
rs(0)=rs(0)-1
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript>alert('編輯成功!');location.href('?action=manage');</script>"
end sub
%>
<% sub manage() %>
<%
dim idcount'記錄總數
dim pages'每頁條數
dim pagec'總頁數
dim page'頁碼
dim pagenc
dim pagenb
dim datafrom'數據表名
dim taxis'排序的語句
'-------------------設置參數開始---------------------------------
'taxis="order by id asc" '正排序
taxis="order by pxid desc,id desc" '倒排序
pages=20'每頁條數
datafrom="gbook"'數據表名
pagenb=7 '每頁顯示的分頁頁碼數量 必須為單整數,例如 3 5 7 9
'-------------------設置參數結束---------------------------------
pagenc=(pagenb-1)/2
dim pagenmax '每頁顯示的分頁的最大頁碼
dim pagenmin '每頁顯示的分頁的最小頁碼
page=clng(request("page"))
dim sqlid'本頁需要用到的id
dim myself'本頁地址
myself = request.servervariables("path_info")
dim i'用于循環的整數
start=timer()
'獲取記錄總數
sql="select count(id) as idcount from ["& datafrom &"]"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,0,1
idcount=rs("idcount")'獲取記錄總數
if(idcount>0) then'如果記錄總數=0,則不處理
if(idcount mod pages=0)then'如果記錄總數除以每頁條數有余數,則=記錄總數/每頁條數+1
pagec=int(idcount/pages)'獲取總頁數
else
pagec=int(idcount/pages)+1'獲取總頁數
end if
'獲取本頁需要用到的id============================================
'讀取所有記錄的id數值,因為只有id所以速度很快
sql="select id from ["& datafrom &"] " & taxis
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize = pages '每頁顯示記錄數
if page < 1 then page = 1
if page > pagec then page = pagec
if pagec > 0 then rs.absolutepage = page
for i=1 to rs.pagesize
if rs.eof then exit for
if(i=1)then
sqlid=rs("id")
else
sqlid=sqlid &","&rs("id")
end if
rs.movenext
next
'獲取本頁需要用到的id結束============================================
end if
%>
<%
if(idcount>0 and sqlid<>"") then'如果記錄總數=0,則不處理
'用in刷選本頁所語言的數據,僅讀取本頁所需的數據,所以速度快
sql="select [id],[title],[name],[date],[pxid] from ["& datafrom &"] where id in("& sqlid &")"&taxis
'sql="select [id],[aaaa],[bbbb],[cccc] from ["& datafrom &"] where id in("& sqlid &") "&taxis
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,0,1
%>
<table width="760" border="1" cellpadding="1" cellspacing="1" bordercolor="66ccff">
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr align="center" bgcolor="#3399CC">
<td height="25" colspan="5">留言管理</td>
</tr>
<tr align="center" bgcolor="#006699">
<td width="10%" height="25">ID</td>
<td width="45%">標題</td>
<td width="22%">姓名</td>
<td width="13%">留言時間</td>
<td width="10%">操作</td>
</tr>
<%
dim ii
ii=0
while(not rs.eof)'填充數據到表格
'if ii mod 5=0 then
'response.write"<tr>"
'end if
%>
<tr align="center" class="fonthei">
<td height="25" bgcolor="#006699"><%=rs("id")%><br>
<a href="?id=<%=rs("id")%>&action=designup">上</a> [<%=rs("pxid")%>] <a href="?id=<%=rs("id")%>&action=designdown">下</a> </td>
<td align="left" bgcolor="#66CCFF"><a href="#" title="<%=rs("title")%>"><font class="fonthei"><%=rs("title")%></font></a></td>
<td bgcolor="#66CCFF"><%=rs("name")%></td>
<td bgcolor="#66CCFF"><%=rs("date")%></td>
<td bgcolor="#006699"><a href="?id=<%=rs("id")%>&action=view">回復</a> <a href="?id=<%=rs("id")%>&action=del">刪除</a></td>
</tr>
<%
rs.movenext
ii=ii+1
wend
%>
<tr bgcolor="#3399CC" >
<td height="25" colspan="5">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><span class="fontmenu1"><span class="fontlan">共有<strong><font color="#ff0000"><%=idcount%></font></strong>條數據,第<strong><font color="#ff0000"><%=pagec%></font></strong>/<strong><font color="#ff0000"><%=page%></font></strong>頁,每頁<strong><font color="#ff0000"><%=pages%></font></strong>條</span>
<%
'設置分頁頁碼開始===============================
pagenmin=page-pagenc'計算頁碼開始值
pagenmax=page+pagenc'計算頁碼結束值
if(pagenmin<1) then'如果頁碼開始值小于1則=1
pagenmin=1
end if
if(page>1) then'如果頁碼大于1則顯示(第一頁)
response.write ("<a href='"& myself &"?action=manage&page=1'><FONT face=Webdings color='#FFFFFF'>9</FONT></a> ")
end if
if(pagenmin>1) then'如果頁碼開始值大于1則顯示(更前)
response.write ("<a href='"& myself &"?action=manage&page="& page-(pagenc*2+1) &"'><FONT face=Webdings color='#FFFFFF'>7</FONT></a> ")
end if
if(pagenmax>pagec) then'如果頁碼結束值大于總頁數,則=總頁數
pagenmax=pagec
end if
for i = pagenmin to pagenmax'循環輸出頁碼
if(i=page) then
response.write ("<font color='#ff0000'><strong>["& i &"]</strong></font> ")
else
response.write (" <a href="& myself &"?action=manage&page="& i &"><font color='#FFFFFF'>["& i &"]</font></a> ")
end if
next
if(pagenmax<pagec) then'如果頁碼結束值小于總頁數則顯示(更后)
response.write ("<a href='"& myself &"?action=manage&page="& page+(pagenc*2+1) &"'><FONT face=webdings color='#FFFFFF'>8</FONT></a> ")
end if
if(page<pagec) then'如果頁碼小于總頁數則顯示(最后頁)
response.write ("<a href='"& myself &"?action=manage&page="& pagec &"'><FONT face=webdings color='#ff0000'>:</FONT></A> ")
end if
'設置分頁頁碼結束===============================
%>
轉到
<script language="javascript">
<!--
function gopage() {
window.location.href="<%=myself%>?action=manage&page="+ page.value;
}
//-->
</script>
<input name="page" type="text" class="pagego" value="<%=page%>" size="2" onmouseover='this.focus();this.select()'>
頁
<input name="submit" type="button" class="pagego" onClick="gopage()" value=" G O ">
</span></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<% Else %>
<table width="760" border="1" cellpadding="1" cellspacing="1" bordercolor="66ccff">
<tr>
<td align="center"><form action="?action=login" method="post" name="login" id="login">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr align="center" bgcolor="#3399CC">
<td height="25" colspan="2">目前還沒有留言</td>
</tr>
<tr>
<td width="47%" height="25" align="right" bgcolor="#66CCFF" class="fonthei"> </td>
<td width="53%" align="left" bgcolor="#006699"> </td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei"> </td>
<td align="left" bgcolor="#006699"> </td>
</tr>
<tr bgcolor="#3399CC">
<td height="25" align="right" class="fonthei"> </td>
<td align="left"> </td>
</tr>
</table>
</form></td>
</tr>
</table>
<% End If
'endt=timer()
rs.close
set rs=nothing
%>
<br>
<% end sub %>
<% sub view() %>
<% sql="select * from gbook where id="&request("id")&""
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1 %>
<table width="760" border="1" cellpadding="1" cellspacing="1" bordercolor="66ccff">
<tr>
<td align="center"><form action="?id=<%=rs("id")%>&action=gmhuifu" method="post" name="delgbook" id="delgbook">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr align="center" bgcolor="#3399CC">
<td height="25" colspan="3">查看留言 </td>
</tr>
<tr>
<td width="10%" height="25" align="right" bgcolor="#66CCFF" class="fonthei">姓名:</td>
<td colspan="2" align="left" bgcolor="#006699">
<input name="name" type="text" class="input" id="name" value="<%= rs("name") %>" size="15"></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">QQ:</td>
<td colspan="2" align="left" bgcolor="#006699">
<input name="qq" type="text" class="input" id="qq" value="<%= rs("qq") %>" size="15"></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">E-mail:</td>
<td colspan="2" align="left" bgcolor="#006699">
<input name="email" type="text" class="input" id="email" value="<%= rs("email") %>" size="45"></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">blog:</td>
<td colspan="2" align="left" bgcolor="#006699">
<input name="blog" type="text" class="input" id="blog" value="<%= rs("blog") %>" size="45"></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">homepage:</td>
<td colspan="2" align="left" bgcolor="#006699">
<input name="homepage" type="text" class="input" id="homepage" value="<%= rs("homepage") %>" size="45"></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">留言時間:</td>
<td colspan="2" align="left" bgcolor="#006699"> <%=rs("date")%></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">標題:</td>
<td colspan="2" align="left" bgcolor="#006699">
<input name="title" type="text" class="input" id="title" value="<%= rs("title") %>" size="45"></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">內容:</td>
<td colspan="2" align="left" bgcolor="#006699">
<textarea name="content" cols="45" rows="5" class="input" id="content"><%= rs("content") %></textarea></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">回復:</td>
<td colspan="2" align="left" bgcolor="#006699">
<textarea name="gmcontent" cols="45" rows="5" class="input" id="gmcontent"><%= rs("gmcontent") %></textarea></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">回復時間:</td>
<td colspan="2" align="left" bgcolor="#006699"> <%=rs("gmdate")%></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#66CCFF" class="fonthei">ID:</td>
<td width="7%" align="left" bgcolor="#006699"> <%=rs("id")%></td>
<td width="83%" align="left" bgcolor="#006699"><span class="fonthei">
<input name="Submit" type="submit" class="inputbt" value="提交">
<input name="Submit" type="button" class="inputbt" value="返 回" onClick="javascript:history.back()">
</span></td>
</tr>
</table>
</form></td>
</tr>
</table>
<br>
<%
rs.close
set rs=nothing
%>
<% end sub %>
<br>
<!--#include file="bottom.asp" -->
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -