<%
sub DoSynbindDNSALL
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
End Sub

sub DoSynbindDNS

named="include ""C:\windows\system32\etc\rndc.key"";"&vbcrlf&_
"options {"&vbcrlf&_
"allow-query { any; };"&vbcrlf&_
"allow-query-cache{ any; };"&vbcrlf&_
"allow-recursion { none; };"&vbcrlf&_
"};"&vbcrlf



SOASN=Right(year(now)&month(now)&day(now)&hour(now)&Minute(now),10)
TTL=dsBindserver("TTL")

	Set dsCDNserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerCDNlist where cdntype='多点分布CDN加速用' and (Bindserverid1='"&dsBindserver("id")&"' or Bindserverid2='"&dsBindserver("id")&"') order by id asc"
		dsCDNserver.Open Sql,conn,1,1
while Not dsCDNserver.eof

If dsCDNserver("IpAry")="" Then'是any服务器

nameddefault="view ""view_any"" {"&vbcrlf&_
"match-clients { any; };"&vbcrlf&_
"zone """&dsBindserver("domain")&""" {"&vbcrlf&_
"    type master;"&vbcrlf&_
"#,"&dsCDNserver("id")&","&dsBindserver("domain")&","&dsBindserver("nsname")&","&dsBindserver("aname")&","&SOASN&","&TTL&","&dsCDNserver("ip")&vbcrlf&_
"file ""C:\WINDOWS\system32\etc\"&dsCDNserver("id")&"-"&dsBindserver("domain")&".txt"";"&vbcrlf&_
"};"&vbcrlf&_
"};"&vbcrlf

If dsCDNserver("iserr")=true And dsCDNserver("backupCDNid")>0 Then'是故障
	Set dsCDNserverBAD = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerCDNlist where cdntype='多点分布CDN加速用' and id='"&dsCDNserver("backupCDNid")&"'"
		dsCDNserverBAD.Open Sql,conn,1,1
If Not dsCDNserverBAD.eof Then
nameddefault="view ""view_any"" {"&vbcrlf&_
"match-clients { any; };"&vbcrlf&_
"zone """&dsBindserver("domain")&""" {"&vbcrlf&_
"    type master;"&vbcrlf&_
"#,"&dsCDNserverBAD("id")&","&dsBindserver("domain")&","&dsBindserver("nsname")&","&dsBindserver("aname")&","&SOASN&","&TTL&","&dsCDNserverBAD("ip")&vbcrlf&_
"file ""C:\WINDOWS\system32\etc\"&dsCDNserverBAD("id")&"-"&dsBindserver("domain")&".txt"";"&vbcrlf&_
"};"&vbcrlf&_
"};"&vbcrlf
End if
End if

Else


willerr=false

If dsCDNserver("iserr")=true And dsCDNserver("backupCDNid")>0 Then'是故障
	Set dsCDNserverBAD = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerCDNlist where cdntype='多点分布CDN加速用' and id='"&dsCDNserver("backupCDNid")&"'"
		dsCDNserverBAD.Open Sql,conn,1,1
If Not dsCDNserverBAD.eof Then
willerr=true'用回原来的id，不然会重复
named=named&"view ""view_"&dsCDNserver("id")&""" {"&vbcrlf&_
"match-clients { acl_"&dsCDNserver("id")&"; };"&vbcrlf&_
"zone """&dsBindserver("domain")&""" {"&vbcrlf&_
"    type master;"&vbcrlf&_
"#,"&dsCDNserverBAD("id")&","&dsBindserver("domain")&","&dsBindserver("nsname")&","&dsBindserver("aname")&","&SOASN&","&TTL&","&dsCDNserverBAD("ip")&vbcrlf&_
"file ""C:\WINDOWS\system32\etc\"&dsCDNserverBAD("id")&"-"&dsBindserver("domain")&".txt"";"&vbcrlf&_
"};"&vbcrlf&_
"};"&vbcrlf

named=named&"acl ""acl_"&dsCDNserver("id")&""" {"&vbcrlf&_
dsCDNserverBAD("IpAry")&vbcrlf&_
"};"&vbcrlf
End if
End If

If willerr=False then

named=named&"view ""view_"&dsCDNserver("id")&""" {"&vbcrlf&_
"match-clients { acl_"&dsCDNserver("id")&"; };"&vbcrlf&_
"zone """&dsBindserver("domain")&""" {"&vbcrlf&_
"    type master;"&vbcrlf&_
"#,"&dsCDNserver("id")&","&dsBindserver("domain")&","&dsBindserver("nsname")&","&dsBindserver("aname")&","&SOASN&","&TTL&","&dsCDNserver("ip")&vbcrlf&_
"file ""C:\WINDOWS\system32\etc\"&dsCDNserver("id")&"-"&dsBindserver("domain")&".txt"";"&vbcrlf&_
"};"&vbcrlf&_
"};"&vbcrlf

named=named&"acl ""acl_"&dsCDNserver("id")&""" {"&vbcrlf&_
dsCDNserver("IpAry")&vbcrlf&_
"};"&vbcrlf
End if

End If'不是any

dsCDNserver.movenext
wend


named=named&nameddefault

'Response.Write named

op=1
Bindcon="reload"
retstr=retstr&vbcrlf&vbcrlf&vbcrlf&"  装入bind:"&CDNDNSOP(URL,FreeHostsharekey,Bindcon,named,op)

response.write "<pre>"&named&"</pre>"

Bindcon="flush"
named=""
retstr=retstr&vbcrlf&vbcrlf&vbcrlf&"  更新bind:"&CDNDNSOP(URL,FreeHostsharekey,Bindcon,named,op)




'response.end



end Sub

Function CDNDNSOP(URL,FreeHostsharekey,varcon,named,op)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
body=URLEncoding("varcon="&server.URLEncode(varcon)&"&named="&server.URLEncode(named)&"&op="&op)
RetInfo=MaintoCSCom.DOHTTPSSL(Url&"?CDNDNSOP",FreeHostsharekey,body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Set MaintoCSCom =Nothing
CDNDNSOP=RetInfo
End Function

%>