<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Include/conn.asp"-->
<!--#include file="../Include/ConnDatabase.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方网站http://www.ip126.com
'技术支持论坛 http://bbs.ip126.com/
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<%Response.Charset="utf-8"%>
<%
if request.QueryString("Action")="Out" then
   session.contents.remove "MemName"
   session.contents.remove "GroupID"
   session.contents.remove "GroupLevel"
   session.contents.remove "MemLogin"
   Session("Access_Token")=""
   session("openid")=""
   session("binding")=""
   response.redirect Cstr(request.ServerVariables("HTTP_REFERER"))
   response.end
end If

dim LoginName,LoginPassword,VerifyCode,MemName,Password,GroupID,GroupName,Working,rs,sql
LoginName=trim(request.form("LoginName"))
LoginPassword=Md5(request.form("LoginPassword"))
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_Members where MemName='"&LoginName&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
   response.write "<script language='JavaScript'>alert('用户名错误或不存在！');" & "history.back()" & "</script>"
   response.end
else
   MemName=rs("MemName")
   Password=rs("Password")
   GroupID=rs("GroupID")
   GroupName=rs("GroupName")
   Working=rs("Working")
end if

if LoginPassword<>Password then
   response.write "<script language='JavaScript'>alert('用户密码错误！');" & "history.back()" & "</script>"
   response.end
end if

if not Working then
   response.write "<script language='JavaScript'>alert('帐号未通过审核或被禁用！');" & "history.back()" & "</script>"
   response.end
end if

if UCase(LoginName)=UCase(MemName) and LoginPassword=Password then
   rs("LastLoginTime")=now()
   rs("LastLoginIP")=Request.ServerVariables("Remote_Addr")
   rs("LoginTimes")=rs("LoginTimes")+1
   rs.update
   rs.close
   set rs=nothing
   session("MemName")=MemName
   session("GroupID")=GroupID
   set rs = server.createobject("adodb.recordset")
   sql="select * from TianTianCMS_MemGroup where GroupID='"&GroupID&"'"
   rs.open sql,conn,1,1
   session("GroupLevel")=rs("GroupLevel")
   rs.close
   set rs=nothing
   session("MemLogin")="Succeed"
   session.timeout=60
   response.redirect Cstr(request.ServerVariables("HTTP_REFERER"))
   'response.redirect "login.asp"
   response.end
end if
%>