<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =2400
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("VPStype")=""  or Instr(Request.Form ("VPStype"), "'")>1  Then
	ef=True
	ec="产品名没填！"
ElseIf Request.Form ("ServerlistID")="" And Request.Form ("isagentpd")="" Then
	ef=True
	ec="所在服务器没填！"
ElseIf Request.Form ("maxram")="" Then
	ef=True
	ec="内存上限没填！"
ElseIf not IsNumeric(Request.Form ("maxram"))  Then
	ef=True
	ec="内存上限应该是数字！"

ElseIf Request.Form ("isagentpd")="1" And not IsNumeric(Request.Form ("Agnidc"))  Then
	ef=True
	ec="上级代理服务器ID应该是数字！"
ElseIf Request.Form ("isagentpd")="1" And not IsNumeric(Request.Form ("Agnproductid"))  Then
	ef=True
	ec="上级代理产品ID应该是数字！"
ElseIf Request.Form ("isagentpd")="1" And Request.Form ("VPSApiName")=""  Then
	ef=True
	ec="上级代理API域名不能为空！"
ElseIf Request.Form ("isagentpd")="1" And Request.Form ("VPScpdomain")=""  Then
	ef=True
	ec="上级代理面板域名不能为空！"
ElseIf Request.Form ("isagentpd")="1" And Request.Form ("Agnuserid")=""  Then
	ef=True
	ec="上级代理名不能为空！"
ElseIf Request.Form ("isagentpd")="1" And Request.Form ("Domain_Agent_nonemd5_6")=""  Then
	ef=True
	ec="上级代理密码不能为空！"



ElseIf Request.Form ("maxram")<256  Then
	ef=True
	ec="内存上限不能小于256M！"
ElseIf Request.Form ("maxcpu")="" Then
	ef=True
	ec="cpu上限没填！"
ElseIf not IsNumeric(Request.Form ("maxcpu"))  Then
	ef=True
	ec="cpu上限应该是数字！"
ElseIf Request.Form ("maxcpu")<1  Then
	ef=True
	ec="cpu上限不能小于1！"
ElseIf Not (Request.Form ("cpunum")=1 Or Request.Form ("cpunum")=2 Or Request.Form ("cpunum")=4 Or Request.Form ("cpunum")=8 Or Request.Form ("cpunum")=16) Then
	ef=True
	ec="cpu数量请设置为1或者2或者4或者8或者16"
ElseIf Request.Form ("maxspace")="" Then
	ef=True
	ec="空间大小限制没填！"
ElseIf not IsNumeric(Request.Form ("maxspace"))  Then
	ef=True
	ec="空间上限应该是数字！"
ElseIf Request.Form ("maxspace")<11  Then
	ef=True
	ec="空间上限不能小于11G！"
ElseIf Request.Form ("usermoney")="" Then
	ef=True
	ec="金额没填！"
ElseIf not IsNumeric(Request.Form ("usermoney"))  Then
	ef=True
	ec="金额应该是数字！"

ElseIf Request.Form ("PAY_Day")="" Then
	ef=True
	ec="日付没填！"
ElseIf not IsNumeric(Request.Form ("PAY_Day"))  Then
	ef=True
	ec="日付应该是数字！"

ElseIf Request.Form ("PAY_WeeK")="" Then
	ef=True
	ec="周付没填！"
ElseIf not IsNumeric(Request.Form ("PAY_WeeK"))  Then
	ef=True
	ec="周付应该是数字！"

ElseIf Request.Form ("PAY_Month")="" Then
	ef=True
	ec="月付没填！"
ElseIf not IsNumeric(Request.Form ("PAY_Month"))  Then
	ef=True
	ec="月付应该是数字！"
ElseIf Request.Form ("PAY_Season")="" Then
	ef=True
	ec="季付没填！"
ElseIf not IsNumeric(Request.Form ("PAY_Season"))  Then
	ef=True
	ec="季付应该是数字！"
ElseIf Request.Form ("PAY_halfyear")="" Then
	ef=True
	ec="半年付没填！"
ElseIf not IsNumeric(Request.Form ("PAY_halfyear"))  Then
	ef=True
	ec="半年付应该是数字！"
ElseIf Request.Form ("PAY_Nextyear")="" Then
	ef=True
	ec="续费没填！"
ElseIf not IsNumeric(Request.Form ("PAY_Nextyear"))  Then
	ef=True
	ec="续费应该是数字！"
ElseIf Request.Form ("PAY_2year")="" Then
	ef=True
	ec="二年付费率没填！"
ElseIf not IsNumeric(Request.Form ("PAY_2year"))  Then
	ef=True
	ec="二年付费率应该是数字！"
ElseIf Request.Form ("PAY_3year")="" Then
	ef=True
	ec="三年付费率没填！"
ElseIf not IsNumeric(Request.Form ("PAY_3year"))  Then
	ef=True
	ec="三年付费率应该是数字！"
ElseIf Request.Form ("PAY_4year")="" Then
	ef=True
	ec="四年付费率没填！"
ElseIf not IsNumeric(Request.Form ("PAY_4year"))  Then
	ef=True
	ec="四年付费率应该是数字！"
ElseIf Request.Form ("PAY_5year")="" Then
	ef=True
	ec="五年付费率没填！"
ElseIf not IsNumeric(Request.Form ("PAY_5year"))  Then
	ef=True
	ec="五年付费率应该是数字！"
elseIf session("cansetpro")="" Then
	ef=True
	ec="您没有此操作的权限。"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&Request.Form ("VPStype")&"'"
		ds.Open Sql,conn,1,3
if not ds.Eof and Request.Form ("modify")<>"修改" and Request.Form ("delit")<>"删除" then
	ef=True
	ec="已存在同名的产品！"
end if

if Request.Form ("modify")="修改" and ds.Eof then
	ef=True
	ec="没找到要修改的产品！"
end if

if Request.Form ("delit")="删除" and not ds.Eof then
Set dsph = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Product_VPS where VPStype='"&Request.Form ("VPStype")&"'"
	dsph.Open Sql,conn,1,1
if not dsph.Eof then
	ef=True
	ec="此产品已有开通的用户，只能修改，不能删除！"
end if
dsph.close
set dsph=nothing
end if


if not ef then
if Request.Form ("delit")<>"删除" then
if Request.Form ("modify")<>"修改" then ds.addnew
ds("VPStype")=Request.Form("VPStype")
ds("usermoney")=Request.Form("usermoney")
ds("ServerlistID")=Request.Form("ServerlistID")
ds("info")=Request.Form("info")
ds("infomore")=Request.Form("infomore")

if Request.Form("caninstallos")="y" then
ds("caninstallos")="y"
else
ds("caninstallos")="n"
end if

if Request.Form("canbackupvhd")="y" then
ds("canbackupvhd")="y"
else
ds("canbackupvhd")="n"
end if

if Request.Form("cantest")="y" then
ds("cantest")="y"
else
ds("cantest")="n"
end if
if Request.Form("canday")="y" then
ds("canday")="y"
else
ds("canday")="n"
end If
if Request.Form("canweek")="y" then
ds("canweek")="y"
else
ds("canweek")="n"
end if

if Request.Form("canmonth")="y" then
ds("canmonth")="y"
else
ds("canmonth")="n"
end if

if Request.Form("canseason")="y" then
ds("canseason")="y"
else
ds("canseason")="n"
end if

if Request.Form("canhalfyear")="y" then
ds("canhalfyear")="y"
else
ds("canhalfyear")="n"
end if

if Request.Form("canbyenduser")="y" then
ds("canbyenduser")="y"
else
ds("canbyenduser")="n"
end if
if Request.Form("canbyagnenduser")="y" then
ds("canbyagnenduser")="y"
else
ds("canbyagnenduser")="n"
end if
if Request.Form("canbyagn")="y" then
ds("canbyagn")="y"
else
ds("canbyagn")="n"
end if

if  IsNumeric(Request.Form("orderbyid")) then
ds("orderbyid")=Request.Form("orderbyid")
else
ds("orderbyid")=0
end if

if  IsNumeric(Request.Form("typeid")) then
ds("typeid")=Request.Form("typeid")
else
ds("typeid")=0
end If

if Request.Form("autoselect")="y" then
ds("autoselect")=1
else
ds("autoselect")=0
end If

if  IsNumeric(Request.Form("Servertypeid")) then
ds("Servertypeid")=Request.Form("Servertypeid")
else
ds("Servertypeid")=0
end if

if Request.Form("allowupdate")="y" then
ds("allowupdate")="y"
else
ds("allowupdate")="n"
end if

if Request.Form("allowupdatetoother")="y" then
ds("allowupdatetoother")="y"
else
ds("allowupdatetoother")="n"
end if

ds("canSNAEN")=Request.Form ("canSNAEN")
ds("canSNAST")=Request.Form ("canSNAST")

ds("MaxIOPS")=Request.Form ("MaxIOPS")
ds("MaxIOPS2")=Request.Form ("MaxIOPS2")
ds("OSLimbyRam")=Request.Form ("OSLimbyRam")
ds("OSLimbyCPU")=Request.Form ("OSLimbyCPU")
ds("OSlim")=Request.Form ("OSlim")
ds("addCpuNum")=Request.Form ("addCpuNum")
ds("addCpuCost")=Request.Form ("addCpuCost")
ds("addCpuLim")=Request.Form ("addCpuLim")
ds("addRamNum")=Request.Form ("addRamNum")
ds("addRamCost")=Request.Form ("addRamCost")
ds("addRamLim")=Request.Form ("addRamLim")
ds("addVHDNum")=Request.Form ("addVHDNum")
ds("addVHDCost")=Request.Form ("addVHDCost")
ds("addVHDLim")=Request.Form ("addVHDLim")
ds("addMbpsNum")=Request.Form ("addMbpsNum")
ds("addMbpsCost")=Request.Form ("addMbpsCost")
ds("addMbpsLim")=Request.Form ("addMbpsLim")
ds("addNGBNum")=Request.Form ("addNGBNum")
ds("addNGBCost")=Request.Form ("addNGBCost")
ds("addNGBLim")=Request.Form ("addNGBLim")
ds("addIPNum")=Request.Form ("addIPNum")
ds("addIPCost")=Request.Form ("addIPCost")
ds("addIPLim")=Request.Form ("addIPLim")
ds("addSNANum")=Request.Form ("addSNANum")
ds("addSNACost")=Request.Form ("addSNACost")
ds("addSNALim")=Request.Form ("addSNALim")
ds("addBakNum")=Request.Form ("addBakNum")
ds("addBakCost")=Request.Form ("addBakCost")
ds("addBakLim")=Request.Form ("addBakLim")
ds("addIopsNum")=Request.Form ("addIopsNum")
ds("addIopsCost")=Request.Form ("addIopsCost")
ds("addIopsLim")=Request.Form ("addIopsLim")

If ds("MaxIOPS")=0 Then ds("addIopsLim")=0
If ds("CDNMaxMb")=0 Then ds("addNGBLim")=0

ds("MaxSNA")=Request.Form ("MaxSNA")
ds("MaxBak")=Request.Form ("MaxBak")
ds("MaxIP")=Request.Form ("MaxIP")


ds("MaxCPU")=Request.Form ("MaxCPU")
ds("Maxspace")=Request.Form ("Maxspace")
ds("Maxram")=Request.Form ("Maxram")
ds("CPUNum")=Request.Form ("CPUNum")
ds("allowdomain")=Request.Form ("allowdomain")
ds("CDNMaxMb")=Request.Form ("CDNMaxMb")
ds("StartRam")=Request.Form ("StartRam")

ds("isagentpd")=Request.Form ("isagentpd")

if Request.Form("canUseISO")="" then
ds("canUseISO")=false
else
ds("canUseISO")=true
end If

if Request.Form("canUseConsol")="" then
ds("canUseConsol")=false
else
ds("canUseConsol")=true
end If

if Request.Form("canUseTool")="" then
ds("canUseTool")=false
else
ds("canUseTool")=true
end If

if Request.Form("cancloud")="" then
ds("cancloud")=false
else
ds("cancloud")=true
end If

if Request.Form("ISOlim")="" then
ds("ISOlim")=NULL
Else
ds("ISOlim")=Trim(Request.Form ("ISOlim"))
End if

if Request.Form("canADSL")="" then
ds("canADSL")=false
else
ds("canADSL")=true
end If

if  IsNumeric(Request.Form("VLANid")) then
ds("VLANid")=Request.Form("VLANid")
else
ds("VLANid")=0
end If

ds("NetCardlimtype")=Request.Form("NetCardlimtype")
'Response.write Request.Form("NetCardlimtype")
'Response.end
If ds("isagentpd")=true Then 
ds("ServerlistID")=0
ds("OSLimbyCPU")=1
ds("VPSComName")=Request.Form ("VPSComName")
ds("VPSApiName")=Replace(replace(lcase(trim(Request.Form ("VPSApiName"))),"http://",""),"/hostadm/","")
ds("VPScpdomain")=Replace(replace(lcase(trim(Request.Form ("VPScpdomain"))),"http://",""),"/hostadm/","")
ds("Agnuserid")=Request.Form ("Agnuserid")
ds("Domain_Agent_nonemd5_6")=Request.Form ("Domain_Agent_nonemd5_6")
ds("Agnidc")=Request.Form ("Agnidc")
ds("Agnproductid")=Request.Form ("Agnproductid")






Set dsph = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Product_VPS where VPStype='"&ds ("VPStype")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
dsph("isagentpd")=ds("isagentpd")
dsph("VPSComName")=ds("VPSComName")
dsph("VPSApiName")=ds("VPSApiName")
dsph("VPScpdomain")=ds("VPScpdomain")
dsph("Agnuserid")=ds("Agnuserid")
dsph("Domain_Agent_nonemd5_6")=ds("Domain_Agent_nonemd5_6")
dsph("Agnidc")=ds("Agnidc")
dsph("Agnproductid")=ds("Agnproductid")
dsph.update
dsph.movenext
wend
dsph.close
set dsph=Nothing
Else
ds("isagentpd")=false
End if

If Request.Form ("Maxmbps8")>0 then
ds("Maxmbps8")=Fix(Request.Form ("Maxmbps8"))

If ds("Maxmbps8")>1 Then
ds("Minmbps8")=Fix(ds("Maxmbps8")/2)
Else
ds("Minmbps8")=1
End If
End if



if Request.Form("updatebytypeid")="y" then
ds("updatebytypeid")="y"
else
ds("updatebytypeid")="n"
end if






if  IsNumeric(Request.Form("ServerlistID2")) then ds("ServerlistID2")=Request.Form("ServerlistID2")
if  IsNumeric(Request.Form("ServerlistID3")) then ds("ServerlistID3")=Request.Form("ServerlistID3")
if  IsNumeric(Request.Form("ServerlistID4")) then ds("ServerlistID4")=Request.Form("ServerlistID4")
if  IsNumeric(Request.Form("ServerlistID5")) then ds("ServerlistID5")=Request.Form("ServerlistID5")

If Request.Form("ServerlistID")="" Then ds("ServerlistID")=0
If Request.Form("ServerlistID2")="" Then ds("ServerlistID2")=0
If Request.Form("ServerlistID3")="" Then ds("ServerlistID3")=0
If Request.Form("ServerlistID4")="" Then ds("ServerlistID4")=0
If Request.Form("ServerlistID5")="" Then ds("ServerlistID5")=0

If ds("isagentpd")=true Then 
ds("ServerlistID")=0
ds("ServerlistID2")=0
ds("ServerlistID3")=0
ds("ServerlistID4")=0
ds("ServerlistID5")=0
End if

ds("PAY_Day")=Request.Form("PAY_Day")
ds("PAY_WeeK")=Request.Form("PAY_WeeK")

ds("PAY_Month")=Request.Form("PAY_Month")
ds("PAY_Season")=Request.Form("PAY_Season")
ds("PAY_halfyear")=Request.Form("PAY_halfyear")
ds("PAY_Nextyear")=Request.Form("PAY_Nextyear")
ds("PAY_2year")=Request.Form("PAY_2year")
ds("PAY_3year")=Request.Form("PAY_3year")
ds("PAY_4year")=Request.Form("PAY_4year")
ds("PAY_5year")=Request.Form("PAY_5year")

If Trim(Request.Form("onlyusebyagn"))<>"" then
ds("onlyusebyagn")=Request.Form("onlyusebyagn")
Else
ds("onlyusebyagn")=null
End If


ds.Update



else
ds.delete
end if
ds.Update

ds.Close
set ds=nothing
conn.Close 
set conn=nothing
Response.Redirect "product-vps.asp"
end if

end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>