<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("HOSTAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.QueryString ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Instr(1, Request.QueryString ("id"), "'", 1)>0 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_Host where id='"&session("HOSTAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,1
if dsph.Eof then
	ef=True
	ec="不存在的虚拟主机ID！"
end if
end if

if not ef then
if dsph("canseelog")="n" then
	ef=True
	ec="很抱歉，您的虚拟主机不允许查看流量及CPU信息！"
end if
end if

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

if not ef then

username=dsph("Ftpname")
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
　流量使用及CPU情况
<br><br>
<font color="#000000">昨天总流量:
          <%
'处理sub
thismonbytesALLsub=0
CPUALLsub=0
BytesReceivedSub=0
BytesSentSub=0
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"' and allowsub='n' and ftpname='"&dsph("ftpname")&"'"
	dsphsub.Open Sql,conn,1,1
while not dsphsub.eof
thismonbytesALLsub=thismonbytesALLsub+CDbl(dsphsub("thismonbytes"))
CPUALLsub=CPUALLsub+CDbl(dsphsub("TimeTaken"))
BytesReceivedSub=BytesReceivedSub+CDbl(dsphsub("BytesReceived"))
BytesSentSub=BytesSentSub+CDbl(dsphsub("BytesSent"))
dsphsub.movenext
wend

value=FormatNumber(((CDbl(dsph("BytesReceived"))+CDbl(dsph("BytesSent"))+BytesReceivedSub+BytesSentSub)/1048576),1,-1)
%>
          <%=value%> M
          <br>
昨天流入流量:
<%
value=FormatNumber(((CDbl(dsph("BytesReceived"))+BytesReceivedSub)/1048576),1,-1)
%>
          <%=value%> M
		  <br>
昨天流出流量:
<%
value=FormatNumber(((CDbl(dsph("BytesSent"))+BytesSentSub)/1048576),1,-1)
%>
<%=value%> M<br>

<%
spaceused=FormatNumber((CDbl(dsph("thismonbytesALL"))/1048576),1,-1)
spacelimit=FormatNumber((CDbl(dsph("Maxbytes"))/1048576),1,-1)
Response.Write "本月已用流量:"&spaceused&" M<br>"
if spacelimit=0 then
Response.Write "本月流量上限:　无限制<br>"
else
Response.Write "本月流量上限:"&spacelimit&" M<br>"
end if
if spacelimit=0 then
 spacelimit=-1
 spaceused=0
end if
if spacelimit<1 then spacelimit=1
%>
<%=CLNG(CLNG(spaceused)*100/int(spacelimit))%>%<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
  <tr>
    <td height="30">
	<table width="<%=CLNG(CLNG(spaceused)*100/CLNG(spacelimit))%>%" height="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FF0000">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>

	</td>
  </tr>
</table>
<br>
<%
spaceused=FormatNumber(((CDbl(dsph("TimeTaken"))+CPUALLsub)/8640000/5),1,-1)
spacelimit=FormatNumber((CDbl(dsph("MaxCPU"))/8640000/5),1,-1)
lastcpu=spaceused
if spaceused>90 then lastcpu=90
Response.Write "<br><br>昨天使用CPU:"&lastcpu&" %<br>"
if spacelimit=0 then
Response.Write "CPU上限:　无限制<br>"
else
Response.Write "CPU上限:"&spacelimit&" %<br>"
end if
if spacelimit>0 then endp=spaceused*100/spacelimit
if endp>99 then endp=100
if spacelimit=0 Then endp=0
%>
<%=endp%>%<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
  <tr>
    <td height="30">
	<table width="<%=endp%>%" height="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FF0000">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>

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