<!--#include file="conn.asp"-->
<!--#include file="../../inc/function.asp"-->
<!--#include file="_html_fun.asp"-->
<!--#include file="../../../include/Lebi_Db_cls.asp"-->
<!--#include file="../../../include/lebi_cache_cls.asp"-->
<!--#include file="../../../include/lebi_cache.asp"-->
<!--#include file="_html_lang.asp"-->
<!--#include file="../../../include/lebi_main.asp"-->
<!--#include file="../../../include/lebi_item/item_showsort_fn.asp"-->
<%
'**************************************
'* 最后更新 2012-05-20 by 56770.kingdge
'* copyright www.56770.com
'**************************************
'on error resume next
server.scripttimeout =99999
html_page="1"
eshop_url = replace(eshop_url,"/tohtml/","/")
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<style type="text/css">
body{margin-top:0px;margin-left:0px;position:absolute;background-color:#ffffff;font-size:11px;}
td{font-size:11px;}
</style>
<body>
<!--#include file="../../../include/lebi_function.asp"-->
<!--#include file="../../../include/lebi_page_cls.asp"-->
<%
admin_flag=",12.6,"
if request.cookies(cookiesname)("admin_name")="" or instr(","&request.cookies(cookiesname)("flag")&",",admin_flag)=0 then
		response.write("没有操作此功能的权限！")
		response.end
end if
if show_html <> 1 then
		response.write("请先选择静态模式(HTML)！")
		response.end
end if
rem html_type 0全部 1新数据
html_type=request("html_type")
sle_type = request("sle_type")
c_id = Replace(request("c_id")," ","")
NextC_id = request("NextC_id")
starttime = request("starttime")
startid=request("startid")
If Not IsNumeric(startid) Then startid=0
Endid=request("endid")
If Not IsNumeric(endid) Then Endid=0
stoptime=request("stoptime")
If Not IsNumeric(stoptime) Then stoptime=3
Write_Lebi_Eshop("<div id=""table_sort"">")
Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">")
Write_Lebi_Eshop("<tr><td width=""60"">分类生成：</td>")
Write_Lebi_Eshop("<td width=""300"" align=""left"">")
Write_Lebi_Eshop("<table width=""300"" border=""0"" cellspacing=""1"" cellpadding=""1"" height=""8"" bgcolor=""#B2B2A6""><tr><td bgcolor=ffffff height=""8""><img src=""../../../images/bar.gif"" width=0 height=8 id=bar_img name=bar_img align=absmiddle></td></tr></table></td>")
Write_Lebi_Eshop("<td><span id=bar_txt2 name=bar_txt2 style=""font-size:9pt;color:red;""></span><span id=bar_txt1 name=bar_txt1 style=""font-size:9pt"">0</span><span style=""font-size:9pt"">%</span></td></tr><tr><td width=""60"">分页生成：</td>")
Write_Lebi_Eshop("<td width=""300"" align=""left"">")
Write_Lebi_Eshop("<table width=""300"" border=""0"" cellspacing=""1"" cellpadding=""1"" height=""8"" bgcolor=""#B2B2A6""><tr><td bgcolor=ffffff height=""8""><img src=""../../../images/bar.gif"" width=0 height=8 id=bar_p_img name=bar_p_img align=absmiddle></td></tr></table></td>")
Write_Lebi_Eshop("<td><span id=bar_p_txt2 name=bar_p_txt2 style=""font-size:9pt;color:red;""></span><span id=bar_p_txt1 name=bar_p_txt1 style=""font-size:9pt"">0</span><span style=""font-size:9pt"">%</span></td></tr></table></div>")
Dim Body_showsort
Set fs=Server.CreateObject("Scripting.FileSystemObject")
foldeRs_category=server.mappath("../../../"& LangPath & Folder(2))
If fs.FolderExists(foldeRs_category)=False Then
        fs.CreateFolder(foldeRs_category)
End If
rem 取得数据库中最大的一条ID
Set rs = conn.execute("select top 1 c_id from [Lebi_category] order by c_id desc")
lastnum = rs(0)
rs.close:Set rs=Nothing
If CLng(startid) >= CLng(lastnum) Then
        Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td height=30 class=classtd>·全部分类生成完毕！</td></tr></table>")
		Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
		response.End
End If
skin_body = LoadFile("../../../skins/"& template &"/template/product_list.htm")
s_text=LoadFile("../../text/Lebi_Pro_List"& LangTxt &".text")
sitename = Trim(Split(s_text,"$$$")(0))
Set Rs_list=Server.CreateObject("ADODB.RecordSet")
sql="select c_id,c_name,c_skin,c_filename from [Lebi_category] where 1=1"
If c_id<>"" Then sql=sql&" and c_id in ("&c_id&")"
If html_type="1" Then sql=sql&" and c_html=0"
If c_id="" Then sql=sql&" and c_id="&NextC_id&""
Rs_list.open sql,conn,1,1
savenum = 1
If Rs_list.eof Then
        If CLng(Endid) > CLng(startid) And c_id<>"" Then
                Set rs = conn.execute("select top 1 c_id from [Lebi_category] where c_id>"& startid &" order by c_id asc")
                NextC_id = rs(0)
                rs.close : Set rs = Nothing
                Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td height=30 class=classtd>·ID没找到，<font color=red><span id=""resettime"">0</span></font> 秒后生成任务继续执行...</td></tr></table>")
		        Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
		        Write_Lebi_Eshop("<script language=""JavaScript"">Url=""?sle_type="&sle_type&"&c_id="&c_id&"&NextC_id="&NextC_id&"&startid="&startid&"&Endid="&Endid&"&stoptime="&stoptime&""";if (!Url){Url=document.referrer}function countDown(secs){document.getElementById(""resettime"").innerHTML=secs;if(--secs>0) {setTimeout(""countDown(""+secs+"")"",1000);}else {window.location.href=Url;}}countDown(1);</script>")
		Else
		        Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td height=30 class=classtd>·开始分类ID "& startid &" 结束分类ID "& Endid &"生成完毕！</td></tr></table>")
				Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
		End If
Else
        Do While Not Rs_list.eof
        sort_id = Rs_list("c_id")
		c_name = Rs_list("c_name")
        sql_i = "select id from [Lebi_product] where zhuangtai=1"
        if IsSqlDataBase ="1" then sql_i = sql_i &" and CharIndex(',"& sort_id &",',categoryid)>0"
        if IsSqlDataBase ="0" then sql_i = sql_i &" and instr(categoryid,',"& sort_id &",')>0"
		If sle_type = 1 Then sql_i = sql_i &" and Isnew=1"
		If sle_type = 2 Then sql_i = sql_i &" and views>"&Config_Lebi_Eshop(6)&""
		If sle_type = 3 Then sql_i = sql_i &" and (stj=1 or ytj=1)"
		If sle_type = 4 Then sql_i = sql_i &" and cx=1"
        sql_i = sql_i &" order by p_order desc,id desc"
        set rs_i = server.createobject("adodb.recordset")
        rs_i.open sql_i,conn,1,1
		rs_i.pagesize = top12
        If rs_i.eof Then
                pagecounts = 1
        Else
	            pagecounts = rs_i.pagecount
        End If
		If Rs_list("c_skin") <> "" And Not IsNull(Rs_list("c_skin")) Then
				skin_body = LoadStyle(Eshop_url & style_folder &"category/"& Rs_list("c_skin"))
		End If
		Write_Lebi_Eshop("<script>bar_img.width=" & Fix((savenum/Rs_list.recordcount) * 300) & ";")
		Write_Lebi_Eshop("bar_txt1.innerHTML=""" & formatnumber2(savenum/Rs_list.recordcount*100) & """;")
		Write_Lebi_Eshop("bar_img.title=""成功生成页数 (" & savenum & ") "";</script>")
		Response.Flush
        for page = 1 to pagecounts
	            rem ----------------------------------------------------------------------------
		        Write_Lebi_Eshop("<script>bar_p_img.width=" & Fix((page/pagecounts) * 300) & ";")
		        Write_Lebi_Eshop("bar_p_txt1.innerHTML=""" & formatnumber2(page/pagecounts*100) & """;")
		        Write_Lebi_Eshop("bar_p_img.title=""成功生成分页数 (" & page & ") "";</script>")
		        Response.Flush
                %><!-- #include file="../../../include/Lebi_item/item_showsort.asp"--><%
                If sle_type <> "0" Then
                        HtmlName = "../../../"& LangPath & Folder(2) & Rs_list("c_filename") &"-"& sle_type &"."& page &"."& Sys_Ext
				Else
				        HtmlName = "../../../"& LangPath & Folder(2) & Rs_list("c_filename") &"."& page &"."& Sys_Ext
				End If
				Savehtml HtmlName,html_splits(skin_body)
        		rem -----------------------------------------------------------------------------------------
        next
		Write_Lebi_Eshop("<script>bar_p_img.width=300;bar_p_txt2.innerHTML='';bar_p_txt1.innerHTML=""100"";</script>")
		If c_id <> "" Then
        		'Write_Lebi_Eshop("·"& c_name &" 静态页生成完毕！")
				Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display="""";</script>")
				Response.Flush
		Else
				If CLng(sort_id) < CLng(Endid) Then
						If CLng(sort_id) >= CLng(lastnum) Then
								Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td height=30 class=classtd>·全部分类生成完毕！</td></tr></table>")
								Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
						Else
								Set rs = conn.execute("select top 1 c_id from [Lebi_category] where c_id>"& sort_id &" order by c_id asc")
								NextC_id = rs(0)
								rs.close : Set rs = Nothing
								Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td height=30 class=classtd>·缓解服务器压力，<font color=red><span id=""resettime"">0</span></font> 秒后生成任务继续执行...</td></tr></table>")
								Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
								Write_Lebi_Eshop("<script language=""JavaScript"">Url=""?sle_type="&sle_type&"&c_id="&c_id&"&NextC_id="&NextC_id&"&startid="&startid&"&Endid="&Endid&"&stoptime="&stoptime&""";if (!Url){Url=document.referrer}function countDown(secs){document.getElementById(""resettime"").innerHTML=secs;if(--secs>0) {setTimeout(""countDown(""+secs+"")"",1000);}else {window.location.href=Url;}}countDown("&stoptime&");</script>")
						End If
				Else
						Write_Lebi_Eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td height=30 class=classtd>·开始分类ID "& startid &" 结束分类ID "& Endid &"生成完毕！</td></tr></table>")
						Write_Lebi_Eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
				End If
		End If
		Rs_list.movenext
		savenum = savenum + 1
		loop
End If
Rs_list.close:Set Rs_list=Nothing
Write_Lebi_Eshop("<script>bar_img.width=300;bar_txt2.innerHTML='';bar_txt1.innerHTML=""100"";</script>")
%>
</body>
</html>