<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
'##################################################################                                                                 
'★         web08.net - 威博购物系统                                              
'★  版权所有: web08.net                                                                                                       
'★  程序制作: 威博网络技术公司                                     
'★           email:web08net@hotmail.com                           
'★            Q Q :645095280,475980829
'★	       电话:021-55520018                                                                                                         
'★  相关网址: [产品介绍] http://www.021web.com.cn/gwxt.html
'★            [支持论坛] http://bbs.web08.net/                                                                                     
'★  主页地址: http://www.web08.net/  
'★		http://www.021web.com.cn/			                                                                 
'###################################################################
%>
<!--#include file="../inc/conn.asp"-->
<!--#include file=../inc/inc.asp-->

<%
response.charset="UTF-8"
dim admin,password
conndb
client_ip=getIP 
admin=trim(request.form("admin"))
tmppass=trim(request.form("password"))
passlen=len(tmppass)-4
tmppass2=right(tmppass,4)
tmppass=left(tmppass,passlen)&","&tmppass2
tmppwd=split(trim(tmppass),",")
passcode=request.form("passcode")
v_loginstop=LoginStop()
if v_loginstop="true" then
	response.Write "<script LANGUAGE='javascript'>alert('登录失败！服务器拒绝！');history.go(-1);</script>"
	response.end
end if 
if passcode="" then
	response.Write "<script LANGUAGE='javascript'>alert('登录失败！请输入您的验证码！');history.go(-1);</script>"
	response.end
end if
passcode=Cint(request.form("passcode"))
if cint(passcode)<>cint(Session("CheckCode")) then
	response.Write "<script LANGUAGE='javascript'>alert('登录失败！验证码错误！');history.go(-1);</script>"
	response.end
end if

if session("loginnum")="" then
	session("loginnum")=1
elseif session("loginnum")<=5 then
	session("loginnum")=session("loginnum")+1
else
	sql="insert into Web_loginlog(l_uid,l_pid,l_state,l_ip,l_locked,l_time) values('"&admin&"','********',3,'"&client_ip&"',1,'"&timeformat(now(),0)&"')"
	conn.execute(sql)
	session("loginnum")=""
	response.write "<script LANGUAGE='javascript'>alert('对不起，你在尝试非法登陆，系统已写登陆日志!');history.go(-1);</script>"
	response.end 
end if

if ubound(tmppwd)<1 then
	sql="insert into Web_loginlog(l_uid,l_pid,l_state,l_ip,l_locked,l_time) values('"&admin&"','********',4,'"&client_ip&"',0,'"&timeformat(now(),0)&"')"
	conn.execute(sql)
	response.write "<script LANGUAGE='javascript'>alert('登录失败! 你的用户名或者密码错误!');history.go(-1);</script>"
	response.end	
end if 

set rs=server.CreateObject("adodb.recordset")
sql="select * from [Web_Admin] where A_admin='"&admin&"' "
'response.write sql
rs.open sql,conn,2,2
if rs.bof and rs.eof then
	sql="insert into Web_loginlog(l_uid,l_pid,l_state,l_ip,l_locked,l_time) values('"&admin&"','"&tmppwd(0)&"',0,'"&client_ip&"',0,'"&timeformat(now(),0)&"')"
	conn.execute(sql)
	response.write "<script LANGUAGE='javascript'>alert('登录失败! 用户名或者密码错误!');history.go(-1);</script>"
else
	password=md5(tmppwd(0))
	in_code=web_l_safecode(tmppwd(1))
	dbcode=trim(getonevalue("Web_SafeCode","SC_code",""))
	if password=rs("a_password") and admin=rs("a_admin") and in_code=dbcode then
		on error resume next
		sql="insert into Web_loginlog(l_uid,l_pid,l_state,l_ip,l_locked,l_time) values('"&admin&"','********',1,'"&client_ip&"',0,'"&timeformat(now(),0)&"')"
		conn.execute(sql)
                rs("A_lastlogin")=timeformat(now(),0)
                rs("A_loginnum")=rs("A_loginnum")+1
                rs("A_loginip")=getIP()
		response.cookies("kkadmin")=trim(rs("a_admin"))
		response.cookies("kkadminlogin")="true"
		response.cookies("rank")=rs("a_rank")
		
                rs.update
		rs.Close
		set rs=nothing
		conn.Close
		set conn=nothing
		session("loginnum")=""
		call chkupdate()
		if err then
			err.clear
			response.write "<script>window.location.href='main.asp';</script>"
			response.end
		end if
	elseif password<>rs("a_password") then 
		sql="insert into Web_loginlog(l_uid,l_pid,l_state,l_ip,l_locked,l_time) values('"&admin&"','"&tmppwd(0)&"',0,'"&client_ip&"',0,'"&timeformat(now(),0)&"')"
		conn.execute(sql)
		response.write "<script LANGUAGE='javascript'>alert('登录失败！你的用户名或密码错误！');history.go(-1);</script>"
	else
		sql="insert into Web_loginlog(l_uid,l_pid,l_state,l_ip,l_locked,l_time) values('"&admin&"','********',2,'"&client_ip&"',0,'"&timeformat(now(),0)&"')"
		conn.execute(sql)
		response.write "<script LANGUAGE='javascript'>alert('登录失败！用户名或密码错误！');history.go(-1);</script>"
		
	end if
end if
closedb
%>

