Esempio n. 1
0
function is_ok()
{
    // check tokens, session vars, ip, referrer, cookie etc
    // in case of problem, destroy session and redirect
    global $auto_restrict;
    $expired = false;
    // fatal problem
    if (!checkReferer()) {
        return death("You are definitely NOT from here !");
    }
    if (!checkIP()) {
        return death("Hey... you were banished, f**k off !");
    }
    if (!checkToken()) {
        return death("You need a valid token to do that, boy !");
    }
    //
    if (checkCookie()) {
        return true;
    }
    if (!isset($_SESSION['id_user'])) {
        return false;
    }
    if ($_SESSION['expire'] < time()) {
        $expired = true;
    }
    $sid = Dechiffre($_SESSION['id_user'], $auto_restrict['encryption_key']);
    $id = id_user();
    if ($sid != $id || $expired == true) {
        // problème d'identité
        return false;
    } else {
        // all fine
        //session can survive a bit more ^^
        $_SESSION['expire'] = time() + 60 * $auto_restrict['session_expiration_delay'];
        return true;
    }
}
Esempio n. 2
0
function is_ok()
{
    # check tokens, session vars, ip, referrer, cookie etc
    # in case of problem, destroy session and redirect
    global $auto_restrict;
    $expired = false;
    if (!isset($_SESSION['id_user'])) {
        return false;
    }
    # fatal problem
    if (!checkReferer()) {
        return death('<div class="error">You are definitely NOT from here !</div>');
    }
    if (!checkIP()) {
        return death('<div class="error">Hey... you were banished, f**k off !</div>');
    }
    if (!checkToken()) {
        return death('<div class="error">Invalid token</div>');
    }
    #
    if (checkCookie()) {
        return true;
    }
    if ($_SESSION['expire'] < time()) {
        $expired = true;
    }
    $sid = Dechiffre($_SESSION['id_user'], $auto_restrict['users'][$_SESSION['login']]['encryption_key']);
    $id = id_user();
    if ($sid != $id || $expired == true) {
        # problème d'identité
        return false;
    } else {
        # all fine
        #session can survive a bit more ^^
        $_SESSION['expire'] = time() + 60 * $auto_restrict['session_expiration_delay'];
        return true;
    }
}