<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canadmuser")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf Request.Form ("agent1")<>"" and RegExpTest("[^A-Za-z0-9]",Request.Form ("agent1")) 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,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
if request.Form("agent1")<>"" 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

	ds("agent1")=Request.Form ("agent1")
	if ds("agent1")="" then ds("agent1")="n"
	ds.update


  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&request.Form("username")&"'"
		dsagent.Open Sql,conn,1,3
If Not dsagent.Eof Then
If dsagent("username")<>ds("agent1") then
		dsagent("agent1")=ds("agent1")
		dsagent.update
End if
end if


Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing



Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_ALLEmail where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing


Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=Nothing

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_idc where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing


Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_idc_repair where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Domain where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Preopen_Product where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing



Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Other where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=Nothing

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_CDN where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=Nothing

Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where username='"&ds("username")&"'"
	dsph.Open Sql,conn,1,3
while not dsph.Eof
	dsph("agent1")=Request.Form ("agent1")
	if dsph("agent1")="" then dsph("agent1")="n"
	dsph.update
	dsph.movenext
wend
dsph.close
set dsph=nothing

FreeHost_oplog session("admusername"),"成功",Request.Form ("username")&" 的变更另一代理名下："&Request.Form ("agent1")

%>
修改成功
<br><br>
操作完成。
<%end if

if ef then%>
<%=ec%>
<%end if%>
<script>
var partable=parent.document.getElementById("table0");
if (partable!=null)
partable.style.display='';

partable=parent.document.getElementById("outconM");
if (partable!=null)
partable.innerHTML = document.body.innerHTML;
</script>