<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%

Function ShowAllDrive(URL,FreeHostsharekey,CMD)
  Dim returnstr,body
body=URLEncoding("CMD="&CMD)
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.setTimeouts 5, 5, 5, 5
xml.Open "POST", Url&"/FreeHost.dll?ShowAllDrive", False
xml.setRequestHeader "Content-Length",Len(body)
xml.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
xml.setRequestHeader "FreeHost",FreeHostsharekey
xml.send body
returnstr = bytes2BSTR(xml.responsebody)
Set xml = Nothing
  ShowAllDrive = returnstr
End Function

Function URLEncoding(vstrIn)
    strReturn = ""
    For i = 1 To Len(vstrIn)
        ThisChr = Mid(vStrIn,i,1)
        If Abs(Asc(ThisChr)) < &HFF Then
            strReturn = strReturn & ThisChr
        Else
            innerCode = Asc(ThisChr)
            If innerCode < 0 Then
                innerCode = innerCode + &H10000
            End If
            Hight8 = (innerCode  And &HFF00)\ &HFF
            Low8 = innerCode And &HFF
            strReturn = strReturn & "%" & Hex(Hight8) &  "%" & Hex(Low8)
        End If
    Next
    URLEncoding = strReturn
End Function

Function Bytes2bStr(vin)
  Dim BytesStream,StringReturn
  Set BytesStream = Server.CreateObject("ADODB.Stream")
  BytesStream.Type = 2
  BytesStream.Open
  BytesStream.WriteText vin
  BytesStream.Position = 0
  BytesStream.Charset = "gb2312"
  BytesStream.Position = 2
  StringReturn =BytesStream.ReadText
  BytesStream.close
  Set BytesStream = Nothing
  Bytes2bStr = StringReturn
End Function

If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
ElseIf not IsNumeric(Request("ipid"))  Then
	ef=True
	ec="IPID应该是数字！"		
ElseIf not IsNumeric(Request("adslid"))  Then
	ef=True
	ec="adslid应该是数字！"			
elseIf session("cansetserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
end if
if not ef then%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD width="150"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="120" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="servervpslist.asp"><font color="#FFFFFF">云服务器状态列表</font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="150" align="left">&nbsp;</TD>
      <TD width="185" align="left">&nbsp;</TD>
      <TD align="left">&nbsp;</TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF"><br>
	  
<%
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_ServerVPSlist order by orderbyid desc,id asc"
if request("id")<>"" Then Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&Request("id")&"'"
		ds.Open Sql,conn,1,1
If ds.Eof Then%>
服务器列表为空.
<%else%>  
<DIV class="tableborder">
<table width="100%"  border="0" cellspacing="1">
  <tr >
    <td width="43" height="24" align="center" background="img/tablebg.gif"><font color="#FFFFFF">编号</font></td>
    <td width="150" align="center" background="img/tablebg.gif"><font color="#FFFFFF">云服务器名称</font></td>
    <td width="975" align="center" background="img/tablebg.gif"><font color="#FFFFFF">状态</font></td>
    <td width="222" align="center" background="img/tablebg.gif"><font color="#FFFFFF">总共</font></td>
    <td width="234" align="center" background="img/tablebg.gif"><font color="#FFFFFF">空闲</font></td>
  </tr>
<%while not ds.Eof
%>

  <tr>
    <td width="43" height="30" align="center" bgcolor="#E4EAF2"><%=ds("id")%></td>
    <td width="150" align="left" bgcolor="#E4EAF2">　　<%=ds("servername")%>(<%=ds("site")%>) IP:<%=ds("ip")%>
      <%if ds("agent1")<>"n" then%>
      　 代理名：<a href="searchagent.asp?username=<%=ds("agent1")%>"><font color="#0000FF"><%=ds("agent1")%></font></a>
      <%end if%>      　
      排队:<%=ds("orderbyid")%></td>
    <td colspan="3" align="center">
<DIV style="BORDER-RIGHT: #345487 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #345487 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: #345487 1px solid; WIDTH: 100%; PADDING-TOP: 0px; BORDER-BOTTOM: #345487 1px solid; BACKGROUND-COLOR: #fff">	
	<table width="100%"  border="0" cellspacing="1">
      <%
URL=ds("site")
FreeHostsharekey=ds("FreeHostsharekey")
outcon=replace(ShowAllDrive(URL,FreeHostsharekey,"IWEBMSG"),"调用出错！","")

if Not instr(outcon,"全部磁盘容量")>1 then 
Response.Write "这台受控服务器自检没有通过，请在站点管理，虚拟主机中自检来分析原因。"
Response.End 
end if 

arryA=split(outcon,"	　　")
for i=0 to ubound(arryA)
arryB=split(arryA(i),":")
if ubound(arryB)>0 then
arryC=split(replace(arryB(1),"\",""),"	")
arryC(0)=replace(replace(arryC(0),"全部磁盘容量是 ",""),"GB","")
arryC(1)=replace(replace(arryC(1),"空余磁盘容量是 ",""),"GB","")
spaceused=CDbl(arryC(0))-CDbl(arryC(1))
spacelimit=CDbl(arryC(0))
%>
      <tr bgcolor="#E4EAF2">
        <td width="11%" height="50" align="center"><%=arryB(0)%>: 盘</td>
        <td width="57%" align="left"><table width="<%=int(Clng(spaceused)*100/spacelimit)%>%" height="20"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FF0000">
            <%=int(Clng(spaceused)*100/spacelimit)%>%
        </table></td>
        <td width="16%" align="center"><%=FormatNumber(arryC(0),3,-1)%> GB</td>
        <td width="16%" align="center"><%=FormatNumber(arryC(1),3,-1)%> GB</td>
      </tr>
      <%
end if
next%>
      <%
outcon=ShowAllDrive(URL,FreeHostsharekey,"RAM")
if Not instr(outcon,"物理内存")>1 then 
Response.Write "这台受控服务器受控没升级，请先升级。"
Response.End 
end if 

arryRam=split(outcon,";")
arryRamT=split(arryRam(0),"：")
'Response.write "<br>总物理内存："&arryRamT(1)&"<br><br>"
arryRamA=split(arryRam(1),"：")
'Response.write "<br>可用物理内存："&arryRamA(1)&"<br><br>"
arryRamP=split(arryRam(2),"：")
'Response.write "<br>已用物理内存比例："&arryRamP(1)&"<br><br>"
'Response.write "<br>内存使用情况："&outcon&"<br><br>"
%>
      <tr bgcolor="#E4EAF2">
        <td height="50" align="center">内存</td>
        <td align="left"><table width="<%=arryRamP(1)%>" height="20"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FF0000">
            <%=arryRamP(1)%>
        </table></td>
        <td width="16%" align="center"><%=arryRamT(1)%></td>
        <td width="16%" align="center"><%=arryRamA(1)%></td>
      </tr>
    </table></td>
    </tr>
<%
ds.movenext
wend%>
</table>
<%end if%>
</div>
</TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>
<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
