<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/sql_filter.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员登录-<%=SiteName%></title>
<link href="../style/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body>
<%
dim act,directurl,rs
act=request.QueryString("act")
if(request.QueryString("directurl")<>"") then
	directurl=request.QueryString("directurl")
else
	directurl=request.ServerVariables("HTTP_REFERER")
end if
if(directurl="") then
	directurl=SiteUrl
else
end if
directurl="/member/"
if(act="do") then
	dim flag,username,userpass,userpass2,email,ip,loginok,expire
	loginok=false
	if(isSelfRefer()) then
		if  Cstr(request.Form("checkcode")) <> Cstr(Session("GetCode"))  then 
			call alertstr("验证码错误！请返回刷新页面后再试。",1)
		else
			Session("GetCode")=""
			username=request.Form("username")
			expire=Cint(request.Form("expire"))
			username=replaceBadChar(username)
			userpass=request.Form("userpass")
			userpass=replace(userpass,"'","")
			userpass=md5(userpass,32)			
			ip=GetIp()
			set rs=server.CreateObject("adodb.recordset") 
			rs.open "select * from t_member where UserId='"&username&"' and UserPass='"&userpass&"' order by id desc",conn,3,3
			if rs.eof or rs.bof then
				loginok=false		
			else
				if(rs("IsLocked")=1) then
					loginok=false
				else
					loginok=true
					rs("LastLoginIp")=ip
					rs("LastLoginDate")=now()
					rs("LoginNum")=rs("LoginNum")+1
					rs.update
				end if
			end if
			rs.close
			set rs=nothing
			if(loginok=true) then
				conn.execute("update t_member set LoginNum=LoginNum+1 where UserId='"&username&"'")
				''''''''''''''''''''''设置Cookie''''''''''''''''''''''
				Response.Cookies("TotCms_Cookie")("UserName")=username
				Response.Cookies("TotCms_Cookie")("UserPass")=userpass	
				Response.Cookies("TotCms_Cookie")("LastVisite")=now()			
        Response.Cookies("TotCms_Cookie").Expires=Date()+expire
				session("TotCms_UserName")=username
				session("TotCms_UserPass")=userpass
				response.Write("<meta http-equiv=""Refresh"" content=""1;URL="&directurl&""" />"&Chr(10))
				response.Write("<p align=""center"">成功登录，正在转向上一页面.....</p>")
				Session("GetCode")=""
			else
				call alertstr("用户名与密码不匹配或帐户锁定!",1)
			end if
		end if
	else
		call alertstr("请从本站登录",1)
	end if
else
%>
<script type="text/javascript">
function check(obj){
	with(obj){
		if(username.value==""){
			alert("用户名不能空为!");
			username.focus();
			username.select();
			return false;
		}
		if(userpass.value==""){
			alert("密码不能空为!");
			userpass.focus();
			userpass.select();
			return false;
		}		
		if(checkcode.value==""){
			alert("验证码不能空为!");
			checkcode.focus();
			checkcode.select();
			return false;
		}
		return true;
	}
}
function checkemail(obj){
	var pattern = /^([\.a-zA-Z0-9_-]){3,}@([\.a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9]){2,4}){1,2}$/; 
	if(!pattern.test(obj.value)){
		alert("请输入您正确的邮箱格式!");
		obj.focus();
	}
}
function checkblur(obj){
	if(/[^\u4e00-\u9fa50-9a-zA-Z_]/g.test(obj.value)){
		alert('只限英文字母、数字和下划线!');
		obj.focus();
		obj.select();
	}
}
</script>
<!--#include file="../head.asp"-->
<div class="br"></div>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
  	<td><form id="form1" name="form1" method="post" action="?act=do&directurl=<%=directurl%>" onsubmit="return check(this)">
  	  <table width="760" border="0" align="center" cellpadding="0" cellspacing="0" class="body_bg">
    <tr>
      <td height="35" colspan="2"><div align="center"><strong>会员登录</strong> <a href="reg.asp?gourl=<%=server.URLEncode(directurl)%>">还没有注册？</a> </div></td>
    </tr>
    <tr>
      <td width="344" height="35"><div align="right">用户名：</div></td>
      <td width="452"><div align="left">
          <input name="username" type="text" id="username" onblur="checkblur(this)" />
      (<span class="style1">*</span>)</div></td>
    </tr>
    <tr>
      <td height="35"><div align="right">密码：</div></td>
      <td><div align="left">
          <input name="userpass" type="password" id="userpass" />
      (<span class="style1">*</span>)</div></td>
    </tr>
    <tr>
      <td height="35"><div align="right">保存登录：</div></td>
      <td>
	    <div align="left">
	      <select name="expire" id="expire">
	        <option value="0" selected="selected">不保存</option>
			<option value="1">一天</option>
	        <option value="7">一周</option>
	        <option value="30">一个月</option>
          </select>
        </div></td>
    </tr>
    <tr>
      <td height="35"><div align="right">验证码：</div></td>
      <td><div align="left">
          <input name="checkcode" type="text" id="checkcode" size="10" /> 
          <%=GetCode%>
      (<span class="style1">*</span>)</div></td>
    </tr>
    <tr>
      <td height="50" colspan="2"><div align="center">
        <input type="submit" name="Submit" value="登  录" />&nbsp;&nbsp;
        <input type="reset" name="Submit2" value="重  写" />
      </div></td>
    </tr>
  </table>
</form>
		</td>
	</tr>
</table>
<!--#include file="../root.asp"-->
<%end if%>
</body>
</html>
<%
call connclose()
%>