Ejemplo n.º 1
0
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;
        }
        $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]);
Ejemplo n.º 2
0
/**
 * Uploads a temp file which contains bookmarks to import
 * @global type $imported_bookmarks
 * @global type $repository_path
 * @global type $user_files_path
 * @global type $bookmarks_validation_file
 * @global type $album
 * @global type $asset
 */
function bookmarks_upload()
{
    global $imported_bookmarks;
    global $repository_path;
    global $user_files_path;
    global $bookmarks_validation_file;
    global $album;
    global $asset;
    $album = $_POST['album'];
    // the album user wants to import in
    $asset = $_POST['asset'];
    // the asset user wants to import in
    $target = $_POST['target'];
    // personal bookmarks or table of contents
    $_SESSION['album'] = $album;
    $_SESSION['asset'] = $asset;
    $_SESSION['target'] = $target;
    // 1) Sanity checks
    if ($_FILES['XMLbookmarks']['error'] > 0) {
        error_print_message(template_get_message('upload_error', get_lang()));
        log_append('error', 'upload_bookmarks: an error occurred during file upload (code ' . $_FILES['XMLbookmarks']['error']);
        die;
    }
    if ($_FILES['XMLbookmarks']['type'] != 'text/xml') {
        error_print_message(template_get_message('error_mimetype', get_lang()));
        log_append('warning', 'upload_bookmarks: invalid mimetype for file ' . $_FILES['XMLbookmarks']['tmp_name']);
        die;
    }
    if ($_FILES['XMLbookmarks']['size'] > 2147483) {
        error_print_message(template_get_message('error_size', get_lang()));
        log_append('warning', 'upload_bookmarks: file too big ' . $_FILES['XMLbookmarks']['tmp_name']);
        die;
    }
    // 2) Validates the XML file and converts it in associative array
    if (file_exists($_FILES['XMLbookmarks']['tmp_name'])) {
        // Validates XML structure
        $xml_dom = new DOMDocument();
        // trim heading and trailing white spaces
        // because blank lines in top and end of XML file lead to
        // validation error
        file_put_contents($_FILES['XMLbookmarks']['tmp_name'], trim(file_get_contents($_FILES['XMLbookmarks']['tmp_name'])));
        $xml_dom->load($_FILES['XMLbookmarks']['tmp_name']);
        if (!$xml_dom->schemaValidate($bookmarks_validation_file)) {
            include_once template_getpath('div_import_bookmarks.php');
            error_print_message(template_get_message('error_structure', get_lang()));
        }
        // Converts XML file in SimpleXMLElement
        $xml = simplexml_load_file($_FILES['XMLbookmarks']['tmp_name']);
        $imported_bookmarks = xml_file2assoc_array($xml, 'bookmark');
    }
    // init paths
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    // Keeps only bookmarks from existing assets
    foreach ($imported_bookmarks as $index => $bookmark) {
        if (!ezmam_asset_exists($bookmark['album'], $bookmark['asset'])) {
            unset($imported_bookmarks[$index]);
        }
    }
    log_append('upload_bookmarks: file imported');
    // lvl, action, album, asset, target (in official|personal bookmarks), number of bookmarks uploaded
    trace_append(array($asset != '' ? '3' : '2', 'bookmarks_upload', $album, $asset != '' ? $asset : '-', $target, count($imported_bookmarks)));
    echo '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>';
    //   echo  "<script language='javascript' type='text/javascript'>window.top.window.document.getElementById('popup_import_bookmarks').innerHTML='$lapin';</script>";
    include_once template_getpath('div_import_bookmarks.php');
}
Ejemplo n.º 3
0
/**
 * Displays the popup with the ulb code to copypaste
 * @global type $input
 * @global type $repository_path
 * @global type $url 
 */
function popup_ulb_code()
{
    global $input;
    global $repository_path;
    $asset_name = $input['asset'];
    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&amp;popup=ulb_code&amp;album=ALBUM&amp;asset=ASSET&amp;media=MEDIA';
        die;
    }
    if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_message(ezmam_last_error());
        die;
    }
    $ulb_code = get_code_to_media($input['album'], $input['asset'], $input['media']);
    // Displaying the popup
    require_once template_getpath('popup_ulb_code.php');
}
Ejemplo n.º 4
0
/**
 * @param bool $assoc(false) If set to true, the function returns an associative array listing every album by its name (key) and its description (value). If set to false, only the album name (value) is returned
 * @return array|false An array with all the album names the user can use but still hasn't 
 */
function acl_authorized_albums_list_not_created($assoc = false)
{
    if (!acl_user_is_logged()) {
        error_print_message('Error: acl_authorized_albums_list_not_created: You are not logged in');
        return false;
    }
    if ($assoc) {
        return $_SESSION['acl_not_created_albums_descriptions'];
    } else {
        return $_SESSION['acl_not_created_albums'];
    }
}
Ejemplo n.º 5
0
/**
 * Returns a special code that contains information about the media
 * @global type $url
 * @param string $album
 * @param string $asset
 * @param string $media
 * @return string Media
 */
function get_code_to_media($album, $asset, $media)
{
    global $ezplayer_url;
    global $distribute_url;
    global $repository_path;
    ezmam_repository_path($repository_path);
    //
    // Usual sanity checks
    //
    if (!ezmam_album_exists($album)) {
        error_print_message('get_link_to_media: Album ' . $album . ' does not exist');
        return false;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        error_print_message('get_link_to_media: Asset ' . $asset . ' does not exist');
        return false;
    }
    // We take the asset's token if it exists.
    // If not, then we use the album's token instead.
    $token = ezmam_asset_token_get($album, $asset);
    if (!$token) {
        $token = ezmam_album_token_get($album);
    }
    if (!$token) {
        error_print_message('get_link_to_media: ' . ezmam_last_error());
        return false;
    }
    $media_infos = explode('_', $media);
    // 'media' is like high_cam, so we want to extract the "high" part (quality) and the "cam" part (type)
    $quality = $media_infos[0];
    $type = $media_infos[1];
    return $album . '/' . $asset . '/' . $type . '/' . $quality . '/' . $token;
}
Ejemplo n.º 6
0
/**
 * Returns the number of watched assets
 * @param string $album
 * @return int
 */
function acl_watched_count($album)
{
    if (!acl_user_is_logged()) {
        error_print_message('Error: acl_has_album_permissions: You are not logged in');
        return 0;
    }
    $count = 0;
    foreach ($_SESSION['acl_watched_assets'] as $watched) {
        if ($watched['album'] == $album) {
            $album_assets = ezmam_asset_list($album);
            foreach ($watched['assets'] as $asset) {
                if (in_array($asset, $album_assets)) {
                    ++$count;
                }
            }
        }
    }
    return $count;
}