⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_news_to_html.asp

📁 Art2008 CMS是一款具有强大的功能的基于ASP语言的网站管理软件
💻 ASP
📖 第 1 页 / 共 4 页
字号:
				 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&"&nbsp;"
	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>&nbsp;"
	pp=pp&"<img border='0' src='"&root_path&"images/print.gif' width='16' height='16'><a href='javascript:window.print()'>打印本页</a>&nbsp;"
	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)   

 'out_html_nr=replace(out_html_nr,"$$相关$$",html_xgnews)  

   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   '如果要生成静态文件.判断结束.



     rs.close
    set rs=nothing

    aaa=split(out_to_db_file_name,"|")
    create_html_file=file_path&aaa(0) '返回创建成功时的文件路径和名称
	
	response.write "<font color="&lm_color&">["&lm_name&"]</font>&nbsp;<a href='"&root_path&create_html_file&"' target='_blank'><font color='"&titlecolor&"'>"&webtitle&"</font></a> <font color=red style='font-size:18px'> <b>√</b></font>&nbsp;&nbsp;<font color=999999> 静态网页创建成功!</font><BR>"

end function    '结束创建静态文件的子函数


'删除静态文件或数据库中的新闻的函数。
function  del_html_file(html_news_id)   ' 删除静态文件的子过程,参数是新闻的ID号
  
  delid=html_news_id  '取出新闻的ID号
  if delid="" or not isnumeric(clng(delid)) then
         del_html_file=false   '返回的函数值。
       exit function
  end if  

  html_url_sql = "select id,title,titlecolor,file_path,file_name from news where id="&clng(delid)
  Set html_url_rs = Server.CreateObject("ADODB.RecordSet")
  html_url_rs.Open  html_url_sql,conn,1,3
 if  html_url_rs("file_path")<>"" and html_url_rs("file_name")<>"" then  '判断静态文件
   
    array_file_name=split(html_url_rs("file_name"),"|")
    file_path=html_url_rs("file_path")
    title=html_url_rs("title")
    titlecolor=html_url_rs("titlecolor")
  '判断是否有文件存在,如果存在,则调用静态文件,不存在,调用数据库显示
	root_path=finddir(request.servervariables("URL"))   '取出系统程序的工作目录.

	wl_root_path=server.mappath(root_path)&"\"   '栏目物理存放的目录 
    
	 set fileobj=Server.Createobject("Scripting.FileSystemObject")

	for file_n=0 to ubound(array_file_name)
	    file_name=array_file_name(file_n)
         wl_file=wl_root_path&file_path&file_name
	   If fileobj.FileExists(wl_file) Then
	       fileobj.DeleteFile(wl_file) '跳转到静态文件
	  end if
	 next 
    set fileobj=nothing


end if  '结束判断html_url_rs("file_path")<>"" 的条件.
  html_url_rs.close
  set html_url_rs=nothing
  	response.write "&nbsp;<a href='"&root_path&"news_view.asp?newsid="&delid&"' target='_blank'><font color='"&titlecolor&"'>"&title&"</font></a> <font color=red style='font-size:18px'> <b>√</b></font>&nbsp;&nbsp;<font color=999999> 静态网页删除成功!</font><BR>"

   del_html_file=true  '删除新闻成功,返回这个值给调用的语句。
end function  '结束--删除静态文件的子过程



Sub InnerJS(NowNum,TotalNum,itemname)
		  With Response
				.Write "<script>"
				.Write "fsohtml.style.display='';" & vbCrLf
				.Write "fsohtml2.style.display='';" & vbCrLf
				.Write "img2.width=" & Fix((NowNum / TotalNum) * 400) & ";" & vbCrLf
				.Write "txt2.innerHTML=""生成进度:" & FormatNumber(NowNum / TotalNum * 100, 2, -1) & """;" & vbCrLf
				.Write "txt3.innerHTML=""总共需要生成 <font color=red><b>" & TotalNum & "</b></font> " & itemname & ",<font color=red><b>在此过程中请勿刷新此页面!!!</b></font> 系统正在生成第 <font color=red><b>" & NowNum & "</b></font> " & itemname & """;" & vbCrLf
				.Write "img2.title=""(" & NowNum & ")"";</script>" & vbCrLf
				.Flush
		  End With
		End Sub

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -