<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostEmail.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("cansetserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsserver = Server.CreateObject("ADODB.Recordset")
Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&Request("id")&"'"
		dsserver.Open Sql,conn,1,1
If dsserver.Eof Then
	ef=True
	ec="服务器不存在。"
end if
end if

if not ef then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")%><!--#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 align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="80" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="serverlist.asp"><font color="#FFFFFF">服务器管理</font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></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>
<br>

<DIV class="tableborder"><br>
<br>
<br>
<%if Request("op")="iisrestart" then Response.Write SystemIISRESET(URL,FreeHostsharekey,"/restart")
if Request("op")="iisstop" then Response.Write SystemIISRESET(URL,FreeHostsharekey,"/stop")
if Request("op")="reboot" then Response.Write SystemIISRESET(URL,FreeHostsharekey,"/reboot")
if Request("op")="stopmssql" then Response.Write SystemNetStop(URL,FreeHostsharekey,"MSSQLSERVER")
if Request("op")="startmssql" then Response.Write SystemNetStart(URL,FreeHostsharekey,"MSSQLSERVER")
if Request("op")="stopmysql" then Response.Write SystemNetStop(URL,FreeHostsharekey,"Mysql")
if Request("op")="startmysql" then Response.Write SystemNetStart(URL,FreeHostsharekey,"Mysql")
if Request("op")="stopwinwebmail" then Response.Write SystemNetStop(URL,FreeHostsharekey,"WinWebMail Server")
if Request("op")="startwinwebmail" then Response.Write SystemNetStart(URL,FreeHostsharekey,"WinWebMail Server")
if Request("op")="stopimail" then Response.Write SystemNetStop(URL,FreeHostsharekey,"SMTPD32")
if Request("op")="stopimail" then Response.Write SystemNetStop(URL,FreeHostsharekey,"POP3D32")
if Request("op")="stopimail" then Response.Write SystemNetStop(URL,FreeHostsharekey,"IWEBMSG")
if Request("op")="startimail" then Response.Write SystemNetStart(URL,FreeHostsharekey,"SMTPD32")
if Request("op")="startimail" then Response.Write SystemNetStart(URL,FreeHostsharekey,"POP3D32")
if Request("op")="startimail" then Response.Write SystemNetStart(URL,FreeHostsharekey,"IWEBMSG")

if Request("op")="siteback" then
nottype=dsserver("nottype")
if isnull(dsserver("nottype")) then nottype="*.log"
Response.Write siteback(URL,FreeHostsharekey,"-"&dsserver("backupsave"),dsserver("backupdir"),nottype)
'7i24iislog2.exe 0 c:\backup *.log x
end if

if Request("op")="analog" then
Response.Write CountLOG(URL,FreeHostsharekey,"a b -1")
conn.Execute "update FreeHost.FreeHost_Serverlist set lastanatime='"&now&"' where id="&dsserver("id")&""
end if


if Request("op")="clearlog" then
conn.Execute "update freehost.FreeHost_Product_Host set oldmonthbytes=thismonbytes,thismonbytes=0,thismonbytesALL=0 where serverlistid="&dsserver("id")&""
response.write "成功将流量清零。<br>"
end if

if Request("op")="uplog" then%>
如果未能得到统计结果或出错,请参考:<a href="http://sys.7i24.com/system/support/show.asp?id=109261105282" target="_blank">http://sys.7i24.com/system/support/show.asp?id=109261105282</a> 中第8点的说明<br>
<br>
<%
serverbyte=0
 txml=dateadd("y",-1,now)
 httpurl=Url&"/log/"&year(txml)&"-"&month(txml)&"-"&day(txml)&".xml"
 response.write "处理:"&httpurl
Set http=Server.CreateObject("MSXML2.ServerXMLHTTP")
http.Open "GET",httpurl,False
http.send
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.load(http.ResponseXML)
Set root = xmlDoc.documentElement
   For i = 0 To (root.childNodes.length - 1)
   if RegExpTest("[A-Za-z0-9]",root.childNodes.Item(i).childNodes.Item(0).Text) then

If RegExpTest("[^A-Za-z0-9]",root.childNodes.Item(i).childNodes.Item(0).Text) Then
response.write "err sql----------------------------------"&root.childNodes.Item(i).childNodes.Item(0).Text
response.end
End If


   	Set dsphtemp = Server.CreateObject("ADODB.Recordset")
Sql="Select * from FreeHost.FreeHost_Product_Host where  ServerlistID="&dsserver("id")&"  and ( ftpname='"&root.childNodes.Item(i).childNodes.Item(0).Text&"' or iisid='"&root.childNodes.Item(i).childNodes.Item(0).Text&"')"    

dsphtemp.Open Sql,conn,1,3
if not dsphtemp.Eof then
'if DateDiff("h" , dsphtemp("lastlogtime"),Now)>12 or isnull(dsphtemp("lastlogtime")) then
response.write "更新以下主机的流量记录："&dsphtemp("ftpname")&" "
dsphtemp("lastlogtime")=now

if IsNumeric(root.childNodes.Item(i).childNodes.Item(1).Text) then
dsphtemp("BytesReceived")=root.childNodes.Item(i).childNodes.Item(1).Text
else
dsphtemp("BytesReceived")=0
end if
if IsNumeric(root.childNodes.Item(i).childNodes.Item(2).Text) then
dsphtemp("BytesSent")=root.childNodes.Item(i).childNodes.Item(2).Text
else
dsphtemp("BytesSent")=0
end if
if IsNumeric(root.childNodes.Item(i).childNodes.Item(3).Text) then
dsphtemp("TimeTaken")=root.childNodes.Item(i).childNodes.Item(3).Text
else
dsphtemp("TimeTaken")=0
end If

response.write "流量为:"&round(CDbl(CDbl(dsphtemp("BytesReceived"))+CDbl(dsphtemp("BytesSent")))/1048576,2)&"M<br>"

'dsphtemp("thismonbytes")=CDbl(dsphtemp("BytesReceived"))+CDbl(dsphtemp("BytesSent"))+CDbl(dsphtemp("thismonbytes"))

serverbyte=CDbl(dsphtemp("BytesReceived"))+CDbl(dsphtemp("BytesSent"))+serverbyte



'每月一次的计划，将thismonbytes=0,oldmonthbytes=thismonbytes
'if Day(now)=1 then '每月1日更新
'response.write "更新month流量记录："
'dsphtemp("oldmonthbytes")=CDbl(dsphtemp("thismonbytes"))
'dsphtemp("thismonbytes")=CDbl(0)
'end if
dsphtemp.update

'end if

end if


  '  conn.Execute "update FreeHost_Product_Host set  lastlogtime='"&now&"',BytesReceived="&root.childNodes.Item(i).childNodes.Item(1).Text&",BytesSent="&root.childNodes.Item(i).childNodes.Item(2).Text&",TimeTaken="&root.childNodes.Item(i).childNodes.Item(3).Text&" ,tempbytes= "&root.childNodes.Item(i).childNodes.Item(1).Text&"+"&root.childNodes.Item(i).childNodes.Item(2).Text&"+thismonbytes where ftpname='"&root.childNodes.Item(i).childNodes.Item(0).Text&"'"  
	'    conn.Execute "update FreeHost_Product_Host set thismonbytes= tempbytes  where ftpname='"&root.childNodes.Item(i).childNodes.Item(0).Text&"'"    
	'	response.write "A"&root.childNodes.Item(i).childNodes.Item(0).Text
	end if
   Next

response.write "<br>服务器总流量为:"&round(CDbl(serverbyte)/1048576,2)&"M<br>"
conn.Execute "update FreeHost.FreeHost_Serverlist set lastlogtime='"&now&"',Bytes='"&serverbyte&"' where id="&dsserver("id")&""

	response.write "完成"
end if

%>
	    <br>
	    <br>
	    <br>
	  </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
%>
