예제 #1
0
/**
 * Checks that $var holds a valid value
 * @param type $var
 * @return type 
 */
function check_val($var, $error)
{
    if (!isset($var) || empty($var)) {
        $error = template_get_message($error, 'en');
    }
}
예제 #2
0
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;
        }
        $login = $input['login'];
        $passwd = $input['passwd'];
        // 0) Sanity checks
        if (empty($login) || empty($passwd)) {
            $error = template_get_message('empty_username_password', get_lang());
            view_login_form();
            die;
        }
        $user_passwd = file_get_contents("../first_user");
        $user_passwd = explode(" , ", $user_passwd);
        $salt = substr($user_passwd[1], 0, 2);
        $cpasswd = crypt($passwd, $salt);
        $user_passwd[1] = rtrim($user_passwd[1]);
        $res = $login == $user_passwd[0] && $user_passwd[1] == $cpasswd;
        if (!$res) {
            $error = "Authentication failed";
            view_login_form();
            die;
        }
        $_SESSION['user_login'] = $login;
예제 #3
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();
}
예제 #4
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();
}
예제 #5
0
/**
 * DIsplays the popup with the embed code to copypaste
 * @global type $input
 * @global type $repository_path
 * @global type $url 
 */
function popup_embed_code()
{
    global $input;
    global $repository_path;
    global $ezmanager_url;
    global $distribute_url;
    ezmam_repository_path($repository_path);
    template_load_dictionnary('translations.xml');
    //
    // Sanity checks
    //
    if (!isset($input['album']) || !isset($input['asset']) || !isset($input['media'])) {
        echo 'Usage: index.php?action=show_popup&popup=embed_code&album=ALBUM&asset=ASSET&media=MEDIA';
        die;
    }
    if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_message(ezmam_last_error());
        die;
    }
    // Retrieving the info needed for the embed code and target link
    $metadata = ezmam_media_metadata_get($input['album'], $input['asset'], $input['media']);
    $token = ezmam_asset_token_get($input['album'], $input['asset']);
    if (!$token) {
        $token = ezmam_album_token_get($input['album']);
    }
    $media_infos = explode('_', $input['media']);
    $type = $media_infos[1];
    $quality = $media_infos[0];
    //compute iframe size according to media size
    $iframe_height = $metadata['height'] + 40;
    $iframe_width = $metadata['width'] + 30;
    // Embed code
    $link_target = $distribute_url . '?action=embed&album=' . $input['album'] . '&asset=' . $input['asset'] . '&type=' . $type . '&quality=' . $quality . '&token=' . $token;
    $embed_code_web = '<iframe width="' . $iframe_width . '" height="' . $iframe_height . '" style="padding: 0;" frameborder="0" scrolling="no" src="' . $distribute_url . '?action=embed_link&album=' . $input['album'] . '&asset=' . $input['asset'] . '&type=' . $type . '&quality=' . $quality . '&token=' . $token . '&width=' . $metadata['width'] . '&height=' . $metadata['height'] . '&lang=' . get_lang() . '"><a href="' . $link_target . '">' . template_get_message('view_video', get_lang()) . '</a></iframe>';
    $embed_code = htmlentities($embed_code_web, ENT_COMPAT, 'UTF-8');
    // Displaying the popup
    require_once template_getpath('popup_embed_code.php');
}
예제 #6
0
/**
 * Returns the asset full title from an asset name
 * @global type $repository_path 
 * @param type $album 
 * @param type $asset the original asset name
 * @return boolean|string the asset full title if the asset exists ; false otherwise
 */
function get_asset_title($album, $asset)
{
    global $repository_path;
    global $template_folder;
    ezmam_repository_path($repository_path);
    //
    // Usual sanity checks
    //
    if (!ezmam_album_exists($album)) {
        return false;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        return template_get_message('Inexistant', get_lang());
    }
    $asset_title = ezmam_asset_metadata_get($album, $asset);
    $asset_title = $asset_title['title'];
    return $asset_title;
}
예제 #7
0
/**
 * Takes a ls-friendly date and translates it into human-readable
 * @param string $date The date in format YYYY_mm_dd_HHhii
 * @param string $space_char The delimiter to use between digits
 * @param bool $long_months_names(true) If set to "false", the month will be displayed as a number instead of a noun
 * @param string $lang Language the months are displayed in, in cast $long_months_names is set to true
 * @param bool $long_date if set to true, the date will be a "gramatically correct" date, instead of a "easily computable" one
 * @return string The date in format dd_mmmm_YYYY_HH:ii
 */
function get_user_friendly_date($date, $space_char = '_', $long_months_names = true, $lang = 'fr', $long_date = false)
{
    if (!isset($date) || empty($date)) {
        return null;
    }
    $matches = array();
    preg_match('!(\\d{4})\\_(\\d{2})\\_(\\d{2})\\_(\\d{2})h(\\d{2})!', $date, $matches);
    $new_date = $matches[3] . $space_char;
    // Day
    // If we want long month names (in letters, that is), we retrieve these names
    // from the translations file, and remove the non-ASCII characters if needed
    if ($long_months_names) {
        template_load_dictionnary('translations.xml');
        if ($lang == 'fr-ASCII') {
            $new_date .= str_replace(array('é', 'û'), array('e', 'u'), template_get_message('month_' . $matches[2], 'fr'));
        } else {
            $new_date .= template_get_message('month_' . $matches[2], $lang);
        }
    } else {
        $new_date .= $matches[2];
    }
    $new_date .= $space_char . $matches[1];
    // year
    if ($long_date) {
        $new_date .= $space_char . $at;
    }
    // Separator between date and hour
    $new_date .= $space_char . $matches[4] . 'h' . $matches[5];
    // Hours and minutes
    return $new_date;
}