<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
session.Timeout =25
server.ScriptTimeout =240
If Request.Form ("username")="" or RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="用户名没填或非法！"
elseIf Request.Form ("password")="" Then
	ef=True
	ec="密码没填！"
ElseIf Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com"  And ((Request.Form ("Vcode")<>session("Vcode") or session("Vcode")="") and Request.Cookies("usernamecook")<>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 dsreg.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
end if
end if

if not ef then
if md5(Request.Form ("password"))<>dsreg("password") then
		ef=True
		ec="密码不正确！"
else
session("username")=""
session("password")=""
session("AgnRunasUser")=False
haveclosehtml=dsreg("haveclosehtml")
end if
end if
    

if not ef then
'if Application("emailau")=true then
'if dsreg("emailau")="n" then 
'		ef=True
'		ec="此帐号尚未激活，请查收邮箱，激活帐号！"
'session.Abandon()
'end if
'end If
if not ef then
If dsreg("haveblock")=true Then
		ef=True
		ec="此帐号已锁定,不允许登陆,请联系管理员处理！"
session.Abandon()
Response.Redirect "e.asp?e="&ec
End if
end If

if Application("smsau")=true then
if dsreg("checkmobiok")=false then 
'session.Abandon()
    session("SMSAUusername")=dsreg("username")
Response.Redirect "/agent/checkmobi.asp"
end if
end If
end If

if not ef then
if dsreg("agenttype")="n" then
		ef=True
		ec="您的代理资格尚未被审批！"
session.Abandon()
end if
end If

if not ef then
If IsNull(dsreg("usermoney")) Then
		ef=True
		ec="此帐号金额为空,不允许登陆,请联系管理员处理！"
End if
end If



if not ef then
	Set dsstyle = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HtmlStyle where username='"&dsreg("username")&"'"
		dsstyle.Open Sql,conn,1,1
if dsstyle.eof then
	Set dsstyle = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HtmlStyle where username='"&dsreg("agent1")&"'"
		dsstyle.Open Sql,conn,1,1
end if
if dsstyle.eof then
	Set dsstyle = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_HtmlStyle where username='freehost' and agentdefault='1' order by id desc"
		dsstyle.Open Sql,conn,1,1
if dsstyle.eof then Response.Redirect "e.asp?e=管理区最少应该定义其中一个模板是默认代理模板，代理才有模板可以用。"

ism=false
for i=0 to ubound(Application("sitearry"))
if Application("sitearry")(i)=Request.ServerVariables("SERVER_NAME") then
ism=true
exit for
end if
next

if ism=false 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
end if
'else
'session("ism")=true
end if
dsstyle.close
set dsstyle=nothing
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("agentusername")=dsreg("username")
session("agentusername_A")=dsreg("username")
session("atspace")="代理区"
session("agentpassword")=dsreg("password")
session("agentpasswordORI")=Request.Form ("password")
session("agenttype")=dsreg("agenttype")
session("agentusermoney")=dsreg("usermoney")
session("agentdegree")=dsreg("agentdegree")
if dsreg("cannextagn")="y" then session("cannextagn")=dsreg("cannextagn")
if dsreg("canmyserver")="y" then session("canmyserver")=dsreg("canmyserver")
session("awstoadmin")=dsreg("awstoadmin")

session("lastusetime")=dsreg("lastuse")

dsreg("lastuse")=now
dsreg.update
'if session("ism")=true then Response.Redirect "htmlstyle.asp" 2005-5-10
If Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" Then Response.Cookies("agnnamecook")=Request.Form("username")
if session("admusername")="" and Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" then Response.Cookies("url")=Request.ServerVariables("url")

FreeHost_Loginlog session("agentusername"),"代理"

If Request("goto")="beian" Then Response.Redirect "/beianuser/info.asp"
If Application("opencheckmobi")=true Then
If dsreg("checkmobiok")=false Then
If dsreg("wantcheckmobiok")=True Then
Response.Redirect "checkmobi.asp"
End if
End if
End if

Response.Redirect "logininfo.asp"
dsreg.close
conn.Close
set conn=nothing
end if

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