<!-- #Include File="../Include/Skin.asp" -->
<!-- #Include File="../Include/Inc_md5.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================
if action="logout" then
	if ChkName(login_username) then
		Call Cls.AsaiMHDelOnlineNum(login_username,1)
		Cls.session_del(login_username)
	End If
	call cookies_clear(1)
	dim o_url
	o_url=trim(request.servervariables("http_referer"))
	if instr(o_url,"login.asp")>0 or instr(o_url,"user_")>1 or o_url="" then o_url="./"
	call format_redirect(o_url)
End If

if login_username<>"" and login_password<>"" then
	call format_redirect("Index.asp")
End If

Index_Url="Index"
tit_fir=format_menu(Index_Url)
tit="用户登陆"

call DoWebHead(0,0)
	select case action
	case "login_chk"
		call login_chk()
        case else
		call login_main()
	end select
call DoWebEnd()

sub login_main()
	dim old_url,err_var
	old_url=Cls.code_query("old_url")
	if Cls.Is_Null(old_url)<>"" then
		if old_url="back" then old_url=request.servervariables("http_referer")
		old_url="&old_url="&server.urlencode(old_url)
		err_var="<font class=red>请先注册并登陆本站再浏览前一页面</font>"
	end if
	Cls.ReadPage "login_false"
	Cls.HtmlRcod "valcode",Cls.GetCode()
	Cls.HtmlRcod "old_url",old_url
	Cls.HtmlRcod "err_var",err_var
	Cls.HtmlRcod "tit",tit
	Cls.OutPage
end sub

sub login_chk()
	dim password,gname,found_err,id,power,hidden,face,old_url,num,startim,endtim,s_id,username,login_type
	old_url = Cls.code_query("old_url")
	if Cls.Code_Form("login_type") = "userloginid" then
		id = Cls.Code_Form("logininfo")
	else
		if ChkName(login_username)=true then
			username = login_username
		else
			username = Cls.Code_Form("logininfo")
		End If
	End If
	if ChkPassWord(login_password)=true then
		password = login_password
	else
		password = Cls.Code_Form("password")
		password = AsaiMHMd5(password,"short")
	End If
	If int(format_mid_num(4))=1 Then
		found_err=""
		if Cls.Code_Form("login_type") = "userloginid" then
			if ChkID(id)=false then
				found_err=found_err&"+您输入的 <font class=red>用户 ID</font> 为空或不符合相关规则！<br />"
			end if
		else
			if ChkName(username)=false then
				found_err=found_err&"+您输入的 <font class=red>用户名称</font> 为空或不符合相关规则！<br />"
			end if
		End If
		if ChkPassWord(password)=false then
			found_err=found_err&"+您输入的 <font class=red2>登陆密码</font> 为空或不符合相关规则！<br />"
		end if
		if Not Cls.CodeIsTrue() then
			found_err=found_err&"+您输入的 <font class=red2>验 证 码</font> 为空或者有错误存在！<br />"
		End If
		if found_err<>"" then
			found_err=found_err&"+请查阅有关 <a href='"&cls.web_dir&"User/Register.asp' target=_blank class=red>系统提示注意事项</a> 并重新填写。"
			Cls.ReadPage "common"
			Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
			Cls.HtmlRcod "tit",tit
			Cls.OutPage
			exit sub
		end if
	else
		found_err=found_err&"+<font class=red><b>网站关闭用户登陆功能，如有需要请理系管理员！</b></font>"
		Cls.ReadPage "common"
		Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
		Cls.HtmlRcod "tit",tit
		Cls.OutPage
		exit sub
	end if
	if Cls.Code_Form("login_type") = "userloginid" then
		sql="select top 1 id,username,power,u_ip,hidden from AsaiMHUserData where id="&id&" and password='"&password&"'"
	else
		sql="select top 1 id,username,power,u_ip,hidden from AsaiMHUserData where username='"&username&"' and password='"&password&"'"
	End If
	set rs=Cls.exec(sql,1)
	if rs.eof then
		rs.close
		call ip_stop1()
		if Cls.Code_Form("login_type") = "userloginid" then
			found_err=found_err&"+您输入的 <font class=red>用户ID</font> 和 <font class=red>登陆密码</font>  有错误！<br />"
			if useripstop=1 then
				found_err=found_err&"+尝试登陆超过 <font color=red>"&s_dlcs&"</font> 次将被锁定IP！<br />"
			End If
			found_err=found_err&"+请重新输入以并继续登陆本站！"
			Cls.ReadPage "common"
			Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
			Cls.HtmlRcod "tit",tit
			Cls.OutPage
			exit sub
		else
			found_err=found_err&"+您输入的 <font class=red>用户名称</font> 和 <font class=red>登陆密码</font>  有错误！<br />"
			if useripstop=1 then
				found_err=found_err&"+尝试登陆超过 <font color=red>"&s_dlcs&"</font> 次将被锁定IP！<br />"
			End If
			found_err=found_err&"+请重新输入以并继续登陆本站！"
			Cls.ReadPage "common"
			Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
			Cls.HtmlRcod "tit",tit
			Cls.OutPage
			exit sub
		End If
  	else
		username=rs("username")
		power=rs("power")
		hidden=rs("hidden")
		'----用户登陆IP限制开始---
		if rs("u_ip") <> "" then
			if rs("u_ip")<>Cls.ip_sys(0) then
				Response.write "<script>alert('您现在登陆的用户帐号为："&username&"，登陆IP是"&Cls.ip_sys(0)&"。\n\n该帐号已经指定为IP是"&rs("u_ip")&"的用户登录。系统禁止同一帐号同时在不同IP多次登陆！\n\n如需修改指定IP，请及时与管理员"&web_dim(5)&"（E_mail："&web_dim(6)&"）联系。');window.close(); </script>"
				response.end
			End If
		End If
		rs.close
		'---用户登陆IP限制结束---
		if hidden=true then
			response.cookies(Cls.web_cookies)("time_load")=DateAdd("s",-5,Cls.now_time)
			response.cookies(Cls.web_cookies)("login_username")=username
			response.cookies(Cls.web_cookies)("login_password")=Cls.Code_Encrypt(password)
			sql="update AsaiMHUserdata set last_tim='"&Cls.now_time&"',login_num=login_num+1,last_ip='"&Cls.ip_sys(0)&"' where username='"&username&"'"
			call Cls.exec(sql,0)
			gname=request.cookies(Cls.web_cookies)("guest_name")
			gname=Cls.code_html(gname,1,0)
			if Cls.Is_Null(gname)<>"" then
				Call Cls.Session_Del(gname)
				Call Cls.AsaiMHDelOnlineNum(gname,0)
			End If
			Call Cls.Session_Del("guest")
			if trim(request.form("memery_info"))="no" then
				response.cookies(Cls.web_cookies)("iscookies")="no"
			End If
			if trim(request.form("memery_info"))="1" then
				response.cookies(Cls.web_cookies)("iscookies")="1"
				response.cookies(Cls.web_cookies).expires=Date+1    '记住登陆 设为一天
			End If
			if trim(request.form("memery_info"))="31" then
				response.cookies(Cls.web_cookies)("iscookies")="31"
				response.cookies(Cls.web_cookies).expires=Date+31   '记住登陆 设为一个月
			End If
			if trim(request.form("memery_info"))="yes" then
				response.cookies(Cls.web_cookies)("iscookies")="yes"
				response.cookies(Cls.web_cookies).expires=Date+365  '记住登陆 设为一年
			End If
			if old_url="back" then old_url=request.servervariables("http_referer")
			if old_url<>"" then
				call format_redirect(old_url)
			End If
			Cls.ReadPage "login_true"
			Cls.HtmlRcod "tit",tit
			Cls.HtmlRcod "login_username",username
			Cls.HtmlRcod "login_mode_var",Format_Power(power,1)
			Cls.HtmlRcod "refresh_url","<meta http-equiv='refresh' content='"&Format_Mid_Num(25)&"; url=./'>"
			Cls.OutPage
		Else
			found_err=found_err&"+你的帐号尚未审核，请审核后再登陆!<br />"
			found_err=found_err&"+请查阅有关 <a href='"&cls.web_dir&"User/Register.asp' target=_blank class=red>用户注册注意事项</a> 并重新填写。"
			Cls.ReadPage "common"
			Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
			Cls.HtmlRcod "tit",tit
			Cls.OutPage
		End If
	End If
End Sub
%>
