<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostEmail.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("cannextagn")="" Then
	ef=True
	ec="您没有此操作的权限。"
elseIf Request.Form ("username")="" or RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="会员名没有写/或会员名中有非法字符！"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsreg = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent where username='"&Request.Form ("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsreg.Open Sql,conn,1,3
if not dsreg.eof then
	ef=True
	ec="代理表中已有这个代理会员了！"
end if
end if

If not ef then
  Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&Request.Form ("username")&"'  and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"')"
		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
dsreg.AddNew
dsreg("username")=LCASE(trim(ds ("username")))
dsreg("password")=ds ("password")
dsreg("email")=ds ("email")
dsreg("truename")=ds ("truename")
dsreg("etruename")=ds ("etruename")
dsreg("coun")=ds ("coun")
dsreg("ecoun")=ds ("ecoun")
dsreg("prv")=ds ("prv")
dsreg("eprv")=ds ("eprv")
dsreg("city")=ds ("city")
dsreg("ecity")=ds ("ecity")
dsreg("address")=ds ("address")
dsreg("eaddress")=ds ("eaddress")
dsreg("postid")=ds ("postid")
dsreg("tel")=ds ("tel")
dsreg("qq")=ds ("qq")

dsreg("regtime")=NOW
dsreg("lastuse")=NOW
dsreg("regip")=Request.ServerVariables("REMOTE_ADDR")
If Request.ServerVariables("HTTP_FreeHostAPIIP")<>"" Then dsreg("regip")=Request.ServerVariables("HTTP_FreeHostAPIIP")

dsreg("usermoney")="0.00"

dsreg("hostphcount")=0
dsreg("emailphcount")=0
dsreg("domainphcount")=0

dsreg("agenttype")="n"
dsreg("haveupdate")="y"'3.0
dsreg("agent1")=session("agentusername")
dsreg("agent2")="n"

ds("agent1")=dsreg("username")

ds.update




'dim Subject,body
'EmailAgentRegister
'ret=Send2Mail(conn,ds("username"),Subject,body)


dsreg.Update
dsreg.Close
set dsreg=nothing
conn.Close
set conn=nothing
end if

If not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>　操作成功
<%=htmlwrite("html6")%><br>
<br>

授权 <%=Request.Form ("username")%> 用户成为 未定代理级别的代理用户 成功！

<%=htmlwrite("html7")%>
<%
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if
%>
