示例#1
0
 */
/**
 * @package ezcast.ezadmin.installer
 */
/**
 * This file is aimed to install EZcast and its components.
 * It creates the tables of the database and sets up the configuration files 
 * according to the user's preferences
 */
require_once '../commons/lib_template.php';
require_once '../commons/lib_database.php';
require_once 'lib_various.php';
require_once 'lib_error.php';
$template_folder = 'tmpl/';
date_default_timezone_set("Europe/Brussels");
template_repository_path($template_folder . get_lang());
template_load_dictionnary('translations.xml');
if (file_exists('config.inc')) {
    echo "Nothing to do here ;-)";
    die;
}
session_name("ezcast_installer");
session_start();
$_SESSION['install'] = true;
$errors = array();
$input = array_merge($_GET, $_POST);
if (!isset($_SESSION['user_logged'])) {
    if (isset($input['action']) && $input['action'] == 'login') {
        if (!isset($input['login']) || !isset($input['passwd'])) {
            error_print_message(template_get_message('empty_username_password', get_lang()));
            die;
示例#2
0
/**
 * Effectively logs the user in
 * @param string $login
 * @param string $passwd
 */
function user_login($login, $passwd)
{
    global $input;
    global $template_folder;
    global $error;
    global $ezplayer_url;
    // 0) Sanity checks
    if (empty($login) || empty($passwd)) {
        $error = template_get_message('empty_username_password', get_lang());
        view_login_form();
        die;
    }
    $login_parts = explode("/", $login);
    // 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(strtolower($login), $passwd);
    if (!$res) {
        $error = checkauth_last_error();
        view_login_form();
        die;
    }
    // 1) Initializing session vars
    $_SESSION['ezplayer_logged'] = "user_logged";
    // "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;
    //check flash plugin or GET parameter no_flash
    if (!isset($_SESSION['has_flash'])) {
        //no noflash param when login
        //check flash plugin
        if ($input['has_flash'] == 'N') {
            $_SESSION['has_flash'] = false;
        } else {
            $_SESSION['has_flash'] = true;
        }
    }
    // 2) Initializing the ACLs
    acl_init($login);
    // 3) Setting correct language
    set_lang($input['lang']);
    // 4) Resetting the template path to the one of the language chosen
    template_repository_path($template_folder . get_lang());
    // 5) Logging the login operation
    log_append("login");
    log_append("user's browser : " . $_SESSION['browser_full']);
    // lvl, action, browser_name, browser_version, user_os, browser_full_info
    trace_append(array("1", "login", $_SESSION['browser_name'], $_SESSION['browser_version'], $_SESSION['user_os'], $_SESSION['browser_full'], session_id()));
    // 6) Displaying the page
    //    view_main();
    if (count($_SESSION['first_input']) > 0) {
        $ezplayer_url .= '/index.php?';
    }
    foreach ($_SESSION['first_input'] as $key => $value) {
        $ezplayer_url .= "{$key}={$value}&";
    }
    header("Location: " . $ezplayer_url);
    load_page();
}
示例#3
0
/**
 * Displays the flash player
 * @global type $input 
 */
function view_embed()
{
    global $input;
    global $repository_path;
    global $flash_only_browsers;
    global $template_folder;
    global $ezmanager_url;
    // Sanity checks
    if (!isset($input['album']) || !isset($input['asset']) || !isset($input['quality']) || !isset($input['type']) || !isset($input['token'])) {
        echo "Usage: distribute.php?action=embed&amp;album=ALBUM&amp;asset=ASSET&amp;type=TYPE&amp;quality=QUALITY&amp;token=TOKEN<br/>";
        echo "Optional parameters: width: Video width in pixels. height: video height in pixels. iframe: set to true if you want the return code to be an iframe instead of a full HTML page";
        die;
    }
    if (!ezmam_album_exists($input['album'])) {
        error_print_http(404);
        log_append('warning', 'view_embed: tried to access non-existant album ' . $input['album']);
        die;
    }
    if (!ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_http(404);
        log_append('warning', 'tried to access non-existant asset ' . $input['asset'] . ' of album ' . $input['album']);
        die;
    }
    if (!ezmam_album_token_check($input['album'], $input['token']) && !ezmam_asset_token_check($input['album'], $input['asset'], $input['token'])) {
        error_print_http(403);
        log_append('warning', 'view_media: tried to access asset ' . $input['asset'] . ' from album ' . $input['album'] . ' with invalid token ' . $input['token']);
        die;
    }
    // Then we retrieve the useful information, i.e. the media path and the dimensions
    // Fallback: if the media doesn't exist in the requested quality,
    // we try to find it in another one available
    $media_name = $input['quality'] . '_' . $input['type'];
    if (!ezmam_media_exists($input['album'], $input['asset'], $media_name)) {
        if ($input['quality'] == 'high') {
            $media_name = 'low_' . $input['type'];
        } else {
            if ($input['quality'] == 'low') {
                $media_name = 'high_' . $input['type'];
            }
        }
        // If no quality is available, we tell that to the user.
        if (!ezmam_media_exists($input['album'], $input['asset'], $media_name)) {
            error_print_http(404);
            die;
        }
    }
    $metadata = ezmam_media_metadata_get($input['album'], $input['asset'], $media_name);
    $width = $metadata['width'];
    if (isset($input['width']) && !empty($input['width'])) {
        $width = $input['width'] - 5;
    }
    $height = $metadata['height'];
    if (isset($input['height']) && !empty($input['height'])) {
        $height = $input['height'] - 5;
    }
    $origin = $input['origin'] == 'ezmanager' ? 'ezmanager' : 'embed';
    $media_url = urlencode(ezmam_media_geturl($input['album'], $input['asset'], $media_name) . '&origin=' . $origin);
    $player_url = $ezmanager_url . '/swf/bugatti.swf';
    // And finally we display the player through a template!
    // If the user wanted to have the player in an iframe, we must change the code a little bit
    if (isset($input['iframe']) && $input['iframe'] == 'true') {
        $origin = $input['origin'] == 'ezmanager' ? 'ezmanager' : 'embed';
        echo '<iframe style="padding: 0; z-index: 100;" frameborder="0" scrolling="no" src="distribute.php?action=embed&amp;album=' . $input['album'] . '&amp;asset=' . $input['asset'] . '&amp;type=' . $input['type'] . '&amp;quality=' . $input['quality'] . '&amp;token=' . $input['token'] . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;origin=' . $origin . '" width="' . $width . '" height="' . $height . '"></iframe>';
    } else {
        template_repository_path($template_folder . 'en');
        require_once template_getpath('embed_header.php');
        // We check if the user's browser is a flash-only browser or if it accepts HTML5
        // It's a Flash browser IIF
        // UA includes 'Firefox' OR UA includes 'MSIE' BUT UA does not include 'MSIE 9.'
        // TODO: prepare for future revisions of MSIE
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.') !== false) {
            require_once template_getpath('embed_flash.php');
            require_once template_getpath('embed_footer.php');
            die;
        }
        // Otherwise, if it accepts HTML5, we display the HTML5 browser
        require_once template_getpath('embed_html5.php');
        require_once template_getpath('embed_footer.php');
    }
}
示例#4
0
/**
 * Returns the path to a specified template
 * @param type $tmpl_name 
 */
function template_getpath($tmpl_name)
{
    $path = template_repository_path();
    if ($path === false) {
        template_last_error("Error: template repository not found");
    }
    if (!file_exists($path . '/' . $tmpl_name)) {
        template_last_error("Error: template {$tmpl_name} not found");
    }
    return $path . '/' . $tmpl_name;
}
示例#5
0
/**
 * Effectively logs the user in
 * @param string $login
 * @param string $passwd
 */
function user_login($login, $passwd)
{
    global $input;
    global $template_folder;
    global $error;
    global $ezadmin_url;
    // 0) Sanity checks
    if (empty($login) || empty($passwd)) {
        $error = template_get_message('empty_username_password', get_lang());
        view_login_form();
        die;
    }
    $login_parts = explode("/", $login);
    // checks if runas
    if (count($login_parts) >= 2) {
        $error = "No runas here !";
        view_login_form();
        die;
    }
    if (!file_exists('admin.inc')) {
        $error = "User not authorized";
        view_login_form();
        die;
    }
    include 'admin.inc';
    //file containing an assoc array of admin users
    if (!isset($users[$login_parts[0]])) {
        $error = "User not authorized";
        view_login_form();
        die;
    }
    $res = checkauth(strtolower($login), $passwd);
    if (!$res) {
        $error = checkauth_last_error();
        view_login_form();
        die;
    }
    // 1) Initializing session vars
    $_SESSION['podcastcours_logged'] = "LEtimin";
    // "boolean" stating that we're logged
    $_SESSION['user_login'] = $login;
    $_SESSION['user_real_login'] = $res['real_login'];
    $_SESSION['user_full_name'] = $res['full_name'];
    $_SESSION['user_email'] = $res['email'];
    // 3) Setting correct language
    set_lang($input['lang']);
    // 4) Resetting the template path to the one of the language chosen
    template_repository_path($template_folder . get_lang());
    // 5) Logging the login operation
    log_append("login");
    // 6) Displaying the page
    header("Location: " . $ezadmin_url);
    view_main();
}
示例#6
0
/**
 * Effectively logs the user in
 * @param string $login
 * @param string $passwd
 */
function user_login($login, $passwd)
{
    global $input;
    global $template_folder;
    global $error;
    global $ezmanager_url;
    // 0) Sanity checks
    if (empty($login) || empty($passwd)) {
        $error = template_get_message('empty_username_password', get_lang());
        view_login_form();
        die;
    }
    $login_parts = explode("/", $login);
    // 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;
        }
    }
    $res = checkauth(strtolower($login), $passwd);
    if (!$res) {
        $error = checkauth_last_error();
        view_login_form();
        die;
    }
    // 1) Initializing session vars
    $_SESSION['podman_logged'] = "LEtimin";
    // "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'];
    //check flash plugin or GET parameter no_flash
    if (!isset($_SESSION['has_flash'])) {
        //no noflash param when login
        //check flash plugin
        if ($input['has_flash'] == 'N') {
            $_SESSION['has_flash'] = false;
        } else {
            $_SESSION['has_flash'] = true;
        }
    }
    // 2) Initializing the ACLs
    acl_init($login);
    // 3) Setting correct language
    set_lang($input['lang']);
    if (count(acl_authorized_albums_list()) == 0) {
        error_print_message(template_get_message('not_registered', get_lang()), false);
        log_append('warning', $res['login'] . ' tried to access ezmanager but doesn\'t have permission to manage any album.');
        session_destroy();
        view_login_form();
        die;
    }
    // 4) Resetting the template path to the one of the language chosen
    template_repository_path($template_folder . get_lang());
    // 5) Logging the login operation
    log_append("login");
    // 6) Displaying the page
    header("Location: " . $ezmanager_url);
    view_main();
}