<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("VPSAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf not IsNumeric(session("VPSAUID"))  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_VPS where id='"&session("VPSAUID")&"'"
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的数据库产品ID！"
end if
end if

if not ef then
If IsNull(dsph("hostname")) then
	ef=True
	ec="绑定域名后才能下载日志！"
end if
end If


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

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

if not ef then
if isONEip=true then
	Set dsCDNserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerCDNlist where id='"&dsserver ("usecdn1")&"'"
	dsCDNserver.Open Sql,conn,1,1
if dsCDNserver.Eof then
	ef=True
	ec="CDN服务器不存在！"
end if
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-VPS操作尚未处理完，请您稍等五分钟后再试，谢谢您的支持。"
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




%>
<!--#include virtual="/inc-freehost-function/template-vpsadm-top.asp"-->
　云服务器自助管理

<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
txml=dateadd("y",-1,now)		
logfilename=dsph("vpsname")&"_"&md5(dsph("vpsname")&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'2012-12-14
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>请您记下以下的URL,十分钟后下载:

		<%=downurl%>
		
		<%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="selfVPSmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-vpsadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
