<!--#include file = "../inc/dbconn.asp"-->
<!--#include file = "CheckLogin.asp"-->
<!--#include file = "../inc/cache.asp"-->
<!--#include file = "../inc/function.asp"-->
<% Response.Buffer = True %>
<% LOADING_ADMIN_HEAD %>
<% call dbconn %>
<%
select case gqv("do")
	case "makesite":makesite
	case "makelink":makelink
	case "makeindex":makeindex
	case "makeclass":makeclass
	case "makecity":makecity
	case "makecityweb":makecityweb
	case "makeupdat":makeupdat
	case "makehotjs":makehotjs
	case else call alertbox("没有指定任何操作!",2)
end select

sub makeclass
	dim task:task = gqv("task")
	dim id:id = gfv("id")
	if task = "ma" then
		call fileloading("select id,parent from DH654_class where id in(" & id & allchildclass(id,"DH654_Class") & ") and isout=0 order by id desc","class")
	elseif task = "mb" then
		call fileloading("select id,parent from DH654_class where parent=0 and isout=0 order by id desc","class")
	elseif task = "mc" then
		call fileloading("select id,parent from DH654_class where isout=0 order by id desc","class") '有子类才创建
	end if
end sub

sub makecity
	dim task:task = gqv("task")
	dim id:id = gfv("id")
	if task = "ma" then
		call fileloading("select id,parent from CT654_Class where id in(" & id & allchildclass(id,"CT654_Class") & ") order by id desc","city")
	elseif task = "mb" then
		call fileloading("select id,parent from CT654_Class where parent=0 order by id desc","city")
	elseif task = "mc" then
		call fileloading("select id,parent from CT654_Class","city") 
	end if
end sub

sub makesite
	dim stime:stime = gfv("stime")
	dim etime:etime = gfv("etime")
	dim classid:classid = gfv("classid")
	dim topnum:topnum = gfv("topnum")
	dim task:task = gqv("task")
	if task = "ma" then
		if stime = "" or etime = "" then
			call alertbox("日期不能为空!",2)
		end if
		call fileloading("select id from DH654_URL where #" & stime & "# < addtime and addtime < #" & etime & "# order by id desc","site")
	elseif task = "mb" then
		call fileloading("select id from DH654_URL where classid in(" & classid & allchildclass(classid,"DH654_Class") & ") order by id desc","site")
	elseif task = "mc" then
		if topnum = "" then
			call alertbox("数目不能为空!",2)
		elseif not isnumeric(topnum) then
			call alertbox("数目填写错误!",2)
		end if
		call fileloading("select top " & topnum & " id from DH654_URL order by id desc","site")
	elseif task = "md" then
		call fileloading("select id from DH654_URL order by id desc","site")
	elseif task = "me" then
		call fileloading("select id from DH654_URL where created=0 order by id desc","site")
	end if
end sub

sub makecityweb
	dim stime:stime = gfv("stime")
	dim etime:etime = gfv("etime")
	dim classid:classid = gfv("classid")
	dim topnum:topnum = gfv("topnum")
	dim task:task = gqv("task")
	if task = "ma" then
		if stime = "" or etime = "" then
			call alertbox("日期不能为空!",2)
		end if
		call fileloading("select id from CT654_URL where #" & stime & "# < addtime and addtime < #" & etime & "# order by id desc","cityweb")
	elseif task = "mb" then
		call fileloading("select id from CT654_URL where classid in(" & classid & allchildclass(classid,"CT654_Class") & ") order by id desc","cityweb")
	elseif task = "mc" then
		if topnum = "" then
			call alertbox("数目不能为空!",2)
		elseif not isnumeric(topnum) then
			call alertbox("数目填写错误!",2)
		end if
		call fileloading("select top " & topnum & " id,title from CT654_URL order by id desc","cityweb")
	elseif task = "md" then
		call fileloading("select id from CT654_URL order by id desc","cityweb")
	elseif task = "me" then
		call fileloading("select id from CT654_URL where created=0 order by id desc","cityweb")
	end if
end sub

sub makelink
	dim classid:classid = gfv("classid")
	dim task:task = gqv("task")
	if task = "ma" then
		call fileloading("select id from ZZ654_Link where classid in(" & classid & allchildclass(classid,"DH654_Class") & ") order by id desc","link")
	elseif task = "mb" then
		call fileloading("select id from ZZ654_Link order by id desc","link")
	elseif task = "mc" then
		call fileloading("select id from ZZ654_Link where created=0 order by id desc","link")
	end if
end sub

sub makeupdat
	dim task:task = gqv("task")
	dim id:id = gfv("id")
	if task = "ma" then
		call fileloading("select id from DH654_class where id in(" & id & allchildclass(id,"DH654_Class") & ") and isout=0 order by id desc","updat")
	elseif task = "mb" then
		call fileloading("select id from DH654_class where isout=0 order by id desc","updat")
	elseif task = "mc" then
		call fileloading("select id from CT654_class where id in(" & id & allchildclass(id,"CT654_Class") & ") order by id desc","updatcity")
	elseif task = "md" then
		call fileloading("select id from CT654_class order by id desc","updatcity")
	end if	
end sub
function updateUrl(id)
    dim tmprs,allurl,sql
    tmprs=conn.execute("Select count(id) from DH654_URL where classid="&id) 
	allurl=tmprs(0) 
	set tmprs=nothing 
	if isnull(allurl) then allurl=0 	
	conn.execute("update DH654_Class set URLNum="&allurl&" where id="&id)
end function
function updateCityUrl(id)
    dim tmprs,allurl,sql
    tmprs=conn.execute("Select count(id) from CT654_URL where classid="&id) 
	allurl=tmprs(0) 
	set tmprs=nothing 
	if isnull(allurl) then allurl=0 	
	conn.execute("update CT654_Class set URLNum="&allurl&" where id="&id)
end function


sub makehotjs
	dim task:task = gqv("task")
	dim id:id = gfv("id")
	if task = "ma" then
		call fileloading("select id from DH654_class where id in(" & id & allchildclass(id,"DH654_Class") & ") and isout=0 order by id desc","hotjs")
	elseif task = "mb" then
		call fileloading("select id from DH654_class where isout=0 order by id desc","hotjs")
	elseif task = "mz" then
		call fileloading("select id from DH654_class where isout=0 order by id desc","hotjs2") '有子类才创建
	end if
end sub

function fileloading(xSQL,types)
    if not Check_Popedom("H201") then call alertbox("你没有权限操作",2)
	dim rs,allcount
	set rs = server.createobject(G_654_RS) 
	rs.open xSQL,conn,1,1
	if rs.eof and rs.bof then
		rs.close:set rs = nothing
		LINE "<BR><BR><div align=""center"">系统没有找到指定数据!可能的原因如下:</div>"
		LINE "<div align=""center""><font color=""red"">①.栏目下无网址连接</font></div>"
		LINE "<div align=""center""><font color=""red"">②.系统产生未知错误</font></div>"
		LINE "<div align=""center""><font color=""red"">③.向乐府诗举报错误</font></div>"
		fileloading = false
		exit function
	else
		allcount = rs.recordcount
	end if
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
	LINE "<tr>"
	LINE "<td align=""center"" valign=""center"">"
	LINE "<table bgcolor=""#c0c0c0"" align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" class=""tbl"" id=tbl>"
	LINE "<tr>"
	LINE "<td width=""100%"" align=""center"" height=""30"" class=""tbl_head"">生成页面</td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td height=""300"" bgcolor=""#ffffff"" align=""center"" valign=""top"">"
	LINE "<table style=""background:ThreeDFace;border:2px outset;-moz-border-left-colors:ThreeDLightShadow ThreeDHighLight;-moz-border-right-colors:ThreeDDarkShadow THreeDShadow;-moz-border-top-colors:ThreeDLightShadow ThreeDHighLight;-moz-border-bottom-colors:ThreeDDarkShadow ThreeDShadow;width:600px;height:auto;margin-top:30px;"" cellspacing=""0"" cellpadding=""0"" align=""center"" border=""0""  class=""tbl"" id=tbl>"
	LINE "<tr class=""tbl_top"">"
	LINE "<td valign=""top"" >"
	LINE "<table cellspacing=""0"" cellpadding=""0"" width=""100%"" align=""center"" border=""0"" class=""tbl"" id=tbl>"
	LINE "<tr class=""tbl_top"">"
	LINE "<td style=""height:20px;vertical-align:top;text-align:left;"" class=""tbl_top"">"
	LINE "<span id=""ProgressBarTitle"" >操作正在进行...请耐心等待</span>"
	LINE "</td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td style=""text-align:center;padding-top:30px;"" class=""tbl_top"">"
	LINE "<div align=""center"">"
	LINE "<div style=""width:90%;height:20px;border:1px solid ThreeDShadow;background:window;overflow:hidden;text-align:left;padding:1px;font-size:0px;-moz-appearance:progressbar"">"
	LINE "<div id=""ProgressBar"" style=""width:1px;height:16px;position:relative;left:0px;background:HighLight;overflow:hidden;-moz-appearance:progresschunk;font-size:0px;""></div>"
	LINE "</div>"
	LINE "</div>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "<tr  class=""tbl_head"">"
	LINE "<td style=""text-align:center;padding:30px 0px 30px 0px;"">"
	LINE "<div align=""center"">"
	LINE "<div style=""width:90%;text-align:left;vertical-align:middle;font:normal;color:buttontext;"">"
	LINE "<div>需要生成静态页面数:[ " & allcount & " ]</div>"
	LINE "<div id=""StaticFileResult"">正在生成静态页面,请稍后...654上网导航为你体贴服务！</div>"
	LINE "<div id=""StaticFileViewer"" name=""StaticFileViewer""></div>"
	LINE "</div>"
	LINE "</div>"
    LINE "<input name=""historyback"" type=""button"" value=""太久了，我不要做了！"" onclick=""window.history.back();"">"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "<script>oMM=document.getElementById('StaticFileViewer');oResult=document.getElementById('StaticFileResult');oProgressBar=document.getElementById('ProgressBar');</script>"
	on error resume next
	dim stime:stime = timer()
	dim i,percentnum
	if types = "class" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			CreateClass rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next
	elseif types = "site" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			creatsitefile rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next
	elseif types = "link" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			creatlinkfile rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next
	elseif types = "updat" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			updateUrl rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next	
	elseif types = "updatcity" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			updatecityUrl rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next	
	elseif types = "hotjs" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			Creathotjs rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next			
	elseif types = "hotjs2" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			if ischildclass(rs("id"),"DH654_Class")=true then
			   Creathotjs rs("id")
			end if			
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next
	elseif types = "city" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			if rs("parent")=0 then			
			  CreateCityIndex rs("id")
			else			
			  CreateCityClass rs("id")
			end if
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then percentnum = 0
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next
	elseif types = "cityweb" then
		for i = 1 to allcount
			if not response.isclientconnected then response.end
			CreateCityWeb rs("id")
			percentnum = formatnumber(i/allcount*100,0)
			if percentnum = "" then
				percentnum = 0
			end if
			response.write("<script>oMM.innerHTML=""系统生成进度百分比:[ " & percentnum & " % ]<br>正在生成第[ " & i & " ]个静态页面!"";oProgressBar.style.width=" & percentnum & "+'%';</script>")
			response.flush
			rs.movenext
		next		
	end if
	rs.close:set rs = nothing
	fileloading = true
	dim etime:etime = timer()
	dim output:output = formatnumber((etime-stime)*1,3)
	response.write("<script>oResult.innerHTML=""成功生成静态页面数:[ " & i - 1 & " ]"";document.getElementById('ProgressBarTitle').innerHTML=""操作成功完成"";</script>")
	response.write("<p align=""center"">程序执行耗时: " & output & " 秒!</p>")
	response.write("<p align=""center""><font color=""red"">完成生成!</font></p>")
	response.end()
end function

sub makeindex
    if not Check_Popedom("H201") then call alertbox("你没有权限操作",2)
	dim stime:stime = timer()
	createindex
	dim etime:etime = timer()
	dim output:output = formatnumber((etime-stime)*1,3)
	response.write("<script>alert(""恭喜!成功生成网站首页!\n\n程序执行耗时: " & output & " 秒!"");location.href=""DH_Make.asp?do=site"";</script>")
end sub%>

<% LOADING_ADMIN_FOOT %>
