<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim NCheck:NCheck=false

%>
<!--#include file="cgi/Config.asp"-->
<%
Dim macStr:macStr=request("mac")

Dim act:act=request("act")
select case act
	case "login"
		Dim logname:logname=mobj.CheckBadstr(trim(request("logname")))
		Dim logpass:logpass=mobj.CheckBadstr(trim(request("logpass")))
		if logname="" or logpass=""  then  mobj.JsCheck "账户、密码不能为空",1
		if len(logname)>20 or len(logpass)>20 then  mobj.JsCheck "账户、密码不规范",1
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from b2c_admin where a_active=1 and a_username='"&logname&"' and a_userpass='"&md5(logpass)&"'",dstr,1,3
		if rs.eof and rs.bof then			
			rs.close
			set rs=nothing
			mobj.cexe "insert into b2c_log(l_username,l_uid,l_ip,l_ok) values('"&logname&"',0,'"&mobj.Query()&"',0)"
			mobj.JsCheck "账户或者密码错误",1
		else
			Session("islog")=true
			if rs("a_type")=1 then 	Session("master")=true
			Session("a_id")=rs("a_id")
			Session("a_username")=rs("a_username")
			Session("a_type")=rs("a_type")
			rs("a_lastIp")=mobj.Query()
			rs("a_lastTime")=now()
			rs.update
			rs.close
			set rs=nothing
			'写入系统日志
			mobj.cexe "insert into b2c_log(l_username,l_uid,l_ip,l_ok) values('"&Session("a_username")&"',"&Session("a_id")&",'"&mobj.Query()&"',1)"
			'mobj.aclog Session("a_username"),1,101,"无"
			response.Redirect("main.asp")
			'Response.Cookies("username")=Session("a_username")
			'Response.Cookies("username").Expires=dateadd("d",365,now())
			
			
		end if
	case "logout"
		Session("islog")=false
		Session("a_id")=""
		Session("a_username")=""
		Session("master")=false
		
	case else
end select
%>
<!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>管理登陆 V1.0</title>
<script src="js/jquery-1.7.1.min.js" language="javascript"></script>
<script src="js/jquery.cookiesmin.js" language="javascript"></script>
<style type="text/css">
body,td,th {
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	background-color: #08377D;
}
form,p,ul,li{ margin:0px; padding:0px;}
.oa_main{ width:889px; margin:0px auto; clear:both;}
#oa_top{
	height:230px;
	background-image: url(images/t.jpg);
	background-repeat: no-repeat;
}
#oa_end{ height:200px;background-image: url(images/b.jpg);
	background-repeat: no-repeat;}
	#oa_center{ height:126px;}
	.oa_left{
	float:left;
	width:332px;
	height:126px;
	background-image: url(images/c_left.jpg);
	background-repeat: no-repeat;
}

.oa_right{
	float:right;
	width:230px;
	height:126px;
	background-image: url(images/c_right.jpg);
	background-repeat: no-repeat;
}
.oa_center{
	float:left;
	width:327px;
	height:126px;
	background-image: url(images/center.jpg);
	background-repeat: no-repeat;
}
.userlog{
	width:137px;
	height:18px;
	border: 1px solid #9FD1EC;
	float:left;
	padding-top:2px;
	position:absolute;
	margin-left:80px;
	background-color: #6BA5CD;
	
	font-weight:bold;
	font-size:14px;
	font-family: Georgia, "Times New Roman", Times, serif; color:#0600FD;
}
.username{  margin-top:37px;}
.userpass{  margin-top:71px;}
.jizhu{ position:absolute; float:left; margin-left:60px; margin-top:100px; font-size:13px; color:#FFF; font-family:"微软雅黑", "新宋体", "宋体", "黑体";}

a.xitbangzhu{
	position:absolute;
	float:left;
	margin-left:160px;
	margin-top:102px;
	font-size:13px;
	color:#FFF;
	font-family:"微软雅黑", "新宋体", "宋体", "黑体";
	width:80px;
	
	text-decoration: none;
}
a.sublog{
	float:left;
	width:65px;
	height:60px;
	position:absolute;
	margin-left:248px;
	margin-top:37px;
	color: #FFF;
	text-decoration: none;
}
</style>
<script language="javascript">
	function checklogin(){
		var newOptions = {domain: '<%=request.ServerVariables("HTTP_HOST")%>',path: '/',expiresAt: new Date( 2015, 1, 1 ),secure: false}
		if (document.getElementById("logname").value=="") {
			alert("账户名称不能为空!");
			document.getElementById("logname").focus();
			return;
		}
		
		if (document.getElementById("logpass").value=="") {
			alert("登陆密码不能为空!");
			document.getElementById("logpass").focus();
			return;
		}
		
		if($("#jizhuuser").attr("checked")){
			

	
		$.cookies.set('username', $("#logname").val(),newOptions);
	

		}
		document.getElementById("loginform").submit();
		}
</script>
</head>

<body>
<form method="post" action="index2.asp" target="_self" id="loginform">
<div class="oa_main" id="oa_top"></div>
<div class="oa_main" id="oa_center">
  <div class="oa_left"></div>
  <div class="oa_center">
  <input type="text" class="userlog username" name="logname" id="logname"  maxlength="20" autocomplete="off" />
  <input type="password" class="userlog userpass" name="logpass" id="logpass" />
  <a href="javascript:checklogin();" class="sublog">&nbsp;</a><input name="act" type="hidden" value="login" />
  <label for="jizhuuser" class="jizhu"><input name="jizhuuser" type="checkbox" id="jizhuuser" value="" checked="checked" align="middle" />记住用户名</label>
  <a class="xitbangzhu" href="#"></a>
  </div>
  
  <div class="oa_right"></div>
</div>
<div class="oa_main" id="oa_end"></div>
</form>
</body>
</html>
<script language="javascript">
$(document).ready(function(){
  //alert($.cookie("username"));
  //$.cookies.set("username","123")
 
$("#logname").val($.cookies.get("username"));


if($.cookies.get("username")!=null){
		$("#logpass").focus();
	}
	else{
		$("#logname").focus();
	}
	

  $(document).bind("contextmenu",function(e){   
          return false;   
   });
 $("html").die().live("keydown",function(event){  
    if(event.keyCode==13){  
        checklogin();
    }  
}); 
 
 
 
});



</script>
