📄 admin_news_syscode.asp
字号:
<%
'*************************************************************************************
'函数名:create_html()
'作 用:生成静态文件
'*************************************************************************************
Sub create_html(news_id)
'dim file_html,file_type,file_rule,nextpage,page_css,addnews_time,yyyy,mm_month,dd_day,hh,mm,ss,root_path
'dim get_lm_rs,news_mb_sql,news_mb_rs,lm_path,lm_mb,lm_name
'dim title,webtitle,htitle,piczz,updown,rs4,top,down, uuu_path,out_hit,uuu,page,content,array_content, max_page_numbers,p
'dim webxgnews,write_hit,pp,array_file,file_path,file_name,db_more_file_name,array_db_more_file_name,db_file_name,db_file_path,old_file
'dim array_db_file_path,array_db_file_name,old_lm_path,new_lm_path,old_file_ext,new_file_ext,del_old_file,array_old_file
'dim wl_root_path,wl_file_path,n_mulu
'dim only_one_page,this_write_file,a_create_file,create_filethis_write_file
'dim array_will_file_name,will_del_path,file_n
'dim file_output,out_html_nr,ppll,uuu_xg,url
'dim out_to_db_file_name
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") '取出添加新闻时的时间,2006-9-17
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_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_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
response.write "<script>alert('文章已保存,但不能生成静态网页!\n原因是:栏目["&lm_name&"]的模板还没有设置。');history.go(-1);</Script>"
response.end
end if
'结束判断模板的ID号是否为空。
'如果lm中有模板有设置,但是newsmb中没有存在这个模板ID时,则退出,不生成静态文件。
news_mb_sql = "select * from newsmb where id="&clng(lm_mb)
Set news_mb_rs = Server.CreateObject("ADODB.RecordSet")
news_mb_rs.Open news_mb_sql,conn,1,1
'不存在模板时,则不能生成静态网页,并退出。
if news_mb_rs.recordcount=0 then
news_mb_rs.close
set news_mb_rs=nothing
rs.close
set rs=nothing
response.write "<script>alert('文章已保存,但不能生成静态网页!\n原因是:栏目["&lm_name&"]的模板[mb="&lm_mb&"]不存在,请设置正确的模板。');history.go(-1);</Script>"
response.end
else
dim fddh '08_09_01 增加$$浮动导航$$标签
if config("fddh") =0 then
fddh_x=config("fddh_x")
fddh_y=config("fddh_y")
fddh_body=config("fddh_body")
fddh="<SCRIPT FOR=window EVENT=onload LANGUAGE=""javascript"">initAd();</SCRIPT>"
fddh=fddh&"<script language=""javascript"">function initAd() {" & vbcrlf
fddh=fddh&" document.all.AdLayer.style.posTop = -250;" & vbcrlf
fddh=fddh&" document.all.AdLayer.style.visibility = 'visible'" & vbcrlf
fddh=fddh& " MoveLayer('AdLayer');}" & vbcrlf
fddh=fddh& " function MoveLayer(layerName) {" & vbcrlf
fddh=fddh&" var x = "& fddh_x &";" & vbcrlf
fddh=fddh&" var y = "& fddh_y &";" & vbcrlf
fddh=fddh&" var diff = (document.body.scrollTop + y - document.all.AdLayer.style.posTop)*.40;" & vbcrlf
fddh=fddh&" var y = document.body.scrollTop + y - diff;" & vbcrlf
fddh=fddh&" eval(""document.all."" + layerName + "".style.posTop = y"");" & vbcrlf
fddh=fddh&" eval(""document.all."" + layerName + "".style.posLeft = x"");" & vbcrlf
fddh=fddh&" setTimeout(""MoveLayer('AdLayer');"", 10);}" & vbcrlf
fddh=fddh&" </script>" & vbcrlf
fddh=fddh&"<div id=AdLayer style='position:absolute; width:61px; height:59px; z-index:20; visibility:hidden;; left: "& fddh_x&"'>"& fddh_body &"</div>"
else
fddh=""
end if
dim digg
digg="<SCRIPT src="""&root_path&"Include/digg/ArtDigg.js"" type=text/javascript></SCRIPT>"
digg=digg&"<SCRIPT src="""&root_path&"Include/digg/prototype.js"" type=text/javascript></SCRIPT>"
digg=digg&"<DIV class=endPageVote ><UL><LI>"
digg=digg&"<div class=diggArea>"& vbcrlf
digg=digg&"<div id=Art_ding"&news_id&" class=diggNum><SCRIPT language=javascript src="""&root_path&"Include/digg/digg.asp?id="&news_id&"&post=diggshow""></SCRIPT></div>"& vbcrlf
digg=digg&"<div id=diggact"&news_id&" class=diggLink><a onclick=""javascript:Digg("&news_id&",'"&root_path&"');"" href=""javascript:void(0);"">顶一下</a></div>"& vbcrlf
digg=digg&"</div>"& vbcrlf
digg=digg&"</LI><LI>" & vbcrlf
digg=digg&"<div class=diggArea>"& vbcrlf
digg=digg&"<div id=Art_down"&news_id&" class=diggNum><SCRIPT language=javascript src="""&root_path&"Include/digg/digg.asp?id="&news_id&"&post=downshow""></SCRIPT></div>"& vbcrlf
digg=digg&"<div id=downact"&news_id&" class=diggLink><a onclick=""javascript:down("&news_id&",'"&root_path&"');"" href=""javascript:void(0);"">踩一脚</a></div>"& vbcrlf
digg=digg&"</div>"& vbcrlf
digg=digg&"</LI><LI>" & vbcrlf
digg=digg&"<div class=diggArea>"& vbcrlf
digg=digg&"<div class=diggimg><a href="""&root_path&""" target=_self><img src="""&root_path&"images/end_n_i4.gif"" alt=返回首页 width=""12"" height=""13"" border=""0""align=""absmiddle"" ></a></div>"& vbcrlf
digg=digg&"<div class=diggLink><a href="""&root_path&""" target=_self>返回首页</a></div>"& vbcrlf
digg=digg&"</div>"& vbcrlf
digg=digg&"</LI></UL></DIV>"
dim NewsPurview:NewsPurview="<script language=""javascript"" src="""&root_path&"js_news_read.asp?news_id="&news_id&"&lm_id="&lm_id&"&news_Pay="&news_Pay&"""></script>"
title="<font color="&rs("titlecolor")&">"&title&"</font>"
webtitle=rs("title")
htitle=trim(rs("htitle"))
if htitle="" then htitle=" "
piczz=trim(rs("piczz")) '2007_12_28 增加一个图片来源
if piczz="" then piczz="不详"
updown=news_mb_rs("updown")
nr=NewsPurview&news_mb_rs("mid")
Comment=news_mb_rs("pl")
plfb=news_mb_rs("plfb")
Set rs4 = Server.CreateObject("ADODB.RecordSet") '廖2008-6-1新增,页头页尾调用开始
rs4.Open "select * from [config]",conn,1,1
if rs4.recordcount<>0 then
top=rs4("top")
down=rs4("down")
nr=replace(nr,"$$通用页头$$",top)
nr=replace(nr,"$$通用页尾$$",down)
rs4.close
set rs4=nothing
end if '廖2008-6-1新增,页头页尾调用结束
nr=replace(nr,"$$浮动导航$$",fddh) '08_09_01 增加$$浮动导航$$标签
nr=replace(nr,"$$Digg$$",digg)
nr=replace(nr,"$$页标题$$",webtitle)
nr=replace(nr,"$$标题$$",title)
nr=replace(nr,"$$副标题$$",htitle)
nr=replace(nr,"$$栏目名$$",lm_name)
nr=replace(nr,"$$时间$$",rs("time"))
nr=replace(nr,"$$来源$$",rs("zz"))
nr=replace(nr,"$$图片来源$$",piczz) '2007_12_28 增加一个图片来源
nr=replace(nr,"$$编辑$$",rs("adduser")) '2006-9-16-增加一个编辑
nr=replace(nr,"$$网站目录$$",root_path) '2006-10-23-增加一个网站目录,代替绝对路径。方便网站的转移时,不必再修改模板
nr=replace(nr,"$$NEWSID$$",newsid) '2。5版的newsid标签。
nr=replace(nr,"$$网站名$$",setting("sitename"))
nr=replace(nr,"$$网站描述$$",ClassDescription)
nr=replace(nr,"$$关键字$$",ClassKeywords)
nr=replace(nr,"$$版权信息$$",setting("sitecr"))
'if Instr(nr,"$$会员阅读$$")>0 then '-增2006-9-29,会员阅读限制
' uuu_path="<script language=""javascript"" src="""&root_path&"js_news_read.asp?news_id="&news_id&"&lm_id="&lm_id&"&news_Pay="&news_Pay&"""><//script>"
'nr=replace(nr,"$$会员阅读$$",uuu_path)
'end if
if Instr(nr,"$$路径$$")>0 then
uuu_path="<script language=""javascript"" src="""&root_path&"js_news_lmpath.asp?news_id="&news_id&"""></script>"
nr=replace(nr,"$$路径$$",uuu_path)
end if
if Instr(nr,"$$访问量$$")>0 then
out_hit="<script language=""javascript"" src="""&root_path&"js_news_hit.asp?action=1&news_id="&news_id&"""></script>"
nr=replace(nr,"$$访问量$$",out_hit)
end if
if Instr(nr,"$$上下条$$")>0 then
uuu="<script language=""javascript"" src="""&root_path&"js_news_updown.asp?updown="&updown&"&news_id="&news_id&"&lm_id="&lm_id&"""></script>"
nr=replace(nr,"$$上下条$$",uuu)
end if
news_mb_rs.close
set news_mb_rs=nothing
end if
'结束步骤二.
'步骤四:取出文章的内容,并根据是否有分页符进行内容截取,并生成若个的静态文件.
content=rs("content")
if config("NewsWordKeyon")=1 then '080917___Art增加新闻内容关键字搜索功能
NewsWordKey=","&config("NewsWordKey")&","
aabb=split(NewsWordKey,",")
for jjj=0 to ubound(aabb)
content=replace(content,aabb(jjj),"<a target=_blank title='查看更多' href="&root_path&"so/?word="&aabb(jjj)&"><u>"&aabb(jjj)&"</u></a>")
next
end if
'080705___Art增加自动分页功能
IF PaginationType=1 Then '判断分页类型
Content=SplitNewsPage(Content,MaxCharPerPage) '自动分页函数
End IF
'自动分页功能增加结束
if right(content,len(nextpage_string))=nextpage_string then content=left(content,len(content)-len(nextpage_string)) '去掉最后一个分页符.防止一个人无意在最后加一个分页符.导至下面数组出错
if content<>"" then
array_content=split(content,nextpage_string)
else
array_content=split(content&" ",nextpage_string)
end if
max_page_numbers=ubound(array_content)
if max_page_numbers=0 then only_one_page="yes"
'取出本文章有多少页
for page=0 to max_page_numbers 'n_html--表示第几个页面。
content=array_content(page)
if max_page_numbers>0 then '只有一页时,不显示分页状态条.
content=content&"<Div class=Pagetype>"
select case page_Css
case "1"
content=content&"<DIV class=Pagetype1><TABLE align=right><tr><td>"
content=content&"共["&max_page_numbers+1&"]页:"
for p=0 to max_page_numbers
if p=0 then
content=content&" <a href=""@@静态文件@@.@@扩展名@@"">[第"&p+1&"页]</a> "
else
content=content&" <a href=""@@静态文件@@_"&p&".@@扩展名@@"">[第"&p+1&"页]</a> "
end if
next
content=content&"</td></tr></TABLE></Div>"
case "2"
content=content&"<DIV class=Pagetype2><TABLE align=right><tr><td>"
content=content&"第<font color='red'>["&page+1&"]</font>页 "
'显示第一页
if page=0 then
content=content&" <a href=""@@静态文件@@_"&(page+1)&".@@扩展名@@"">下一页>></a> "
end if
'显示上一页及下一页
if page<>0 and page<>max_page_numbers then
'显示上一页及首页
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -