通达OA2017记住密码与自动登录

时间:2022-07-03 23:18:27
 
 
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
<meta http-equiv="Content-Type" content="text/html; charset={charset}" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="stylesheet" type="text/css" href="{static_server}/static/templates/2017_01/login.css?20170425"/>
<link rel="shortcut icon" href="{static_server}/static/images/tongda.ico" />
<script type="text/javascript" src="/static/js/base64/base64.min.js"></script>
<script type="text/javascript"src="{static_server}/static/templates/2017_01/jquery.min.js"></script>
<script type="text/javascript"src="{static_server}/static/templates/2017_01/jquery.cookie.js"></script>

<script type="text/javascript">


 $(document).ready(function () {
            if ($.cookie("rmbUser") == "true"){ 
           	$("#chkRem").attr("checked", true);  
            $("#name").val($.cookie("username"));  
            $("#password").val($.cookie("password"));
	var psw = document.form1.PASSWORD.value;
	alert(psw)
  	//document.form1.PASSWORD.value = Base64.encode(psw);
   	var pp=Base64.encode(psw);
	alert(pp);
   	var names=document.form1.UNAME.value;
	
	var dl="";
	$.ajax({  
               type: "POST",  
               url: "check.php",  
               data: "UNAME="+names+"&PASSWORD="+pp+"&encode_type=1",  
               success: function(data){  
                       // $("#myDiv").html('<h2>'+data+'</h2>');  
					   alert(data);
					   dl=data;
					   
					   if(dl!=1){
	//删除cookie
	$.cookie('#name', null); 
	$.cookie('#password', null); 
	//$.cookie('#rmbUser', false); 
	$("#chkRem").attr("checked", false); 
	document.form1.PASSWORD.value="";
	//alert("删除cookie成功!");
	alert("用户名或密码错误!");
	
	}
	else {
	
	window.location.href="logincheck.php?UNAME="+names+"&PASSWORD="+pp+"&encode_type=1";
	
	}
                  }  
            });   //end  ajax

	
            }  
        });  
      
function CheckForm()
{
	if ($("#chkRem").attr("checked")) {  
                var str_username = $("#name").val();  
                var str_password = $("#password").val(); 
               
                $.cookie("rmbUser", "true", { expires: 365 }); 
                $.cookie("username", str_username, { expires:365 });  
                $.cookie("password", str_password, { expires: 365 });
                 var spw= $("#password").val();
				}  
            else {  
                $.cookie("rmbUser", "false", { expire: -1 });  
                $.cookie("username", "", { expires: -1 });  
                $.cookie("password", "", { expires: -1 });  
            }  

		var psw = document.form1.PASSWORD.value;
		document.form1.PASSWORD.value = Base64.encode(psw);
		var pp=document.form1.PASSWORD.value;
		//alert(pp);
		//alert(document.form1.PASSWORD.value = Base64.encode(psw));
  
    return true;
};

</script>
</head>
<body>
{update_tips}
		<div class="header_con fixed">
			<form class="login_form" name="form1" method="post" action="logincheck.php" {autocomplete} onsubmit="return CheckForm();">
				<div class="hCon">
					<div class="logo"><img src="/static/templates/2017_01/logo-new.jpg" alt="" width="183" height="78"/></div>
				</div>
				<div id="left">
				<div id="in">
					<div id="diff"> </div>
				    <center>
				    <ul>
				        <li>
				       <span>用户名</span><input type="text" id="name" name="UNAME" maxlength="20" autocomplete="off"   class="logintext" placeholder="请输入用户名"/>
				        </li>
				        <li></li>
				        <li>
				        	
				        	<span>密码</span><input type="password" id="password" name="PASSWORD" autocomplete="new-password" class="logintext" placeholder="请输入密码"  />
				        </li>
				        <li class="controller">
				        	<input type="checkbox" name="chkRem" id="chkRem"><label for="chkRem">自动登录</label>
				        	<input type="hidden" name="encode_type" value="1">
				        	
				        	<button  type="submit" id="submit" class="button" title="登录"></button>
				        </li>
				        <div class="msg">
	        				<div>{tips}</div>
	       					<div>{usb_key_option}</div>
	        				<div>{miibeian}</div>
	        				<div>{antivirus_script}</div>
   						 </div>
				        <li class="errorMessage"></li>
					</ul>
				    </center>
				</div>
				<div id="copyright">
					</div>
				</div>
				{usbkey_object}
			</form>
			 
			<div id="detail" style="letter-spacing: 2px;line-height: 1.5;">
				
				</div>
			</div>
				<div id="noticedetail" style="overflow: auto;margin: 10px;height: 400px;color: #888;text-indent:2em;"></div>
				<div style="clear: both;"></div>
			</div>
			
</body>
</html>

check.php
 
<?php
include_once "inc/session.php";
session_start();
ob_start();
include_once "inc/conn.php";
include_once "inc/td_core.php";
include_once "inc/utility.php";
include_once "inc/utility_cache.php";

if ($_POST["LANGUAGE"] != "") {
	$LANG_ARRAY = get_lang_array();

	if (in_array($_POST["LANGUAGE"], $LANG_ARRAY)) {
		setcookie("LANG_COOKIE", $_POST["LANGUAGE"], time() + (60 * 60 * 24 * 1000), "/");
	}
}


if ($UNAME != "") {
	$USERNAME = $UNAME;
}
else {
	$USERNAME = $_POST["USERNAME"];
}

$USERNAME = trim($USERNAME);
$encode_type = intval($encode_type);
$PASSWORD = ($encode_type == 1 ? base64_decode((string) $PASSWORD) : $PASSWORD);
$LOGIN_MSG = login_check($USERNAME, $PASSWORD, $KEY_DIGEST, $KEY_SN, $KEY_USER, 0);

if ($LOGIN_MSG != "1") {
	$ARR_BTN = array(
		array("value" => _("重新登录"), "href" => "/")
		);
	$SYS_PARA = get_sys_para("RETRIEVE_PWD");
	if (($SYS_PARA["RETRIEVE_PWD"] == "1") && ($USERNAME != "admin")) {
		$_SESSION["RETRIEVE_PWD_USER"] = strip_tags($USERNAME);
		$ARR_BTN[] = array("value" => _("找回密码"), "href" => "/module/retrieve_pwd/");
	}

	//Message(_("错误"), $LOGIN_MSG, "error", $ARR_BTN);


	echo $LOGIN_MSG;
	

} else {
	echo "1";
	}
?>