<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("username")="" or RegExpTest("[^A-Za-z0-9]",Request("username")) or len(Request("username"))<3 Then
	ef=True
	ec="会员名没有写/或会员名中有非法字符/或会员名长度小于3个字符！"
elseIf session("cansetagn")="" 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_Agent where username = '"&Request("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		ds.Open Sql,conn,1,3
if ds.Eof then
	ef=True
	ec="代理会员不存在！"
end if
end if


if not ef then
Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_USER where (agent1='"&Request("username")&"' or agent2='"&Request("username")&"')"
	dsph.Open Sql,conn,1,1
if not dsph.Eof then
	ef=True
	ec="此代理有已开通的名下用户，请先删除它的名下用户！"
end if
end if



if not ef then


'删除
Sql="delete from FreeHost.FreeHost_Agent_price where username='"&Request("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
    conn.Execute Sql

'删除
Sql="delete from FreeHost.FreeHost_Agent_user_price where username='"&Request("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
    conn.Execute Sql

'删除
Sql="delete from FreeHost.FreeHost_Agent_ALLdomain where username='"&Request("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 Then
Response.Write "非法字符！"
Response.End
end if
    conn.Execute Sql

'删除
Sql="delete from FreeHost.FreeHost_HtmlStyle where username='"&Request("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
    conn.Execute Sql


'删除
Sql="delete from FreeHost.FreeHost_Loginlog where username='"&ds("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
    conn.Execute Sql

'删除
Sql="delete from FreeHost.FreeHost_online_aws where username='"&ds("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
    conn.Execute Sql

conn.Execute "delete from FreeHost.FreeHost_HostProductlist_AGN where agent1='"&ds("username")&"'"
conn.Execute "delete from FreeHost.FreeHost_EmailProductlist_AGN where agent1='"&ds("username")&"'"
conn.Execute "delete from FreeHost.FreeHost_SqlProductlist_AGN where agent1='"&ds("username")&"'"
conn.Execute "delete from FreeHost.FreeHost_VPSProductlist_AGN where agent1='"&ds("username")&"'"
conn.Execute "delete from FreeHost.FreeHost_OtherProductlist_AGN where agent1='"&ds("username")&"'"
conn.Execute "delete from FreeHost.FreeHost_CDNProductlist_AGN where agent1='"&ds("username")&"'"

%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
 　删除代理
 <%=htmlwrite("html9")%>

<br><br><br>
代理 <%=ds ("username")%>，删除成功！

<%
ds.delete
ds.update
ds.Close
set ds=nothing
conn.Close 
set conn=nothing
%>
<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
