📄 admin_news_to_html.asp
字号:
</select>
日
</div>
<!-- 结束--查找从某年某月某日到某年某月某日的选择 -->
<!-- 结束时间段 -->
<tr class="tdbg">
<td align="center">
<input name="done_action" type="hidden" value="">
<input name="b1" type="submit" value="批量生成静态网页" onClick="done_action.value='add_html'" >
<input name="b2" type="submit" value="批量删除静态网页" onClick="done_action.value='del_html'" onSubmit="return Form_Validator(this)">
<input name="db_news_del" type="checkbox" value="1" onclick='if(confirm("严重警告:\n如果你“勾选”后,指定栏目和属于这个栏目下的所有子栏目中的新闻\n将从数据库中删除,而且此操作后将不能再恢复所删除的新闻!")){return true;}return false;'>同时删除数据库中的新闻
<input name="b3" type="button" value=" 返 回 " onClick="javascript:history.back()">
</form>
</td></tr></table>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"><tr class="tdbg"><td>
<div align="left" class="style2">
操作说明:<BR> 一、1. 批量生成/删除静态网页时,将按指定的条件批量生成/删除静态网页文件。<FONT COLOR="#FF0000"><br>
2. 如果你“勾选”了同时删除数据库中的新闻,那么执行后指定的新闻将永久被删除,而且不能恢复。</FONT><BR>
二、批量生成或删除新闻时,如果:1. 选中三级栏目时,仅对三级栏目执行。<br>
2. 选中某个二级栏目,这个二级栏目的新闻和属于这个二级栏目下所有的三级栏目新闻也相应执行相同的操作。<br>
3. 选中某个一级栏目,这个一级栏目新闻和属于这个一级栏目下的所有二级栏目新闻和属于这个一级栏目下的所有三级栏目新闻都会执行相同的操作。
<HR size="1" color="#FFCCCC">
</div>
<%
With Response
.Write "<table id=fsohtml style='display:none' width=""400"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1"">"
.Write "<tr> "
.Write "<td bgcolor=000000>"
.Write " <table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""1"" >"
.Write "<tr> "
.Write "<td bgcolor=ffffff height=9><img src=""../images/r2_c2.jpg"" width=0 height=10 id=img2 name=img2 align=absmiddle></td></tr></table>"
.Write "</td></tr></table>"
.Write "<table width=""550"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1"" id=fsohtml2 style='display:none'><tr> "
.Write "<td align=center> <span id=txt2 name=txt2 style=""font-size:9pt"">0</span><span id=txt4 style=""font-size:9pt"">%</span></td></tr> "
.Write "<tr><td align=center><span id=txt3 name=txt3 style=""font-size:9pt"">0</span></td></tr>"
.Write "</table>"
.Write "</td></tr></table>"
End With
%>
</td></tr></table>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" ><tr class="tdbg"><td>
<%
Select Case action
Case "New"
Dim TotalNum:TotalNum=S("TotalNum")
response.write "<b>执行结果如下:</b><BR><BR>"
news_sql = "select Top " & TotalNum & " id from news where sh=1 " '发布最新添加的--条
news_sql=news_sql&" order by id desc "
Set news_rs = Server.CreateObject("ADODB.RecordSet")
news_rs.Open news_sql,conn,1,1
shi_hao=0
if news_rs.recordcount=0 then response.write "<font color=red>没有新闻存在!</font>"
do while not news_rs.eof
shi_hao=shi_hao+1
Call InnerJS(shi_hao,news_rs.recordcount,"篇文章")
done_news_id=news_rs("id")
response.write shi_hao&"、"
aa=create_html_file(done_news_id) ''批量增加新闻的静态网页文件。
news_rs.movenext
loop
news_rs.close: set news_rs=nothing
Case "InfoID"
Dim StartID:StartID=S("StartID")
Dim EndID:EndID=S("EndID")
response.write "<b>执行结果如下:</b><BR><BR>"
news_sql = "select id from news where sh=1 and ID>= " & StartID & " And ID <=" & EndID '按文章ID发布从--到--
news_sql=news_sql&" order by id desc "
Set news_rs = Server.CreateObject("ADODB.RecordSet")
news_rs.Open news_sql,conn,1,1
shi_hao=0
if news_rs.recordcount=0 then response.write "<font color=red>没有新闻存在!</font>"
do while not news_rs.eof
shi_hao=shi_hao+1
Call InnerJS(shi_hao,news_rs.recordcount,"篇文章")
done_news_id=news_rs("id")
response.write shi_hao&"、"
aa=create_html_file(done_news_id) ''批量增加新闻的静态网页文件。
news_rs.movenext
loop
news_rs.close: set news_rs=nothing
Case "Lmordate"
if done_action<>"" and select_lm<>"" then
'批量增加/删除新闻的静态网页文件,方便网站管理静态网页和节省服务器空间。
response.write "<b>执行结果如下:</b><BR><BR>"
'输出查询时间段的内容
if create_time="cho_time" then
if DataBaseType=0 then
where_date_sql=" ([time]>= #"&yymmdd_1&"# and [time]<= #"&yymmdd_2&"#) " '奇怪:在ACCESS数据库,必须用 #时间字符串# 来表示。给#符号搞死我。
else
where_date_sql=" ([time]>= '"&yymmdd_1&"' and [time]<= '"&yymmdd_2&"') " '奇怪:如果是在SQL数据库。用这个是正常的。但在ACCESS数据库,不能正常运行。
end if
else
where_date_sql=" "&create_time '奇怪:本语句在SQL数据库调试是正常运行的。但在ACCESS数据库,不能正常运行。
end if
if select_lm<>"lm=0" then
array_select_lm=split(select_lm,"=") '由于SQL语句不认识lm=1333中的后面数字是文本或字符,所以只能分隔出来,并做处理。
where_lm_sql=" where "&array_select_lm(0)&"='"&array_select_lm(1)&"'"
'选择栏目, 如果lm=0 则表示选择全部。
news_where_sql=where_lm_sql&" and "&where_date_sql
else
news_where_sql=" where "&where_date_sql
end if
news_sql = "select id from news "&news_where_sql
news_sql=news_sql&"and sh=1 order by id desc "
Set news_rs = Server.CreateObject("ADODB.RecordSet")
news_rs.Open news_sql,conn,1,1
shi_hao=0
if news_rs.recordcount=0 then response.write "<font color=red>没有新闻存在!</font>"
do while not news_rs.eof
shi_hao=shi_hao+1
Call InnerJS(shi_hao,news_rs.recordcount,"篇文章")
done_news_id=news_rs("id")
response.write shi_hao&"、"
if done_action="add_html" then
aa=create_html_file(done_news_id) ''批量增加新闻的静态网页文件。
end if
if done_action="del_html" then
del_html_file(done_news_id) '批量删除新闻的静态网页文件。 {20080607}___Art2008 添加 清空“file_path” “file_name”字段数据
conn.Execute "update [News] set [file_path]='' , [file_name]='' where ID="&done_news_id
if db_news_del=1 then '同时删除数据库中的新闻
conn.Execute "delete from [news] where ID="&done_news_id '----不能删除数据库中的新闻。取消
conn.Execute "delete from [newspl] where newsID="&done_news_id '--不能删除数据库的新闻评论。取消
end if
end if
news_rs.movenext
loop
news_rs.close
set news_rs=nothing
'结束处理批量增加/删除新闻的静态网页文件。
end if ' 结束 done_action<>""
End Select
%>
</td></tr></table>
<%call AdminPageEnd()%>
</body>
</html>
<%
conn.close
set conn=nothing
%>
<%
function create_html_file(html_news_id) ' 创建静态文件的子过程,参数是新闻的ID号
news_id=html_news_id '取出新闻的ID号
if news_id="" or not isnumeric(clng(news_id)) then
create_html_file="" '返回空值的函数值。
exit function
end if
sql = "select * from news where id="&news_id
sql=sql&" order by id desc "
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
if rs.recordcount=0 then
create_html_file="" '返回空值的函数值。
exit function
end if
lm1=rs("lm")
lm2=rs("lm2")
lm3 =rs("lm3")
title=rs("title")
htitle=rs("htitle")
titlecolor=rs("titlecolor")
content=rs("content")
zz=rs("zz")
piczz=rs("piczz")
tj=rs("tj")
pic=rs("pic")
url=rs("url")
xgnews=rs("xgnews")
ontop=rs("ontop")
MaxCharPerPage=rs("MaxCharPerPage")
PaginationType=rs("PaginationType")
'增加:写入静态文件
'步骤一:取出静态文件的路径和文件名:
'豪气冲天--2006-8-27日增,取出配置文件中的是否生成静态html文件的设置
file_html=config("file_html")
file_type=config("file_type")
file_rule=config("file_rule")
nextpage_string=config("nextpage")
page_css=config("page_css")
if file_html=1 then '如果需要写入静态网页
addnews_time=rs("time") '取出添加新闻时的时间
yyyy=cstr(year(addnews_time))
mm_month=cstr(month(addnews_time))
dd_day=day(addnews_time)
hh=hour(addnews_time)
mm=minute(addnews_time)
ss=second(addnews_time)
if len(mm_month)<2 then mm_month="0"&mm_month
if len(dd_day)<2 then dd_day="0"&dd_day
if len(hh)<2 then hh="0"&hh
if len(mm)<2 then mm="0"&mm
if len(ss)<2 then ss="0"&ss
file_rule=replace(file_rule,"年",yyyy)
file_rule=replace(file_rule,"月",mm_month)
file_rule=replace(file_rule,"日",dd_day)
file_rule=replace(file_rule,"时间",hh&mm&ss)
file_rule=replace(file_rule,"扩展名",file_type)
'根据配置的命名规则,取出当前静态文件的文件路径和文件名.
root_path=finddir(request.servervariables("URL")) '取出系统程序的工作目录.
'豪--结束步聚一:,取出配置静态文件.
'步骤二:取出栏目的目录名称和栏目的命名,栏目的ID号,和模板的ID号:
if lm3<>"0" then
lm_id=clng(lm3)
end if
if lm3="0" and lm2<>"" then
lm_id=clng(lm2)
end if
if lm3="0" and lm2="0" and lm1<>"0" then
lm_id=clng(lm1)
end if
'取出栏目的相关设置:
if vartype("lm_id")=vbString then lm_id=clng(lm_id) '如果不是数字型,则要把字符型转为数字型
set get_lm_rs = Server.CreateObject("ADODB.RecordSet")
get_lm_rs.Open "select * from [lm] where id="&lm_id&" order by id desc",conn,1,1
if get_lm_rs.recordcount<>0 then
lm_path=get_lm_rs("lm_path")
lm_mb=trim(get_lm_rs("mb"))
lm_color=trim(get_lm_rs("fontcolor"))
lm_name=trim(get_lm_rs("lm"))&trim(get_lm_rs("lm2"))&trim(get_lm_rs("lm3"))
ClassKeywords=get_lm_rs("ClassKeywords")
ClassDescription=get_lm_rs("ClassDescription")
if ClassKeywords="" then ClassKeywords=setting("sitekey")
if ClassDescription="" then ClassDescription=setting("sitedes")
else
lm_path=""
lm_mb=""
lm_color=""
lm_name=""
end if
get_lm_rs.close
set get_lm_rs=nothing
'如果模板设置不正确,则退出,不生成静态文件
if lm_mb="" or isNull(lm_mb) or isEmpty(lm_mb) then
rs.close
set rs=nothing
'2006-9-22日--改为退出函数。防止批量因出错而中止后面的新闻生成。
response.write "<font color="&lm_color&">["&lm_name&"]</font> <a href='news_view.asp?newsid="&news_id&"' target='_blank'><font color='"&titlecolor&"'>"&title&"</a>,<font color='red'>静态网页创建失败,原因是:栏目["&lm_name&"]的模板还没有设置!</font><BR>"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -