<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If not IsNumeric(Request ("id"))  Then
response.write "id非法"
response.End
End If

'If RegExpTest("[^A-Za-z0-9]",Request("vpsname")) Then
'response.write "vpsname非法"
'response.End
'End if

'response.write Request ("id")
'response.End

'response.write Request.ServerVariables("HTTP_FreeHostsyn")
'response.End

Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsVPSserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&Request ("id")&"'"
	dsVPSserver.Open Sql,conn,1,1

if not dsVPSserver.Eof then

If md5(dsVPSserver("FreeHostsharekey")&"lsoftsystem2.0")<>Request.ServerVariables("HTTP_FreeHostsyn")  Then
response.write "synkey非法"
response.End
End if


response.write "合法请求开始处理...."&vbcrlf

HourNow=hour(Now)
txml=day(dateadd("y",-1,now))



aryline=Split(Request.Form,Chr(10))'换行符

'response.write aryline(0)&vbcrlf
If ubound(aryline)>0 then
For i=1 To ubound(aryline)
'response.write aryline(i)&vbcrlf
aryEveryline=Split(aryline(i),",")
If ubound(aryEveryline)>10 Then
If RegExpTest("[^A-Za-z0-9]",aryEveryline(0)) Then
response.write "不合法的VPS名："&aryEveryline(0)&vbcrlf
else
response.write aryEveryline(0)&vbcrlf'name
'response.write aryEveryline(1)&vbcrlf'guid
response.write aryEveryline(3)&vbcrlf'CPUavg'AvgCPU(Mhz): the sum of the average processor usage, in megahertz, of the virtual machines under the specified resource pool
response.write aryEveryline(5)&vbcrlf'RAMavg
response.write aryEveryline(9)&vbcrlf'All
response.write aryEveryline(10)&vbcrlf'IN
response.write aryEveryline(11)&vbcrlf'OUT

'操作SQL'当前的小时hour(now)，当时的日day(now)
'Response.write "UPDATE [FreeHost].[FreeHost_Product_VPS] set HourMB"&HourNow&"="&aryEveryline(9)&",HourMBin"&HourNow&"="&aryEveryline(10)&",HourCpu"&HourNow&"="&aryEveryline(5)&" where vpsname='"&aryEveryline(0)&"'"
'2012
If ubound(aryEveryline)=11 Then conn.Execute "UPDATE [FreeHost].[FreeHost_Product_VPS] set HourMB"&HourNow&"="&aryEveryline(9)&",HourMBin"&HourNow&"="&aryEveryline(10)&",HourCpu"&HourNow&"="&aryEveryline(3)&" where vpsname='"&aryEveryline(0)&"'"
'2012R2
If ubound(aryEveryline)>15 Then'2012R2
response.write "IOPS:"&aryEveryline(12)&vbcrlf'IOPS
response.write "NetCardinfos:"&aryEveryline(16)&vbcrlf'IOPS
If dsVPSserver("IsCluster")=True Then
 conn.Execute "UPDATE [FreeHost].[FreeHost_Product_VPS] set ServerlistID="&dsVPSserver("id")&",NetCardinfos='"&Left(aryEveryline(16),499)&"',HourMB"&HourNow&"="&aryEveryline(9)&",HourMBin"&HourNow&"="&aryEveryline(10)&",HourCpu"&HourNow&"="&aryEveryline(3)&",HourIOPS"&HourNow&"="&aryEveryline(12)&" where vpsname='"&aryEveryline(0)&"'"'同步----------

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where vpsname='"&aryEveryline(0)&"'"
	dsph.Open Sql,conn,1,1
if Not dsph.Eof then
 conn.Execute "UPDATE FreeHost.FreeHost_Product_VPS_IP set ServerlistID="&dsVPSserver("id")&" where  VPSID='"&dsph("id")&"'"
End If
dsph.close

else
 conn.Execute "UPDATE [FreeHost].[FreeHost_Product_VPS] set NetCardinfos='"&Left(aryEveryline(16),499)&"',HourMB"&HourNow&"="&aryEveryline(9)&",HourMBin"&HourNow&"="&aryEveryline(10)&",HourCpu"&HourNow&"="&aryEveryline(3)&",HourIOPS"&HourNow&"="&aryEveryline(12)&" where vpsname='"&aryEveryline(0)&"'"
End if
End if

End if
End if
Next
End If




'更新昨天日流量
If dsVPSserver("isONEip")=False then
If HourNow=0 then'0点才更新-------------
strsql="LastDayMb="
For t=0 To 23'从0-23
strsql=strsql&"+"&"HourMB"&t
Next
strsql=strsql&",LastDayMbin="

For t=0 To 23'从0-23
strsql=strsql&"+"&"HourMBin"&t
Next

strsql=strsql&",LastDayCpu="
For t=0 To 23'从0-23
strsql=strsql&"+"&"HourCpu"&t
Next

strsql=strsql&",LastDayIOPS="
For t=0 To 23'从0-23
strsql=strsql&"+"&"HourIOPS"&t
Next

strsql=strsql&",CDNMB"&txml&"=LastDayMb"
strsql=Replace(strsql,"=+","=")
Response.write "UPDATE [FreeHost].[FreeHost_Product_VPS] set "&strsql&" where ServerlistID="&Request ("id")&vbcrlf
conn.Execute "UPDATE [FreeHost].[FreeHost_Product_VPS] set "&strsql&" where ServerlistID="&Request ("id")
End If
End if'不是共享ＩＰ


'更新日流量
strsql="TodayMB="
For t=0 To HourNow'从一起changet to 0
strsql=strsql&"+"&"HourMB"&t
Next
strsql=strsql&",TodayMBin="
For t=0 To HourNow
strsql=strsql&"+"&"HourMBin"&t
Next
strsql=strsql&",TodayCpu="
For t=0 To HourNow
strsql=strsql&"+"&"HourCpu"&t
Next
strsql=strsql&",TodayIOPS="
For t=0 To HourNow
strsql=strsql&"+"&"HourIOPS"&t
Next

If dsVPSserver("isONEip")=False Then strsql=strsql&" ,CDNMB"&day(Now)&"=TodayMB"'统一下
strsql=Replace(strsql,"=+","=")
Response.write "UPDATE [FreeHost].[FreeHost_Product_VPS] set "&strsql&" where ServerlistID="&Request ("id")
'Response.End
conn.Execute "UPDATE [FreeHost].[FreeHost_Product_VPS] set "&strsql&" where ServerlistID="&Request ("id")



'更新月流量
If dsVPSserver("isONEip")=False then
strsql="CDNMBthismonth="
For t=1 To txml+1
strsql=strsql&"+"&"CDNMB"&t
Next
Response.write vbcrlf
'Response.write strsql
Response.write "UPDATE [FreeHost].[FreeHost_Product_VPS] set "&strsql&" where ServerlistID="&Request ("id")
conn.Execute  "UPDATE [FreeHost].[FreeHost_Product_VPS] set "&strsql&" where ServerlistID="&Request ("id")
End if


else
response.write "none servervpsid"
response.End
End If

%>