<!--#include file="sdcms_check.asp"-->
<%
set sdcms=new Sdcms_Admin
sdcms.Check_admin
sdcms.Check_lever 14
set sdcms=nothing
sdcms_head
sd_table="sd_class"
%>
<div class="sdcms_notice"><span>管理操作：</span><a href="?t=0">生成管理</a>　┊　<a href="?t=1">按分类生成</a></div>
<br>
<ul id="sdcms_sub_title">
	<li class="sub"><a href="javascript:void(0)" onClick="selectTag('tagContent0',this)">生成管理</a></li>
</ul>

<div id="sdcms_right_b">
<script></script>
<%
select case t
case "1":case_list_info
case "2":case_list
case else:case_all
end select
sub case_list_info
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="table_b" >
	<form action="?action=list_info&t=1" method="post">
   <tr >
      <td  class="tdbg"><select name="t0" size="15" multiple="multiple" id="t0" style="width:400px;">
        <%ssort(0)%>
        </select><br /><input type="radio" name="t1" value="0"  checked="checked" id="t1"/>
        <label for="t2">生成信息</label>　<input name="t1" type="radio" value="1"  id="t1"/>
<label for="t3">生成分类</label>　
<br />
        <input  type="submit"  id="c_08" class="bnt" value="生成" />　<span id="pl" style="background:#f00;border:1px solid #ccc;color:#fff;padding:4px;"></span> 
        </td>
       
    </tr>
	 </form>
  </table>
<%
end sub
sub case_all
%>
  <table border="0" align="center" cellpadding="3" cellspacing="1" class="table_b" id="tagContent0">
    <tr>
      <td width="100" class="title_bg">项目</td>
      <td class="title_bg">进度</td>
      <td width="100" class="title_bg">操作</td>
    </tr>
   <tr >
      <td align="center" class="tdbg"><span>生成首页</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;' id="progress1"><span id="pstr1">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_01" name="button" type="button"  class="bnt01" onClick="location.href='?action=index';" value="生成"></td>
    </tr>
	<tr >
      <td align="center" class="tdbg"><span>生成公告</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;' id="progress2"><span id="pstr2">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_02" name="button" type="button"  class="bnt01" onClick="if(confirm('此操作比较耗时，确认要操作？'))location.href='?action=n_list';return false;" value="生成"></td>
    </tr>
	<tr >
      <td align="center" class="tdbg"><span>生成分类</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;' id="progress3"><span id="pstr3">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_03" name="button" type="button"  class="bnt01" onClick="location.href='?action=c_list';" value="生成"></td>
    </tr>
	<tr >
      <td align="center" class="tdbg"><span>生成信息</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;height:14px;overflow:hidden;' id="progress4"><span id="pstr4">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_04" name="button" type="button"  class="bnt01" onClick="if(confirm('此操作比较耗时，确认要操作？'))location.href='?action=i_list';return false;" value="生成"></td>
    </tr>
    <tr >
      <td align="center" class="tdbg"><span>生成单页</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;' id="progress5"><span id="pstr5">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_05" name="button" type="button"  class="bnt01" onClick="location.href='?action=o_list';" value="生成"></td>
    </tr>
	<tr >
      <td align="center" class="tdbg"><span>生成地图</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;' id="progress7"><span id="pstr7">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_07" name="button" type="button"  class="bnt01" onClick="location.href='?action=map';" value="生成"></td>
    </tr>
	<tr>
      <td align="center" class="tdbg"><span>生成全站</span></td>
      <td  class="tdbg"><div style='border:1px solid #ccc;'>
<div style='width:0%;background:#f00;' id="progress8"><span id="pstr8">　</span></div></div></td>
      <td align="center" class="tdbg"><input id="c_08" name="button" type="button"  class="bnt01" onClick="if(confirm('此操作比较耗时，确认要操作？'))location.href='?action=website&t0=1';return false;"  value="生成"></td>
    </tr>
  </table>
<%
end sub

Sub list_info
echo "<script>$(""c_08"").disabled=true;</script>"
	t0=trim(request("t0"))
	t1=trim(request("t1"))
	set sdcms_c=new sdcms_create
	select case t1
		case "0","1"
		case else:t1=1
	end select
	'echo t0:died
	if t0="" then 	echo "<script>alert('至少选择一个类别');location.href='?t=1';</script>":Died
	if instr(t0,", ")>0 then
		t00=split(t0,", ")
		for i=0 to ubound(t00)
			if t1=0 then
				sql="select id from sd_info where classid="&t00(i)&""
				set rs_c=server.CreateObject("adodb.recordset")
				rs_c.open sql,conn,1,1
				while not rs_c.eof
					sdcms_c.Create_info_show rs_c(0)
					response.Flush()
					rs_c.movenext
				wend
			end if
		
			if t1=1 then
				sdcms_c.Create_class_list t00(i)
				response.Flush()
			end if
		next
	else
	    if t1=0 then
		lastid=request("lastid")
		if lastid="" or not isnumeric(lastid) then lastid=0
			sql="select top 20 id from sd_info where classid="&t0&" and id>"&lastid&" "
			set rs_c=server.CreateObject("adodb.recordset")
			rs_c.open sql,conn,1,1
			while not rs_c.eof
				sdcms_c.Create_info_show rs_c(0)
				lastid=rs_c(0)
				if showmsg then echo "<script>$(""pl"").innerHTML=""编号为："&rs_c(0)&"的信息生成成功"";</script>" & VbCrLf
				response.Flush()
				rs_c.movenext
			wend
			set rs1=conn.execute("select top 1 id from sd_info where classid="&t0&" and id>"&lastid&"")
			if not rs1.eof then
			echo "<script>$(""pl"").innerHTML=""5秒后继续生成下面的信息"";</script>" & VbCrLf
	response.Flush()
			response.Flush()
			echo "<script language=JavaScript>"
			echo "var secs = 5;var wait = secs * 1000;"
			echo "for(i = 1; i <= secs; i++){window.setTimeout(""Update("" + i + "")"", i * 1000);}"
			echo "function Update(num){if(num != secs){printnr = (wait / 1000) - num;"
			echo "$(""pl"").innerHTML=""剩余""+printnr+""秒""}}"
			echo "setTimeout(""window.location='?action=list_info&lastid="&lastid&"&t=1&t1=0&t0="&t0&"'"","&Int(5000)&");</script>"
			Response.Flush()
			end if
		end if
		if t1=1 then			
				sdcms_c.Create_class_list t0
				response.Flush()
			end if
	end if
set sdcms_c=nothing
echo "<script>$(""c_08"").value='完成';</script>"
End Sub
select case action
	case "index":make_index
	case "n_list":make_n_list
	case "c_list":make_c_list
	case "i_list":make_i_list
	case "o_list":make_o_list
	case "map":make_map
	case "list_info":list_info
	case "website":make_website
	case else
end select
 
sub make_index
	set sdcms=new sdcms_create
	echo "<script>$(""c_01"").disabled=true;</script>"
		sdcms.Create_index
		progress 100,1
	echo "<script>$(""c_01"").value='完成';</script>"
	set sdcms=nothing
end sub

sub make_n_list
	echo "<script>$(""c_02"").disabled=true;</script>"
	set sdcms_c=new sdcms_create
		sql="select id from sd_notice order by id desc"
		set rs_c=server.CreateObject("adodb.recordset")
		rs_c.open sql,conn,1,1
		i=1
		p=rs_c.recordcount+1
		while not rs_c.eof
			sdcms_c.Create_notice_show rs_c(0)
			progress Int((i/p)*100),2
			i=i+1
			response.Flush()
		rs_c.movenext
		wend
	sdcms_c.Create_n_list
	set sdcms_c=nothing
	progress 100,2
	echo "<script>$(""c_02"").value='完成';</script>"
end sub

sub make_c_list
    echo "<script>$(""c_03"").disabled=true;</script>"
	set sdcms_c=new sdcms_create
	    if clng(request("id"))<>0 then
		tj="where id="&id&" "
		end if
		sql="select id from sd_class "&tj&" order by id "
	    set rs_c=server.CreateObject("adodb.recordset")
		rs_c.open sql,conn,1,1
		i=1
		p=rs_c.recordcount+1
		while not rs_c.eof
			sdcms_c.Create_class_list rs_c(0)
			progress Int((i/p)*100),3
			i=i+1
			response.Flush()
		rs_c.movenext
		wend
	set sdcms_c=nothing
	progress 100,3
	echo "<script>$(""c_03"").value='完成';</script>"
end sub

sub make_i_list
	t0=request("t0")
	if t0="" or not isnumeric(t0) then t0=0
	if t0=1 then
	echo "<script>$(""c_01"").disabled=true;</script>"
	echo "<script>$(""c_02"").disabled=true;</script>"
	echo "<script>$(""c_03"").disabled=true;</script>"
	echo "<script>$(""c_05"").disabled=true;</script>"
	echo "<script>$(""c_06"").disabled=true;</script>"
	echo "<script>$(""c_07"").disabled=true;</script>"
	echo "<script>$(""c_08"").disabled=true;</script>"
	progress 100,1:progress 100,2:progress 100,3:progress 100,5:progress 100,6:progress 100,7:progress 75,8
	end if
    echo "<script>$(""c_04"").disabled=true;</script>"
	
	lastid=request("lastid")
	if lastid="" or not isnumeric(lastid) then lastid=0
	set sdcms_c=new sdcms_create
		conn.execute("update sd_info set iscreate=1")
	    sql="select top 20 id from sd_info where id>"&lastid&" "
	    set rs_c=server.CreateObject("adodb.recordset")
		rs_c.open sql,conn,1,1
		i=1
		p=rs_c.recordcount+1
		while not rs_c.eof
			sdcms_c.Create_info_show rs_c(0)
			progress Int((i/p)*100),4
			i=i+1
			lastid=rs_c(0)
			response.Flush()
		rs_c.movenext
		wend
	set sdcms_c=nothing
	progress 100,4
	echo "<script>$(""c_04"").value='完成';</script>"
	set rs1=conn.execute("select top 1 id from sd_info where id>"&lastid&"")
	if not rs1.eof then
	echo "<script>$(""progress4"").innerHTML=""5秒后继续生成下面的信息"";</script>" & VbCrLf
	response.Flush()
	echo "<script language=JavaScript>"
	echo "var secs = 5;var wait = secs * 1000;"
	echo "for(i = 1; i <= secs; i++){window.setTimeout(""Update("" + i + "")"", i * 1000);}"
	echo "function Update(num){if(num != secs){printnr = (wait / 1000) - num;"
	echo "$(""progress4"").style.width=(num/secs)*100+""%"";"
	echo "$(""progress4"").innerHTML=""剩余""+printnr+""秒""}}"
	echo "setTimeout(""window.location='?action=i_list&lastid="&lastid&"&t0="&t0&"'"","&Int(5000)&");</script>"
	Response.Flush()
	else
		if t0=1 then
		progress 80,8:progress 90,8:progress 100,8
		for i=1 to 8
		echo "<script>$(""c_0"&i&""").value='完成';</script>"
		next
		end if
	end if
end sub

sub make_o_list
	echo "<script>$(""c_05"").disabled=true;</script>"
	set sdcms_c=new sdcms_create
		sql="select id from sd_other order by id desc"
	    set rs_c=server.CreateObject("adodb.recordset")
		rs_c.open sql,conn,1,1
		i=1
		p=rs_c.recordcount+1
		while not rs_c.eof
			sdcms_c.Create_other rs_c(0)
			progress Int((i/p)*100),5
			i=i+1
			response.Flush()
		rs_c.movenext
		wend
	set sdcms_c=nothing
	progress 100,5
	echo "<script>$(""c_05"").value='完成';</script>"
end sub

sub make_map
	set sdcms=new sdcms_create
	echo "<script>$(""c_07"").disabled=true;</script>"
		sdcms.Create_map
		progress 100,7
	echo "<script>$(""c_07"").value='完成';</script>"
	set sdcms=nothing
end sub

Sub make_website
echo "<script>document.getElementById(""c_07"").disabled=true;</script>"
make_index
progress int((1/8)*100),8
make_n_list
progress int((2/8)*100),8
make_c_list
progress int((3/8)*100),8
make_o_list
progress int((4/8)*100),8
make_map
progress int((5/8)*100),8
make_i_list
progress int((6/8)*100),8
progress 100,8
echo "<script>document.getElementById(""c_07"").value='完成';</script>"
End Sub

dim iii
iii=0
sub ssort(t0)
with response

sql="Select id,title,ordnum,followid From ["&sd_table&"] where followid="&t0&"  order by ordnum desc"
Set rs1=Conn.Execute(sql)
do while not rs1.eof
.write("<option value='"&rs1(0)&"' ")
if id=""&rs1(0)&"" then
.write("selected")
end if
.write(">")
if t<>0 then
.write(""&string(iii,"　")&" ")
set rsn=conn.execute("select max(ordnum),min(ordnum) from "&sd_table&" where followid="&Rs1(3)&"")
if rs1(2)=rsn(0) and rs1(2)=rsn(1) then
.write("└")
elseif rs1(2)=rsn(0) and rs1(2)>rsn(1) then
.write("├")
elseif rs1(2)<rsn(0) and rs1(2)=rsn(1) then
.write("└")
elseif rs1(2)<rsn(0) and rs1(2)>rsn(1) then
.write("├")
rsn.close
end if
end if
.write("&nbsp;"&rs1(1)&"</option>")
iii=iii+1
ssort rs1(0)
iii=iii-1
rs1.Movenext
loop
Set Rs1 = Nothing
end with
end sub
closedb
%>
</div>

 
</body>
</html>