📄 managearticles.asp
字号:
<%
' Project Name: Simple Blog
' Version: 1.1
' Author: James Tang
' Email: fwsous@gmail.com
' Web site: www.fwso.cn
' Copyright (C) 2008 James Tang. All Rights Reserved.
'
' Note: This program can be used for any purpose for free.
'
%>
<!--#include file="../lib/util.asp"-->
<%
Dim ACTION_PATH
ACTION_PATH = "admin.asp?act=manage"
Dim catListSQL, catListRS
Dim catFilter
If Request.QueryString("filter") <> "" Then
catFilter = Request.QueryString("filter")
Else
catFilter = "-1"
End if
catListSQL = "SELECT cat_id, cat_name, cat_desc FROM categories"
Set catListRS = Server.CreateObject("ADODB.Recordset")
catListRS.open catListSQL, conn, 1,1
If catListRS.EOF or catListRS.BOF Then
Response.Write("There is no categoy yet.")
Else
%>
<form id="filterForm" name="filterForm" method="get" action="admin.asp">
<div id="filterArticle">
<input type="hidden" name="act" value="manage" />
<select id="filter" name="filter" class="inputBox">
<%
Dim selected
selected = false
Do until catListRS.EOF
If catListRS("cat_id") = cInt(catFilter) Then
Response.Write("<option value=""" + cStr(catListRS("cat_id")) + """ selected=""selected"">"+ catListRS("cat_name") + "</option>")
selected = true
Else
Response.Write("<option value=""" + cStr(catListRS("cat_id")) + """>"+ catListRS("cat_name") + "</option>")
End if
catListRS.MoveNext
Loop
If selected = false Then
Response.Write("<option value=""-1"" selected=""selected"">All Categories</option>")
Else
Response.Write("<option value=""-1"">All Categories</option>")
End If
%>
</select>
<input type="submit" value="Filter" class="button" />
</div><!--End #filterArticle-->
</form>
<%
End If
catListRS.close
Set catListRS = nothing
%>
<%
Dim listRS, listSQL
If catFilter = "-1" Then
listSQL = "SELECT article_id, article_title, article_date, user_name, cat_name FROM articles AS a, users AS u, categories AS c WHERE a.user_id=u.user_id AND a.cat_id=c.cat_id ORDER BY article_date DESC"
Else
listSQL = "SELECT article_id, article_title, article_date, user_name, cat_name FROM articles AS a, users AS u, categories AS c WHERE a.user_id=u.user_id AND a.cat_id=c.cat_id AND a.cat_id=" + cStr(catFilter) + " ORDER BY article_date DESC"
End If
Set listRS = Server.CreateObject("ADODB.Recordset")
listRS.open listSQL, conn, 1,1
If listRS.EOF or listRS.BOF then
Response.Write("There is no article yet.")
Else
Dim currentPage, intPageCount, intRecordCount, intRecord
If Request.QueryString("page") <> "" Then
currentPage = cInt(Request.QueryString("page"))
Else
currentPage = 1
End if
listRS.pageSize = 10
listRS.cacheSize = listRS.pageSize
intPageCount = listRS.pageCount
intRecordCount = listRS.recordCount
If currentPage >= intPageCount Then currentPage = intPageCount
If currentPage <= 0 Then currentPage = 1
listRS.absolutePage = currentPage
intRecord = 0
%>
<form id="postListForm" name="postListForm" method="post" action="JavaScript:void(0);">
<table id="articleList" class="articleList" cellpadding="0" cellspacing="0">
<tr>
<th style="width:20px;"><input type="checkbox" id="post_all" name="post_all" value="" /></th>
<th>Title</th>
<th>Author</th>
<th>Category</th>
<th>Date</th>
</tr>
<%
Dim countPost, rowClass
countPost = 1
Do until intRecord = listRS.pageSize or listRS.EOF
If countPost MOD 2 = 1 Then
rowClass = "oddRow"
Else
rowClass = "evenRow"
End If
%>
<tr class="<%=rowClass%>" onmouseover="changeBackColor(this, 'overRow');" onmouseout="changeBackColor(this, '<%=rowClass%>')">
<td><input type="checkbox" name="post_<%=listRS("article_id")%>" value="<%=listRS("article_id")%>" /></td>
<td><%=listRS("article_title")%></td>
<td><%=listRS("user_name")%></td>
<td><%=listRS("cat_name")%></td>
<td><%=convertDateTime(listRS("article_date"))%></td>
</tr>
<%
countPost = countPost + 1
intRecord = intRecord + 1
listRS.moveNext
Loop
%>
</table>
<div id="postListTitle">
<input type="submit" class="button" value="Delete" name="deletePosts" id="deletePosts" />
<%
Dim url
url = ACTION_PATH + "&filter=" + catFilter + "&page="
If currentPage <> 1 Then
Response.Write("<a href=""" + url + cStr(currentPage - 1) + """>Previous Page</a>")
End if
Response.Write(" | ")
If currentPage <> intPageCount Then
Response.Write("<a href=""" + url + cStr(currentPage + 1) + """>Next Page</a>")
End if
%>
</div><!--End #postListTitle-->
</form>
<%
End If
listRS.close
Set listRS = nothing
conn.close
Set conn = nothing
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -