<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!-- #include file="inc/function.asp" -->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>静态生成管理 - 后台管理中心 - 126电影程序CMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/css_body.css" type=text/css rel=stylesheet>
<script language="javascript" src="images/admin.js"></script>
<script language="javascript">
function $() 
{ 
  var elements = new Array(); 
  for (var i = 0; i < arguments.length; i++) 
  { 
    var element = arguments[i]; 
    if (typeof element == 'string') 
      element = document.getElementById(element); 
    if (arguments.length == 1) 
      return element; 
    elements.push(element); 
  } 
  return elements; 
}
</script>
</HEAD>
<BODY>
<DIV class=bodytitle>
<DIV class=bodytitleleft></DIV>
<DIV class=bodytitletxt>静态生成管理</DIV>
<DIV class=bodytitletxt2></DIV>
</DIV>

<%
response.Charset="GBK"
dim action
dim page

action = SafeData("RQ","action",0)

Select case action
	case "index" : makeindex
	case "map" : makemap
	case "type" : checkViewType : maketype
	case "typeall" : checkViewType :maketypeall
	case "view" : checkViewType :makeview
	case "viewall" : checkViewType :makeviewall
	case "topic" : checkViewType :maketopic
	case "topicall" : checkViewType :maketopicall
	case "google" : makegoogle
	case "baidu" : makebaidu
	case "rss" : makerss
	case "now" : checkViewType :makenow
	case "article" :checkViewType :makearticle
	case "articleall" :checkViewType :makearticleall
	case else : main
End Select

Sub checkViewType
	if app_viewtype=0 then  
	ErrMsg "系统信息","<font color='red'>网站运行模式为动态，不允许生成</font>"
	end if
End Sub

sub makeindex
	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/index.html"
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
	TemplateOBJ.replaceLabel()
	FSOOBJ.createhtml "../index."&app_htmlSuffix,TemplateOBJ.html
	WriteFlush  "首页生成完毕 <a target='_blank' href='"&app_installdir&"index."&app_htmlSuffix&"'><font color=red>浏览首页</font></a><br>" 	
end sub

sub makemap
	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/map.html"
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
	TemplateOBJ.replaceLabel()
	FSOOBJ.createhtml "../allmovie."&app_htmlSuffix,TemplateOBJ.html
	WriteFlush  "地图页生成完毕 <a target='_blank' href='"&app_installdir&"allmovie."&app_htmlSuffix&"'><font color=red>浏览地图页</font></a><br>" 	
end sub

dim num
sub maketype
	dim typeId : typeId = replace(SafeData("R","D_Type",0)," ","")
	if isN(typeId) or typeId =0  then ErrMsg "系统提示","请选择分类..."
	maketypebyid typeId
end sub

sub maketypeall
	dim typecount,typeId,num
	num = 	SafeData("RQ","num",0)
	
	dim Rs : set Rs= Database.GetRecordBySQL("SELECT T_ID FROM Tbl_Type order by T_Sort asc")
	if not Rs.eof then
		typecount = Rs.recordcount
	
		if isN(num) then 
			num = 0
		else
			if clng(num)>clng(typecount)-1 then
				AlertUrl "生成所有分类全部搞定","admin_makehtml.asp"	
				exit sub
			end if
		end if
		rs.movefirst
		if (num > 0) and (clng(num) < Rs.recordcount) then 
			rs.move(clng(num))
		end if
		
		typeId = Rs("t_id")
		maketypebyid typeId
		WriteFlush "<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNexttype();"","&app_makeinterval&"000);function makeNexttype(){location.href='?action=typeall&num="&num + 1&"';}</script>"
	end if
 	Database.C(rs)
end sub

sub maketypebyid(Byval typeId)
    Dim sql,rs,pSize,pCount,tempLabelStr,i,typeLink,typename
	
	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/list.html"
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
	
	sql = "select  d_id,d_name,D_type from tbl_datas where D_type in ("&typeId&")"
	set rs = Database.GetRecordBySQL(sql)
	if rs.recordcount=0 then WriteFlush "<font color='red'>ID为 "&typeId&" 的分类没有数据</font><br>" : Exit Sub
	pSize = getPageSize(TemplateOBJ.html,"page") : if isN(pSize) then pSize = 10
	
	rs.pagesize = pSize : currenttypeid = typeId : pCount = rs.pagecount : tempLabelStr = TemplateOBJ.html
	typename = getDicName("tbl_type","t_name","t_id",currenttypeid)
	tempLabelStr = replace(tempLabelStr,"{typepage:id}",currenttypeid)
	tempLabelStr = replace(tempLabelStr,"{typepage:name}",typename)
	tempLabelStr = replace(tempLabelStr,"{typepage:link}",getTypeLink(currenttypeid))
	
	
	for i=1 to pCount
		typeLink = getChannelPagesLink(currentTypeId,i)
		if app_installdir <> "/" then
			typeLink = replace(typeLink,app_installdir,"../")
		else
			typeLink = ".." &  typeLink
		end if
		
		page = i
		TemplateOBJ.html = tempLabelStr
		TemplateOBJ.replaceLabel()
		FSOOBJ.createhtml typeLink,TemplateOBJ.html
		WriteFlush typename & " 生成完毕 <a target='_blank' href='"&typeLink&"'>"&typeLink&"&nbsp;&nbsp;<font color=red>浏览</font></a><br>" 	
	next
	Database.C(rs)
end sub

sub makeview
	dim typeId : typeId = replace(SafeData("R","D_Type",0)," ","")
	if isN(typeId) or typeId =0  then ErrMsg "系统提示","请选择分类..."
	makeviewbytype typeId
end sub

sub makeviewbytype(ByVal typeId)
	dim rs,sql,i,curpage,num,typename,action2
	action2= SafeData("R","action2",0)
    typeId = clng(typeId)
	curpage = SafeData("RQ","page",0)
	set Rs= Database.GetRecordBySQL("SELECT d_id,d_name,d_type FROM Tbl_Datas where d_type=" &typeId)
	if isN(curpage)  then curpage=1 else curpage=clng(curpage)
	if rs.recordcount=0 then 
		if isN(action2) then
			WriteFlush "<font color='red'>ID为 "&typeId&" 的分类没有数据</font><br>"
			exit sub
	    else 
			WriteFlush "恭喜此分类搞定<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNextPage();"","&app_makeinterval&"000);function makeNextPage(){location.href='?action=viewall&D_Type="&typeId + 1&"&page="&curpage&"&action2="&action2&"';}</script>"
			Exit Sub
		end if
	else
		
	end if
	typename = getDicName("tbl_type","t_name","t_id",typeId)
	
	rs.pagesize=100
	rs.absolutepage= curpage 
	WriteFlush "正在开始生成栏目<font color='red'>"&typename&"</font>的内容页,当前是第<font color='red'>"&curpage&"</font>页,共<font color='red'>"&rs.pagecount&"</font>页<br>"
	for i=0 to rs.pagesize
		makeviewbyid(rs(0))
		rs.movenext
		if rs.eof  then
			if isN(action2) then
				WriteFlush "恭喜此分类搞定" : Exit Sub	
			else
		WriteFlush "恭喜此分类搞定<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNextPage();"","&app_makeinterval&"000);function makeNextPage(){location.href='?action=viewall&D_Type="&typeId + 1&"&page="&curpage&"&action2="&action2&"';}</script>"
				Exit Sub
			end if
		end if
	next
	
	WriteFlush "<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNextPage();"","&app_makeinterval&"000);function makeNextPage(){location.href='?action=view&D_Type="&typeId&"&page="&curpage&"&action2="&action2&"';}</script>"
	
	Database.C(rs)
end sub

sub makeviewall
	dim typecount,typeId,num
	num = 	SafeData("RQ","D_Type",0)
	
	dim Rs : set Rs= Database.GetRecordBySQL("SELECT T_ID FROM Tbl_Type order by T_Sort asc")
	if not Rs.eof then
		typecount = Rs.recordcount
	
		if isN(num) then 
			num = 0
		else
			if clng(num)>clng(typecount)-1 then
				AlertUrl "生成全部内容页完成","admin_makehtml.asp"	
				exit sub
			end if
		end if
		rs.movefirst
		if (num > 0) and (clng(num) < Rs.recordcount) then 
			rs.move(clng(num))
		end if
		
		typeId = Rs("t_id")
		makeviewbytype typeId
	end if
 	Database.C(rs)
end sub


sub makeviewbyid(ByVal viewId)
	Dim viewLink,playLink
	
	Dim rs : Set rs = Database.GetRecordDetail("tbl_datas","D_ID=" & viewId)  
	if rs.eof then
		WriteFlush "找不到此ID : "&viewId&"的影片!"
		exit sub
	end if
	currenttypeid =  rs("d_type")
	
	viewLink = getViewLink(currenttypeid,viewId)
	if app_installdir <> "/" then
		viewLink = replace(viewLink,app_installdir,"../")
	else
		viewLink = ".." &  viewLink
	end if
	
	Dim viewFilepath : viewFilepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/view.html"
	Dim playFilepath : playFilepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/play.html"
	
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",viewFilepath)
	TemplateOBJ.replaceLabel()
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:id]",rs("d_id"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typeid]",rs("d_type"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:name]",getData(rs("d_name")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:colorname]",getColorName(getData(rs("d_name")),getData(rs("d_color"))))
	
	Dim d_pic
	d_pic = getData(rs("d_pic"))
	if inStr(d_pic,"http://") <=0 then d_pic = app_installdir&getData(rs("d_pic"))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:pic]",d_pic)
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:starring]",getData(rs("d_starring")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:directed]",getData(rs("d_directed")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:hit]",rs("d_hits"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:des]",getData(rs("D_Content")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:time]",getData(rs("d_AddTime")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:level]",rs("D_Level"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:state]",getData(rs("D_state")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:year]",getData(rs("D_year")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:source1]",getData(rs("D_Source1")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:source2]",getData(rs("D_Source2")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:stint]",getData(rs("D_Stint")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:playurl1]",getPlayUrlList(1,getData(rs("D_PlayUrl1")),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:playurl2]",getPlayUrlList(2,getData(rs("D_PlayUrl2")),rs("d_id")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:link]",getViewLink(rs("d_type"),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typelink]",getTypeLink(rs("d_type")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typename]",getDicName("tbl_type","t_name","t_id",rs("d_type")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:language]",getDicName("Tbl_Language","l_name","l_id",rs("D_Language")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:area]",getDicName("Tbl_Area","a_name","a_id",rs("D_Area")))
	
	TemplateOBJ.replaceComment(viewId)
	
	FSOOBJ.createhtml viewLink,TemplateOBJ.html
	WriteFlush getData(rs("d_name")) & " 生成完毕 <a target='_blank' href='"&viewLink&"'>"&viewLink&"&nbsp;&nbsp;<font color=red>浏览</font></a><br>" 	
	
	if app_makeplay <> 0 then
	playLink = getPlayLink(currenttypeid,viewId)
	if app_installdir <> "/" then
		playLink = replace(playLink,app_installdir,"../")
	else
		playLink = ".." &  playLink
	end if


	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",playFilepath)
	TemplateOBJ.replaceLabel()
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:id]",rs("d_id"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typeid]",rs("d_type"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:name]",getData(rs("d_name")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:colorname]",getColorName(getData(rs("d_name")),getData(rs("d_color"))))
	
	d_pic = getData(rs("d_pic"))
	if inStr(d_pic,"http://") <=0 then d_pic = app_installdir&getData(rs("d_pic"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:pic]",d_pic)
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:starring]",getData(rs("d_starring")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:directed]",getData(rs("d_directed")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:hit]",rs("d_hits"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:des]",getData(rs("D_Content")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:time]",getData(rs("d_AddTime")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:level]",rs("D_Level"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:state]",getData(rs("D_state")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:year]",getData(rs("D_year")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:source1]",getData(rs("D_Source1")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:source2]",getData(rs("D_Source2")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:stint]",getData(rs("D_Stint")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:num]","")
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:info]",getPlayInfo(getData(rs("D_Source1")),getData(rs("D_PlayUrl1")),getData(rs("D_PlayUrl2")),getData(rs("D_Source2"))))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:player]",getPlayer())
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:playurl1]",getPlayUrlList(1,getData(rs("D_PlayUrl1")),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:playurl2]",getPlayUrlList(2,getData(rs("D_PlayUrl2")),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:link]",getViewLink(rs("d_type"),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typelink]",getTypeLink(rs("d_type")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typename]",getDicName("tbl_type","t_name","t_id",rs("d_type")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:language]",getDicName("Tbl_Language","l_name","l_id",rs("D_Language")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:area]",getDicName("Tbl_Area","a_name","a_id",rs("D_Area")))
	
	FSOOBJ.createhtml playLink,TemplateOBJ.html
	end if
end sub

sub maketopic
	dim topic : topic=  SafeData("R","D_Topic",0)
	if isN(topic) or topic =0  then ErrMsg "系统提示","请选择专题..."
	makeTopicById topic
	makeTopicIndex
end sub

sub maketopicall
	dim typecount,topicId,num
	num = 	SafeData("RQ","num",0)
	
	dim Rs : set Rs= Database.GetRecordBySQL("SELECT T_ID FROM Tbl_Topic")
	if not Rs.eof then
		typecount = Rs.recordcount
	
		if isN(num) then 
			num = 0
		else
			if clng(num)>clng(typecount)-1 then
				AlertUrl "生成所有专题全部搞定","admin_makehtml.asp"	
				exit sub
			end if
		end if
		rs.movefirst
		if (num > 0) and (clng(num) < Rs.recordcount) then 
			rs.move(clng(num))
		end if
		
		topicId = Rs("t_id")
		makeTopicById topicId
		WriteFlush "<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNexttype();"","&app_makeinterval&"000);function makeNexttype(){location.href='?action=topicall&num="&num + 1&"';}</script>"
	end if
 	Database.C(rs)
	makeTopicIndex
end sub


sub makeTopicById(ByVal topicId)
	dim sql,rs
	dim T_Name,T_EnName,T_template
	
	sql = "select T_ID,T_Name,T_EnName,T_template from Tbl_Topic where T_ID = "&topicId
	
	set rs = Database.GetRecordBySQL(sql)
	if rs.recordcount=0 then WriteFlush "<font color='red'>ID为 "&topicId&" 的专题不存在</font><br>" : Exit Sub
	currentTopicId = topicId
	T_Name = getData(rs("T_Name"))
	T_EnName = getData(rs("T_EnName"))
	T_template = getData(rs("T_template"))
	
	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/" & getData(rs("T_template"))
		
		CacheOBJ.clscache()
		TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
		TemplateOBJ.replaceLabel()
		TemplateOBJ.html = replace(TemplateOBJ.html,"{topic:name}",getData(rs("t_name")))
		
	FSOOBJ.createhtml "../"&app_topicpath&"/"&T_EnName&"."&app_htmlSuffix,TemplateOBJ.html
	WriteFlush "专题<font color='red'>"&T_Name&"</font>生成完毕 <a target='_blank' href='"&app_installdir&app_topicpath&"/"&T_EnName&"."&app_htmlSuffix&"'><font color=red>浏览此专题页</font></a><br>" 
		
	Database.C(rs)
end sub

sub makeTopicIndex
	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/topic.html"
	CacheOBJ.clscache()
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
	TemplateOBJ.replaceLabel()
	FSOOBJ.createhtml "../"&app_topicpath&"/index."&app_htmlSuffix,TemplateOBJ.html
	WriteFlush "专题首页生成完毕 <a target='_blank' href='"&app_installdir&app_topicpath&"/index."&app_htmlSuffix&"'><font color=red>浏览专题首页</font></a><br>"
	
end sub

sub makenow
	dim sql,whereStr,page,rs,i
	page =  SafeData("RQ","page",0)
	sql = "select d_id,d_name,d_type from tbl_datas where 1=1 "
	whereStr = " and year(D_AddTime)="&Year(date)&" and month(D_AddTime)="&month(date)&" and day(D_AddTime)="&day(date)
	set rs = Database.GetRecordBySQL(sql & whereStr)
	if rs.recordcount=0 then WriteFlush "<br><font color='red'>当天没有更新数据</font><br>":Exit Sub
	rs.pagesize=100
	if isN(page) then page=1 else page=clng(page)
	if page>rs.pagecount then page=rs.pagecount
	rs.absolutepage= page 
	WriteFlush "正在开始生成当天影片,当前是第<font color='red'>"&page&"</font>页,共<font color='red'>"&rs.pagecount&"</font>页<br>"
	for i=0 to rs.pagesize
		makeviewbyid(rs(0))
		rs.movenext
		if rs.eof  then
			WriteFlush "生成当天影片搞定"
			Exit Sub	
		end if
	next
	WriteFlush "<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNextPage();"","&app_makeinterval&"000);function makeNextPage(){location.href='?action=now&page="&page+1&"';}</script>"
	
end sub


Sub makeBaidu
	dim flag : flag = SafeData("RQ","flag",0)
	if isN(flag) then flag = 0 else flag = clng(flag)
	dim makenum : makenum = SafeData("RQ","makenum",0)
	if flag<>1 then
		writeflush "<br><div><b>生成baidu地图</b>： 总输出数量<input type='text' id='allmakenum' value='500'>每页数量<input type='text' id='makenum' value='100'> <input type='button' class='btn' value='开始生成' onclick=""javascript:location.href='?action=baidu&flag=1&allmakenum='+$('allmakenum').value+'&makenum='+$('makenum').value"" /></div>"
	else
		if isN(makenum) then makenum=100 else makenum=clng(makenum)
		allmakenum = SafeData("RQ","allmakenum",0) : if isN(allmakenum) then allmakenum=500 else allmakenum=clng(allmakenum)
		dim i,j,rs,baiduStr,allmakenum,pagenum,xmlUrl,sql
		dim D_ID,D_name,D_type,D_Pic,D_Starring,D_Content,D_AddTime,viewLink
		
		sql = "select top "&allmakenum&" D_id,D_name,D_pic,D_Starring,D_Content,D_AddTime,D_type from Tbl_Datas order by d_addtime desc"
		set rs = Database.GetRecordBySQL(sql)
		
		rs.pagesize=makenum
		pagenum=rs.pagecount
		for i=1 to pagenum
			rs.absolutepage=i
			baiduStr =  "<?xml version=""1.0"" encoding=""GBK"" ?>"&vbcrlf&_
							"<document>"&vbcrlf&_
							"<webSite>http://"&app_siteurl&"</webSite>"&vbcrlf&_
							"<webMaster>"&app_sitename&"</webMaster>"&vbcrlf&_
							"<updatePeri>1800</updatePeri>"&vbcrlf
			for j=1 to rs.pagesize
				D_ID = rs("D_id")
				D_name = getData(rs("D_name"))
				D_type = rs("D_type")
				D_Pic = getData(rs("D_Pic"))
				D_Starring = getData(rs("D_Starring"))
				D_Content = getData(rs("D_Content"))
				D_AddTime = getData(rs("D_AddTime"))
				viewLink = "http://"& app_siteurl & getViewLink(D_type,D_ID)
				
				
				baiduStr = baiduStr & "<item>"&vbcrlf&_
									  "<title>"&server.htmlencode(D_name)&"</title>"&vbcrlf&_
									  "<link>"&viewLink&"</link>"&vbcrlf&_  
									  "<text>"&server.htmlencode(left(D_Content, 300))&"</text>"&vbcrlf
				If left(D_Pic, 7) = "http://"  Then
					baiduStr = baiduStr & "<image>"&D_Pic&"</image>"&vbcrlf
				Else
					baiduStr = baiduStr & "<image>http://"&app_siteurl&app_installdir&D_Pic&"</image>"&vbcrlf
				End If
				baiduStr = baiduStr & "<keywords>"&D_name&","&D_Starring&"</keywords>"&vbcrlf&_
									  "<author>"&app_sitename&"</author>"&vbcrlf&_
									  "<source>"&app_sitename&"</source>"&vbcrlf&_
									  "<pubDate>"&split(D_AddTime," ")(0)&"</pubDate>"&vbcrlf&_
									  "</item>"&vbcrlf
				rs.movenext
				if rs.eof then exit for
			next
			baiduStr = baiduStr + "</document>"&vbcrlf
			if i=1 then xmlUrl="" else xmlUrl="_"&i
			FSOOBJ.createhtml "../baidu"&xmlUrl&".xml",baiduStr
			writeflush "http://"&app_siteurl&app_installdir&"baidu"&xmlUrl&".xml"&" 生成完毕 <a target='_blank' href='../baidu"&xmlUrl&".xml'><font color=red>浏览</font></a><br>"
		next
		Database.c(rs)
		writeflush "生成完毕"
		writeflush  "请通过<a href='http://news.baidu.com/newsop.html' target='_blank'>http://news.baidu.com/newsop.html</a>提交!"
	end if	
End Sub

Sub makeGoogle
	dim flag : flag = SafeData("RQ","flag",0)
	if isN(flag) then flag = 0 else flag = clng(flag)
	dim makenum : makenum = SafeData("RQ","makenum",0)
	if flag<>1 then
		writeflush "<div><b>生成google地图</b>： 总输出数量<input type='text' id='allmakenum' value='500'>每页数量<input type='text' id='makenum' value='100'> <input type='button' class='btn' value='开始生成' onclick=""javascript:location.href='?action=google&flag=1&allmakenum='+$('allmakenum').value+'&makenum='+$('makenum').value""/></div>"
	else
		if isN(makenum) then makenum=100 else makenum=clng(makenum)
		allmakenum = SafeData("RQ","allmakenum",0) : if isN(allmakenum) then allmakenum=500 else allmakenum=clng(allmakenum)
		dim i,j,rs,googleStr,allmakenum,pagenum,xmlUrl,googleDateArray,googleDate,sql
		dim D_ID,D_name,D_type,D_Pic,D_Starring,D_Content,D_AddTime,viewLink
		
		sql = "select top "&allmakenum&" D_id,D_name,D_pic,D_Starring,D_Content,D_AddTime,D_type from Tbl_Datas order by d_addtime desc"

		set rs = Database.GetRecordBySQL(sql)
		rs.pagesize=makenum
		pagenum=rs.pagecount
		
		for i=1 to pagenum
		
				D_ID = rs("D_id")
				D_type = rs("D_type")
				D_AddTime = getData(rs("D_AddTime"))
				viewLink = "http://"& app_siteurl & getViewLink(D_type,D_ID)

			rs.absolutepage=i
			googleStr =  "<?xml version=""1.0"" encoding=""UTF-8""?>"&vbcrlf&_
							"<urlset xmlns=""http://www.google.com/schemas/sitemap/0.84"">"&vbcrlf&_
							"<url>"&vbcrlf&_
							"<loc>http://"&app_siteurl&"</loc>"&vbcrlf&_
							"</url>"&vbcrlf
		
			for j=1 to rs.pagesize
					googleDateArray=split(split(D_AddTime," ")(0),"-")
					googleDate=transTimeFormat(4,googleDateArray(0))&"-"&transTimeFormat(2,googleDateArray(1))&"-"&transTimeFormat(2,googleDateArray(2))
					googleStr = googleStr & "<url>"&vbcrlf&_
										  "<loc>"&viewLink&"</loc>"&vbcrlf&_
										  "<lastmod>"&googleDate&"</lastmod>"&vbcrlf&_
										  "</url>"&vbcrlf
					rs.movenext
					if rs.eof then exit for
			next
			googleStr = googleStr + "</urlset>"&vbcrlf
			if i=1 then xmlUrl="" else xmlUrl="_"&i
			FSOOBJ.createhtml "../google"&xmlUrl&".xml",googleStr	
			writeflush "http://"&app_siteurl&app_installdir&"google"&xmlUrl&".xml"&" 生成完毕 <a target='_blank' href='../google"&xmlUrl&".xml'><font color=red>浏览</font></a><br>"
		next
		Database.c(rs)
		writeflush "生成完毕"
		writeflush  "请通过<a href='http://www.google.com/webmasters/tools/' target='_blank'>http://www.google.com/webmasters/tools/</a>提交!"
	end if	
End Sub

Sub makeRss
	dim flag : flag = SafeData("RQ","flag",0)
	if isN(flag) then flag = 0 else flag = clng(flag)
	dim makenum : makenum = SafeData("RQ","makenum",0)
	if flag<>1 then
		writeflush "<div><b>生成RSS地图</b>： 输出数量<input type='text' id='makenum' value='100'> <input type='button' class='btn' value='开始生成' onclick=""javascript:location.href='?action=rss&flag=1&makenum='+$('makenum').value"" /></div>"
	else
		if isN(makenum) then makenum=100 else makenum=clng(makenum)
		dim vDes,i,rs,rssStr,sql,j
		dim D_ID,D_name,D_type,D_Pic,D_Starring,D_Content,D_AddTime,viewLink
		
		 sql = "select top "&makenum&" D_id,D_name,D_pic,D_Starring,D_Content,D_AddTime,D_type from Tbl_Datas order by d_addtime desc"
		set rs = Database.GetRecordBySQL(sql)
		
		rssStr =  "<?xml version=""1.0"" encoding=""GBK"" ?>"&vbcrlf&_
						"<rss version='2.0'>"&vbcrlf&_
						"<channel>"&vbcrlf&_
						"<title><![CDATA["&app_sitename&"]]></title>"&vbcrlf&_
						"<description><![CDATA["&app_sitename&"]]></description>"&vbcrlf&_
						"<link>http://"&app_siteurl&"</link>"&vbcrlf&_
						"<language>zh-cn</language>"&vbcrlf&_
						"<docs>"&app_sitename&"</docs>"&vbcrlf&_
						"<generator>Rss Powered By "&app_siteurl&"</generator>"&vbcrlf&_
						"<image>"&vbcrlf&_
							"<url>http://"&app_siteurl&"/images/logo.gif</url>"&vbcrlf&_
						"</image>"&vbcrlf
		for j=1 to rs.pagesize
				D_ID = rs("D_id")
				D_name = getData(rs("D_name"))
				D_type = rs("D_type")
				D_Pic = getData(rs("D_Pic"))
				D_Starring = getData(rs("D_Starring"))
				D_Content = getData(rs("D_Content"))
				D_AddTime = getData(rs("D_AddTime"))
				viewLink = "http://"& app_siteurl & getViewLink(D_type,D_ID)
				
			rssStr = rssStr & "<item>"&vbcrlf&_
								"<title><![CDATA["&D_name&"]]></title>"&vbcrlf&_
								"<link>"&viewLink&"</link>"&vbcrlf&_
								"<author>"&D_Starring&"</author>"&vbcrlf&_
								"<pubDate>"&D_AddTime&"</pubDate>"&vbcrlf&_
								"<description><![CDATA["&server.htmlencode(left(D_Content, 300))&"]]></description>"&vbcrlf&_		
							   "</item>"&vbcrlf
		next
		rssStr = rssStr & "</channel></rss>"
		FSOOBJ.createhtml "../rss.xml",rssStr
		writeflush "http://"&app_siteurl&app_installdir&"rss.xml <a target='_blank' href='../rss.xml'><font color=red>浏览</font></a><br>"
	end if	
End Sub

Function transTimeFormat(Byval plen,Byval str)
	dim vlen,i,vstr:vstr=str:vlen=len(str)
	for i=1 to (plen-vlen)
		vstr="0"&vstr
	next
	transTimeFormat=vstr
End Function

Sub makearticle
	dim sql,whereStr,page,rs,i
	page =  SafeData("RQ","page",0)
	sql = "select A_ID,A_Title,A_Content,A_Author,A_Color,A_AddTime,A_Hits from Tbl_Article"
	set rs = Database.GetRecordBySQL(sql & whereStr)
	if rs.recordcount=0 then WriteFlush "<br><font color='red'>没有数据</font><br>" :Exit Sub
	rs.pagesize=100
	if isN(page) then page=1 else page=clng(page)
	if page>rs.pagecount then page=rs.pagecount
	rs.absolutepage= page 
	WriteFlush "正在开始生成文章,当前是第<font color='red'>"&page&"</font>页,共<font color='red'>"&rs.pagecount&"</font>页<br>"
	for i=0 to rs.pagesize
		makearticlebyid(rs(0))
		rs.movenext
		if rs.eof  then
			WriteFlush "生成文章完毕"
			Exit Sub	
		end if
	next
	WriteFlush "<br>暂停"&app_makeinterval&"秒后继续生成<script language=""javascript"">setTimeout(""makeNextPage();"","&app_makeinterval&"000);function makeNextPage(){location.href='?action=article&page="&page&"';}</script>"
end Sub


Sub makearticlebyid(ByVal articleId)
	Dim articleLink
	Dim rs : Set rs = Database.GetRecordDetail("Tbl_Article","a_ID=" & articleId)  
	if rs.eof then
		WriteFlush "找不到此ID : "&articleId&"的文章!"
		exit sub
	end if
	
	articleLink = getArticleLink(articleId)
	if app_installdir <> "/" then 
		articleLink = replace(articleLink,app_installdir,"../")
	else
		articleLink= ".." &articleLink
	end if
	
	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/article.html"
	CacheOBJ.clscache()
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
	TemplateOBJ.replaceLabel()
	TemplateOBJ.html = replace(TemplateOBJ.html,"[atricleinfo:id]",rs("A_ID"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[atricleinfo:name]",rs("A_Title"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[atricleinfo:author]",rs("A_author"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[atricleinfo:hit]",getData(rs("A_Hits")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[atricleinfo:des]",getData(rs("A_Content")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[atricleinfo:time]",getData(rs("A_AddTime")))
	
	FSOOBJ.createhtml articleLink,TemplateOBJ.html
	WriteFlush getData(rs("a_title")) & " 生成完毕 <a target='_blank' href='"&articleLink&"'>"&articleLink&"&nbsp;&nbsp;<font color=red>浏览</font></a><br>" 	
	
end Sub

sub main
%>
<TABLE class="tbtitle" cellSpacing="1" cellPadding="5" width="96%" align="center" border="0" style="BACKGROUND: #cad9ea;">
    <TR bgcolor="#f5fafe">
      <TD colSpan=3>生成选项</TD>
    </TR>
	<form name="formtype" action="admin_makehtml.asp?action=type" method="post">
    <TR bgcolor="#FFFFFF">
      <TD width="20%" height="32" align="right">生成栏目：</TD>
      <TD colspan="2">
      &nbsp; <%= Getshowselect("Tbl_Type","T_Name","D_Type","请选择栏目","","T_ID","T_Sort")%>
      <input type="submit" name="Submit" value="生成栏目" class=inputbut>
      <input type="submit" name="Submit" value="生成全部栏目" class=inputbut onClick="javascript:document.formtype.action='?action=typeall';formtype.submit();">
      </TD>
    </TR>
	</form>
	
    <form name="viewform" action="admin_makehtml.asp?action=view" method="post">
    <TR bgcolor="#FFFFFF">
      <TD width="20%" height="32" align="right">生成内容：</TD>
      <TD colspan="2">
      &nbsp; <%= Getshowselect("Tbl_Type","T_Name","D_Type","请选择栏目","","T_ID","T_Sort")%>
      <input type="submit" name="Submit" value="生成内容" class=inputbut>
      <input type="submit" name="Submit" value="生成全部内容" class=inputbut onClick="javascript:document.viewform.action='?action=viewall&action2=viewall';viewform.submit();">
      </TD>
    </TR>
	</form>
    
    <form name="topicform" action="admin_makehtml.asp?action=topic" method="post">
    <TR bgcolor="#FFFFFF">
      <TD width="20%" height="32" align="right">生成专题：</TD>
      <TD colspan="2">
      &nbsp; <%= Getshowselect("Tbl_Topic","T_Name","D_Topic","请选择专题","","T_ID","T_Sort")%>
      <input type="submit" name="Submit" value="生成专题" class=inputbut>
      <input type="submit" name="Submit" value="生成全部专题" class=inputbut onClick="javascript:document.topicform.action='?action=topicall';topicform.submit();">
      </TD>
    </TR>
	</form>
    
	<form name="articleform" action="admin_makehtml.asp?action=article" method="post">
    <TR bgcolor="#FFFFFF">
      <TD width="20%" height="32" align="right">生成文章：</TD>
      <TD colspan="2">
      <input type="submit" name="Submit" value="生成全部文章" class=inputbut>
      </TD>
    </TR>
	</form>
	
</TABLE>



<%
end sub
%>

</BODY>
</HTML>