예제 #1
0
function user_prefs_settings_get($user)
{
    // Sanity check
    if (!isset($user) || $user == '') {
        return false;
    }
    // 1) set repository path
    $user_files_path = user_prefs_repository_path();
    if ($user_files_path === false) {
        return false;
    }
    $settings = array();
    // 2) set user's file path
    $user_path = $user_files_path . "/" . $user;
    // 3) if the xml file exists, it is converted in associative array
    if (file_exists($user_path . "/_settings.xml")) {
        $xml = simplexml_load_file($user_path . "/_settings.xml");
        $settings = xml_file2assoc_array($xml);
    }
    return $settings;
}
예제 #2
0
/**
 * Used to sign in without a login
 * @global array $input
 * @global type $template_folder
 * @global type $login_error
 * @global type $repository_path
 * @global type $user_files_path
 * @global type $ezplayer_url
 */
function anonymous_login()
{
    global $input;
    global $template_folder;
    global $login_error;
    global $repository_path;
    global $user_files_path;
    global $ezplayer_url;
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    $login_error = '';
    $login = $input['login'];
    $passwd = $input['passwd'];
    unset($input['login']);
    unset($input['passwd']);
    $input['action'] = $_SESSION['ezplayer_mode'];
    $album_tokens = $_SESSION['acl_album_tokens'];
    unset($input['click']);
    // 0) Sanity checks
    if (!isset($login) || !isset($passwd) || empty($login) || empty($passwd)) {
        $login_error = template_get_message('empty_username_password', get_lang());
        load_page();
        die;
    }
    // checks if runas
    if (count($login_parts) == 2) {
        if (!file_exists('admin.inc')) {
            $error = "Not admin. runas login failed";
            view_login_form();
            die;
        }
        include 'admin.inc';
        //file containing an assoc array of admin users
        if (!isset($admin[$login_parts[0]])) {
            $error = "Not admin. runas login failed";
            view_login_form();
            die;
        }
        $_SESSION['user_is_admin'] = true;
        $_SESSION['user_runas'] = true;
    } else {
        if (file_exists('admin.inc')) {
            include 'admin.inc';
            //file containing an assoc array of admin users
            if (isset($admin[$login])) {
                $_SESSION['user_is_admin'] = true;
            }
        }
    }
    $res = checkauth($login, $passwd);
    if (!$res) {
        $login_error = checkauth_last_error();
        load_page();
        die;
    }
    // 1) Initializing session vars
    $_SESSION['ezplayer_logged'] = "user_logged";
    // "boolean" stating that we're logged
    unset($_SESSION['ezplayer_anonymous']);
    // "boolean" stating that we're logged
    $_SESSION['user_login'] = $res['login'];
    $_SESSION['user_real_login'] = $res['real_login'];
    $_SESSION['user_full_name'] = $res['full_name'];
    $_SESSION['user_email'] = $res['email'];
    $_SESSION['admin_enabled'] = false;
    if (isset($album_tokens)) {
        user_prefs_tokens_add($_SESSION['user_login'], $album_tokens);
    }
    // 2) Initializing the ACLs
    acl_init($login);
    // 3) Logging the login operation
    log_append("anonymous user logged in");
    // lvl, action, browser_name, browser_version, user_os, browser_full_info
    $lvl = $_SESSION['album'] != '' && $_SESSION['asset'] != '' ? 3 : ($_SESSION['album'] != '' ? 2 : 1);
    trace_append(array($lvl, "login_from_anonymous", $_SESSION['browser_name'], $_SESSION['browser_version'], $_SESSION['user_os'], $_SESSION['browser_full'], session_id()));
    if (count($input) > 0) {
        $ezplayer_url .= '/index.php?';
    }
    foreach ($input as $key => $value) {
        $ezplayer_url .= "{$key}={$value}&";
    }
    // 4) Displaying the previous page
    header("Location: " . $ezplayer_url);
    load_page();
}
예제 #3
0
파일: lib_acl.php 프로젝트: jingyexu/ezcast
function acl_update_watched_assets()
{
    global $repository_path;
    global $user_files_path;
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    $watched_assets = array();
    if (acl_user_is_logged()) {
        $album_tokens_list = acl_album_tokens_get();
        foreach ($album_tokens_list as $album_token) {
            $global_count[$album_token['album']] = ezmam_asset_count($album_token['album']);
        }
        $watched_assets = user_prefs_watchedlist_get($_SESSION['user_login'], false);
        $_SESSION['acl_global_count'] = $global_count;
    }
    $_SESSION['acl_watched_assets'] = $watched_assets;
}