Esempio n. 1
0
function fs_start_user_session($user)
{
    require_once FS_ABS_PATH . '/php/session.php';
    $ok = fs_session_start();
    if ($ok !== true) {
        $msg = "Error starting session";
        if (is_string($ok)) {
            $msg .= " :{$ok}";
        }
        $msg .= "<br/>";
        echo $msg;
        return false;
    }
    global $FS_SESSION;
    $FS_SESSION['user'] = $user;
    fs_store_session();
    // user is null for dummy sessions (may be needed before login)
    if ($user != null) {
        // raise authenticated event.
        // some initialization code may only happen after the user is authenticated.
        fs_do_action("authenticated");
    }
    return true;
}
Esempio n. 2
0
fs_e('Reset password');
?>
</h3>
<?php 
$instructions = sprintf(fs_r("You can request an password reset email from here. If it does not work or you don't know your username or email, you can also change your password using the %s"), fs_link("tools.php?file_id=manage_users", fs_r('Emergency user management page'))) . "</br>";
echo '<div style="margin-bottom: 30px">';
if (isset($_POST['username'])) {
    echo $instructions;
    $username = $_POST['username'];
    $email = isset($_POST['email']) ? $_POST['email'] : "";
    $user = fs_get_user_by_username_and_email($username, $email);
    if ($user === null) {
        echo "<div class='error'>" . fs_r("A user with this username and email was not found") . "</div>";
    } else {
        if (is_object($user)) {
            $ok = fs_session_start();
            if ($ok !== true) {
                $msg = "Error starting session";
                if (is_string($ok)) {
                    $msg .= " :{$ok}";
                }
                $msg .= "<br/>";
                echo $msg;
                return false;
            }
            global $FS_SESSION;
            $FS_SESSION['user'] = $user;
            fs_store_session();
            $sid = fs_get_session_id();
            $headers = "Content-Type: text/html; charset=\"UTF-8\"\r\n";
            $headers .= "MIME-Version: 1.0 ";
Esempio n. 3
0
<?php

define('FS_AJAX_HANDLER', true);
require_once dirname(__FILE__) . '/session.php';
/**
 * Restoring the session BEFORE including the rest of the files.
 * the is nessecary because those files depends on the context to be established.
 */
$session_specified = true;
$session_init = false;
if (empty($_POST['sid'])) {
    $session_specified = false;
} else {
    $session_init = fs_session_start($_POST['sid']);
}
require_once dirname(dirname(__FILE__)) . '/lib/json/JSON.php';
$json = new Services_JSON();
if (isset($_POST['action'])) {
    ob_start();
    // capture output. if there is output it means there is an error.
    require_once dirname(__FILE__) . '/db-config-utils.php';
    require_once dirname(__FILE__) . '/db-common.php';
    require_once dirname(__FILE__) . '/db-setup.php';
    require_once dirname(__FILE__) . '/auth.php';
    require_once dirname(__FILE__) . '/html-utils.php';
    global $session_specified;
    global $session_init;
    $action = $_POST['action'];
    $response['status'] = 'error';
    $allowed = true;
    if ($action != 'login') {
Esempio n. 4
0
function fs_systest_session()
{
    require_once FS_ABS_PATH . '/php/session.php';
    global $FS_SESSION;
    unset($FS_SESSION);
    $errors = array();
    $res = fs_initialize_session_dir(true);
    if ($res !== true) {
        $errors[] = fs_systest_error("fatal", sprintf("Error initializing session directory: %s", $res));
    } else {
        $ok = fs_session_start(null, true);
        if ($ok !== true) {
            $errors[] = fs_systest_error("fatal", "Error creating test session");
        } else {
            global $FS_SESSION;
            $sid = $FS_SESSION['sid'];
            unset($GLOBALS['FS_SESSION']);
            $ok = fs_session_start($sid, true);
            if ($ok !== true) {
                $errors[] = fs_systest_error("fatal", "Error restoring session : {$ok}");
            }
        }
    }
    return $errors;
}
Esempio n. 5
0
function fs_resume_existing_session()
{
    $sid = null;
    if (isset($_REQUEST['sid']) && !empty($_REQUEST['sid'])) {
        $sid = $_REQUEST['sid'];
    } else {
        if (isset($_COOKIE['FS_SESSION_ID'])) {
            $sid = $_COOKIE['FS_SESSION_ID'];
        } else {
            return "sid not specified";
        }
    }
    $res = fs_session_start($sid);
    global $FS_SESSION;
    if (is_bool($res) && $res) {
        global $FS_CONTEXT;
        $FS_CONTEXT = $FS_SESSION['context'];
        return true;
    } else {
        if (is_string($res)) {
            return $res;
        } else {
            return "Session expired";
        }
    }
}