top
Loading...
ASP進階之文章在線管理更新(九)
ASP進階之文章在線管理更新--管理頁面篇

作者:沙灘小子

前面講述了關于文章管理系統的密碼及密碼驗證,通過密碼驗證可以限制一般瀏覽者所能進入的頁面,這里所要限制的就是普通用戶所不能進入的頁面,也就是包括管理頁面、刪除文章頁面、修改文章頁面以及修改用戶信息和修改欄目信息的頁面。其實這里的主管理頁面就是和文章管理系統的主頁面類似的頁面,只是在里面添加了一些有關管理內容的連接,以方便管理者對文章進行在線的修改刪除等操作。

下面就為大家介紹這一頁面的主要程序內容,由于它和文章管理的主頁面差不多,所以這里只是把其程序寫出來,并注明和主頁面不同的地方,其他相同的部分請大家參考本專題的第七節!

文件manage.asp

"打開數據庫連接
<!--#include file="conn.asp"-->
<%
"限制非管理用戶進入,這個在本專題的第七節有介紹
if request.cookies("adminok")="" then
response.redirect "login.asp"
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ASP技巧專題</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script language="javascript">
function popwin2(id,path)
{ window.open("openarticle.asp?id="+id+"&ppath="+path,"","height=450,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
</script>
</head>
<%
const MaxPerPage=18
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
dim sql
dim rs
dim rstype
dim typesql
dim typeid,typename
if not isEmpty(request("typeid")) then
typeid=request("typeid")
else
typeid=1
end if
set rstype=server.createobject("adodb.recordset")
typesql="select * from type where typeID="&cstr(typeid)
rstype.open typesql,conn,1,1
if not rstype.eof then
typename=rstype("type")
end if
rstype.close
set rstype=nothing
%>
<body>
<div align="center"><center>
<table border="0" width="92%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" style="border-left: thin dotted rgb(0,128,0); border-right: thin dotted rgb(0,128,0)"><p align="center"><br>
動網ASP技巧專題>><font color="#FF0000"><%response.write ""&typename&""%></font><br>
<center>
<a href="manage.asp?typeid=1">ASP教程</a>|<a href="manage.asp?typeid=2">ASP FAQ</a>|<a href="manage.asp?typeid=3">ASP文摘</a>
|<a href="manage.asp?typeid=4">ASP實例</a>|<a href="manage.asp?typeid=5">ASP安全</a>|

"顯示系統管理頁面相關連接,用于修改管理員密碼名稱以及增加修改刪除欄目,這個在后面將有介紹
<a href="changepass.asp" title="用于修改管理員密碼名稱以及增加修改刪除欄目"><font color=red>管理頁面</font></a>
<div align="center"><%
sql="select * from article where typeid="+cstr(typeid)+" order by data desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'> 還 沒 有 任 何 文 章</p>"
else
totalPut=rs.recordcount
totalPut=rs.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,"manage.asp"
showContent
showpage totalput,MaxPerPage,"manage.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"manage.asp"
showContent
showpage totalput,MaxPerPage,"manage.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"manage.asp"
showContent
showpage totalput,MaxPerPage,"manage.asp"
end if
end if
rs.close
end if

set rs=nothing
conn.close
set conn=nothing

sub showContent
dim i
i=0

%>
<div align="center"><center><table border="1" cellspacing="0" width="589" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0">
<tr>
<td width="46" align="center" bgcolor="#D0D0D0" height="20"><strong>ID號</strong></td>
<td width="400" align="center" bgcolor="#D0D0D0"><strong>文章標題</strong></td>
<td width="69" align="center" bgcolor="#D0D0D0"><strong>修改</strong></td>
<td width="68" align="center" bgcolor="#D0D0D0"><strong>刪除</strong></td>
</tr>
<%do while not rs.eof%>
<tr>
<td height="23" width="46"><p align="center"><%=rs("articleid")%></td>
<td width="400"><p align="center"><a href="javascript:popwin2(<%=rs("articleid")%>)"><%=rs("title")%></a></td>

"顯示與修改刪除的相關連接,具體程序在后面章節將有介紹
<td width="69"><p align="center"><a
href="edit.asp?id=<%=rs("articleid")%>">修改</a></td>
<td width="68"><p align="center"><a
href="delete.asp?id=<%=rs("articleid")%>">刪除</a></td>
</tr>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
</center></div><%
end sub

function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber maxperpage
else
n= totalnumber maxperpage+1
end if
response.write "<form method=Post action="&filename&"?typeid="&typeid&">"

"顯示增加文章相關連接,關于添加文章在本專題的第一、二節有介紹
response.write "<p align='center'><a href='addarticle.asp?typeid="&typeid&"'><font color='red'>增加文章</font></a> "
if CurrentPage<2 then
response.write "<font color='#000080'>首頁 上一頁</font> "
else
response.write "<a href="&filename&"?page=1&typeid="&typeid&">首頁</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&"&typeid="&typeid&">上一頁</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一頁 尾頁</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&typeid="&typeid&">"
response.write "下一頁</a> <a href="&filename&"?page="&n&"&typeid="&typeid&">尾頁</a>"
end if
response.write "<font color='#000080'> 頁次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>頁</font> "
response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/頁</font> "
response.write " <font color='#000080'>轉到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">"
response.write "<input class=buttonface type='submit' value='Goto' name='cndok'></span></p></form>"
end function
%>
</div></td>
</tr>
</table>
</center></div>
</body>
</html>

關于管理頁面的程序就是這樣的了,有什么不清楚的地方可以參考本專題的第八節,由于其內容類似,這里就不多說了,有什么問題可以給我EMAIL:wodeail@etang.com。下一章節就為大家介紹文章管理的文章在線刪除篇。

轉載請注明出處http://asky.on.net.cn

北斗有巢氏 有巢氏北斗