<!--#include file="conn.asp"-->
<%
Response.Buffer = true
Server.ScriptTimeOut=999999
dim action,action2,flag,psize,makeinterval,sql,tmprunstart,slink,fpath,suffix,currentnum,currentsrc,num


action = be("get", "action")
action2 = be("all","action2")
flag = be("all", "flag")
psize = be("all", "psize")
tmprunstart = Timer()
curviewtype=2
if app_timming=0 then action="main": writeA "closed"

If flag = "art" Then
	sql = "SELECT * FROM {pre}art WHERE a_hide=0 AND a_type >0 "
Else
	sql = "SELECT *  FROM {pre}vod WHERE d_hide=0 AND d_type>0 "
End If

Select Case action
	Case "index": makeindex
	
	Case "map": makemap
	Case "googlexml": makegoogle
	Case "baiduxml": makebaidu
	Case "rssxml": makerss
	Case "otherday" : makeotherday
	
	Case "diypage": makediypage
	
	Case "type": checkViewType("type"): maketype
	Case "typeday": checkViewType("type"): maketypeday
	
	Case "viewday": checkViewType("content"): makeviewday
	Case "viewnomake": checkViewType("content"): makeviewnomake
	
	Case "topicindex": checkViewType("topic"): maketopicindex
	Case "topic": checkViewType("topic"): maketopic
	
	Case Else:   main
End Select
dispseObj()

Sub checkViewType(byval cs)
	dim viewtype,des
    If flag = "art" Then
    	makeinterval = app_artmakeinterval
    	Select Case cs
    		case "type": viewtype=app_artlistviewtype : des="分类页面"
    		case "content":viewtype=app_artcontentviewtype: des="内容页面"
    		case "topic":viewtype=app_arttopicviewtype: des="专题页面"
    	End Select
    Else
    	makeinterval = app_vodmakeinterval
    	Select Case cs
    		case "type":viewtype=app_vodlistviewtype: des="分类页面"
    		case "content":viewtype=app_vodcontentviewtype: des="内容页面"
    		case "topic":viewtype=app_vodtopicviewtype: des="专题页面"
    	End Select
    end if
    If viewtype < 2 Then writeE des & ":浏览为静态模式时才可以生成相关页面,请切换后重试": Exit Sub
End Sub

sub main

end sub

sub makeindex
	if flag="art" then
		suffix= app_artsuffix : fpath = flag&"index."&suffix: appid=20
	else
		suffix=app_vodsuffix : fpath = "index."&suffix: appid=10
	end if
	
	objTemplate.html = getFileByCache("template_index",app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/"&fpath)
	objTemplate.mark
	objTemplate.ifEx
	objTemplate.run
	slink = "../"&fpath
	objFile.createFile "../"&fpath,objTemplate.html
	writeA  "首页生成完毕 <a target='_blank' href='"&slink&"'><font color=red>浏览首页</font></a><br>"
end sub

sub makemap
	if flag="art" then
		suffix= app_artsuffix
		slink="../artmap."&suffix
		appid=21
	else
		flag="vod"
		suffix=app_vodsuffix
		slink="../map."&suffix
		appid=11
	end if
	
	objTemplate.html = getFileByCache("template_"&flag&"map",app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/"&flag&"map.html")
	objTemplate.mark
	objTemplate.ifEx
	objTemplate.run
	objFile.createFile slink,objTemplate.html
	writeA  "地图页生成完毕 <a target='_blank' href='"&slink&"'><font color=red>浏览地图页</font></a><br>"
end sub

sub makegoogle
	dim allmakenum,i,pagenum,googleStr,sql,rs,viewLink,typearr,t_name,t_enname
	allmakenum = be("all","gallmakenum")
	if isN(allmakenum) then allmakenum=100 else allmakenum = cint(allmakenum)
	sql = "SELECT TOP "& allmakenum &" d_id,d_name,d_enname,d_type,d_addtime,d_time FROM {pre}vod WHERE d_type >0 and d_hide=0 ORDER BY d_time DESC"
	
	set rs = objdb.db(sql,"rs1")
	googleStr =  "<?xml version=""1.0"" encoding=""utf-8""?><urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">"&vbcrlf
	
	for i=1 to allmakenum
		t_name= "未知"
		t_enname=""
		typearr = getValueByArray(cachevodtype, rs("d_type"))
	    if isarray(typearr) then
	    	t_name= typearr(1)
			t_enname=typearr(2)
	    end if
		viewLink = "http://"& app_siteurl & objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),t_name,t_enname)
		googleStr = googleStr & "<url><loc>"&viewLink&"</loc><lastmod>"&getDate("y-mm-dd",rs("d_time"))&"</lastmod><changefreq>hourly</changefreq><priority>1.0</priority></url>"
		rs.movenext
		if rs.eof then exit for
	next
	objdb.c(rs)
	googleStr = googleStr & "</urlset>"
	slink = "../google.xml"
	objFile.createFile slink,googleStr
	writeA "生成完毕 <a target='_blank' href='../google.xml'><font color=red>浏览谷歌XML</font></a>  请通过<a href='http://www.google.com/webmasters/tools/' target='_blank'>http://www.google.com/webmasters/tools/</a>提交!<br>"
end sub

sub makebaidu
	dim allmakenum,i,pagenum,sql,rs,baiduStr,d_name,d_pic,viewLink,typearr,t_name,t_enname
	allmakenum = be("all","ballmakenum")
	if isN(allmakenum) then allmakenum=100 else allmakenum = cint(allmakenum)
	sql = "SELECT TOP "& allmakenum &" d_id,d_name,d_enname,d_type,d_addtime,d_time FROM {pre}vod WHERE d_type >0 and d_hide=0 ORDER BY d_time DESC"
	set rs = objdb.db(sql,"rs1")
	baiduStr =  "<?xml version=""1.0"" encoding=""utf-8"" ?><urlset>"&vbcrlf
	for i=1 to allmakenum
		t_name= "未知"
		t_enname=""
		typearr = getValueByArray(cachevodtype, rs("d_type"))
	    if isarray(typearr) then
	    	t_name= typearr(1)
			t_enname=typearr(2)
	    end if
		viewLink = "http://"& app_siteurl & objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),t_name,t_enname)
		baiduStr = baiduStr & "<url><loc>"&viewLink&"</loc><lastmod>"&getDate("y-mm-dd",rs("d_time"))&"</lastmod>	<changefreq>always</changefreq><priority>1.0</priority></url>"&vbcrlf
		rs.movenext
		if rs.eof then exit for
	next
	objdb.c(rs)
	baiduStr = baiduStr & "</urlset>"&vbcrlf
	objFile.createFile "../baidu.xml",baiduStr
	writeA "生成完毕 <a target='_blank' href='../baidu.xml'><font color=red>浏览百度XML</font></a>  请通过<a href='http://news.baidu.com/newsop.html' target='_blank'>http://news.baidu.com/newsop.html</a>提交!<br>"
end sub

sub makerss
	dim allmakenum,pagenum,sql,rs,rssStr,j,viewLink,typearr,t_name,t_enname
	allmakenum = be("all","rallmakenum")
	if isN(allmakenum) then allmakenum=100 else allmakenum = cint(allmakenum)
	sql = "SELECT TOP "& allmakenum &" d_id,d_name,d_enname,d_type,d_starring,d_content,d_addtime,d_time FROM {pre}vod WHERE d_type >0 and d_hide=0 ORDER BY d_time DESC"
	
	set rs = objdb.db(sql,"rs1")
	rssStr =  "<?xml version=""1.0"" encoding=""utf-8"" ?>"&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 allmakenum
			t_name= "未知"
			t_enname=""
			typearr = getValueByArray(cachevodtype, rs("d_type"))
		    if isarray(typearr) then
		    	t_name= typearr(1)
				t_enname=typearr(2)
		    end if
			viewLink = "http://"& app_siteurl & objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),t_name,t_enname)
			rssStr = rssStr & "<item>"&vbcrlf&_
								"<title><![CDATA["&rs("d_name")&"]]></title>"&vbcrlf&_
								"<link>"&viewLink&"</link>"&vbcrlf&_
								"<author><![CDATA["&rs("d_starring")&"]]></author>"&vbcrlf&_
								"<pubDate>"&rs("d_time")&"</pubDate>"&vbcrlf&_
								"<description><![CDATA["&htmlFilter(left(rs("d_content"), 150))&"]]></description>"&vbcrlf&_
							   "</item>"&vbcrlf
			rs.movenext
			if rs.eof then exit for
	next
	objdb.c(rs)
	rssStr = rssStr & "</channel></rss>"
	objFile.createFile "../rss.xml",rssStr
	writeA "生成完毕<a target='_blank' href='../rss.xml'><font color=red>浏览Rss</font></a><br>"
end sub

sub makediypage
	dim fname : fname = be("all","fname")
	if isN(fname) then writeA "请选择自定义页面" : exit sub
	makediypagebyid fname
end sub

sub makediypagebyid(fname)
	dim tmphtml,i,num,dname,dlink,arr
	objTemplate.html = getFileByCache("label_"&fname,"../template/" & app_templatedir &"/" & app_htmldir & "/" &fname)
	objTemplate.mark()
	tmphtml = objTemplate.html
	
	objTemplate.vodpagelist()
	num = objTemplate.page_count
	
	if isNum(objTemplate.par_maxpage) then
		if num >= cint(objTemplate.par_maxpage) then
			num = cint(objTemplate.par_maxpage)
			objTemplate.page_count = clng(num)
		end if
	end if
	
	objTemplate.pageshow()
	objTemplate.ifEx()
	objTemplate.run()
	
	fname = replaceStr(fname,"label_","")
	fname = replaceStr(fname,"$$","/")
	fpath = "../" & left( fname, InStrRev(fname,"/") )
	fname = right(fname, len(fname) - InStrRev(fname,"/") )
	dlink = fpath & fname
	
	objFile.createFilePath dlink
	objFile.createFile dlink,objTemplate.html
	writeF fname & " 生成完毕 <a target='_blank' href='"&dlink&"'>"&dlink&"&nbsp;&nbsp;<font color=red>浏览</font></a><br>"
	
	arr = split(fname,".")
    if ubound(arr) >1 then dname=arr(0): suffix = arr(1) else dname=arr(0) : suffix="html"
    set arr=nothing
	
	for i=2 to num
		objTemplate.html = tmphtml
		page = i
		objTemplate.vodpagelist()
		dlink = fpath & dname & i & "." & suffix
		objTemplate.page_count = clng(num)
		objTemplate.pageshow()
		objTemplate.ifEx()
		objTemplate.run()
		objFile.createFile dlink,objTemplate.html
		writeF dname & i & "." & suffix & " 生成完毕 <a target='_blank' href='"&dlink&"'>"&dlink&"&nbsp;&nbsp;<font color=red>浏览</font></a><br>"
	next
	
end sub


sub maketype
	dim typeId
	typeId = be("all","mtype")
	if not isNum(typeId) then writeA "非法传递分类id参数" : exit sub
	maketypebyid typeId
end sub

sub maketypebyid(typeId)
    dim sql,rs,pCount,tempLabelStr,i,typeLink,typearr
	
	if flag="art" then
		typearr = getValueByArray(cachearttype,typeId)
		curarttypeid = typeId
		sql = "select  a_id from {pre}art where a_type IN ("& typearr(10) &")"
	else
		typearr = getValueByArray(cachevodtype,typeId)
		curvodtypeid = typeId
		sql = "select  d_id from {pre}vod where d_type IN ("& typearr(12) &") "
	end if
	
    objTemplate.html = getFileByCache("template_" & flag & "list_" & typeid, app_installdir & "template/" & app_templatedir & "/" & app_htmldir & "/" & typearr(7))
    
    Set rs = objdb.DB(sql, "rs1")
    If isN(psize) Then psize = objTemplate.getPageListSizeByCache(flag & "page",flag)
    If Not isNum(psize) Then psize = 10
    tempLabelStr = objTemplate.html
    rs.pagesize = psize: pCount = rs.pagecount
    If rs.recordcount = 0 Then writeF "err no data": pCount = 1
    objdb.C (rs)
    
    if action2="all" and pCount>5 then  pCount=5
    
    For i = 1 To pCount
        page = i
        if flag="art" then
        	objTemplate.loadlist "art", typearr
        else
        	objTemplate.loadlist "vod", typearr
        end if
        typeLink = objTemplate.getPageLink(i)
        If app_installdir <> "/" Then typeLink = replaceStr(typeLink, app_installdir, "../") Else typeLink = ".." & typeLink
        objFile.createFilePath typeLink
        objFile.createFile typeLink, objTemplate.html
        writeF " 第" & i & "页 <a target='_blank' href='" & typeLink & "'>" & replaceStr(typeLink, "../", "") & "&nbsp;&nbsp;<font color=red>浏览</font></a><br>"
    Next
end sub

sub makeotherday()
	makegoogle
	makebaidu
	makerss
	makeindex
	makemap
	writeA "一键生成当天数据完毕!"
end sub

sub maketypeday()
	dim ids,rs,i,fd,sql1,where
	if flag="art" then
		fd="a_type"
		sql1 = "SELECT DISTINCT a_type FROM {pre}art WHERE 1=1 "
		where = " and year(a_time)="&Year(date)&" and month(a_time)="&month(date)&" and day(a_time)="&day(date)
	else
		fd="d_type"
		sql1 = "SELECT DISTINCT d_type FROM {pre}vod WHERE 1=1 "
		where = " and year(d_time)="&Year(date)&" and month(d_time)="&month(date)&" and day(d_time)="&day(date)
	end if
	
	set rs = objdb.db(sql1 & where ,"rs1")
	for i=0 to rs.recordcount
		maketypebyid rs(fd)
		rs.movenext
		if rs.eof  then exit for
	next
	objdb.c(rs)
end sub


sub makeviewday
	dim rs,i,curpage,num,typename,typearr,where,sql1,tmprunstart,ids,rc,id,idsarr
	curpage = be("get","page") : num = 	be("get","num")
	if isN(num) then num = 0 else num = cint(num)
	
	if flag="art" then
		where = " and year(a_time)="&Year(date)&" and month(a_time)="&month(date)&" and day(a_time)="&day(date)
	else
		where = " and year(d_time)="&Year(date)&" and month(d_time)="&month(date)&" and day(d_time)="&day(date)
	end if
	sql = sql & where
	
	set rs= objdb.db(sql,"rs1")
	if isN(curpage)  then curpage=1 else curpage=cint(curpage)
	if rs.recordcount=0 then 
		writeA "err今天没有更新数据" : Exit Sub
	end if
	
	ids=","
	rc=false
	tmprunstart = timer()
	
	Do While Not rs.EOF
		if flag="art" then
			id = rs("a_type")
			typearr = getValueByArray(cachearttype,rs("a_type"))
		else
			id = rs("d_type")
			typearr = getValueByArray(cachevodtype,rs("d_type"))
		end if
		
		if instr(ids,","&id&",") <=0 then
			ids = ids & id & ","
		end if
		makeviewbyrs rs,typearr
		rs.movenext
	loop
	objdb.c(rs)
	writeA "ok恭喜今日数据搞定"
	if action2="all" then 
		idsarr = split(ids,",")
		for i=0 to ubound(idsarr)
			if not isN( idsarr(i) ) then
				maketypebyid idsarr(i)
				objtemplate.freerspage()
			end if
		next
		writeA "ok恭喜今日分类搞定"
	end if
end sub

sub makeviewnomake
	dim rs,i,curpage,num,typename,typearr,where
	curpage = be("get","page") : num = 	be("get","num")
	if isN(num) then num = 0 else num = cint(num)
	
	if flag="art" then
		where = " and (a_maketime<a_time or a_maketime is null) "
	else
		where = " and (d_maketime<d_time or d_maketime is null) "
	end if
	sql = sql & where
	
	set rs= objdb.db(sql,"rs1")
	if isN(curpage)  then curpage=1 else curpage=cint(curpage)
	if rs.recordcount=0 then 
		writeA "<font color='red'>没有更新后未生成数据</font><br>"
		objdb.c(rs)
		Exit Sub
	end if
	
	rs.pagesize= 100 :  rs.absolutepage= 1
	
	dim tmprunstart : tmprunstart = timer()
	for i=0 to rs.pagesize
		if flag="art" then typearr = getValueByArray(cachearttype,rs("a_type")) else typearr = getValueByArray(cachevodtype,rs("d_type"))
		makeviewbyrs rs,typearr
		rs.movenext
		if rs.eof  then
			writeA "<font color='red'>恭喜更新后未生成数据搞定</font>"
			Exit Sub
		end if
	next
	objdb.c(rs)
end sub

sub makeviewbyrs(rs,typearr)
	dim viewLink,strName,viewId,i,j,playlist,sql,strTypePath,strTypeName,tmpHtml,tmpHtml1,rcfrom
	dim sserver,urlfrom,urlshow,url,urlarr,urlarrlen,urlone,urlname,urlpath,d_playurl,d_playfrom,d_playserver,d_downurl,d_downfrom,d_downserver
	dim playLink,playarr1,playarr2,playarr3,downLink,downarr1,downarr2,downarr3
	strTypeName = typearr(1) : strTypePath = typearr(2)
	
	if flag="vod" then
		rcfrom=false
		curvodtypeid = rs("d_type")
		viewId = rs("d_id") : strName= rs("d_name")
		
		if app_playtype = 0 then
			viewLink = objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath)
			if app_installdir <> "/" then viewLink = replaceStr(viewLink,app_installdir,"../") else viewLink = ".." &  viewLink
			if right(viewLink,1)="/" then viewLink = viewLink & "index." & app_vodsuffix
			objTemplate.loadvod rs,typearr,"view"
			objTemplate.run
			objFile.createFilePath viewLink
			objFile.createFile viewLink,objTemplate.html
		else
			
		end if
		
		'播放页
		objTemplate.html = ""
		if app_vodplayviewtype=3 then
			objTemplate.loadvod rs,typearr,"play"
			objTemplate.html = Replace(objTemplate.html,"[playinfo:num]","")
            objTemplate.html = Replace(objTemplate.html, "[playinfo:name]","")
            objTemplate.html = Replace(objTemplate.html, "[playinfo:urlpath]","")
			objTemplate.run
			playLink = objTemplate.getVodPlayUrl(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath,1,1)
			playLink = left(playLink,instr(playLink,"?")-1)
			if app_installdir <> "/" then playLink = replaceStr(playLink,app_installdir,"../") else playLink = ".." &  playLink
			if right(playLink,1)="/" then playLink = playLink & "index." & app_vodsuffix
			
			objFile.createFilePath playLink
			objFile.createFile playLink,objTemplate.html
		elseif app_vodplayviewtype=4 then
			objTemplate.loadvod rs,typearr,"play"
			
			if instr(objTemplate.html,"from=current") >0 then
				rcfrom=true
			else
				objTemplate.playdownlist "play",rs("d_id"), rs("d_name"), rs("d_enname"), rs("d_addtime"),rs("d_type"), typearr(1), typearr(2), rs("d_playfrom"), rs("d_playserver"), rs("d_playurl")
			end if
			tmpHtml = objTemplate.html
			
			if isN(rs("d_playurl")) then d_playurl="" else d_playurl=rs("d_playurl")
			if isN(rs("d_playfrom")) then d_playfrom=""  else d_playfrom=rs("d_playfrom")
			if isN(rs("d_playserver")) then d_playserver="" else d_playserver=rs("d_playserver")
			
			playarr1 = split(d_playurl,"$$$")
			playarr2 = split(d_playfrom,"$$$")
			playarr3 = split(d_playserver,"$$$")
			
			for i=0 to ubound(playarr2)
				sserver=""
				url=""
				if ubound(playarr3) >= ubound(playarr2) then sserver =playarr3(i)
				if ubound(playarr1) >= ubound(playarr2) then url= playarr1(i)
				urlfrom = playarr2(i)
	        	urlshow = getVodXmlText("vodplay.xml","players/player", playarr2(i) , 1)
	        	cursrc = i+1
				urlarr = split(url,"#")
				if rcfrom then
					objTemplate.html = tmpHtml
					objTemplate.playdownlist "play",rs("d_id"), rs("d_name"), rs("d_enname"),rs("d_addtime"), rs("d_type"), typearr(1), typearr(2), rs("d_playfrom"), rs("d_playserver"), rs("d_playurl")
					tmpHtml1 = objTemplate.html
				else
					tmpHtml1 = tmpHtml
				end if
				for j=0 to ubound(urlarr)
					if not isN(urlarr(j)) then
						objTemplate.html = tmpHtml1
						urlone = Split(urlarr(j), "$")
						If UBound(urlone) = 1 Then
							urlname = urlone(0)
							urlpath = urlone(1)
						else
							urlname = "第" & j + 1 & "集"
							urlpath = urlone(0)
						end if
						playLink = objTemplate.getVodPlayUrl(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath,i+1,j+1)
						
						if app_playtype = 1 and i=0 and j=0 then viewLink = playLink & "?" & rs("d_id")&",1,1." & app_htmlSuffix
						if app_installdir <> "/" then playLink = replaceStr(playLink,app_installdir,"../") else playLink = ".." &  playLink
						if right(playLink,1)="/" then playLink = playLink & "index." & app_vodsuffix
						objFile.createFilePath playLink
						
						objTemplate.html = replaceStr(objTemplate.html,"[playinfo:from]",urlfrom)
						objTemplate.html = replaceStr(objTemplate.html,"[playinfo:fromshow]",urlshow)
						objTemplate.html = replaceStr(objTemplate.html,"[playinfo:num]",j+1)
						objTemplate.html = replaceStr(objTemplate.html, "[playinfo:name]",urlname)
						objTemplate.html = replaceStr(objTemplate.html, "[playinfo:urlpath]",urlpath)
						objTemplate.run
						objFile.createFile playLink,objTemplate.html
					end if
				next
			next
		elseif app_vodplayviewtype=5 then
			objTemplate.loadvod rs,typearr,"play"
			objTemplate.html = Replace(objTemplate.html,"[playinfo:num]","")
            objTemplate.html = Replace(objTemplate.html, "[playinfo:name]","")
            objTemplate.html = Replace(objTemplate.html, "[playinfo:urlpath]","")
            
            if instr(objTemplate.html,"from=current") then
				rcfrom=true
			else
				objTemplate.playdownlist "play",rs("d_id"), rs("d_name"), rs("d_enname"), rs("d_addtime"),rs("d_type"), typearr(1), typearr(2), rs("d_playfrom"), rs("d_playserver"), rs("d_playurl")
			end if
            tmpHtml = objTemplate.html
            
			if isN(rs("d_playfrom")) then d_playfrom=""  else d_playfrom=rs("d_playfrom")
			playarr2 = split(d_playfrom,"$$$")
			
			for i=0 to ubound(playarr2)
		       	cursrc = i+1
		       	urlfrom = playarr2(i)
	        	urlshow = getVodXmlText("vodplay.xml","players/player", playarr2(i) , 1)
	        	objTemplate.html = tmpHtml
	        	if rcfrom then
					objTemplate.playdownlist "play",rs("d_id"), rs("d_name"), rs("d_enname"),rs("d_addtime"), rs("d_type"), typearr(1), typearr(2), rs("d_playfrom"), rs("d_playserver"), rs("d_playurl")
				end if
				objTemplate.html = replaceStr(objTemplate.html,"[playinfo:from]",urlfrom)
				objTemplate.html = replaceStr(objTemplate.html,"[playinfo:fromshow]",urlshow)
				
				playLink = objTemplate.getVodPlayUrl(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath,i+1,1)
				playLink = left(playLink,instr(playLink,"?")-1)
				if app_installdir <> "/" then playLink = replaceStr(playLink,app_installdir,"../") else playLink = ".." &  playLink
				if right(playLink,1)="/" then playLink = playLink & "index." & app_vodsuffix
				objFile.createFilePath playLink
				
				objTemplate.run
				objFile.createFile playLink,objTemplate.html
				
			next
		end if
		set playarr1 =nothing
		set playarr2 =nothing
		set playarr3 =nothing
		
		
		'下载页
		objTemplate.html = ""
		if app_voddownviewtype=3 then
			objTemplate.loadvod rs,typearr,"down"
			objTemplate.html = Replace(objTemplate.html,"[downinfo:num]","")
            objTemplate.html = Replace(objTemplate.html, "[downinfo:name]","")
            objTemplate.html = Replace(objTemplate.html, "[downinfo:urlpath]","")
			objTemplate.run
			downLink = objTemplate.getVodDownUrl(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath,1,1)
			downLink = left(downLink,instr(downLink,"?")-1)
			if app_installdir <> "/" then downLink = replaceStr(downLink,app_installdir,"../") else downLink = ".." &  downLink
			if right(downLink,1)="/" then downLink = downLink & "index." & app_vodsuffix
			
			objFile.createFilePath downLink
			objFile.createFile downLink,objTemplate.html
		elseif app_voddownviewtype=4 then
			objTemplate.loadvod rs,typearr,"down"
			
			if instr(objTemplate.html,"from=current") >0 then
				rcfrom=true
			else
				objTemplate.playdownlist "down",rs("d_id"), rs("d_name"), rs("d_enname"), rs("d_addtime"),rs("d_type"), typearr(1), typearr(2), rs("d_downfrom"), rs("d_downserver"), rs("d_downurl")
			end if
			tmpHtml = objTemplate.html
			
			if isN(rs("d_downurl")) then d_downurl="" else d_downurl=rs("d_downurl")
			if isN(rs("d_downfrom")) then d_downfrom=""  else d_downfrom=rs("d_downfrom")
			if isN(rs("d_downserver")) then d_downserver="" else d_downserver=rs("d_downserver")
			
			downarr1 = split(d_downurl,"$$$")
			downarr2 = split(d_downfrom,"$$$")
			downarr3 = split(d_downserver,"$$$")
			
			for i=0 to ubound(downarr2)
				sserver=""
				url=""
				if ubound(downarr3) >= ubound(downarr2) then sserver =downarr3(i)
				if ubound(downarr1) >= ubound(downarr2) then url= downarr1(i)
				urlfrom = downarr2(i)
	        	urlshow = getVodXmlText("voddown.xml","downs/down", downarr2(i) , 1)
	        	cursrc = i+1
				urlarr = split(url,"#")
				if rcfrom then
					objTemplate.html = tmpHtml
					objTemplate.playdownlist "down",rs("d_id"), rs("d_name"), rs("d_enname"),rs("d_addtime"), rs("d_type"), typearr(1), typearr(2), rs("d_downfrom"), rs("d_downserver"), rs("d_downurl")
					tmpHtml1 = objTemplate.html
				else
					tmpHtml1 = tmpHtml
				end if
				for j=0 to ubound(urlarr)
					if not isN(urlarr(j)) then
						objTemplate.html = tmpHtml1
						urlone = Split(urlarr(j), "$")
						If UBound(urlone) = 1 Then
							urlname = urlone(0)
							urlpath = urlone(1)
						else
							urlname = "第" & j + 1 & "集"
							urlpath = urlone(0)
						end if
						downLink = objTemplate.getVodDownUrl(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath,i+1,j+1)
						
						if app_downtype = 1 and i=0 and j=0 then viewLink = downLink & "?" & rs("d_id")&",1,1." & app_htmlSuffix
						if app_installdir <> "/" then downLink = replaceStr(downLink,app_installdir,"../") else downLink = ".." &  downLink
						if right(downLink,1)="/" then downLink = downLink & "index." & app_vodsuffix
						objFile.createFilePath downLink
						
						objTemplate.html = replaceStr(objTemplate.html,"[downinfo:from]",urlfrom)
						objTemplate.html = replaceStr(objTemplate.html,"[downinfo:fromshow]",urlshow)
						objTemplate.html = replaceStr(objTemplate.html,"[downinfo:num]",j+1)
						objTemplate.html = replaceStr(objTemplate.html, "[downinfo:name]",urlname)
						objTemplate.html = replaceStr(objTemplate.html, "[downinfo:urlpath]",urlpath)
						objTemplate.run
						objFile.createFile downLink,objTemplate.html
					end if
				next
			next
		elseif app_voddownviewtype=5 then
			objTemplate.loadvod rs,typearr,"down"
			objTemplate.html = Replace(objTemplate.html,"[downinfo:num]","")
            objTemplate.html = Replace(objTemplate.html, "[downinfo:name]","")
            objTemplate.html = Replace(objTemplate.html, "[downinfo:urlpath]","")
            
            if instr(objTemplate.html,"from=current") then
				rcfrom=true
			else
				objTemplate.playdownlist "down",rs("d_id"), rs("d_name"), rs("d_enname"), rs("d_addtime"),rs("d_type"), typearr(1), typearr(2), rs("d_downfrom"), rs("d_downserver"), rs("d_downurl")
			end if
            tmpHtml = objTemplate.html
            
			if isN(rs("d_downfrom")) then d_downfrom=""  else d_downfrom=rs("d_downfrom")
			downarr2 = split(d_downfrom,"$$$")
			
			for i=0 to ubound(downarr2)
		       	cursrc = i+1
		       	urlfrom = downarr2(i)
	        	urlshow = getVodXmlText("voddown.xml","downs/down", downarr2(i) , 1)
	        	objTemplate.html = tmpHtml
	        	if rcfrom then
					objTemplate.playdownlist "down",rs("d_id"), rs("d_name"), rs("d_enname"),rs("d_addtime"), rs("d_type"), typearr(1), typearr(2), rs("d_downfrom"), rs("d_downserver"), rs("d_downurl")
				end if
				objTemplate.html = replaceStr(objTemplate.html,"[downinfo:from]",urlfrom)
				objTemplate.html = replaceStr(objTemplate.html,"[downinfo:fromshow]",urlshow)
				
				downLink = objTemplate.getVodDownUrl(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),strTypeName,strTypePath,i+1,1)
				downLink = left(downLink,instr(downLink,"?")-1)
				if app_installdir <> "/" then downLink = replaceStr(downLink,app_installdir,"../") else downLink = ".." &  downLink
				if right(downLink,1)="/" then downLink = downLink & "index." & app_vodsuffix
				objFile.createFilePath downLink
				
				objTemplate.run
				objFile.createFile downLink,objTemplate.html
				
			next
		end if
		
		set urlarr=nothing
		set urlone=nothing
		set downarr1 =nothing
		set downarr2 =nothing
		set downarr3 =nothing
		
		objdb.Update "{pre}vod",array("d_maketime"),array(now()),"d_id="&rs("d_id")
	else
		curarttypeid = rs("a_type")
		viewId = rs("a_id")
		strName= rs("a_title")
		urlarr = split(rs("a_content"),"[artinfo:page]")
		urlarrlen = ubound(urlarr)
		For i=0 To urlarrlen
			page = i+1
			objTemplate.set_pagetype = "art"
			objTemplate.page_typearr = typearr
			objTemplate.page_id = rs("a_id")
			objTemplate.page_name = rs("a_title")
			objTemplate.page_enname = rs("a_entitle")
			playLink = objTemplate.getPageLink(i+1)
			if app_installdir <> "/" then playLink = replaceStr(playLink,app_installdir,"../") else playLink = ".." &  playLink
			if right(playLink,1)="/" then playLink = playLink & "index." & app_artsuffix
			if i=0 then viewLink = playLink
			objTemplate.loadart rs,typearr
			objTemplate.run
			objFile.createFilePath playLink
			objFile.createFile playLink,objTemplate.html
		next
		set urlarr=nothing
		objdb.Update "{pre}art",array("a_maketime"),array(now()),"a_id="&rs("a_id")
	end if
	writeF strName & " <a target='_blank' href='"&viewLink&"'>&nbsp;&nbsp;<font color=red>浏览</font></a><br>"
end sub

sub maketopicindex
	dim topicLink,psize,sql,rs,tempLabelStr,pCount,i,t1
	if flag="art" then
		appid=22
	else
		appid=12
	end if
	t1 = app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/"&flag&"topic.html"
	objTemplate.html =  getFileByCache("template_"&flag&"topic",t1)
	tempLabelStr = objTemplate.html
	
	psize = objTemplate.getPageListSizeByCache(flag&"topicpage",flag)
	if isN(psize) then psize = 10
	sql = "select t_id from {pre}"&flag&"_topic"
	set rs = objdb.db(sql,"rs1")
	
	rs.pagesize = psize : pCount = rs.pagecount
	if rs.recordcount=0 then	writeF "<font color='red'>没有专题数据!</font><br>" : pCount =1
	objdb.c(rs)
	writeF "正在开始生成专题首页..."
	
	
	for i=1 to pCount
		page = i
		with objTemplate
			.html = tempLabelStr
			.topicpagelist()
			.mark()
			.ifEx()
			.run()
		end with
		
		topicLink = objTemplate.getPageLink(i)		
		if app_installdir <> "/" then	TopicLink = replace(TopicLink,app_installdir,"../") else	TopicLink = ".." &  TopicLink
		
		objFile.createFilePath topicLink
		objFile.createFile topicLink,objTemplate.html
		writeF " 生成完毕 <a target='_blank' href='"&TopicLink&"'>&nbsp;&nbsp;<font color=red>浏览</font></a><br>"
	next
end sub

sub maketopic
	dim topic : topic=  be("all","mtopic")
	if not isNnum(topic) then writeA "非法传递专题id参数..." : exit sub
	makeTopicById topic
end sub


sub makeTopicById(topicid)
	dim sql,rs,psize,pCount,tempLabelStr,i,typearr,topicIDS,topicLink
	
	if flag = "art" then
		curarttopicid = topicid
		typearr = getValueByArray(cachearttopic,topicid)
		sql = "select  a_id from {pre}art where a_topic = "&topicid&""
	else
		curvodtopicid = topicid
		typearr = getValueByArray(cachevodtopic,topicid)
		sql = "select  d_id from {pre}vod where d_topic = "&topicid&""
	end if
	
	psize = objTemplate.getPageListSizeByCache(flag&"page",flag)
	if isN(psize) then psize = 10
	set rs = objdb.db(sql,"rs1")
	rs.pagesize = psize : pCount = rs.pagecount
	if rs.recordcount=0 then	writeF "<font color='red'>ID为 "&topicid&" 的专题没有数据</font><br>" : pCount =1
	objdb.c(rs)
	writeF "正在开始生成专题<font color='red'>" & typearr(1) & "</font>的列表<br>"
	for i=1 to pCount
		page = i
		objTemplate.loadtopic flag,typearr
		topicLink = objTemplate.getPageLink(i)
		if app_installdir <> "/" then	topicLink = replace(topicLink,app_installdir,"../") else topicLink = ".." &  topicLink
		objFile.createFilePath topicLink
		objFile.createFile topicLink,objTemplate.html
		writeF typearr(1) & " 生成完毕 <a target='_blank' href='"&topicLink&"'>"&topicLink&"&nbsp;&nbsp;<font color=red>浏览</font></a><br>"
	next
end sub
%>