<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
username=Request("username")
If username="" then username=session("agentusername")
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
'ElseIf Request("username")="" Then
'	ef=True
'	ec="请您输入用户名！"
ElseIf RegExpTest("[^A-Za-z0-9]",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_USER where username='"&username&"'"
		dsreg.Open Sql,conn,1,3
if dsreg.eof then

Set dsagn = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&username&"'"
		dsagn.Open Sql,conn,1,1
If not dsagn.Eof Then
dsreg.AddNew
dsreg("username")=LCASE(trim(dsagn ("username")))
dsreg("password")=dsagn ("password")
dsreg("email")=dsagn ("email")
dsreg("truename")=dsagn ("truename")
dsreg("etruename")=dsagn ("etruename")
dsreg("coun")=dsagn ("coun")
dsreg("ecoun")=dsagn ("ecoun")
dsreg("prv")=dsagn ("prv")
dsreg("eprv")=dsagn ("eprv")
dsreg("city")=dsagn ("city")
dsreg("ecity")=dsagn ("ecity")
dsreg("address")=dsagn ("address")
dsreg("eaddress")=dsagn ("eaddress")
dsreg("postid")=dsagn ("postid")
dsreg("tel")=dsagn ("tel")
dsreg("qq")=dsagn ("qq")
'dsreg("perid")=dsagn ("perid")

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("haveupdate")="y"'3.0
dsreg("agent1")=dsreg("username")
dsreg("agent2")="n"
else
	ef=True
	ec="不存在的代理用户!"
end if
end if
end if


if not ef then
if dsreg("agent1")<>session("agentusername") then
	ef=True
	ec="这个用户并不是您名下的用户!"
end if
end if

if not ef then
If dsreg("haveblock")=true Then
		ef=True
		ec="此帐号已锁定,不允许登陆,请联系管理员处理！"
End if
end If

if not ef then

Response.Cookies("usernamecook")=session("agentusername")
Response.Cookies("password")=session("agentpasswordORI")

    session("agentusername")=""
	session("admau")=""
	session("agentname")="n"'200-11-30修改bug加上的。

if dsreg("agent1")<>"n" then
 Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&dsreg("agent1")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsagent.Open Sql,conn,1,1
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
else
session("agenttype")=dsagent("agenttype")
session("agentname")=dsreg("agent1")
haveclosehtml=dsagent("haveclosehtml")
end if
	Set dsstyle = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HtmlStyle where username='"&dsreg("agent1")&"' and nowuse='1'"
		dsstyle.Open Sql,conn,1,1
If not dsstyle.Eof Then'切换
if Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" Then
session("html1")=dsstyle("html1")
session("html2")=dsstyle("html2")
session("html3")=dsstyle("html3")
session("html4")=dsstyle("html4")
session("html5")=dsstyle("html5")
session("html6")=dsstyle("html6")
session("html7")=dsstyle("html7")
session("html8")=Application("html8")
session("html9")=Application("html9")
session("html10")=Application("html10")
session("html11")=dsstyle("html11")
session("html12")=dsstyle("html12")
session("html13")=dsstyle("html13")
session("html14")=dsstyle("html14")
session("html15")=dsstyle("html15")
session("html16")=dsstyle("html16")
session("html17")=dsstyle("html17")
session("html18")=dsstyle("html18")
session("html19")=dsstyle("html19")
session("html20")=dsstyle("html20")
session("html21")=dsstyle("html21")
session("html22")=dsstyle("html22")
session("html23")=dsstyle("html23")
session("html24")=dsstyle("html24")
session("html25")=dsstyle("html25")

session("html26")=dsstyle("html26")
session("html27")=dsstyle("html27")
session("html28")=dsstyle("html28")
session("html29")=dsstyle("html29")
session("html30")=dsstyle("html30")
session("html31")=dsstyle("html31")
session("html32")=dsstyle("html32")
End if
session("ism")=false
else
'session("ism")=true
'----2005-5-10
session("ism")=False
if Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" Then
session("html1")=Application("agnhtml1")
session("html2")=Application("agnhtml2")
session("html3")=Application("agnhtml3")
session("html4")=Application("agnhtml4")
session("html5")=Application("agnhtml5")
session("html6")=Application("agnhtml6")
session("html7")=Application("agnhtml7")
session("html8")=Application("agnhtml8")
session("html9")=Application("agnhtml9")
session("html10")=Application("agnhtml10")
session("html11")=Application("agnhtml11")
session("html12")=Application("agnhtml12")
session("html13")=Application("agnhtml13")
session("html14")=Application("agnhtml14")
session("html15")=Application("agnhtml15")
session("html16")=Application("agnhtml16")
session("html17")=Application("agnhtml17")
session("html18")=Application("agnhtml18")
session("html19")=Application("agnhtml19")
session("html20")=Application("agnhtml20")
session("html21")=Application("agnhtml21")
session("html22")=Application("agnhtml22")
session("html23")=Application("agnhtml23")
session("html24")=Application("agnhtml24")
session("html25")=Application("agnhtml25")

session("html26")=Application("agnhtml26")
session("html27")=Application("agnhtml27")
session("html28")=Application("agnhtml28")
session("html29")=Application("agnhtml29")
session("html30")=Application("agnhtml30")
session("html31")=Application("agnhtml31")
session("html32")=Application("agnhtml32")
End if
'----2005-5-10
end if
dsstyle.close
set dsstyle=nothing
end if
end if

if not ef Then
If haveclosehtml=True Then
if Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" Then
session("html1")=Application("html1")
session("html2")=Application("html2")
session("html3")=Application("html3")
session("html4")=Application("html4")
session("html5")=Application("html5")
session("html6")=Application("html6")
session("html7")=Application("html7")
session("html8")=Application("html8")
session("html9")=Application("html9")
session("html10")=Application("html10")
session("html11")=Application("html11")
session("html12")=Application("html12")
session("html13")=Application("html13")
session("html14")=Application("html14")
session("html15")=Application("html15")
session("html16")=Application("html16")
session("html17")=Application("html17")
session("html18")=Application("html18")
session("html19")=Application("html19")
session("html20")=Application("html20")
session("html21")=Application("html21")
session("html22")=Application("html22")
session("html23")=Application("html23")
session("html24")=Application("html24")
session("html25")=Application("html25")
session("html26")=Application("html26")
session("html27")=Application("html27")
session("html28")=Application("html28")
session("html29")=Application("html29")
session("html30")=Application("html30")
session("html31")=Application("html31")
session("html32")=Application("html32")
end if
End if
session("username")=dsreg("username")
session("password")=dsreg("password")
session("usermoney")=dsreg("usermoney")
session("atspace")="用户区"
dsreg("lastuse")=now
if session("agentname")=session("username") then
session("AgnRunasUser")=true
else
session("AgnRunasUser")=false
end if
dsreg.update
if Request.ServerVariables("HTTP_FreeHostAPI")="7i24.com" Then
Response.write session("password")
Response.end
End if
if session("login_tar")<>"" then
tourl=session("login_tar")&"?"&session("login_QueryString")
session("login_tar")=""
Response.Redirect tourl
end if
FreeHost_Loginlog session("username"),"用户"
Response.Redirect "logininfo.asp"
dsreg.close
conn.Close
set conn=nothing
end if

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