All pastes #964096 Raw Edit

Miscellany

public text v1 · immutable
#964096 ·published 2008-03-31 00:48 UTC
rendered paste body
<?php
	session_start();

 ##User/Password Sanetizer##
function cleanCheck($user,$pass) {
	$cleanUser = '#[a-zA-Z0-9-_.]+#';
	$cleanPass = '#[a-zA-Z0-9!-_.]+#';

	if ( (preg_match($cleanUser,$user,$out)>0) && (preg_match($cleanPass,$pass,$out)>0)) {
		return TRUE;
	} else {
		return FALSE;
	}

} 

$userName = $_POST['userName'];
$password = $_POST['password'];

if (!cleanCheck($userName,$password)) {
	die('Illegal character');
}

 ##I'll but db shit here later##
	if ($userName == 'omg' && $password == 'test') {
		$_SESSION['auth'] = 'TRUE';
		$_SESSION['time'] = time();
		header("Locations: yo.php");
	} else {
		$_SESSION['auth'] = NULL;
		$_session[failedLogin]++;
		header("Location: login.php");
		exit();
	}
?>




AANODAR PAGE <?php
        session_start();

        if(($_SESSION['time'] - time()) > 3600) {
                session_distroy();
                header("Location: login.php");
                exit();
        } else {
                $_SESSION['time'] = time();
        }
        print_r($_SESSION);
        echo "$_SESSION['time'] $_SESSION['auth']";
        echo "</ br> We wait for a minute and kill the session";

?>