<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("VPSAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
end if

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

If not ef then
if (not dsphVPS("status")="正常" And not dsphVPS("status")="等待安装操作系统") or dsphVPS("status")="暂停" then
		ef=True
		ec="必须是处于正常状态的主机才能管理！"
end if
end if


if not ef then
Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsphVPS("id")
		dsX.Open Sql,conn,1,1
If  not dsX.eof then
IP=dsX("IP")
IPmask=dsX("IPmask")
IPgateway=dsX("IPgateway")
IPdns1=dsX("IPdns1")
IPdns2=dsX("IPdns2")
dsX.close
Else
	ef=True
	ec="这个VPS没有分配IP资源,请联系管理员处理！"
end If
end If

if not ef then
	Set dspdl = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&dsphVPS ("VPStype")&"'"
		dspdl.Open Sql,conn,1,1
If dspdl.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='"&dsphVPS ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
else
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsphVPS("username")
vpsname=dsphVPS("vpsname")
'homedir=dsserver("homedir")
todir=dsphVPS("vhdpath")
MAXspace=dsphVPS("MAXspace")
isONEip=dsserver("isONEip")
session("isONEip")=isONEip
end if
end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-vpsadm-top.asp"-->
　云服务器自助管理
          <br>
          <br>
          <table 
            width="100%" border=1 align=center cellpadding=0 cellspacing=0 bordercolorlight=#cccccc bordercolordark=#fbfbfb>
            <tbody>
              <tr>
                <td width="20%" height="35" align="center" valign=middle bgcolor=#F3F3F3>&nbsp;<font color="#000000">产品类型：</font></td>
                <td height="35" colspan="2" bgcolor=#ffffff><%
	vpstype=dspdl("vpstype")
	info=dspdl("info")
	Set ori_VPS_name = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_VPSProductlist where vpstype='"&vpstype&"'"
		ori_VPS_name.Open Sql,conn,1,1
		if not ori_VPS_name.eof then
Set newname_VPS = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_VPSProductlist_AGN where agent1='"&dsphVPS("agent1")&"' and id='"&ori_VPS_name("id")&"'"
		newname_VPS.Open Sql,conn,1,1
if not newname_VPS.eof then
vpstype=newname_VPS("vpstype")
info=newname_VPS("info")
end if
		end if

	%>
                    　　
                    <%=vpstype%> </td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>在数据库中的状态：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　
                    <%if dsphVPS("endtime")>NOW then%>
                    <%if dsphVPS("istest")="y" then%>
                    <font color="#FF0000">试用</font>
                    <%else%>
                    <%=dsphVPS("status")%>
                    <%end if%>
                    <%else%>
                    <font color="#FF0000">过期</font>
                    <%if dsphVPS("status")="暂停" then%>
                    <br>
                    <font color="#FF0000">暂停</font>
                    <%end if%>
                    <%end if%></td>
              </tr>
              <%if isONEip=true then%>
              <tr>
                <td width="20%" height="35" align="center" valign=middle bgcolor=#F3F3F3>CDN信息：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　您用的是共享IP的VPS，每个域名要绑定后才能使用</td>
              </tr>
              <%else%>
              <tr>
                <td width="20%" height="35" align="center" valign=middle bgcolor=#F3F3F3>服务器IP：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　
                    <%
	Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsphVPS("id")
		dsX.Open Sql,conn,1,1
If not dsX.Eof Then
while not dsX.eof
%>
                    <%=dsX("IP")%> 　
                    <%
dsX.movenext
wend
else%>
                    无,请马上分配
                    <%end if%></td>
              </tr>
              <%end if%>
              <tr>
                <td width="20%" height="35" align="center" valign=middle bgcolor=#F3F3F3>开通时间：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　<%=formatdatetime(dsphVPS("starttime"),1)%></td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>到期时间：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　<%if Application("VPStestHour")>0 then%><%=dsphVPS("endtime")%><%else%><%=formatdatetime(dsphVPS("endtime"),1)%><%end if%></td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>云服务器名：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　<%=dsphVPS("vpsname")%>
				<%
if not isnull(dsphVPS("ADSLName")) then
%>　　拨号资源：用户名<%=dsphVPS("ADSLName")%>密码<%=dsphVPS("ADSLpass")%>)
<%else
	Set dsADSL = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_ADSL where VPSID="&dsphVPS("id")
		dsADSL.Open Sql,conn,1,1
while not dsADSL.eof%>
　　拨号资源：用户名<%=dsADSL("ADSLName")%>密码<%=dsADSL("ADSLpass")%>
<%		
dsADSL.movenext
wend
end if%>
				
				</td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>在服务器上的状态：</td>
                <td width="16%" height="35" bgcolor=#ffffff><%
On Error Resume next
varcon="show "&vpsname&" "&Replace(todir,".vhd","-2.vhd")&"  1 2 3 4 7 100 101 102 103 104 105 106 107 108 109"
temp=VPSOP(URL,FreeHostsharekey,varcon,0)

'response.write temp

canpic=false

arrystr=Split(temp,vbcrlf)

For i=0 To UBound(arrystr)
'命令成功执行。显示信息:
'GUID: B6B70FFD-D4D3-4D16-AC9B-481D88BEC41D
'云服务器名: hjkhjh
'创建时间: 20081126043220.149505-000
'说明: 用户名:test,建立于:2008/11/26 12:32:20,建立时资源分配:CPU个数:1个,CPU上限:20%内存上限:555空间上限:15G,VHD位置:c:\vps\hjkhjh.vhd
'CPU数量: 1
'缩略图: 获得成功
str="缩略图: "
If Left(arrystr(i),Len(str))=str Then canpic=true

str="当前CPU使用量: "
If Left(arrystr(i),Len(str))=str Then ProcessorLoad=right(arrystr(i),Len(arrystr(i))-Len(str))

'启动状态: 2
'当前CPU使用量: 0
str="GUID: "
If Left(arrystr(i),Len(str))=str Then GUID=right(arrystr(i),Len(arrystr(i))-Len(str))
str="启动状态: "
If Left(arrystr(i),Len(str))=str Then EnabledState=right(arrystr(i),Len(arrystr(i))-Len(str))
'ProcessorLoadHistory: System.UInt16[]
'内存: 555
str="内存: "
If Left(arrystr(i),Len(str))=str Then maxram=right(arrystr(i),Len(arrystr(i))-Len(str))

'Heartbeat: 2
'运行时间: 16577649
str="运行时间: "
If Left(arrystr(i),Len(str))=str Then Uptime=right(arrystr(i),Len(arrystr(i))-Len(str))/1000
'VPS中的操作系统: Microsoft Windows Server 2003
'健康状态: 5

'FileSize:3723539968
'MaxInternalSize:16106127360
'Type:3
'InUse:TRUE
'InSavedState:TRUE
str="MaxInternalSize:"
If Left(arrystr(i),Len(str))=str Then MaxInternalSize=right(arrystr(i),Len(arrystr(i))-Len(str))/1024/1024/1024

Next

If canpic then
httpurl=Url&"/log/"&vpsname&".jpg"
Set http=Server.CreateObject("MSXML2.ServerXMLHTTP")
http.Open "GET",httpurl,False
'response.write httpurl
http.send
session("picdata")=http.responsebody
End If

If Len(GUID)>10 then
dsphVPS("GUID")=GUID
dsphVPS.update
End if
%>
        　　<%=EnabledState%></td>
                <td width="64%" bgcolor=#ffffff>　更改状态：　<a href="vpsop.asp?id=<%=session("VPSAUID")%>&op=start" onClick="if (confirm('请您确认本次操作?')==false){return false;}">[开机]</a>　<a href="vpsop.asp?id=<%=session("VPSAUID")%>&op=turnoff" onClick="if (confirm('请您确认本次操作?')==false){return false;}">[关机]</a>　<a href="vpsop.asp?id=<%=session("VPSAUID")%>&op=reset" onClick="if (confirm('请您确认本次操作?')==false){return false;}">[重启]</a></td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>　　硬件情况：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　实时CPU使用：<%=ProcessorLoad%>%　内存上限：<%=dsphVPS("MAXRam")%>M　
                    <!--当前内存使用：<%=maxram%>M-->
                    　 硬盘总大小：<%=MaxInternalSize+10%> G</td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>已运行时间:</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　 <%=Fix(Uptime/60)%> 分钟</td>
              </tr>
 <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>唯一识别名GUID:</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　 <%=GUID%></td>
              </tr>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>实时截图：</td>
                <td height="35" colspan="2" bgcolor=#ffffff>　　
                    <%If canpic then%>
                    <img src="vpsimg.asp">
                    <%else%>
                    无
                    <%End if%></td>
              </tr>
              <%If session("admau")<>"" Then%>
              <tr>
                <td height="35" align="center" valign=middle bgcolor=#F3F3F3>服务器上的操作日志：</td>
                <td height="35"  colspan="2"  bgcolor=#ffffff>　　
                    <table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td><%


httpurl=Url&"/log/"&vpsname&".txt"
Set http=Server.CreateObject("MSXML2.ServerXMLHTTP")
http.Open "GET",httpurl,False
http.send

returnstr = Replace(bytes2BSTR(http.responsebody),vbcrlf,"<br>")

If http.status=200 then
response.write returnstr
else%>
              没有日志内容
                <%End if
%></td>
                      </tr>
                  </table></td>
              </tr>
              <%end if%>
            </tbody>
          </table>
          <%If session("username")<>"" Then%><br>
　<a href="/user/vpsadm.asp"><font color="#000000">[返回用户区]</font></a>
<br>
<br>
<%end if%>
 <!--#include virtual="/inc-freehost-function/template-vpsadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>