📄 create_article_list.asp
字号:
<!-- #include file="conn.asp" -->
<!-- #include file="inc/const.asp" -->
<!-- #include file="inc/function.asp" -->
<HTML><HEAD><TITLE>后台管理 </TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="admin.css" type=text/css rel=stylesheet>
</HEAD>
<BODY leftMargin=0 topMargin=0>
<!-- #include file="admin_header.asp" -->
<table width="100%" border="0" cellspacing="2">
<tr>
<td width="20%" align="center" valign="top" class="tdbgleft"><!-- #include file="Admin_Left.asp" --></td>
<td class="b1" valign="top">
<% sub main() %>
<SCRIPT LANGUAGE=javascript>
function SelectAll() {
for (var i=0;i<document.selform.selType.length;i++) {
var e=document.selform.selType[i];
e.checked=!e.checked;
}
}
</script>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" >
<tr>
<th colspan="2" class="tdbg1">批量生成分文章列表静态网页</th>
</tr>
<form action="" method="post" name="selform">
<tr class="tdbg2">
<td colspan="2">(每页显示文章个数:
<input name="MaxPerPage" type="text" id="MaxPerPage" value="25" size="3" maxlength="2">
) (
<input type="checkbox" name="force" value="yes">
设置生成全部,否则只生成更新过的分类) </td>
</tr>
<tr class="tdbg2">
<td colspan="2" align="center"> <input type="submit" name="Submit" value="执行操作"></td>
</tr>
<tr class="tdbg2">
<td width="25">提示</td>
<td width="94%">每页显示的数量越多,服务器执行速度越快;系统第一次使用必须全部生成一次。</td>
</tr>
</form>
</table>
<%
end sub
if not isnull(cUserName) or cUserName<>"" then
if chkMaster(cUserName) then
if Trim(Request.Form("MaxPerPage"))<>"" then
if isInteger(Trim(Request.Form("MaxPerPage"))) then
Server.ScriptTimeOut=9999999
dim fso,CateRs,HtmlFileName,HtmlTemplate,HtmlContent,listContent,i,n,ii,selType,MaxPerPage,totalPut,CurrentPage,TotalPages
dim strTitle,strNavigate,strCateNav,strCateTop,strArticleList
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set Rs=server.createobject("adodb.recordset")
Set CateRs=server.createobject("adodb.recordset")
'读取默认模板
sql="select ID,Article_Head,Article_List,Article_foot from "&CategoryName&"_Template where isActive=true"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "您没有添加模板,或者没有设置默认模板。"
response.end
else
HtmlTemplate=rs("Article_Head")&rs("Article_List")&rs("Article_foot")
end if
rs.close
if Trim(Request.Form("force"))="yes" then
sql="select * from info_Catalog"
else
sql="select * from info_Catalog where isUpdate=1"
end if
CateRs.open sql,conn,1,1
if not(CateRs.eof and CateRs.bof) then
do while not CateRs.eof
msginfo = msginfo & Create_Article_List(CateRs("CatalogID"),""&CateRs("CatalogName")&"",Trim(Request.Form("MaxPerPage")),CateRs("Depth"),CateRs("RootID"))
CateRs.movenext
loop
end if
CateRs.close
set CateRs=Nothing
sql="update info_Catalog set isUpdate=0"
conn.execute sql
msgtitle="批量生成分类文章列表静态网页"
call Sysmsg(msgtitle,msginfo)
Set Rs=nothing
Set fso=nothing
else
msgtitle="批量生成大类文章列表静态网页"
msginfo="输入的文章个数不是整数。"
call Sysmsg(msgtitle,msginfo)
end if
else
call main()
end if
else
msgtitle="批量生成大类文章列表静态网页"
msginfo="<li>操作错误,你不是系统管理员,没有权限进行此项操作!</li>"
call Sysmsg(msgtitle,msginfo)
end if
else
msgtitle="批量生成大类文章列表静态网页"
msginfo="<li>操作错误,你没有登录系统!<li><a href=""User.Asp"">点此登录系统</a></li>"
call Sysmsg(msgtitle,msginfo)
end if
function Create_Article_List(CatalogID,CatalogName,MaxPerPage,isDepth,RootID)
'dim strTitle,strCateNav,strCateTop,strArticleList
strCateNav=article_cate_nav(CatalogID)
strArticleList=""
strTitle=CatalogName
strNavigate=article_nav(CatalogID,"文章列表","")
strCateTop="<script src=""../js/article_Catalog_Top_"&CatalogID&".js""></script>"
if isDepth=0 then
sql= "select ArticleID,Title,CatalogID,CatalogName,DateTime,Hits,isHot from info_Article Where RootID="&RootID&" order by DateTime Desc"
else
sql= "select ArticleID,Title,CatalogID,CatalogName,DateTime,Hits,isHot from info_Article Where CatalogID="&CatalogID&" order by DateTime Desc"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then
strArticleList = strArticleList & "<table width=""100%"" border=""0"" cellpadding=""2"" cellspacing=""0"" bordercolor=""#111111"" id=""Article_List"">" & vbcrlf
strArticleList = strArticleList & " <tr bgcolor=""#EBEBEB""> " & vbcrlf
strArticleList = strArticleList & " <td> 文章标题</td>" & vbcrlf
strArticleList = strArticleList & " <td align=""center""> 日期</td>" & vbcrlf
strArticleList = strArticleList & " <td align=""center"">人气</td>" & vbcrlf
strArticleList = strArticleList & " </tr>" & vbcrlf
strArticleList = strArticleList & " <tr> " & vbcrlf
strArticleList = strArticleList & " <td height=""22"" colspan=""3"">Sorry!本类没有任何文章!</td>" & vbcrlf
strArticleList = strArticleList & " </tr>" & vbcrlf
strArticleList = strArticleList & "</table>" & vbcrlf
HtmlContent=HtmlTemplate
HtmlContent=replace(HtmlContent,"$Title$",""&strTitle&"")
HtmlContent=replace(HtmlContent,"$Navigate$",""&strNavigate&"")
HtmlContent=replace(HtmlContent,"$CateNav$",""&strCateNav&"")
HtmlContent=replace(HtmlContent,"$CateTop$",""&strCateTop&"")
HtmlContent=replace(HtmlContent,"$Article_List$",""&strArticleList&"")
HtmlContent=replace(HtmlContent,"</HEAD>","</HEAD>"&Copyright&"")
HtmlFileName=Server.MapPath("infolist/Catalog_"&CatalogID&"_1.html")
Set fout = fso.CreateTextFile(HtmlFileName)
fout.WriteLine HtmlContent
fout.close:set fout = nothing
else
'MaxPerPage,totalPut,CurrentPage,TotalPages
totalPut=rs.recordcount '文章数
if (totalPut mod MaxPerPage)=0 then
tempPcount= totalPut \ MaxPerPage
else
tempPcount= totalPut \ MaxPerPage + 1
end if
for CurrentPage=1 to tempPcount
if (totalPut mod MaxPerPage)=0 then
Pcount= totalPut \ MaxPerPage
else
Pcount= totalPut \ MaxPerPage + 1
end if
'rs.AbsolutePage=CurrentPage
listContent=""
listContent = listContent & "<table width=""100%"" border=""0"" cellpadding=""2"" cellspacing=""0"" bordercolor=""#111111"" id=""Article_List"">" & vbcrlf
listContent = listContent & " <tr bgcolor=""#EBEBEB""> " & vbcrlf
listContent = listContent & " <td class=""b1""> 文章标题</td>" & vbcrlf
listContent = listContent & " <td align=""center"" class=""b1""> 日期</td>" & vbcrlf
listContent = listContent & " <td align=""center"" class=""b1"">人气</td>" & vbcrlf
listContent = listContent & " </tr>" & vbcrlf
listContent = listContent & " <tr> " & vbcrlf
listContent = listContent & " <td width=""100%"" colspan=""3"" height=""1""></td>" & vbcrlf
listContent = listContent & " </tr>" & vbcrlf
RS.MoveFirst
if currentpage > Pcount then currentpage = Pcount
if currentpage<1 then currentpage=1
RS.Move (currentpage-1) * MaxPerPage
page_count=0
do while not rs.eof and page_count < Clng(MaxPerPage)
listContent = listContent & " <tr height=""22""> " & vbcrlf
listContent = listContent & " <td class=""b1"">·<a href=""../infoview/Article_"&rs("ArticleID")&".html"">"&rs("Title")&"</a></td>" & vbcrlf
listContent = listContent & " <td align=""center"" class=""b1"">"&FormatDateTime(rs("DateTime"),2)&"</td>" & vbcrlf
listContent = listContent & " <td align=""center"" class=""b1"">"&rs("Hits")&"</td>" & vbcrlf
listContent = listContent & " </tr>" & vbcrlf
page_count=page_count+1
rs.movenext
loop
'end if
listContent = listContent & " <tr> " & vbcrlf
listContent = listContent & " <td height=""22"" colspan=""3"">$showPage$</td>" & vbcrlf
listContent = listContent & " </tr>" & vbcrlf
listContent = listContent & "</table>" & vbcrlf
strArticleList=replace(listContent,"$showPage$",""&showPage(CatalogID,CatalogName,totalput,MaxPerPage)&"")
HtmlContent=HtmlTemplate
HtmlContent=replace(HtmlContent,"$Title$",""&strTitle&"")
HtmlContent=replace(HtmlContent,"$Navigate$",""&strNavigate&"")
HtmlContent=replace(HtmlContent,"$CateNav$",""&strCateNav&"")
HtmlContent=replace(HtmlContent,"$CateTop$",""&strCateTop&"")
HtmlContent=replace(HtmlContent,"$Article_List$",""&strArticleList&"")
HtmlContent=replace(HtmlContent,"</HEAD>","</HEAD>"&Copyright&"")
HtmlFileName=Server.MapPath("infolist/Catalog_"&CatalogID&"_"¤tPage&".html")
Set fout = fso.CreateTextFile(HtmlFileName)
fout.WriteLine HtmlContent
fout.close:set fout = nothing
next
end if
rs.close
Create_Article_List="分类名称:"&CatalogName&" 成功创建列表网页。<br>"& vbcrlf
end function
function showPage(CatalogID,CatalogName,TotalNumber,MaxPerPage)
showPage=""
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
showPage=showPage & "<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
showPage=showPage & "<tr><td>[<font color=""red"">"&CatalogName&"</font>] "
if CurrentPage<2 then
showPage=showPage &" 合计<font color=""red""><b>"&totalnumber&"</b></font>篇 | 首页 上一页"
else
showPage=showPage &" 合计<font color=""red""><b>"&totalnumber&"</b></font>篇 | <a href=""Catalog_"&CatalogID&"_1.html"">首页</a>"
showPage=showPage &" <a href=""Catalog_"&CatalogID&"_"&CurrentPage-1&".html"">上一页</a>"
end if
if n-currentpage<1 then
showPage=showPage &" 下一页 尾页"
else
showPage=showPage &" <a href=""Catalog_"&CatalogID&"_"&(CurrentPage+1)&".html"">"
showPage=showPage &" 下一页</a> <a href=""Catalog_"&CatalogID&"_"&n&".html"">尾页</a>"
end if
showPage=showPage &" 页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
showPage=showPage &"<b>"&maxperpage&"</b>篇/页</td>"
showPage=showPage &"<form action="""" method=post onChange=""submit()""><td>Go:<select name=""select"" onChange='javascript:window.open(this.options[this.selectedIndex].value,""_top"")'>"
for intPage=1 to n
showPage=showPage &"<option value=""Catalog_"&CatalogID&"_"&intPage&".html"""
if intPage=CurrentPage then showPage=showPage &" selected"
showPage=showPage &">第"&intPage&"页</option>"
next
showPage=showPage &"</select></td></FORM></tr></table>"
end function
%>
</td>
</tr>
</table>
<!-- #include file="admin_footer.asp" -->
</BODY></HTML>
<% CloseDatabase %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -