made login session-less
This commit is contained in:
		
							parent
							
								
									52e9109843
								
							
						
					
					
						commit
						e201c260f2
					
				@ -1,15 +1,11 @@
 | 
			
		||||
{validate id="userid" message=$lang.login.error.user append="error"}
 | 
			
		||||
{validate id="pwd" message=$lang.login.error.pass append="error"}
 | 
			
		||||
{validate id="password" message=$lang.login.error.match append="error"}
 | 
			
		||||
 | 
			
		||||
{include file=shared:errorlist.tpl}
 | 
			
		||||
 | 
			
		||||
<form id="login" method="post" action="{$smarty.server.PHP_SELF}?redirect={$smarty.request.redirect}" enctype="multipart/form-data">
 | 
			
		||||
<form id="login" method="post" action="{$smarty.server.PHP_SELF}" enctype="multipart/form-data">
 | 
			
		||||
	<fieldset><legend>{$lang.login.fieldset1}</legend>
 | 
			
		||||
	<p><label for="user">{$lang.login.user}</label><br />
 | 
			
		||||
	<input {$error.user|notempty:'class="field-error"'} type="text" name="user" id="user" /></p>
 | 
			
		||||
	<input {$error.user|notempty:'class="field-error"'} type="text" name="user" id="user" {if $smarty.post.user}value="{$smarty.post.user}"{/if} /></p>
 | 
			
		||||
	<p><label for="pass">{$lang.login.pass}</label><br />
 | 
			
		||||
	<input type="password" {$error.pass|notempty:'class="field-error"'} name="pass" id="pass" /></p>
 | 
			
		||||
	<input type="password" {$error.pass|notempty:'class="field-error"'} name="pass" id="pass" {if $smarty.post.pass}value="{$smarty.post.pass}"{/if} /></p>
 | 
			
		||||
	</fieldset>
 | 
			
		||||
	
 | 
			
		||||
	<div class="buttonbar">
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										49
									
								
								login.php
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								login.php
									
									
									
									
									
								
							@ -9,6 +9,36 @@
 | 
			
		||||
	
 | 
			
		||||
	$tpl = 'default.tpl';
 | 
			
		||||
 | 
			
		||||
	function login_validate() {
 | 
			
		||||
		global $smarty, $lang;
 | 
			
		||||
 | 
			
		||||
		$user = trim(@$_POST['user']);
 | 
			
		||||
		$pass = trim(@$_POST['pass']);
 | 
			
		||||
 | 
			
		||||
		$error = array();
 | 
			
		||||
		$lerr =& $lang['login']['error'];
 | 
			
		||||
 | 
			
		||||
		if (!$user) {
 | 
			
		||||
			$error['user'] = $lerr['user']; 
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!$pass) {
 | 
			
		||||
                 	$error['pass'] = $lerr['pass'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!$error && !user_login($user, $pass)) {
 | 
			
		||||
			$error['match'] = $lerr['match']; 
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($error) {
 | 
			
		||||
			$smarty->assign('error', $error);
 | 
			
		||||
			return  0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return 1;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
	function main() {
 | 
			
		||||
		global $lang, $smarty;
 | 
			
		||||
		
 | 
			
		||||
@ -54,26 +84,11 @@
 | 
			
		||||
		
 | 
			
		||||
		
 | 
			
		||||
		} elseif(empty($_POST)) {
 | 
			
		||||
		
 | 
			
		||||
		// new form, we (re)set the session data
 | 
			
		||||
			SmartyValidate::connect($smarty, true);
 | 
			
		||||
		// register our validators
 | 
			
		||||
			SmartyValidate::register_validator('userid', 'user', 'notEmpty', false, false, 'trim');
 | 
			
		||||
			SmartyValidate::register_validator('pwd', 'pass', 'notEmpty', false, false, 'trim');
 | 
			
		||||
			SmartyValidate::register_validator('password', 'user:pass', 'isValidPassword', false, false);
 | 
			
		||||
			
 | 
			
		||||
		// display form
 | 
			
		||||
			$content = (SHARED_TPLS . 'login.tpl'); 
 | 
			
		||||
		       $content = (SHARED_TPLS . 'login.tpl'); 
 | 
			
		||||
		} else {    
 | 
			
		||||
			// validate after a POST
 | 
			
		||||
			SmartyValidate::connect($smarty);
 | 
			
		||||
			if(SmartyValidate::is_valid($_POST)) {
 | 
			
		||||
				SmartyValidate::disconnect();
 | 
			
		||||
				
 | 
			
		||||
				// sess_add('login_do', true);
 | 
			
		||||
				// utils_redirect();
 | 
			
		||||
			if(login_validate()) {
 | 
			
		||||
				utils_redirect('login.php');
 | 
			
		||||
								
 | 
			
		||||
			} else {
 | 
			
		||||
				$smarty->assign($_POST);
 | 
			
		||||
				$content = (SHARED_TPLS . 'login.tpl');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user