<%
	'检查访问的来源是否合法
	'call checkPrePage()

	thispage="CHKLogin.asp"
%>
<!--#include file="conn.asp"-->

<!--#include file="inc/SUB.ASP"-->
<!--#Include File="testCookies.asp"-->
<!--#Include File="inc/PrintMsg.asp"-->
<!--#include file="INC/md5.asp"-->

<%

	dim OutMsg, founderr, ComeURL, LastLoginDate
	if not isOpenCookies then
		PrintMsg "<li>本系统需要 Cookies 支持，请先将 Cookies 打开！"
	end if

	call chklogin()
	if founderr=true then
		Call PrintMsg(OutMsg)
	else
		ComeURL=Request.ServerVariables("HTTP_REFERER")
		if ComeURL="" then
			response.redirect "index.asp"
		else
			response.redirect "Admin_Manager.asp"
		end if
	end if

Sub chklogin()
	dim name, password, ip, Logins, UsableScore
	dim ThisComName
	response.write Session("SafeCode")
	response.write GetVariable("validate")
	'response.end
	if request("validate")<>"1" then
		if trim(GetVariable("validate"))<>trim(Session("SafeCode")) then
			ShowMsg "对不起，您输入的验证码不正确"
		end if
	end if

	if Session("UserID")<>"" then
		ShowMsg "对不起，此计算机上已经打开了管理窗口，请退出后再重新登陆。点击这里<a href=LOGOUT.ASP>注销登录</a>"
	end if
	
	name = replace( trim(GetVariable("name")),"'","" )
	password=replace(trim(GetVariable("password")),"'","")

	if name="" then
		OutMsg=OutMsg+"<center>"+"    请输入您的用户名。</center>"
		founderr=true
		exit sub
	elseif IfEnglish(name)=false then
		OutMsg=OutMsg+"<center>"+"    用户名只能是英文、数字和下划线！</center>"
		founderr=true
		exit sub
	else
		name=Lcase( trim(name) )
	end if
	if password="" then
		OutMsg=OutMsg+"<center>"+"    请输入您的密码。</center>"
		founderr=true
		exit sub
	end if

'+++++++++++++++++++++++++++++++下面这段为用户登录后要记录的COOKIES+++++++++++++++++++++++++++
	
	strSQL="Select top 1 * From v_member Where m_name='" & name & "' And m_password='" & md5(password) & "'"
	set rsMember=Server.CreateObject("ADODB.RecordSet")
	rsMember.open strSQL,conn,3,3
	
	
	
	
	if not (rsMember.bof or rsMember.eof) then
		if rsMember("m_lock") then
			ShowMsg "对不起，您的账号已经被管理员封杀！"
		end if
		if rsMember("m_expire")<date then
			ShowMsg "对不起，您的账号已经过期，如要继续使用请向服务商续费！"
		end if
		Session("UserID")=trim(rsMember("id")) 					'账号ID
		Session("UserPass")=trim(rsMember("m_password"))		'账号密码
		Session("UserName")=trim(rsMember("m_name"))			'账号
		Session("UserCode")=trim(rsMember("m_code"))			'用户级别号
		Session("WebSiteID")=trim(rsMember("w_id"))				'用户站点ID
		Session("WebTitle")=trim(rsMember("w_Title"))			'网站标题
		Session("AgentID")=trim(rsMember("m_AgentName"))		'代理商ID
		Session("WebLanguage")=trim(rsMember("m_language"))		'用户网站所支持的语言
		Session("WebLamu")=trim(rsMember("m_lamu"))				'用户网站所支持的栏目
		Session("WebTemplet")=trim(rsMember("m_templet"))		'用户网站所支持模板
		Session("WebTplock")=trim(rsMember("m_tplock"))			'用户网站所支持模板
		Session("Webprice")=trim(rsMember("m_webprice"))		'代理价格
		
		'记录最后登录时间
		rsMember("m_landLogin")=now()
		rsMember.Update
	else
		OutMsg=OutMsg+"<center>"+"    用户名和密码不正确，请认真检查有没有填错！<br><br></center>"
		founderr=true
		exit sub
	end if
	rsMember.Close
End Sub


%>