function check_session_expired()
{
    my_session_start();
    if (get_session_expired()) {
        return json_encode(array(new command("alert", "Your session has expired. You are now being redirected to the login screen.\n(change the time it takes to expire under settings)"), new command("load page", "/pages/login/index.php")));
    } else {
        return "[]";
    }
}
Пример #2
0
function get_logged_in()
{
    global $global_user;
    if (!isset($_SESSION['loggedin']) || !isset($_SESSION['username']) || !isset($_SESSION['last_activity']) || !isset($_SESSION['crypt_password'])) {
        return NULL;
    }
    if (get_session_expired()) {
        $_POST['session_expired'] = 'Your session has expired';
        return NULL;
    }
    $_SESSION['last_activity'] = time();
    $o_user = new user($_SESSION['username'], NULL, urldecode($_SESSION['crypt_password']));
    if ($o_user->exists_in_db()) {
        $global_user = $o_user;
        return $o_user;
    }
    return NULL;
}