<%@ 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("VPSAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。此功能只有代理可以操作。"
ElseIf not IsNumeric(session("VPSAUID"))  Then
	ef=True
	ec="产品ID应该是数字！"
elseIf session("VPSAUID")<>Clng(Request.Form ("id")) Then
	ef=True
	ec="授权非法，有可能是超时造成的。请返回上一步重新操作。"&Request.Form ("id")&"-"&session("VPSAUID")
ElseIf Request.Form ("vpspdid")="" Then
	ef=True
	ec="请选择产品！"
ElseIf not IsNumeric(Request.Form ("vpspdid"))  Then
	ef=True
	ec="产品号应该是数字！"
elseif IsNumeric(Request.Form ("usermoney")) Then
    If Request.Form ("usermoney")<0 then
	ef=True
	ec="很抱歉,金额不能设为负。"
	End if
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_VPS where id='"&session("VPSAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="要升级的云服务器不存在！"
end if
end If

if not ef then
if dsph("agent1")<>session("agentusername") then
	ef=True
	ec="此云服务器ID并不是当前代理名下所有！"
end If
end If

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsph("username")&"'"
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
	Set dsHost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where id='"&Request.Form ("vpspdid")&"'"
'	Response.Write sql
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHost.Open Sql,conn,1,1
if dsHost.Eof then
	ef=True
	ec="产品不存在！"
end if
end if

if not ef then
if Not IsNull(dsHost("onlyusebyagn")) Then
If session("agentusername")<>dsHost("onlyusebyagn") then
	ef=True
	ec="本产品只允许特定的代理使用！"
End if
end if
end If

'if not ef then
'if dsHost("allowupdate")="y" then
'	ef=True
'	ec="此产品只能直接购买不允许从别的产品升级！"
'end if
'end if

if not ef then
if dsph("istest")="y" then
	ef=True
	ec="处于试用期的产品请您通过延期操作来转成正式产品！"
end if
end If

if not ef then
if dsHost("cancloud")=false then
	ef=True
	ec="弹性购买的产品才能使用本功能"
end if
end If

if not ef then
if not isnull(dsph("repaymoney")) then
	ef=True
	ec="由于此产品被管理员设置了单独的续费价格，因此，请您联系管理员帮您手工升级。"
end if
end if

if not ef then
if dshost("cancloud")=true then'是弹性购买产品'计算增量部分的普通用户情况下的金额
	'PAY_1yearvar=dsHost("usermoney")
'默认最小值addcpuMIN
'当前值addcpuNow
'增量每步addcpuNum
'每步需要钱数addCpuCost
if CInt(Request.Form("CpuValue"))>dsHost("addCpuLim") Then
	ef=True
	ec="CPU超出上限！"
End If
if Clng(Request.Form("RamValue"))>dsHost("addRamLim") Then
	ef=True
	ec="内存超出上限！"
End If
if CInt(Request.Form("VHDValue"))>dsHost("addVHDLim") Then
	ef=True
	ec="虚拟硬盘超出上限！"
End If
if CInt(Request.Form("MbpsValue"))>dsHost("addMbpsLim") Then
	ef=True
	ec="带宽超出上限！"
End If
If dsHost("CDNMaxMb")>0 then
if CInt(Request.Form("NGBValue"))>dsHost("addNGBLim") Then
	ef=True
	ec="流量超出上限！"
End If
End If
If dsHost("MaxIOPS")>0 then
if CInt(Request.Form("IopsValue"))>dsHost("addIOPSLim") Then
	ef=True
	ec="IOPS超出上限！"
End If
End if
if CInt(Request.Form("SNAValue"))>dsHost("addSnaLim") Then
	ef=True
	ec="快照超出上限！"
End If
if CInt(Request.Form("BakValue"))>dsHost("addBakLim") Then
	ef=True
	ec="备份数量超出上限！"
End If
if CInt(Request.Form("IPValue"))>dsHost("addIPLim") Then
	ef=True
	ec="IP数量超出上限！"
End If
if (CInt(Request.Form("CpuValue"))<dsHost("OSLimbyCPU")) Or (Clng(Request.Form("RamValue"))<dsHost("OSLimbyRam")) Then
If InStr(","&dsHost("OSlim"),","&Request.Form("OSAllList")&",")>0 then
	ef=True
	ec="由于内存或CPU限制不能预装这个操作系统！"
End If
End If

Dim cloudAddmoney
cloudAddmoney=0
if (CInt(Request.Form("CpuValue"))>dsHost("CpuNum")) then	cloudAddmoney=cloudAddmoney+((Request.Form("CpuValue")-dsHost("CpuNum"))/dsHost("addCpuNum"))*dsHost("addCpuCost")
if (Clng(Request.Form("RamValue"))>dsHost("MAXRAM")) then	cloudAddmoney=cloudAddmoney+((Request.Form("RamValue")-dsHost("MAXRAM"))/dsHost("addRamNum"))*dsHost("addRamCost")
if (CInt(Request.Form("VHDValue"))>dsHost("Maxspace")) then	cloudAddmoney=cloudAddmoney+((Request.Form("VHDValue")-dsHost("Maxspace"))/dsHost("addVHDNum"))*dsHost("addVHDCost")
if (CInt(Request.Form("MbpsValue"))>dsHost("Maxmbps8")) then	cloudAddmoney=cloudAddmoney+((Request.Form("MbpsValue")-dsHost("Maxmbps8"))/dsHost("addMbpsNum"))*dsHost("addMbpsCost")
If dsHost("CDNMaxMb")>0 then'如果限制流量
if (CInt(Request.Form("NGBValue"))>dsHost("CDNMaxMb")) then	cloudAddmoney=cloudAddmoney+((Request.Form("NGBValue")-dsHost("CDNMaxMb"))/1000/dsHost("addNGBNum"))*dsHost("addNGBCost")
End If
If dsHost("MaxIOPS")>0 then'如果限制IOPS
if (CInt(Request.Form("IopsValue"))>dsHost("MaxIOPS")) then	cloudAddmoney=cloudAddmoney+((Request.Form("IopsValue")-dsHost("MaxIOPS"))/dsHost("addIOPSNum"))*dsHost("addIOPSCost")
End if
if (CInt(Request.Form("SNAValue"))>dsHost("MaxSNA")) then	cloudAddmoney=cloudAddmoney+((Request.Form("SNAValue")-dsHost("MaxSNA"))/dsHost("addSnaNum"))*dsHost("addSnaCost")
if (CInt(Request.Form("BakValue"))>dsHost("MaxBak")) then	cloudAddmoney=cloudAddmoney+((Request.Form("BakValue")-dsHost("MaxBak"))/dsHost("addBakNum"))*dsHost("addBakCost")
if (CInt(Request.Form("IPValue"))>dsHost("MaxIP")) then	cloudAddmoney=cloudAddmoney+((Request.Form("IPValue")-dsHost("MaxIP"))/dsHost("addIpNum"))*dsHost("addIPCost")

cloudAddmoney=Clng(FormatNumber(cloudAddmoney,0,-1,0,0))'四舍五入'弹性购买的基准增量价格
end If
end If

if not ef then
if dshost("cancloud")=true then'是弹性购买产品'计算增量部分的普通用户情况下的金额'原来的增量金额
	'PAY_1yearvar=dsHost("usermoney")
'默认最小值addcpuMIN
'当前值addcpuNow
'增量每步addcpuNum
'每步需要钱数addCpuCost
Dim cloudAddmoneyOld
cloudAddmoneyOld=0
if (dsph("CpuNum")>dsHost("CpuNum")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("CpuNum")-dsHost("CpuNum"))/dsHost("addCpuNum"))*dsHost("addCpuCost")
if (dsph("MAXRAM")>dsHost("MAXRAM")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("MAXRAM")-dsHost("MAXRAM"))/dsHost("addRamNum"))*dsHost("addRamCost")
if (dsph("Maxspace")>dsHost("Maxspace")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("Maxspace")-dsHost("Maxspace"))/dsHost("addVHDNum"))*dsHost("addVHDCost")
if (dsph("Maxmbps8")>dsHost("Maxmbps8")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("Maxmbps8")-dsHost("Maxmbps8"))/dsHost("addMbpsNum"))*dsHost("addMbpsCost")
If dsHost("CDNMaxMb")>0 then'如果限制流量
if (dsph("CDNMaxMb")>dsHost("CDNMaxMb")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("CDNMaxMb")-dsHost("CDNMaxMb"))/1000/dsHost("addNGBNum"))*dsHost("addNGBCost")
End If
If dsHost("MaxIOPS")>0 then'如果限制IOPS
if (dsph("MaxIOPS")>dsHost("MaxIOPS")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("MaxIOPS")-dsHost("MaxIOPS"))/dsHost("addIOPSNum"))*dsHost("addIOPSCost")
End if
if (dsph("MaxSNA")>dsHost("MaxSNA")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("MaxSNA")-dsHost("MaxSNA"))/dsHost("addSnaNum"))*dsHost("addSnaCost")
if (dsph("MaxBak")>dsHost("MaxBak")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("MaxBak")-dsHost("MaxBak"))/dsHost("addBakNum"))*dsHost("addBakCost")
if (dsph("MaxIP")>dsHost("MaxIP")) then	cloudAddmoneyOld=cloudAddmoneyOld+((dsph("MaxIP")-dsHost("MaxIP"))/dsHost("addIpNum"))*dsHost("addIPCost")

cloudAddmoneyOld=Clng(FormatNumber(cloudAddmoneyOld,0,-1,0,0))'四舍五入'原来的增量金额

end If
end If

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
else
    netby=dsserver("netby")
	ip=dsserver("ip")
Dim isAgnHostSer
if dsserver("agent1")="n" then
isAgnHostSer=false
else
isAgnHostSer=true
end if
end if
end If

if not ef then
if dshost("cancloud")=true then'是弹性购买产品
If CInt(Request.Form("IPValue"))>dsph("MaxIP") Then'IP增加
Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select count(*) from FreeHost.FreeHost_Product_VPS_IP where ServerlistID="&dsserver("id")&" and VPSID=0"
		dsVPSip.Open Sql,conn,1,1
If dsVPSip(0)=0 Then
	ef=True
	ec="很抱歉,您选取的服务器的IP资源已用光,管理员尚未分配可用IP,请联系管理员处理."
End If
If dsVPSip(0)<CInt(Request.Form ("IPValue")) Then
	ef=True
	ec="很抱歉,您选取的服务器的IP资源已用光,请联系管理员处理."'&Request.Form ("IPValue")&dsVPSip(0)
End If
End If
End If
End if

if not ef Then
daytoend=DateDiff("d",NOW,dsph("endtime"))
if daytoend<0 Then
	ef=True
	ec="您原来的产品已过期了，请您先延期原产品后才能升级。"
End If
End If

if not ef Then
oldusermoneytake=Clng(FormatNumber((cloudAddmoney-cloudAddmoneyOld)/365*daytoend,0,-1,0,0))'四舍五入'原来的增量金额
if session("AgnRunasUser") Then oldusermoneytake=0'代理自己登陆用户区操作自己用户角色为0
if oldusermoneytake>ds("usermoney") then'检查用户角色上是否有足够的钱
	ef=True
	ec="很抱歉,您的余额不足！升级产品所需金额为:"&oldusermoneytake&"元，当前您的余额为："&ds("usermoney")&"元"
End If
If oldusermoneytake<0 Then
	ef=True
	ec="很抱歉,负数出错A！"
end If
'Response.write oldusermoneytake&"AAA<br>"
'Response.end 
End If



if not ef then
if ds("agent1")<>"n" then

if not ef then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&ds("agent1")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsagent.Open Sql,conn,1,3
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
end if
end if

if not ef then
	Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"& dsagent("agenttype")&"'"
		dsagnettype.Open Sql,conn,1,1
if dsagnettype.Eof then
	ef=True
	ec="代理类型折扣为空，请先设置它！"
end if
end if

if not ef then
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='云服务器产品' and username='"&ds("agent1")&"' and id="&dsHost("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
myrealcost=dsHost("usermoney")*dsagnettype("pers")
else
myrealcost=dsagnpri("usermoney")
end if
dsagnpri.close

	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='云服务器产品' and username='"&ds("agent1")&"' and id="&dsHost("id")&""
		dsendmoney.Open Sql,conn,1,1
if dsendmoney.eof then
usermoney=dsHost("usermoney")
else
usermoney=dsendmoney("usermoney")
end if
dsendmoney.close
end if
end if
end if

if not ef then
if ds("agent1")<>"n" then
defaultMoneyYearvarSTD=dsHost("usermoney")
oldAgentrmoneytake=Clng(FormatNumber((((cloudAddmoney-cloudAddmoneyOld)*(myrealcost/defaultMoneyYearvarSTD))/365*daytoend),0,-1,0,0))'四舍五入
'代理的升级成本价=(新增量代理成本价 - 旧增量代理成本售价)/365 x未到期天数) 
'增量代理成本价=(增量基准价　X　比例[比例的算法是代理年付成本除以普通用户年付标准价] ) 
If dsagent("usermoney")<oldAgentrmoneytake Then
	ef=True
	ec="很抱歉,上级的余额不足！"
end If
If oldAgentrmoneytake<0 Then
	ef=True
	ec="很抱歉,负数出错！"
end If
end If
end If

if not ef Then
if ds("agent1")<>"n" then'代理自己所需成本检查
'oldAgentrmoneytake=round(oldAgentrmoneytake,2)'处理格式
oldAgentrmoneytake=round(oldAgentrmoneytake,0)'处理格式
if oldAgentrmoneytake-oldusermoneytake>dsagent("usermoney") then
	ef=True
	ec="很抱歉,上级余额不足！升级产品所需金额为:"&oldAgentrmoneytake-oldusermoneytake&"元，可操作的余额为："&dsagent("usermoney")&"元"
End If
End If
End If

'用户升级需要支付的金额=(新配置代理公开售价/365 x未到期天数) - (旧配置代理公开售价/365 x未到期天数) 
'代理的升级成本价=(新配置代理成本价/365 x未到期天数) - (旧新配置代理成本售价/365 x未到期天数)
'Response.write oldusermoneytake&"<br>"
'Response.write oldAgentrmoneytake
'Response.end
'如果是折扣代理，成本----就按代理成本价扣百份比(cloudAddmoney-OLDcloudAddmoney)*(1-九折0.9)
'如果不是折扣代理，成本----就按代理成本价扣百份比(cloudAddmoney-OLDcloudAddmoney)*(1-九折0.9)



if not ef Then'处理手工设置扣费的情况
If dsph("username")<>dsph("agent1") Then
If Request.Form ("chmoney")<>"" And IsNumeric(Request.Form ("usermoney")) Then
If Request.Form ("usermoney")>=0 then
oldusermoneytake=Request.Form ("usermoney")
agenthandmoney=true
End if
End If
End If
End if

if not ef Then'处理手工设置扣费的情况
If dsph("username")=dsph("agent1") Then
oldusermoneytake=0'代理操作自己的独立模式的虚拟主机
End If
End If

if not ef Then
'oldusermoneytake=round(oldusermoneytake,2)'处理格式
oldusermoneytake=round(oldusermoneytake,0)'处理格式
if oldusermoneytake>ds("usermoney") then'检查用户角色上是否有足够的钱
	ef=True
	ec="很抱歉,用户的余额不足！升级产品所需金额为:"&oldusermoneytake&"元，当前用户的余额为："&ds("usermoney")&"元"
End If
End If

if not ef Then
if ds("agent1")<>"n" then'代理自己所需成本检查
'oldAgentrmoneytake=round(oldAgentrmoneytake,2)'处理格式
oldAgentrmoneytake=round(oldAgentrmoneytake,0)'处理格式
if oldAgentrmoneytake-oldusermoneytake>dsagent("usermoney") then
	ef=True
	ec="很抱歉,代理您的余额不足！升级产品所需金额为:"&oldAgentrmoneytake-oldusermoneytake&"元，可操作的余额为："&dsagent("usermoney")&"元"
End If
End If
End if

if not ef then


'开始扣费
olduser_money=ds("usermoney")
ds("usermoney") =ds("usermoney") -oldusermoneytake
newuser_money=ds("usermoney")
moneych=oldusermoneytake
ds.update'扣用户角色费用

if ds("agent1")<>"n" then
oldagn_money=dsagent("usermoney")
dsagent("usermoney")=dsagent("usermoney")-oldAgentrmoneytake+oldusermoneytake
mymoneych=-oldAgentrmoneytake+oldusermoneytake
newagn_money=dsagent("usermoney")
dsagent.update
'response.write "新产品价格："&usermoney&" 旧产品价格："&oldusermoney&" 用户原："&ds("usermoney")&" 代理成本折算旧："&oldRmoney&" 用户折算旧："&oldmoney&" tem："&(usermoney-oldmoney)&" tem2："&(myrealcost-oldRmoney)
'response.end
end if








'dsph("useper")=100

'response.write dsph("subweb") 
'response.end
starttime=dsph ("endtime")
temptime=dsph ("endtime")


dim starttime,temptime,pdtype
pdtype="弹性产品类型不变："&dsph ("VPStype")

'更新产品类别
dsph ("VPStype")=dsHost("VPStype")

dsph("MAXCPU")=dsHost("MAXCPU")
dsph("CpuNum")=dsHost("CpuNum")
dsph("MAXRam")=dsHost("MAXRam")
dsph("StartRam")=dsHost("StartRam")
dsph("Maxmbps8")=dsHost("Maxmbps8")
dsph("Minmbps8")=dsHost("Minmbps8")

dsph("MAXspace")=dsHost("MAXspace")

dsph("allowdomain")=dsHost("allowdomain")
dsph("CDNMaxMb")=dsHost("CDNMaxMb")



dsph.update
logfor="(AG)升级云服务器产品"
if isAgnHostSer then logfor="(AG)升级云服务器产品独立模式"
If agenthandmoney=True Then logfor=logfor&"(AG)手工指定扣费"&Request.Form ("usermoney")&"元"

FreeHost_moneyNewlog conn,"y","n","n","n","n",isAgnHostSer,moneych,dsph ("username"),dsph ("agent1"),dsph ("username"),olduser_money,newuser_money,agnusername,agnStmoney,agnEndmoney,supusername,logfor,logfor,"云服务器产品",dsph("id"),pingzheng,type1,bank,haveget,havecheck

if newagn_money-oldagn_money>=0  Then
FreeHost_moneyNewlog conn,"n","y","n","n","y",isAgnHostSer,mymoneych,dsph ("agent1"),dsph ("agent1"),norusername,norStmoney,norEndmoney,dsph ("agent1"),oldagn_money,newagn_money,supusername,logfor&"代理收入",logfor&"代理收入","云服务器产品",dsph("id"),pingzheng,type1,bank,haveget,havecheck
Else
FreeHost_moneyNewlog conn,"n","y","n","n","n",isAgnHostSer,-mymoneych,dsph ("agent1"),dsph ("agent1"),norusername,norStmoney,norEndmoney,dsph ("agent1"),oldagn_money,newagn_money,supusername,logfor&"代理扣费",logfor&"代理扣费","云服务器产品",dsph("id"),pingzheng,type1,bank,haveget,havecheck
End if


URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
vpsname=dsph ("vpsname")
username=dsph ("username")
homedir=dsserver("homedir")
starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("VPStype")

MAXcpu=dsph("MAXCPU")
CpuNum=dsph("CpuNum")
MAXRam=dsph("MAXRam")
StartRam=dsph("StartRam")
Maxmbps8=dsph("Maxmbps8")
Minmbps8=dsph("Minmbps8")

MAXspace=dsph("MAXspace")
vhdpath=dsph("vhdpath")

if dshost("cancloud")=true then'是弹性购买产品
if Not dshost("isagentpd")=true Then
If CInt(Request.Form("IPValue"))>dsph("MaxIP") Then'IP增加2015
ipcount=0
haveaddnewip=true
Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ServerlistID="&dsserver("id")&" and VPSID=0  and ipbyid=0 order by orderbyid desc"
		dsVPSip.Open Sql,conn,1,3
While Not dsVPSip.Eof
'Response.write dsVPSip("VPSID")&":vpsidA<br>"
If ipcount<((CInt(Request.Form("IPValue"))-dsph("MaxIP"))) then'如果选中2014
'Response.write ipcount&"<br>"
dsVPSip("VPSID")=dsph("id")
ipcount=ipcount+1
dsVPSip.update
End If
dsVPSip.movenext
Wend
End If
End If
dsph("Cpunum")=Request.Form("CpuValue")
dsph("MaxRAM")=Request.Form("RamValue")
dsph("MaxSpace")=Request.Form("VHDValue")
dsph("Maxmbps8")=Request.Form("MbpsValue")
dsph("MaxSNA")=Request.Form("SNAValue")
dsph("MaxBak")=Request.Form("BakValue")
dsph("MaxIP")=Request.Form("IPValue")
If dsHost("MaxIOPS")>0 And Request.Form("IopsValue")>0 Then dsph("MaxIOPS2")=Request.Form("IopsValue")'只限制第二硬盘速度'就算用户选不限制产品默认值更优先
If dsHost("CDNMaxMb")>0 Then dsph("CDNMaxMb")=Request.Form("NGBValue")*1000
dsph("FirstOSid")=Request.Form("OSAllList")
dsph.update
end if

MaxIOPS=dsph("MaxIOPS")
MaxIOPS2=dsph("MaxIOPS2")

varcon="modi "&username&" "&vpsname&" "&CpuNum&" "&MAXcpu&" "&MAXRam&" "&MAXspace&" "&vhdpath&" "&StartRam
If dsserver("OStype")="Windows Server 2012" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024
If dsserver("OStype")="Windows Server 2012R2" Or dsserver("OStype")="Windows Server 2016" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024&" "&dsserver("SwitchName")&" "&StartRam&" "&Replace(vhdpath,".vhd","-2.vhd")&" 10 "&(MAXspace-10)&" defaultClusterNameby7i24 "&MaxIOPS&" "&MaxIOPS2&" "&dsHost("NetCardlimtype")
If dsserver("IsCluster")=true Then varcon=Replace(varcon,"defaultClusterNameby7i24",dsserver("ClusterName"))
'modi test 1 10 1024 90 c:\vps\hjkhjh.vhd 
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now

'Response.Write varcon
'Response.Write temp

FreeHost_oplog session("username"),"信息","用户自己升级，云服务器名:"&vpsname&" 返回信息："&temp

%>
<!--#include virtual="/inc-freehost-function/template-vpsadm-top.asp"-->
　云服务器产品升级

<br>
<br>
<table width="65%"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
  <tr align="center" bordercolor="#000000" bgcolor="#999999">
    <td height="39" colspan="4"><font color="#000000">　　　</font><font color="#990000"><font color="#FF0000">升级成功，以下是您的资料：</font></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td width="44%" height="30"><font color="#000000"> 　　　 此用户的原金额：</font></td>
    <td width="56%" colspan="3"><%=FormatNumber(olduser_money,2,-1,-1,0)%> 元</td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="41"><font color="#000000">　　　 此用户的金额变化：</font></td>
    <td colspan="3"><font color=red><%=-moneych%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="39"><font color="#000000">　　　 此用户的新金额：</font></td>
    <td colspan="3"><font color="#000000"><%=FormatNumber(newuser_money,2,-1,-1,0)%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="39"><font color="#000000">　　　 我的原金额：</font></td>
    <td colspan="3"><font color="#000000"><%=oldagn_money%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="39"><font color="#000000">　　　 我的金额变化：</font></td>
    <td colspan="3"><font color=red><%=mymoneych%></font><font color="#000000"> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="39"><font color="#000000">　　　 我的新金额：</font></td>
    <td colspan="3"><font color="#000000"><%=newagn_money%> 元</font></td>
  </tr>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000"> 　　　 到期时间是:</font></td>
    <td colspan="3" bgcolor="#eeeeee"><%=temptime%></td>
  </tr>
<%If haveaddnewip=True then%>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000"> 　　　 您购买了新的IP，<br>
 　　　 请您自行在网卡中绑定</font></td>
    <td height="37" bgcolor="#eeeeee">
      <%
	if dsph("isagentpd")=true then%>
      <%if not isnull(dsph("AgnUpIP")) then%>
      <%=replace(dsph("AgnUpIP"),"|","<br>")%>
      <%end if%>
      <%
	else
	Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsph("id")
		dsX.Open Sql,conn,1,1
while not dsX.eof
%>
      <%=dsX("IP")%> <br>
      <%
if dsX("portstart")>0 then

Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
isONEip=dsserver("isONEip")	

if isONEip=true then
	Set dsPORTserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerPORTlist where id='"&dsserver("useportserver")&"'"
		dsPORTserver.Open Sql,conn,1,1%>
      <%=dsPORTserver("IP")%>(公网)<br>
      <%end if	

end if
dsX.movenext
wend
end if
%></td>
  </tr>
<%End if%>
  <tr bordercolor="#000000" bgcolor="#eeeeee">
    <td colspan="4"><font color="#000000">　　　</font><font color="#000000">　　　</font><font color="#000000">　</font><font color="#000000">　　　</font><font color="#000000">　　　</font><font color="#000000"> 　　　</font> 　</td>
  </tr>
</table>
<br>
<br>
<!--#include virtual="/inc-freehost-function/template-vpsadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>