<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("servername")="" or Instr(Request.Form ("servername"), "'")>1 Then
	ef=True
	ec="服务器名没填或有非法字符！"
ElseIf Request.Form ("site")="" Then
	ef=True
	ec="受控网址没填！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
elseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("FreeHostsharekey")) Then
	ef=True
	ec="共享密码不能有特殊字符！"
elseIf session("cansetserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
elseIf Request.Form ("FreeHostsharekey")="" 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_ServerVPSlist where id='"&Request("id")&"'"
		ds.Open Sql,conn,1,3
if not ds.Eof and Request.Form ("Submit")<>"修改" and Request.Form ("delit")<>"删除" then
	ef=True
	ec="没找到要修改的服务器！"
end if

if not ef then
if Request.Form ("delit")="删除" then
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where ServerlistID='"&ds ("id")&"'"
	dsph.Open Sql,conn,1,3
if not dsph.Eof then
	ef=True
	ec="还有云服务器产品正在使用此服务器，因此不能删除，如果您的服务器损坏了，可以将受控网址改到正常服务器，就可以重开这些网站！"
end if

	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where ServerlistID='"&ds("id")&"'"
	dshost.Open Sql,conn,1,1
if not dshost.Eof then
	ef=True
	ec="还有VPS的[产品定义]正在使用此服务器，因此不能删除，如果您的服务器损坏了，可以将受控网址改到正常服务器，就可以重开这些VPS！产品名："&dshost("VPStype")
end if
end if
end if

if not ef then

if Request.Form ("delit")<>"删除" then
if Request.Form ("Submit")<>"修改" then
ds.AddNew 
ds("agent1")="n"
ds("agent2")="n"
end if
ds("servername")=trim(request.Form ("servername"))
ds("site")=trim(request.Form ("site"))
ds("site")="http://"&replace(ds("site"),"http://","")

'ds("CpuNum")=trim(request.Form ("CpuNum"))

ds("isONEip")=request.Form ("isONEip")
ds("usecdn1")=request.Form ("usecdn1")
If ds("isONEip")=True And ds("usecdn1")=0 Then ds("isONEip")=0

If ds("isONEip")=False Then ds("useportserver")=0

ds("homedir")=LCase(trim(request.Form ("homedir")))
ds("MAXRAM")=request.Form ("MAXRAM")
ds("MaxCPU")=request.Form ("MaxCPU")
ds("MAXSPACE")=request.Form ("MAXSPACE")
ds("MAXVPS")=request.Form ("MAXVPS")

ds("osname1")=trim(request.Form ("osname1"))
ds("osfile1")=trim(request.Form ("osfile1"))
ds("osname2")=trim(request.Form ("osname2"))
ds("osfile2")=trim(request.Form ("osfile2"))
ds("osname3")=trim(request.Form ("osname3"))
ds("osfile3")=trim(request.Form ("osfile3"))
ds("osname4")=trim(request.Form ("osname4"))
ds("osfile4")=trim(request.Form ("osfile4"))

ds("osname5")=trim(request.Form ("osname5"))
ds("osfile5")=trim(request.Form ("osfile5"))
ds("osname6")=trim(request.Form ("osname6"))
ds("osfile6")=trim(request.Form ("osfile6"))
ds("osname7")=trim(request.Form ("osname7"))
ds("osfile7")=trim(request.Form ("osfile7"))
ds("osname8")=trim(request.Form ("osname8"))
ds("osfile8")=trim(request.Form ("osfile8"))

ds("osname9")=trim(request.Form ("osname9"))
ds("osfile9")=trim(request.Form ("osfile9"))
ds("osname10")=trim(request.Form ("osname10"))
ds("osfile10")=trim(request.Form ("osfile10"))
ds("osname11")=trim(request.Form ("osname11"))
ds("osfile11")=trim(request.Form ("osfile11"))
ds("osname12")=trim(request.Form ("osname12"))
ds("osfile12")=trim(request.Form ("osfile12"))
ds("osname13")=trim(request.Form ("osname13"))
ds("osfile13")=trim(request.Form ("osfile13"))
ds("osname14")=trim(request.Form ("osname14"))
ds("osfile14")=trim(request.Form ("osfile14"))
ds("osname15")=trim(request.Form ("osname15"))
ds("osfile15")=trim(request.Form ("osfile15"))
ds("osname16")=trim(request.Form ("osname16"))
ds("osfile16")=trim(request.Form ("osfile16"))

ds("osname17")=trim(request.Form ("osname17"))
ds("osfile17")=trim(request.Form ("osfile17"))
ds("osname18")=trim(request.Form ("osname18"))
ds("osfile18")=trim(request.Form ("osfile18"))
ds("osname19")=trim(request.Form ("osname19"))
ds("osfile19")=trim(request.Form ("osfile19"))
ds("osname20")=trim(request.Form ("osname20"))
ds("osfile20")=trim(request.Form ("osfile20"))
ds("osname21")=trim(request.Form ("osname21"))
ds("osfile21")=trim(request.Form ("osfile21"))
ds("osname22")=trim(request.Form ("osname22"))
ds("osfile22")=trim(request.Form ("osfile22"))
ds("osname23")=trim(request.Form ("osname23"))
ds("osfile23")=trim(request.Form ("osfile23"))
ds("osname24")=trim(request.Form ("osname24"))
ds("osfile24")=trim(request.Form ("osfile24"))
ds("osname25")=trim(request.Form ("osname25"))
ds("osfile25")=trim(request.Form ("osfile25"))


ds("osnametype1")=request.Form ("osnametype1")
ds("osnametype2")=request.Form ("osnametype2")
ds("osnametype3")=request.Form ("osnametype3")
ds("osnametype4")=request.Form ("osnametype4")
ds("osnametype5")=request.Form ("osnametype5")
ds("osnametype6")=request.Form ("osnametype6")
ds("osnametype7")=request.Form ("osnametype7")
ds("osnametype8")=request.Form ("osnametype8")
ds("osnametype9")=request.Form ("osnametype9")
ds("osnametype10")=request.Form ("osnametype10")
ds("osnametype11")=request.Form ("osnametype11")
ds("osnametype12")=request.Form ("osnametype12")
ds("osnametype13")=request.Form ("osnametype13")
ds("osnametype14")=request.Form ("osnametype14")
ds("osnametype15")=request.Form ("osnametype15")
ds("osnametype16")=request.Form ("osnametype16")

ds("osnametype17")=request.Form ("osnametype17")
ds("osnametype18")=request.Form ("osnametype18")
ds("osnametype19")=request.Form ("osnametype19")
ds("osnametype20")=request.Form ("osnametype20")
ds("osnametype21")=request.Form ("osnametype21")
ds("osnametype22")=request.Form ("osnametype22")
ds("osnametype23")=request.Form ("osnametype23")
ds("osnametype24")=request.Form ("osnametype24")
ds("osnametype25")=request.Form ("osnametype25")

If trim(request.Form ("osfile1"))="" Then ds("osfile1")=Null
If trim(request.Form ("osfile2"))="" Then ds("osfile2")=Null
If trim(request.Form ("osfile3"))="" Then ds("osfile3")=Null
If trim(request.Form ("osfile4"))="" Then ds("osfile4")=Null
If trim(request.Form ("osfile5"))="" Then ds("osfile5")=Null
If trim(request.Form ("osfile6"))="" Then ds("osfile6")=Null
If trim(request.Form ("osfile7"))="" Then ds("osfile7")=Null
If trim(request.Form ("osfile8"))="" Then ds("osfile8")=Null

If trim(request.Form ("osfile9"))="" Then ds("osfile9")=Null
If trim(request.Form ("osfile10"))="" Then ds("osfile10")=Null
If trim(request.Form ("osfile11"))="" Then ds("osfile11")=Null
If trim(request.Form ("osfile12"))="" Then ds("osfile12")=Null
If trim(request.Form ("osfile13"))="" Then ds("osfile13")=Null
If trim(request.Form ("osfile14"))="" Then ds("osfile14")=Null
If trim(request.Form ("osfile15"))="" Then ds("osfile15")=Null
If trim(request.Form ("osfile16"))="" Then ds("osfile16")=Null
If trim(request.Form ("osfile17"))="" Then ds("osfile17")=Null
If trim(request.Form ("osfile18"))="" Then ds("osfile18")=Null
If trim(request.Form ("osfile19"))="" Then ds("osfile19")=Null
If trim(request.Form ("osfile20"))="" Then ds("osfile20")=Null
If trim(request.Form ("osfile21"))="" Then ds("osfile21")=Null
If trim(request.Form ("osfile22"))="" Then ds("osfile22")=Null
If trim(request.Form ("osfile23"))="" Then ds("osfile23")=Null
If trim(request.Form ("osfile24"))="" Then ds("osfile24")=Null
If trim(request.Form ("osfile25"))="" Then ds("osfile25")=Null

for i=1 to 16
ds("ISOname"&i)=trim(request.Form ("ISOname"&i))
ds("ISOdir"&i)=trim(request.Form ("ISOdir"&i))
ds("ISOtype"&i)=request.Form ("ISOtype"&i)
If trim(request.Form ("ISOdir"&i))="" Then ds("ISOdir"&i)=Null
Next

for i=1 to 10
ds("ToolName"&i)=trim(request.Form ("ToolName"&i))
ds("Tooldir"&i)=trim(request.Form ("Tooldir"&i))
If trim(request.Form ("Tooldir"&i))="" Then ds("Tooldir"&i)=Null
next

ds("backupyes")=request.Form ("backupyes")
ds("backupday")=request.Form ("backupday")

ds("OStype")=trim(request.Form ("OStype"))

ds("vhdtype")=trim(request.Form ("vhdtype"))
If request.Form ("vhdtype")="" Then  ds("vhdtype")="vhdx"
If ds("OStype")="Windows 2008R2" Then ds("vhdtype")="vhd"
If ds("OStype")="Windows Server 2012R2" Then ds("vhdtype")="vhdx"
If ds("OStype")="Windows Server 2012" Then ds("vhdtype")="vhdx"
If ds("OStype")="Windows Server 2016" Then ds("vhdtype")="vhdx"

ds("Canselectnow")=request.Form ("Canselectnow")
ds("typeid")=0
If IsNumeric(request.Form ("typeid")) Then ds("typeid")=request.Form ("typeid")

ds("SwitchName")=trim(request.Form ("SwitchName"))
If request.Form ("SwitchName")="" Then  ds("SwitchName")="FreeHostNet"
ds("SwitchName2")=trim(request.Form ("SwitchName2"))
If request.Form ("SwitchName2")="" Then  ds("SwitchName2")=Null

ds("IsCluster")=request.Form ("IsCluster")
ds("ClusterName")=trim(request.Form ("ClusterName"))
ds("ComputerName")=trim(request.Form ("ComputerName"))

ds("ip")=trim(request.Form ("ip"))
If trim(request.Form ("port"))<>"" Then
ds("port")=trim(request.Form ("port"))
Else
ds("port")=80
End if
ds("FreeHostsharekey")=trim(request.Form ("FreeHostsharekey"))
ds("netby")=trim(request.Form ("netby"))

ds("backupdir")=lcase(trim(request.Form ("backupdir")))


ds("useportserver")=trim(request.Form ("useportserver"))

If IsNumeric(request.Form ("orderbyid")) Then ds("orderbyid")=request.Form ("orderbyid")

Else
	 conn.Execute "delete from FreeHost.FreeHost_Product_VPS_ADSL where ServerlistID="&ds("id")&""
	 conn.Execute "delete from FreeHost.FreeHost_Product_VPS_IP where ServerlistID="&ds("id")&""
ds.delete
end if

on error resume next
ds.Update
if err then
Response.write "存在同名的服务器，请另用一个名字，也可能是字段超过了允许的长度"
Response.end
end if

ds.Close
set ds=nothing
conn.Close 
set conn=nothing
Response.Redirect "serverVPSlist.asp"
end if

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