<%@ 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 request.Form ("ostype")="linux" And InStr(replace(request.Form("site"),"http://",""),":")<2 Then
	ef=True
	ec="Linux的受控网址中必须写上端口号,如http://x.x.x.x:2222"

ElseIf request.Form ("ostype")="linux" And RegExpTest("[^0-9]",Replace(Request.Form ("ip"),".","")) Then
	ef=True
	ec="服务器IP地址不对,必须填写准确的IP!"
ElseIf request.Form ("isuseCDN")=1 And RegExpTest("[^0-9]",Replace(Request.Form ("ip"),".","")) Then
	ef=True
	ec="服务器IP地址不对,必须填写准确的IP!"

ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
ElseIf not IsNumeric(Request("backupday"))  Then
	ef=True
	ec="备份时间应该是数字！"
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="共享密码不能为空(Linux请填写admin的密码)。"
elseIf ((Request.Form ("usecdn1")=Request.Form ("usecdn2") Or Request.Form ("usecdn1")=Request.Form ("usecdn3")  Or Request.Form ("usecdn1")=Request.Form ("usecdn4")  Or Request.Form ("usecdn1")=Request.Form ("usecdn5") )And CInt(Request.Form ("usecdn1"))>0) Or ((Request.Form ("usecdn2")=Request.Form ("usecdn3")  Or Request.Form ("usecdn2")=Request.Form ("usecdn4")  Or Request.Form ("usecdn2")=Request.Form ("usecdn5")) And CInt(Request.Form ("usecdn2"))>0)  Or ((Request.Form ("usecdn3")=Request.Form ("usecdn4")  Or Request.Form ("usecdn3")=Request.Form ("usecdn5")) And CInt(Request.Form ("usecdn3"))>0)   Or (Request.Form ("usecdn4")=Request.Form ("usecdn5") And CInt(Request.Form ("usecdn4"))>0)      Then
	ef=True
	ec="CDN服务器不能重复"
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_Serverlist 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_Host 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_HostProductlist where ServerlistID='"&ds("id")&"'"
	dshost.Open Sql,conn,1,1
if not dshost.Eof then
	ef=True
	ec="还有虚拟主机[产品定义]正在使用此服务器，因此不能删除，如果您的服务器损坏了，可以将受控网址改到正常服务器，就可以重开这些网站！产品名："&dshost("Hosttype")
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("isuseCDN")=request.Form ("isuseCDN")
ds("port")=request.Form ("port")
If ds("isuseCDN")=True then
ds("usecdn1")=request.Form ("usecdn1")
ds("usecdn2")=request.Form ("usecdn2")
ds("usecdn3")=request.Form ("usecdn3")
ds("usecdn4")=request.Form ("usecdn4")
ds("usecdn5")=request.Form ("usecdn5")
Else
ds("isuseCDN")=false
ds("usecdn1")=0
ds("usecdn2")=0
ds("usecdn3")=0
ds("usecdn4")=0
ds("usecdn5")=0
End if

ds("ostype")=trim(request.Form ("ostype"))
ds("servername")=trim(request.Form ("servername"))
ds("site")=trim(request.Form ("site"))
ds("site")=LCase("http://"&replace(ds("site"),"http://",""))
If Right(ds("site"),1)="/" Then ds("site")=Left(ds("site"),Len(ds("site"))-1)
ds("tempdomain")=trim(request.Form ("tempdomain"))
ds("tempdomainagn")=trim(request.Form ("tempdomainagn"))
ds("homedir")=trim(request.Form ("homedir"))
ds("pauseweb")=trim(request.Form ("pauseweb"))
ds("pauseweb2")=trim(request.Form ("pauseweb2"))
ds("pauseweb3")=trim(request.Form ("pauseweb3"))
ds("pauseweb4")=trim(request.Form ("pauseweb4"))

ds("asp")=replace(trim(request.Form ("asp")),vbcrlf,"")
ds("aspx")=replace(trim(request.Form ("aspx")),vbcrlf,"")
ds("aspx2")=replace(trim(request.Form ("aspx2")),vbcrlf,"")
ds("aspx4")=replace(trim(request.Form ("aspx4")),vbcrlf,"")
ds("notuserar")=replace(trim(request.Form ("notuserar")),vbcrlf,"")
ds("netver")=trim(request.Form ("netver"))
ds("php")=replace(trim(request.Form ("php")),vbcrlf,"")
ds("cgi")=replace(trim(request.Form ("cgi")),vbcrlf,"")
ds("infosafe")=replace(trim(request.Form ("infosafe")),vbcrlf,"")
if right(ds("infosafe"),1)=" " then ds("infosafe")=left(ds("infosafe"),len(ds("infosafe"))-1)
if right(ds("infosafe"),1)=" " then ds("infosafe")=left(ds("infosafe"),len(ds("infosafe"))-1)
ds("ftpdomain")=trim(request.Form ("ftpdomain"))
ds("ip")=trim(request.Form ("ip"))
ds("FreeHostsharekey")=trim(request.Form ("FreeHostsharekey"))
ds("netby")=trim(request.Form ("netby"))

ds("backupdir")=lcase(trim(request.Form ("backupdir")))
ds("backupyes")=request.Form ("backupyes")
ds("backupday")=request.Form ("backupday")
ds("backupsave")=request.Form ("backupsave")

ds("openmustre")=request.Form ("openmustre")
ds("autodelicp")=request.Form ("autodelicp")

ds("useisp")=request.Form ("useisp")

ds("canphpver")=request.Form ("canphpver")

if trim(request.Form ("nottype"))<>"" then
ds("nottype")=trim(request.Form ("nottype"))
else
ds("nottype")=null
end If

if trim(request.Form ("cname"))<>"" then
ds("cname")=trim(request.Form ("cname"))
else
ds("cname")=null
end If

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

if trim(request.Form ("ispinfo"))<>"" then
ds("ispinfo")=request.Form ("ispinfo")
else
ds("ispinfo")=null
end If

else
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 "serverlist.asp"
end if

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