<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("CDNAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。此功能只有代理可以操作。"
elseIf session("CDNAUID")<>Clng(Request.Form ("id")) Then
	ef=True
	ec="授权非法，有可能是超时造成的。请返回上一步重新操作。"&Request.Form ("id")&"-"&session("CDNAUID")
ElseIf not IsNumeric(session("CDNAUID"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Request.Form ("newusername")<>"" and RegExpTest("[^A-Za-z0-9]",Request.Form ("newusername")) Then
	ef=True
	ec="转移用户名中有非法字符！"
ElseIf Request.Form ("newusername")="" And Request.Form ("Submit")="马上转移" Then
	ef=True
	ec="请输入转移用户名！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_CDN where id='"&session("CDNAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的CDN产品ID！"
end if
end If

if not ef then
if dsph("agent1")<>session("agentusername") then
	ef=True
	ec="此CDN产品ID并不是当前代理名下所有！"
end If
end If

if not ef then
If Request.Form ("Submit")="马上转移" then
	Set dsNew = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where  (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and username='"&Request.Form ("newusername")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsNew.Open Sql,conn,1,1
if dsNew.eof then
	ef=True
	ec="要转移的用户不存在或不是您名下的用户!"
end if
end if
end if

if not ef then
	Set dsHostpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_CDNProductlist where CDNtype='"&dsph("CDNtype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHostpdlist.Open Sql,conn,1,1
if dsHostpdlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end If

if not ef then
isAgnHostSer=false
end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-CDNadm-top.asp"-->
　代理 <%=session("agentusername")%> 管理名下用户 <%=dsph("username")%> 的CDN


<br>
<br>
<%
if Request.Form ("Submit")="马上转移" then%>
用户 <%=dsph("username")%> 的CDN成功转移：<br><br>
<%
dsph("username")=Request.Form ("newusername")
response.write "产品已转移到用户："&Request.Form ("newusername")&" 名下。<br>"
'if Request.Form ("changeagn")="y" then
'dsph("agent1")=dsNEW("agent1")
'end if
dsph.update
dsph.close
end if



%><br><br><br>　<a href="selfCDNmodify.asp?id=<%=session("CDNAUID")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-CDNadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>