<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("Domain")="" or Instr(Request.Form ("Domain"), "'")>1 Then
	ef=True
	ec="域名没填或有非法字符！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf Instr(1, Request.Form ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf Instr(1, Request.Form ("byid"), "'", 1)>0 then
	ef=True
	ec="非法产品byid！"
'ElseIf not IsNumeric(Request.Form ("id"))  Then
'	ef=True
'	ec="产品ID应该是数字！"
ElseIf Request.Form ("agent1")<>"" and RegExpTest("[^A-Za-z0-9]",Request.Form ("agent1")) Then
	ef=True
	ec="代理名中有非法字符！"
elseIf session("canadmdomain")="" 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_USER where username='"&request.Form ("username")&"'"
		ds.Open Sql,conn,1,1
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
if request.Form("agent1")<>"" and request.Form("agent1")<>"n" then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&request.Form("agent1")&"'"
		dsagent.Open Sql,conn,1,1
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在！"
end if
end if
end if

if not ef then
if request.Form("byid")<>"" then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&request.Form("byid")&"' and username='"&request.Form("username")&"'"
		dsagent.Open Sql,conn,1,1
If dsagent.Eof Then
		ef=True
		ec="附于的虚拟主机产品不存在或不是这个会员名下的！"
end if
end if
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Domain where id='"&request.Form ("id")&"'"
		ds.Open Sql,conn,1,3
if ds.Eof Then
ds.AddNew
ds("api7select")=Application("api7select")
End if

ds("username")=trim(request.Form ("username"))
ds("Domain")=trim(request.Form ("Domain"))
ds("status")=trim(request.Form ("status"))
If ds("status")="正常" Then
ds("emailstatus")=Null
ds("smsstatus")=null
End if
ds("starttime")=trim(request.Form ("starttime"))
if trim(request.Form ("endtime"))<>"" then ds("endtime")=trim(request.Form ("endtime"))
if trim(request.Form ("agent1"))<>"" then ds("agent1")=trim(request.Form ("agent1"))
if trim(request.Form ("agent1"))="" then ds("agent1")="n"

if trim(request.Form ("isbyhost"))<>"" then
ds("isbyhost")=trim(request.Form ("isbyhost"))
else
ds("isbyhost")="n"
end if
if trim(request.Form ("Hosttype"))<>"" then ds("Hosttype")=trim(request.Form ("Hosttype"))
if trim(request.Form ("byid"))<>"" then
ds("byid")=trim(request.Form ("byid"))
else
ds("byid")=null
end if
ds("inipass")=trim(request.Form ("inipass"))
ds("Domain_API")=trim(request.Form ("Domain_API"))
ds("api7select")=trim(request.Form ("api7select"))
If ds("Domain_API")<>7 Then ds("api7select")=0
ds("DNS_API")=request.Form ("DNS_API")
ds("years")=request.form("years")
ds("type1")=request.form("type1")
ds("DNScount")=request.form("DNScount")
ds.Update


ds.Close
set ds=nothing
conn.Close 
set conn=nothing
Response.Redirect "listmydomain.asp?pid="&request.Form ("id")
end if

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