<!--#include file="conn.asp"-->
<!--#include file="char.inc"-->
<!--#include file="config.asp"-->
<!--#include file="md5.asp"-->

<%
'on error resume next
dim rs
UserName1=CheckStr(request.form("UserName"))
passwd1=md5(trim(request.form("passwd")))
verifycode=cstr(trim(request.form("verifycode")))
dim ViewUrl1
ViewUrl1="admin_index.asp"


if cstr(session("verifycode"))<>verifycode then
	Show_Err("验证码出错，可能是您在管理登录页面停留太久了，请返回后刷新页面。<br><br><a href='javascript:history.back()'>返回</a>")
	response.end
else
	set rs=server.createobject("adodb.recordset")
	sql="select * from "& db_wygkcn_Manage_Table &" where ("& db_ManageUser_Name &"='"&username1&"' and adder='"& ChkRequest(request.cookies(echsys)("username"), 0) &"')"
	rs.open sql,Conn,1,3
	If Not(rs.BOF OR rs.EOF) Then
	if (passwd1<>rs(db_ManageUser_Password) or UserName1<>rs(db_ManageUser_Name)) then
		Show_Err("用户名或密码出错，请返回检查<br><br><a href='javascript:history.back()'>返回重来</a>")
		response.end
	else
		rs(db_ManageUser_LastLoginIP)=Request.ServerVariables("REMOTE_ADDR")
		rs(db_ManageUser_LastLoginTime)=Now()
		rs(db_ManageUser_LoginTimes)=rs(db_ManageUser_LoginTimes)+1
		rs.update
		
		response.cookies(echsys)("ManageUserName")=RS(db_ManageUser_Name)
		response.cookies(echsys)("ManagePasswd")=rs(db_ManageUser_Password)
		response.cookies(echsys)("ManageUserEmail")=RS(db_ManageUser_Email)
		response.cookies(echsys)("ManageKEY")=rs("OSKEY")
		response.cookies(echsys)("ManagePurview")=rs("purview")
		response.cookies(echsys)("ManageFullName")=rs("fullname")
		response.cookies(echsys)("ManageReglevel")=rs("reglevel")
		response.cookies(echsys)("ManageSex")=rs(db_ManageUser_Sex)
		response.cookies(echsys)("ManageUserLoginTimes")=rs(db_ManageUser_LoginTimes)
		rs.close
		set rs=nothing
		conn.close
		set conn=nothing
	
		response.redirect "admin_index.asp"
		response.end
	end if
	Else
		response.write "<meta http-equiv=""refresh"" content="""&freetime&";url="&Cstr(Request.ServerVariables("HTTP_REFERER"))&""">"
		Show_Message("<p align=center><font color=red>用户不存在。</font><br><br>"&freetime&"秒钟后<a href=login.asp>返回</a>!")
		response.end
	End if
end if
rs.close
set rs=nothing
Conn.close
set Conn=nothing
%>