<% Option Explicit %>
<!--#include file="../Inc/Cls_DB.asp" -->
<!--#include file="../Inc/Const.asp" -->
<!--#include file="../Inc/Md5.asp" -->
<%

Dim DBC,Conn,RsLoginObj,RsLogObj
Dim MemName,Password,VerifyCode,SqlLogin,Url
Url = Request("UrlAddress")
if Url = "" then
	Url = "Usermain.asp"
end if

Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
MemName = Replace(Trim(Request.Form("MemName")),"'","''")
Password = md5(Replace(Trim(Request.Form("Password")),"'","''"),16)

if MemName = "" or  Password = "" then 
    Response.Write("<script>alert(""用户名和密码不能为空！"");location=""javascript:history.back()"";</script>")  
    Response.End
end if

set RsLoginObj = server.CreateObject ("ADODB.RecordSet")
SqlLogin = "select * from members where MemName='"&MemName&"' and  password='"&Password&"'"
RsLoginObj.Open SqlLogin,Conn,1,1
if Not RsLoginObj.EOF then 
   if RsloginObj("Lock")=true then
      Response.Write("<script>alert(""您已经被管理员锁定，请与管理员联系！"");location=""javascript:history.back()"";</script>")  
      Response.End
   end if
   Session("MemName") = MemName
   Session("MemPassWord") = Password
   Session("MemID") = RsLoginObj("ID")
   Session("GroupID") = RsLoginObj("GroupID")
   Session("Point") = RsLoginObj("Point")
   Response.Cookies("Foosun")("MemName") = MemName
   Response.Cookies("Foosun")("MemPassword") = Password
   Response.Cookies("Foosun")("MemID") = RsLoginObj("ID")
   Response.Cookies("Foosun")("GroupID") = RsLoginObj("GroupID")
   Response.Cookies("Foosun")("Point") = RsLoginObj("Point")
   dim LoginTime
   LoginTime = date()
   Dim Rscon
   set Rscon= conn.execute("select NumberContPoint,NumberLoginPoint from Config")
   conn.execute("update members set LoginNum=LoginNum+1,Point=Point+"&clng(Rscon("NumberLoginPoint"))&",LastLoginIP='"&Request.ServerVariables("Remote_ADDR")&"',LastLoginTime='"&LoginTime&"' where MemName='"&MemName&"'")'用户登陆一次，积分+1分
   Rscon.close
   set Rscon=nothing
   Response.Redirect(Url) 
   Response.End
else
   Response.Write("<script>alert(""非法登陆，请确认密码的正确性！"");location=""javascript:history.back()"";</script>")  
   Response.End
end if
set Conn = Nothing
Set RsLoginObj = Nothing
%>