예제 #1
0
function login($ip, $nick, $password)
{
    /*$intentos = 0;
    		if (isset($_COOKIE['intentos'])){ 
    			$intentos = $_COOKIE['intentos'];
    		}
    				
    		if ($intentos <= 3){*/
    $hashedPassword = hash("sha256", $password, false);
    if (checkNickPassword($nick, $hashedPassword)) {
        $email = getEmail($nick);
        $_SESSION['nick'] = $nick;
        $_SESSION['email'] = $email;
        $_SESSION['role'] = getRole($email);
        //setcookie( 'intentos', 0, time() + 1800 ); //30 minutos
        addAction($nick, $email, $ip, 'logged_in');
        addConnection($nick, $email, $ip);
        return '0';
        // Logged.
    } else {
        //if ($intentos < 3) {
        //setcookie( 'intentos', $intentos + 1, time() + 1800 ); //30 minutos
        return '1';
        // Log in failed.
    }
    /*} 
    		
    		setcookie( 'intentos', 0, time() + 1800);
    		return '2';	// Superado el límite de intentos.
    		*/
}
예제 #2
0
<?php

include './functions/database_logic.php';
include './functions/user_logic.php';
session_start();
$ip = get_client_ip();
$nick = $_SESSION['nick'];
$email = $_SESSION['email'];
$oldPass = $_POST['oldPass'];
$newPass = $_POST['newPass'];
$newPassRepe = $_POST['newPassRepe'];
if ($newPass == $newPassRepe) {
    if (checkNickPassword($nick, $oldPass)) {
        if (changePassword($nick, $newPass)) {
            echo "La contrase�a se ha cambiado correctamente.";
        } else {
            echo "Ha habido un problema.";
        }
    } else {
        echo "La contrase�a anterior es incorrecta.";
    }
} else {
    echo "Ha introducido mal la nueva contrase�a.";
}
?>