<!--#include file = "Startup.asp"-->
<!-- #include file="Function.asp" -->
<!--#include file="inc/md5.asp"-->
<%
Call ComeUrl()
session("username")=""
session("password")=""
%>
<%
dim username,password,CheckCode,FoundErr,ErrMsg,LoginTimes,userclass,LastLoginIP1,LastLoginIP
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
CheckCode=replace(trim(Request("CheckCode")),"'","")
Dim sSql1,sSql2
%>

<%if username<>"" and password<>"" then

	password=md5(password)
	ssql="select * from admin where username='"&username&"' and password='"&password&"'"
	ors.open ssql,oConn,1,1
	if not ors.eof then
		if CheckCode<>CStr(session("CheckCode")) then
			response.write("<table width='100%' height='100%'  border='0' cellpadding='0' cellspacing='0'><tr><td><div align='center'>您输入的确认码和系统产生的不一致，请重新输入！</div></td></tr></table>")
			response.write"<meta http-equiv='refresh' content='2;URL=login.asp'>"
			Response.End
		End If
		if ors("username")<>username then
 		  response.write("<table width='100%' height='100%'  border='0' cellpadding='0' cellspacing='0'><tr><td><div align='center'><div align='center'>用户名不对！</div></td></tr></table>")
	 	  response.write"<meta http-equiv='refresh' content='2;URL=login.asp'>"
	 	  Response.End
		End If
		if password=ors("password") then
   			LoginTimes=oRs("LoginTimes")
		   	LoginTimes=LoginTimes+1
			session("username")=ors("username")
   			session("password")=ors("password")
	   		session("userclass")=ors("userclass")
		   	userclass=ors("userclass")
   			sSql2="Update admin Set LastLoginIP=LastLoginIP1,LastLoginIP1='"&Request.ServerVariables("REMOTE_ADDR")&"',LastLoginTime='"&now()&"',LoginTimes=LoginTimes+1 Where  username='"&username&"'"
	   		oConn.Execute sSql2
		   	sSql1="Insert into admin_list (username,userclass,lastloginip,lastlogintime) values ('"&username&"','"&userclass&"','"&Request.ServerVariables("REMOTE_ADDR")&"','"&now()&"')"
   			oconn.execute ssql1
   			response.redirect "admin.asp"
		else
   			response.write("<table width='100%' height='100%'  border='0' cellpadding='0' cellspacing='0'><tr><td><div align='center'><div align='center'>密码不对哦！</div></td></tr></table>")
   			response.write"<meta http-equiv='refresh' content='2;URL=login.asp'>"
		end if
	else
   		response.write("<table width='100%' height='100%'  border='0' cellpadding='0' cellspacing='0'><tr><td><div align='center'><div align='center'>用户名或密码错误！</div></td></tr></table>")
	   	response.write"<meta http-equiv='refresh' content='2;URL=login.asp'>"
	end if
	ors.close
	set ors=nothing  
	oconn.close
	set oconn=nothing
end if
%>