<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/BindDNS.asp"-->
<%
'120s
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
'CDN err check
If Minute(now)=1 Or Minute(now)=10 Or Minute(now)=15 Or Minute(now)=20 Or Minute(now)=25 Or Minute(now)=30 Or Minute(now)=35 Or Minute(now)=40 Or Minute(now)=45 Or Minute(now)=50 Or Minute(now)=55 then
	Set dsCDNserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerCDNlist where cdntype='多点分布CDN加速用' and (iserr=0 or iserr is null)  and backupCDNid>0"
	dsCDNserver.Open Sql,conn,1,3
While not dsCDNserver.Eof
On Error Resume Next
URL=dsCDNserver("site")
FreeHostsharekey=dsCDNserver("FreeHostsharekey")
op=0
CDNcon="-p 80 mgr:info"
CDNret=CDNOP(URL,FreeHostsharekey,CDNcon,cachemgr,mime,squid,squid_radius_auth,hosts,op)
'dsCDNserver("lastErrChecktime")=Now
'dsCDNserver.update

'If InStr(CDNret,"http/1.0")<0 Or InStr(CDNret,"失败")>0 Then
If Not InStr(LCase(CDNret),"cpu usage")>0 Then
'
FreeHost_oplog "CDN自动任务","出错信息","CDN故障检查操作返回:"&CDNret&" CDN服务器ID:"&dsCDNserver("id")&"此服务器已自动设置为离线"
'进入故障处理---------------------------------
'将状态改为err
'response.write "err....."
dsCDNserver("iserr")=true
dsCDNserver.update
'将这个CDN的IP段发给另一台服务器,然后同步DNS
Dim named,Bindserverid1,Bindserverid2
Bindserverid1=dsCDNserver("Bindserverid1")
Bindserverid2=dsCDNserver("Bindserverid2")
Set dsBindserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerBindlist where (id='"&Bindserverid1&"' or id='"&Bindserverid2&"')"
		dsBindserver.Open Sql,conn,1,1
		response.write sql
While not dsBindserver.Eof
URL=dsBindserver("site")
FreeHostsharekey=dsBindserver("FreeHostsharekey")
DoSynbindDNS
dsBindserver.movenext
Wend

'Else
'FreeHost_oplog "CDN自动任务","检查信息","CDN故障检查操作返回:"&CDNret&" CDN服务器ID:"&dsCDNserver("id")&"此服务器认为是正常状态V2"
End If



'response.write CDNret
dsCDNserver.movenext
Wend
End if

'CDN'新版本受控不再使用
'If Minute(now)=1 Or Minute(now)=13 Or Minute(now)=21 Or Minute(now)=41  Or Minute(now)=52 then
'	Set dsCDNserver = Server.CreateObject("ADODB.Recordset")	
'	Sql="Select * from FreeHost.FreeHost_ServerCDNlist where (iserr=0 or iserr is null) and (lastchangetime>lastSYNtime or lastSYNtime is null or lastchangetime is null) order by lastSYNtime ASC"
'	dsCDNserver.Open Sql,conn,1,3
'While not dsCDNserver.Eof
'server.ScriptTimeout =1200
'URL=dsCDNserver("site")
'FreeHostsharekey=dsCDNserver("FreeHostsharekey")
'Nalldomain
'op=2
'CDNcon="-k reconfigure -n squid"
'hosts=""
'squid=Replace(dsCDNserver("squidHead")&vbcrlf&"access_log "&dsCDNserver("logpath")&"access.log combined"&vbcrlf&dsCDNserver("squid"),vbcrlf&vbcrlf,vbcrlf)
'On Error Resume Next
'CDNret="更新失败"
'CDNret="  CDN操作返回:"&CDNOP(URL,FreeHostsharekey,CDNcon,cachemgr,mime,squid,squid_radius_auth,hosts,op)
'dsCDNserver("lastchangetime")=now
'dsCDNserver("lastSYNtime")=Now
'dsCDNserver.update
'If InStr(CDNret,"成功")<0 Then
'FreeHost_oplog "CDN自动任务","出错信息","CDN操作返回:"&CDNret&" CDN服务器ID:"&dsCDNserver("id")
'End if
'dsCDNserver.movenext
'Wend
'End if

nextcheckhour=10'首次检查后,10小时后才作第二次检查,不能设置为0,最少应该是1以上

if Application("autodelicp")=true and Application("beianusecode")=0 then'如果启用后台检查
if hour(now)=2 Or hour(now)=3 Or hour(now)=4 Or hour(now)=5 Or hour(now)=6 Or Request("donow")="yes" Then

If Request("donow")="yes" Then
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>运行中...............................</title>
<meta http-equiv="refresh" content="10;URL=maindo.asp?donow=yes">
</head>
<body>
正在运行.......<%=now%>....<br>10秒后本页会自动刷新
<%
Response.Flush()
End If

'开始检查所有没有备案成功的域名
Set dsICPDB = Server.CreateObject("ADODB.Recordset")
Sql="Select * from FreeHost.FreeHost_ICPDB where (status='尚未检测' or status='未提交备案' or status='已提交备案，尚未备案成功') and (checktime<'"&dateadd("h",-nextcheckhour,now)&"' or checktime is null)"
If Application("beianrecheck")>0 Then  Sql="Select * from FreeHost.FreeHost_ICPDB where ((status='尚未检测' or status='未提交备案' or status='已提交备案，尚未备案成功') and (checktime<'"&dateadd("h",-nextcheckhour,now)&"' or checktime is null)) or (status='备案成功' and (checktime<'"&dateadd("d",-Application("beianrecheck"),now)&"' or checktime is null) )"
	dsICPDB.Open sql,conn,1,3
'response.write sql
'response.end
while not dsICPDB.eof

'先查工信部数据库
Dim status
status="尚未检测"

Response.write "检查"&dsICPDB("domain")&"<br>"
response.write dsICPDB("domain")&" "&ICP_Who&" "&status&"<br>"
'response.end

If InStr(status,"出错")<1 then

dsICPDB("checktime")=Now
dsICPDB("status")=status
If ICP_SN<>"" Then dsICPDB("ICP_SN")=ICP_SN
If ICP_Who<>"" Then dsICPDB("ICP_Who")=Left(ICP_Who,25)
End if

if status="未提交备案" Then
End if

dsICPDB.update
dsICPDB.movenext
wend
dsICPDB.close



End if'限制时间
End if'完成后台务案检查

If Application("canagnrar")=true Then
'response.write "管理员允许启用本功能"
'response.end


	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AgentRaR where status='处理中'"
		ds.Open Sql,conn,1,3
if not ds.eof Then


timenow=dateadd("s",90,now)

imgrarpath=Application("agnimgpath")&"\img.rar"
imgrarpath=Replace(imgrarpath,"\\","\")

command=hour(timenow)&":"&minute(timenow)&" freehostagnrar "&ds("site1")&"  "&imgrarpath&" "&ds("username")&" "&Application("agnimgpath")&" "&ds("site2")
Application("lastatcommand")=command

ds("status")="打包中"
'ds.delete
ds.update

End if



response.write "at:"
response.write command

If request("agentname")<>"" Then
If RegExpTest("[^A-Za-z0-9]",Request("agentname")) Then
response.write "thisagentnotexist"
response.end
End If
If RegExpTest("[A-Za-z0-9]",request("agentname")) Then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AgentRaR where username='"&request("agentname")&"' and status='打包中'"
		ds.Open Sql,conn,1,3
if not ds.eof Then
ds("status")="已完成"
response.write "完成"
ds.update
End If
End If
End If

End if


Function RegExpTest(patrn, strng)
  Dim regEx
  Set regEx = New RegExp
  regEx.Pattern = patrn
  regEx.IgnoreCase = False
  RegExpTest = regEx.Test(strng)
End Function 

If Application("openispsystem")=True Then%>
<head>
<title>自动提示信息..</title>
<meta http-equiv="refresh" content="20;URL=maindo.asp">
</head>
<body>
<%=now%>　
<%


If Application("syntype")=True Then
If Not (Application("synH")=Hour(now) and Application("synM")=minute(now)) Then
	ef=True
	ec="现在没有到同步的时间！"
response.write ec
response.end
End if
End if

	ef=false
	ec=""

'if not ef then
'if DateDiff("s", Application("ispoptime"),NOW )<60 and Application("ispoplock")=true then
'	ef=True
'	ec="系统繁忙，前一个备案操作尚未处理完，请您稍等两分钟后再试，谢谢您的支持。"&DateDiff("s", Application("ispoptime"),NOW )
'response.write ec
'response.end
'end If
'end if


'Application.lock
'Application("ispoptime")=now
'Application("ispoplock")=true
'Application.unlock
'Application.lock
response.write "上传同步开始"
server.Execute  "/beian/all-up-do.asp"
response.write "下载同步开始"
server.Execute  "/beian/all-down-do.asp"
'Application.unlock
'response.write "同步监控服务器开始"
'server.Execute  "/beian/synserver.asp"
'Application.lock
'Application("ispoplock")=false
'Application.unlock


End if

%>
