<!--#include file="sd_mdb.asp"-->
<%
if session("User")="" then
	response.write"<SCRIPT language=JavaScript>alert('您尚未登录！');"
	response.write"location.href=""sd_admin_login.asp"";</SCRIPT>"
end if
%>
<%
set sd=server.createobject("adodb.recordset")
sd.open "select * from sd_title",conn,1,3
sd_sd=sd("sd_sd")
sd.close
set sd=nothing
%>
<head>
<%Server.ScriptTimeOut=3600%>
<%
dim diy,qb,qto
if sd_sd=0 then
response.Write "<script LANGUAGE='javascript'>alert('未打开生成HTM设置！');window.location='sd_htmnto.asp';</script>"
response.end
end if

  Sub TimeDelaySeconds(DelaySeconds)  
  SecCount = 0  
  Sec2 = 0  
  While SecCount < DelaySeconds + 1  
  Sec1 = Second(Time())  
  If Sec1 <> Sec2 Then  
  Sec2 = Second(Time())  
  SecCount = SecCount + 1  
  End If  
  Wend  
  End Sub  

  TimeDelaySeconds(2)

qb=""
qto="sd_show.asp"
Function GetPage(url) 
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP") 
With Retrieval 
.Open "Get", url, False ', "", "" 
.Send 
GetPage = BytesToBstr(.ResponseBody)
End With 
Set Retrieval = Nothing 
End Function

Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText 
objstream.Close
set objstream = nothing
End Function


dim strUrl,Item_Classid,sd_id,sd_weburl,FileName,FilePath,Do_Url,Html_Temp,row,rszhai

Action=Request("Action")
if Action="ok" then  
set rszhai=conn.execute("select * from sd_web order by sd_id desc")
elseif Action="Update" then
set rszhai=conn.execute("select * from sd_web where sd_id >= "&request("Bid")&" and sd_id <= "&request("Eid")&" order by sd_id desc")
elseif Action="Uptime" then
set rszhai=conn.execute("select * from sd_web where datediff('d',sd_REGTime,now)<"&request("fd")&" order by sd_REGTime desc")
end if 
on error resume next      
		do while not rszhai.Eof
		Html_Temp="<UL>"   
		row=0
  Html_Temp   =   Html_Temp&"<LI>"   
  Item_Classid   = rszhai("sd_id")   
  FileName   =   ""&rszhai("sd_WEBurl")&".html"   
  FilePath   =   Server.MapPath("../links")&"\"&FileName   
  Html_Temp   =   Html_Temp&FilePath&"</LI>"   
  Do_Url   =   "http://"&sd_siteurl&"/"&qto&"?id="&Item_Classid 
  strUrl   =   Do_Url  
  dim objXmlHttp
set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.CreateObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2 
objAdoStream.Close()    
  Html_Temp   =   Html_Temp&"<UL>"   
  		rszhai.movenext
		row=row+1
		loop
		rszhai.close
response.write "<script language=""javascript"">"
response.write "  alert(""所有记录生成HTML完成！"")"
response.write "</script>"
Response.Write Html_Temp  
%>


<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body onLoad="MM_goToURL('self','sd_htmnto.asp');return document.MM_returnValue">