📄 admin_news_syscode.asp
字号:
if page=1 then
content=content&" <a href=""@@静态文件@@.@@扩展名@@"">首页</a> "
else
content=content&" <a href=""@@静态文件@@_"&(page-1)&".@@扩展名@@"">上一页</a> "
end if
'显示下页及尾页
if page=max_page_numbers-1 then
content=content&" <a href=""@@静态文件@@_"&(page+1)&".@@扩展名@@"">[尾页]</a> "
else
content=content&" <a href=""@@静态文件@@_"&(page+1)&".@@扩展名@@"">下一页</a> "
end if
end if
'结束显示上一页及下一页
'显示最后一页
if page=max_page_numbers then
if page=1 then
content=content&" <a href=""@@静态文件@@.@@扩展名@@""><<首页</a> "
else
content=content&" <a href=""@@静态文件@@_"&(page-1)&".@@扩展名@@""><<上一页</a> "
end if
end if
'显示总页数
content=content&"共["&max_page_numbers+1&"]页"
content=content&"</td></tr></TABLE></Div>"
case "3"
content=content&"<DIV class=Pagetype3><TABLE align=right><tr><td>"
If Page=0 Then
Content=Content&"<SPAN class=""s3"">上一页</SPAN>"
ElseIf Page=1 Then
Content=Content&"<a href=""@@静态文件@@.@@扩展名@@"" title=""上一页"" class=s1>上一页</a>"
Else
Content=Content&"<a href=""@@静态文件@@_"&(page-1)&".@@扩展名@@"" title=""上一页"" class=s1>上一页</a>"
End If
startpage=0:n=0
if (Page>=10) then startpage=(Page\10-1)*10+Page mod 10+2
For J=startpage To max_page_numbers
If J= Page Then
Content=Content&"<a href=""#"" class=s2 >"& cstr(J+1) &"</a>"
Else
if J=0 then
content=content&"<a href=""@@静态文件@@.@@扩展名@@"">" & (J+1) & "</a>"
else
Content=Content&"<a href=""@@静态文件@@_"&(J)&".@@扩展名@@"">" & (J+1) & "</a>"
end if
End If
n=n+1
if n>10 Then Exit For
Next
If Page=max_page_numbers Then
Content=Content&"<SPAN class=s3>下一页</SPAN> "
Else
Content=Content&"<a href=""@@静态文件@@_"&(page+1)&".@@扩展名@@"" title=""下一页"" class=s1>下一页</a>"
End If
content=content&"</td></tr></TABLE></Div>"
case "4"
content=content&"<DIV class=Pagetype4><TABLE align=right><tr><td>"
If Page=0 Then
Content=Content& "<font face=webdings>9</font> <font face=webdings>7</font>"
ElseIf Page=1 Then
Content=Content& "<a href=""@@静态文件@@.@@扩展名@@"" title=""首页""><font face=webdings>9</font></a> <a href=""@@静态文件@@.@@扩展名@@"" title=""上一页""><font face=webdings>7</font></a>"
Else
Content=Content& "<a href=""@@静态文件@@.@@扩展名@@"" title=""首页""><font face=webdings>9</font></a> <a href=""@@静态文件@@_"&(page-1)&".@@扩展名@@"" title=""上一页""><font face=webdings>7</font></a> "
End If
startpage=0:n=0
if (Page>=10) then startpage=(Page\10-1)*10+Page mod 10+2
For J=startpage To max_page_numbers
If J= Page Then
Content=Content&" <a href=""#"" >"& cstr(J+1) &"</a>"
Else
if J=0 then
content=content&" <a href=""@@静态文件@@.@@扩展名@@"">" & (J+1) & "</a>"
else
Content=Content&" <a href=""@@静态文件@@_"&(J)&".@@扩展名@@"">" & (J+1) & "</a>"
end if
End If
n=n+1
if n>10 Then Exit For
Next
If Page=max_page_numbers Then
Content=Content& " <font face=webdings>8</font> <font face=webdings>:</font>"
Else
Content=Content&" <a href=""@@静态文件@@_"&(page+1)&".@@扩展名@@"" title=""下一页"" ><font face=webdings>8</font></a> <a href=""@@静态文件@@_"&max_page_numbers&".@@扩展名@@""><font face=webdings>:</font></a> "
End If
content=content&"</td></tr></TABLE></Div>"
end select
content=content&"</Div>"
end if '结束:只有一页时,不显示分页状态条.
'结束步骤四.
'步骤六:根据lm的模板生成静态文件
'以下内容多数是news_view.asp中截取出来,以便生成静态文件。
'相关内容
webxgnews=chkhtm(trim(rs("xgnews")))
if webxgnews="" then webxgnews=left(rs("title"),5)
if webxgnews<>"" then
webxgnews=replace(webxgnews,"[","")
webxgnews=replace(webxgnews,"]","")
end if
if Comment=1 then ppll="<BR><hR size=1><script language=""javascript"" src="""&root_path&"js_news_pl.asp?id="&news_id&"&form="&plfb&"""></script>"
'这句是用来记来点击次数的。可以做成JS调用,以便静态网页使用。
write_hit="<script language=""javascript"" src="""&root_path&"js_news_hit.asp?action=0&news_id="&news_id&"""></script>"
pp=""
pp=pp&" "
pp=pp&"<a name=pl><img src="&root_path&"images/bbstitle.gif></a><a href=#pl onclick='window.open("""&root_path&"newspl.asp?id="&rs("id")&""",""newsview"",""width=805,height=400,top=70,left=150,scrollbars=yes"" )' title='"&rs("title")&"'>发表,查看评论(<script charset='gb2312' TYPE='text/javascript' language='javascript' src='"&root_path&"js-pls.asp?newsid="&rs("id")&" '></script>)</a> "
pp=pp&"<img border='0' src='"&root_path&"images/print.gif' width='16' height='16'><a href='javascript:window.print()'>打印本页</a> "
pp=pp&"<img border='0' src='"&root_path&"images/soso.gif'><a href="&root_path&"so/?word="&webxgnews&" target=_blank>搜索相关信息</a>"
'步骤三:创建静态文件的目录
'把命名规则中的栏目替换为栏目名称:
file_rule=replace(file_rule,"栏目",lm_path)
array_file=split(file_rule,"/") '取出文件的各级目录名称和文件名
file_path=replace(file_rule,array_file(ubound(array_file)),"") '取出文件的目录
file_name=array_file(ubound(array_file)) '取出文件的文件名
if request("id")<>"" and rs("file_path")<>"" and rs("file_name")<>"" then '新增的新闻,目录按规则定
db_more_file_name=rs("file_name") '文件名是数组形式保存:file1|file2|file3
array_db_more_file_name=split(db_more_file_name,"|")
db_file_name=array_db_more_file_name(0) '仅取出第一个文件名称
db_file_path=rs("file_path")
old_file=db_file_path&db_file_name
' 判断:如果栏目与原栏目不相同或文件扩展名与原扩展名不相同,则新建目录和新创建文件
array_db_file_path=split(db_file_path,"/")
array_db_file_name=split(db_file_name,".")
old_lm_path=array_db_file_path(0)&"/"&array_db_file_path(1) '旧栏目的目录
new_lm_path=array_file(0)&"/"&array_file(1) '新栏目的目录
old_file_ext=array_db_file_name(1) '旧的文件名扩展名
new_file_ext=file_type '新的文件名扩展名
if old_lm_path=new_lm_path and old_file_ext=new_file_ext then
del_old_file="not"
'假如保留原有路径和名称,则重定义file_rule的值。
array_old_file=split(old_file,"/") '取出文件的各级目录名称和文件名
redim array_file(ubound(array_old_file))
array_file=split(old_file,"/") '取出文件的各级目录名称和文件名
file_path=db_file_path '取出文件的目录
file_name=db_file_name '取出文件的文件名
else
del_old_file="yes"
end if
end if
'(一):静态文件存放目录:
wl_root_path=server.mappath(root_path)&"\" '栏目物理存放的目录 '把静态文件存放在:./html目录之下。可改其它目录名。这里调用的是服务器的物理路径
'创建这两个目录
dim fileobj, folder
set fileobj=Server.Createobject("Scripting.FileSystemObject")
'建立目录时,只能逐级一步步来建立
wl_file_path=wl_root_path
for n_mulu=0 to ubound(array_file)-1
wl_file_path=wl_file_path&"\"&array_file(n_mulu)
'创建指定规则的目录
if not fileobj.folderexists(wl_file_path) then
set folder=fileobj.CreateFolder(wl_file_path)
end if
next
'所有的目录创建完毕
'要保存的文件的物理路径和名称是:
if only_one_page="yes" then
wl_file_name=wl_file_path&"\"&array_file(ubound(array_file))
this_write_file=array_file(ubound(array_file)) '当前文件名
else
a_create_file=split(array_file(ubound(array_file)),".")
if page=0 then
create_file=a_create_file(0)&"."&a_create_file(1)
else
create_file=a_create_file(0)&"_"&page&"."&a_create_file(1)
end if
wl_file_name=wl_file_path&"\"&create_file
this_write_file=create_file '当前的文件名
end if
'结束步骤三.
'创建静态文件
'如果旧文件不符合现有的规则,则删除旧文件:
if del_old_file="yes" then
'修改,2006-9-16,应该删除所有的分页文件,不应只是一个文件.
will_del_path=rs("file_path")
array_will_file_name=split(rs("file_name") ,"|")
for file_n=0 to ubound(array_will_file_name)
will_del_file_name=array_will_file_name(file_n)
wl_del_file=wl_root_path&will_del_path&will_del_file_name
If fileobj.FileExists(wl_del_file) Then
fileobj.DeleteFile(wl_del_file) '跳转到静态文件
end if
next
'修改结束,2006-9-16,应该删除所有的分页文件,不应只是一个文件.
end if
'创建新文件:
Set file_output= fileobj.Createtextfile(wl_file_name,true)
out_html_nr=replace(nr,"$$内容$$",content) '不能用nr=这个参数。否则第二次没有$$内容$$这个替换值了。
out_html_nr=out_html_nr&write_hit '把阅读次数写入HTML文件中
if only_one_page<>"yes" then '把分页网页中的@@静态文件@@替换成文件名:
array_page_file_name=split(file_name,".")
out_html_nr=replace(out_html_nr,"@@静态文件@@",root_path&file_path&array_page_file_name(0))
out_html_nr=replace(out_html_nr,"@@扩展名@@",array_page_file_name(1))
end if
out_html_nr=replace(out_html_nr,"$$评论$$",ppll)
out_html_nr=replace(out_html_nr,"$$打印$$",pp)
out_html_nr=replace(out_html_nr,"$$工具栏$$",pp)
'2006-9-16,取消下句,增JS调用相关内容
if Instr(out_html_nr,"$$相关$$")>0 then
uuu_xg="<script language=""javascript"" src="""&root_path&"js_news_xg.asp?news_id="&news_id&"""></script>"
out_html_nr=replace(out_html_nr,"$$相关$$",uuu_xg)
end if
'增加JS相关结束
if trim(url)<>"" then out_html_nr="<html>"&vbCrLf&"<head>"&vbCrLf&"<meta http-equiv=""refresh"" content=""3; url="&url&""">"&vbCrLf&"</head>"&vbCrLf&"<body>"&vbCrLf&"<table cellpadding=0cellspacing=0 border=0 width=95% align=center><tr><td align=center bgcolor=FFFFFF height=50><font color=red>正在跳转中…………</font></td></tr></table>"&vbCrLf&write_hit&vbCrLf&"</body></html>" '如果只是跳转,则生成转到别的网页去的内容。
'阿蚊少-08-06-08,增加解决相对路径问题,可解决大部分问题,部分不能处理请使用绝对路径
out_html_nr=an_Replace(out_html_nr,root_path)
file_output.writeline out_html_nr '把内容写入静态文件中。
file_output.close
set fileobj=nothing
'创建文件结束
'结束步骤六.
if only_one_page<>"yes" then '如果有多页时,保存在数据库的文件名用数组形式表示:
out_to_db_file_name=out_to_db_file_name& this_write_file&"|" '以数组形式保存文件名
else
out_to_db_file_name=this_write_file
end if
next '结束循环,page的循环。生成几个静态文件(要对文件个数进行判断)
'步骤七:把相关的目录和文件名存放入[news]表中
rs("file_path")=file_path
if right(out_to_db_file_name,1)="|" then out_to_db_file_name=left(out_to_db_file_name,len(out_to_db_file_name)-1) '把左边第1个“|”分隔符删除。
rs("file_name")=out_to_db_file_name
rs.update
'结束步骤七.
end if '如果要生成静态文件.判断结束.
'生成静态文件结束
end Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -