<!--#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"-->
<%
'**************************************
'* 最后更新 2012-05-20 by 56770.kingdge
'* copyright www.56770.com
'**************************************
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_item/item_news_fn.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")
if not isnumeric(html_type) or isempty(html_type) then html_type = "0"
stoptime=request("stoptime")
if not isnumeric(stoptime) then stoptime=3
startid=request("startid")
if not isnumeric(startid) or isempty(startid) then startid=0
endid=request("endid")
if not isnumeric(endid) or isempty(endid) then endid=0
html_id=request("html_id")
if not isnumeric(html_id) or isempty(html_id) then html_id = "0"
resave=request("resave")
if not isnumeric(resave) or isempty(resave) then resave=0
write_lebi_eshop("<div id=""table_sort"">")
write_lebi_eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">")
write_lebi_eshop("<tr><td colspan=""2"" id=""categoryname""></td></tr>")
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></table></div>")
dim body_news_list,skin_news_list
set fs=server.createobject("scripting.filesystemobject")
if fs.folderexists(server.mappath("../../../"& LangPath & folder(1)&""))=false then
        fs.createfolder(server.mappath("../../../"& LangPath & folder(1)&""))
end if
if fs.folderexists(server.mappath("../../../"& LangPath & folder(1)&"info/"))=false then
        fs.createfolder(server.mappath("../../../"& LangPath & folder(1)&"info/"))
end if
rem 取得数据库中最大的一条id
sql="select top 1 id from [lebi_news] where 1=1"
if html_type="1" then sql=sql&" and html=0"
sql=sql &" order by id desc"
set rs = conn.execute(sql)
if rs.eof then
        lastnum = 0
else
        lastnum = rs(0)
end if
rs.close:set rs=nothing
rem 取得数据库中最大的一条id
sql="select top 1 id from [lebi_news] where 1=1"
if html_type="1" then sql=sql&" and html=0"
if startid<>0 and endid<>0 then sql=sql&" and id>="&startid&" and id <="&endid&""
sql=sql &" order by id desc"
set rs = conn.execute(sql)
if rs.eof then
        thislastnum = 0
else
        thislastnum = rs(0)
end if
rs.close:set rs=nothing
if lastnum = 0 then
        write_lebi_eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td class=classtd>·没有数据可供生成！</td></tr></table>")
		write_lebi_eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
		response.end
end if
s_text=loadfile("../../text/lebi_news"& LangTxt &".text")
sitename = trim(split(s_text,"$$$")(0))
description = "" ' 为了获得更好效果，不设置描述和关键词 trim(split(s_text,"$$$")(2))
keywords = "" 'trim(split(s_text,"$$$")(3))
skin_body = LoadFile("../../../skins/"& template &"/template/news_detail.htm")
set rs_list=server.createobject("adodb.recordset")
sql="select * from [lebi_news] where 1=1"
if html_type="1" then sql=sql&" and html=0"
if html_id<>"0" then sql=sql&" and id = "& html_id &""
if startid<>0 and endid<>0 then sql=sql&" and id>="&startid&" and id <="&endid&""
'sql = sql &" and id = 44"
sql=sql &" order by id asc"
rs_list.open sql,conn,1,3
savepage = 1
do while not rs_list.eof
        showpath = "<a href='"& eshop_url & url_1 &"'>"& lebi_word(0) &"</a> → <a href='"& eshop_url & url_7 &"'>"& lebi_word(18) &"</a>"
		conn.execute("update [lebi_news] set html = 1 where id = "& rs_list("id") &"")
        id=rs_list("id")
	    rem ----------------------------------------------------------------------------
		html_pageline = Config_Lebi_Eshop(20)
		html_plinenum = split(rs_list("content"),"<p>")
		html_blinenum = split(rs_list("content"),"<br />")
		html_pallline = ubound(html_plinenum)+1
		html_ballline = ubound(html_blinenum)+1
		If html_pallline > html_ballline Then
				html_allline=html_pallline
		Else
				html_allline=html_ballline
		End If
		html_pagecount = int(html_allline\html_pageline)+1 '计算总页数
		for page = 1 to html_pagecount
		%><!--#include file="../../../include/lebi_item/item_news_list.asp"--><%
				If Rs_list("n_skin") <> "" And Not IsNull(Rs_list("n_skin")) Then
						skin_body = LoadStyle(Eshop_url & Style_folder &"news/list/"& Rs_list("n_skin"))
				End If
				If page = 1 Then
						HtmlName = "../../../"& LangPath & folder(1) & "info/"& rs_list("n_filename") &"."& Sys_Ext
				Else
						HtmlName = "../../../"& LangPath & folder(1) & "info/"& rs_list("n_filename") &"."& page &"."& Sys_Ext
				End If
				savehtml HtmlName,html_splits(skin_body)
		Next
		body_news_list = ""
		write_lebi_eshop("<script>bar_img.width=" & fix((savepage/rs_list.recordcount) * 300) & ";")
		write_lebi_eshop("bar_txt1.innerHTML=""当前页数 " & savepage & " ，完成 " & formatnumber2(savepage/rs_list.recordcount*100) & """;")
		write_lebi_eshop("bar_img.title=""成功生成页数 (" & savepage & ") "";</script>")
		response.flush
        rem -----------------------------------------------------------------------------------------
rs_list.movenext
savepage = savepage + 1
loop
rs_list.close : set rs_list = nothing
write_lebi_eshop("<script>bar_img.width=300;bar_txt2.innerHTML='';bar_txt1.innerHTML=""100"";</script>")
if html_id <> 0 then
        write_lebi_eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td class=classtd>·静态页生成完毕！</td></tr></table>")
		write_lebi_eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
end if
if clng(startid) >= clng(lastnum) then
        write_lebi_eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td class=classtd>·全部数据生成完毕！</td></tr></table>")
		write_lebi_eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
		response.end
end if
if resave = 0 and clng(id) >= clng(thislastnum) then
        write_lebi_eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td class=classtd>·开始id "& startid &" 结束id "& endid &" 静态页生成完毕！</td></tr></table>")
		write_lebi_eshop("<script>document.getElementById(""table_sort"").style.display=""none"";</script>")
else
		write_lebi_eshop("<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"" class=""classlist""><tr><td 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=""?html_type="&html_type&"&startid="&CLng(endid)+1&"&Endid="&CLng(endid)+(CLng(endid)-CLng(startid))+1&"&stoptime="&stoptime&"&resave="&resave&""";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
%>
</body>
</html>