<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf lcase(Request.Form ("servername"))="" or Instr(lcase(Request.Form ("servername")), "'")>1 Then
	ef=True
	ec="服务器名没填或有非法字符！"
ElseIf lcase(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 Request.Form ("FreeHostsharekey")="" Then
	ef=True
	ec="共享密码不能为空。"
elseIf session("canmyserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
elseIf checkscript(Request.Form ("servername")) Then
	ef=True
	ec="名字有非法字符！如<>script"
elseIf checkscript(Replace(Request.Form ("site"),"http://","")) Then
	ef=True
	ec="受控域名有非法字符！如<>script"
elseIf checkscript(Request.Form ("ip")) Then
	ef=True
	ec="IP有非法字符！如<>script"
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")&"' and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"')"
		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_AGN 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("servername")=trim(lcase(Request.Form ("servername")))
ds("site")=trim(lcase(Request.Form ("site")))
ds("site")="http://"&replace(ds("site"),"http://","")
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")=trim(request.Form ("asp"))
ds("aspx")=trim(request.Form ("aspx"))
ds("aspx2")=trim(request.Form ("aspx2"))
ds("aspx4")=trim(request.Form ("aspx4"))
ds("notuserar")=replace(trim(request.Form ("notuserar")),vbcrlf,"")
ds("netver")=trim(request.Form ("netver"))
ds("php")=trim(request.Form ("php"))
ds("cgi")=trim(request.Form ("cgi"))
ds("infosafe")=trim(request.Form ("infosafe"))
ds("ftpdomain")=trim(request.Form ("ftpdomain"))
ds("ip")=trim(lcase(Request.Form ("ip")))
ds("agent1")=session("agentusername")
ds("agent2")="n"
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")


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

ds("ostype")="windows"

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%>