<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
isagentpd=False
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canadmvpsset")="" and session("canadmvps")="" and session("canadmvpsch")="" and session("canadmvpsmidsub")="" and session("canadmvpsmiddomain")="" and session("canadmvpsmidcpu")="" and session("canadmvpsmidrepay")="" and session("canadmvpsdel")=""  and session("canadmvpsoth")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request.QueryString ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf not IsNumeric(Request.QueryString ("id"))  Then
	ef=True
	ec="ID应该是数字！"
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='"&Request.QueryString ("id")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的VPS！"
Else
If dsph ("isagentpd")=True Then isagentpd=true'代理的产品
end if
end if

If not ef then
if not dsph("status")="正常" And Request.QueryString ("go")<>"c" then
		ef=True
		ec="必须是处于正常状态的主机才能管理！"
end if
end if

If Not isagentpd then
if not ef then
session("vpsAUID")=dsph("id")
if Request.QueryString ("go")="a" then Response.Redirect "/vpsadm/selfvpsmodify.asp?id="&dsph("id")
'if Request.QueryString ("go")="c" then Response.Redirect "/cdnadm/selfcdnmodifyrepay.asp?id="&dsph("id")
'if Request.QueryString ("go")="d" then Response.Redirect "/cdnadm/selfcdnmodifyup.asp?id="&dsph("id")
end If
End If

If isagentpd then
If not ef Then
'向上级查密码及ip

VPSApiName=dsph("VPSApiName")
userid=dsph("Agnuserid")
vpsname=dsph("vpsname")
userstr=md5(dsph("Domain_Agent_nonemd5_6")&"7i24.com")
yearAgn=Request.Form ("year")
idc=dsph("Agnidc")
productid=dsph("Agnproductid")
tar="http://"&VPSApiName&"/api/cloudapi.asp?userid="&userid&"&userstr="&userstr&"&vpsname="&dsph ("vpsname")&"&action=getinfo"

temp=ONLY_GET(tar,"")
'得到 密码&IP&状态&到期时间
'post 上级
'Response.write temp
'Response.end
vpspassword=""
ip=""
getinfoAry=Split(temp,"&")
For i=0 To ubound(getinfoAry)
If Left(getinfoAry(i),12)="vpspassword=" Then vpspassword=Replace(getinfoAry(i),"vpspassword=","")
If Left(getinfoAry(i),3)="ip=" Then ip=Replace(getinfoAry(i),"ip=","")
Next
If vpspassword="" Then
		ef=True
		ec=" 查询上级API信息密码时返回出错！原因："&server.urlencode(temp)
End If
If ip="" Then
		ef=True
		ec=" 查询上级API信息ip时返回出错！原因："&server.urlencode(temp)
End If

if Not ef Then

dsph("vpspassword")=vpspassword
dsph("AgnUpIP")=Left(ip,499)
dsph.update
'Response.write vpspassword
'Response.write ip

%>
<form name="form1" method="post" action="http://<%=dsph("VPScpdomain")%>/vpsadm/login.asp" ID="Form1">
<input name="vpsname" type="hidden" value="<%=dsph("vpsname")%>">
<input name="vpspassword" type="hidden" value="<%=dsph("vpspassword")%>">
<input type="submit" name="Submit" value="<%If ef then%>Error if you want to login pls click here<%else%>login...........<%End if%>">
</form>
<script language="JavaScript">
document.Form1.submit();
</script>
<%
end If
end If
End If

if ef then
Response.Redirect "e.asp?e="&ec
end if%>