<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("CDNAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf not IsNumeric(session("CDNAUID"))  Then
	ef=True
	ec="osid应该是数字！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_CDN where id='"&session("CDNAUID")&"'"
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的数据库产品ID！"
end if
end if

if not ef then
	Set dsCDNpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_CDNProductlist where CDNtype='"&dsph("CDNtype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsCDNpdlist.Open Sql,conn,1,1
if dsCDNpdlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerBindlist where id='"&dsph ("Bindserverid1")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="DNS服务器1不存在！"
end if
end If

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerBindlist where id='"&dsph ("Bindserverid2")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="DNS服务器2不存在！"
end if
end If

if not ef then
	Set dsCDNserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerCDNlist where cdntype='多点分布CDN加速用'  and (Bindserverid1='"&dsph ("Bindserverid1")&"' or Bindserverid1='"&dsph ("Bindserverid2")&"' or Bindserverid2='"&dsph ("Bindserverid1")&"' or Bindserverid2='"&dsph ("Bindserverid2")&"')"
	dsCDNserver.Open Sql,conn,1,1
if dsCDNserver.Eof then
	ef=True
	ec="CDN服务器不存在！"
end if
end if

if request("op")="downlog" then
if not ef then
if DateDiff("s",Application("candownCDN"&dsCDNserver("id")&"optime"),NOW )<300 and Application("candownCDN"&dsCDNserver("id"))=true then
	ef=True
	ec="系统繁忙，前一个CDN操作尚未处理完，请您稍等五分钟后再试，谢谢您的支持。"
end if
end if
if not ef then'time
Application.lock
Application("candownCDN"&dsCDNserver("id")&"optime")=now
Application("candownCDN"&dsCDNserver("id"))=true
Application.unlock
end If
End if

if not ef Then
If dsph("hostname")="" Or IsNull(dsph("hostname")) then
	ef=True
	ec="您尚未绑定域名,这个功能无法使用。"
end if
End if

if not ef Then
%>
<!--#include virtual="/inc-freehost-function/template-CDNadm-top.asp"-->
　CDN自助管理

<br>
<form action="CDNop2.asp" method="post" name="modhostname" id="modhostname">
  <TABLE width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
    <TBODY>
      <TR align="center">
        <TD height="35" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">
          <input name="id" type="hidden" value="<%=Request("id")%>">
        日志下载：</font></TD>
      </TR>
      <TR>
        <TD height="35" align="center" vAlign=middle bgColor=#FFFFFF>
		
		<%if request("op")="downlog" Then

while not dsCDNserver.Eof

txml=dateadd("y",-1,now)		
logfilename=dsph("ftpname")&"_"&md5(dsph("ftpname")&dsph("starttime"))&".txt"
'response.write dsCDNserver("site")
aryport=Split(Replace(dsCDNserver("site"),"http://",""),":")
sysport=":"&aryport(1)
downurl="http://"&Replace(dsCDNserver("ip")&sysport&"/"&logfilename,"//","/")

hostname_arry=Split(dsph("hostname"), ",")
SQL=""
for i=0 to ubound(hostname_arry)
domain=replace(hostname_arry(i), " ","")
domainary=Split(domain,":")
SQL="Field3=["&domainary(2)&"] or "&SQL
Next

SQL=left(SQL,Len(SQL)-3)

'response.write sql
'response.end

URL=dsCDNserver("site")
FreeHostsharekey=dsCDNserver("FreeHostsharekey")
timedif="cdnop downlog "&logfilename&" """&SQL&""""
response.Write	CountLOG(URL,FreeHostsharekey,timedif)
		
		%><br>CDN服务器:<%=dsCDNserver("servername")%>(<%=dsCDNserver("ip")%>) 请您记下以下的URL,十分钟后下载:

		<%=downurl%><br>
		
		<%
dsCDNserver.movenext
wend
		%>
		<%else%>
		<a href="?op=downlog">点击生成日志&gt;&gt;&gt;</a>
		<%end if%>
		
		</TD>
      </TR>
    </TBODY>
  </TABLE>
<input name="id" type="hidden" value="<%=Request("id")%>">
</form>

<br>


　<a href="selfCDNmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-CDNadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
