示例#1
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');
    }
}
示例#2
0
/**
 * Displays the asset details and bookmarks.
 * This function is called when a user selects a bookmark from the bookmarks 
 * tab in the assets page or when a user shares a link to a specific timecode 
 * with an other user.
 * @global type $input
 * @global type $repository_path
 * @global type $asset_meta
 * @global string $panel_display
 * @global type $album
 * @global type $user_files_path
 * @global type $is_bookmark
 * @global type $asset_bookmarks
 * @global type $timecode
 * @param type $refresh_center
 */
function view_asset_bookmark($refresh_center = true)
{
    global $appname;
    global $input;
    global $asset_meta;
    global $album;
    global $user_files_path;
    global $repository_path;
    global $ezplayer_url;
    // used in a popup window
    global $is_bookmark;
    global $asset_bookmarks;
    global $toc_bookmarks;
    global $default_bookmarks_order;
    global $default_toc_order;
    global $timecode;
    global $error_asset;
    global $login_error;
    // used to display error when anonymous user login
    // the video will be loaded by a different way
    $_SESSION['load_video'] = false;
    // determines if the user is logged and has album authorization
    $is_bookmark = false;
    $error_asset = '';
    // session has expired, the whole page has to be refreshed
    if ($_SESSION['reloaded']) {
        unset($input['click']);
        unset($_SESSION['reloaded']);
        $refresh_center = true;
    }
    // Setting up various variables we'll need later
    if (isset($input['album'])) {
        $album = $input['album'];
    } else {
        $album = $_SESSION['album'];
    }
    if (isset($input['asset'])) {
        $asset = $input['asset'];
    } else {
        $asset = $_SESSION['asset'];
    }
    if (isset($input['t'])) {
        $timecode = $input['t'];
    } else {
        $timecode = $_SESSION['timecode'];
    }
    if (isset($input['thread_id'])) {
        $thread_id = $input['thread_id'];
    }
    // init paths
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    //
    // 0) Sanity checks
    //
    if (!isset($album) || !ezmam_album_exists($album)) {
        if ($input['click']) {
            // refresh a part of the page
            include_once template_getpath('error_album_not_found.php');
        } else {
            // refresh the whole page
            $error_path = template_getpath('error_album_not_found.php');
            include_once template_getpath('main.php');
        }
        log_append('warning', 'view_asset_bookmark: tried to access album ' . $album . ' which does not exist');
        die;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        $error_asset = $asset;
        if ($input['click']) {
            include_once template_getpath('error_asset_not_found.php');
        } else {
            $error_path = template_getpath('error_asset_not_found.php');
            include_once template_getpath('main.php');
        }
        log_append('warning', 'view_asset_bookmark: tried to access asset ' . $asset . ' of album ' . $album . ' which does not exist');
        die;
    }
    // only users who have album authorization can access a specific bookmark
    // anonymous users cannot access a shared bookmark
    if (acl_has_album_permissions($album)) {
        $is_bookmark = true;
    } else {
        if (!ezmam_asset_token_check($album, $asset, $_SESSION['asset_token'])) {
            if ($input['click']) {
                include_once template_getpath('error_permission_denied.php');
            } else {
                $error_path = template_getpath('error_permission_denied.php');
                include_once template_getpath('main.php');
            }
            log_append('warning', 'view_asset_bookmark: no permission to asset ' . $input['asset'] . 'in album ' . $input['album']);
            die;
        }
    }
    if (acl_user_is_logged()) {
        if (user_prefs_watched_add($_SESSION['user_login'], $album, $asset) && acl_show_notifications()) {
            acl_update_watched_assets();
        }
    }
    // 1) info for the selected asset
    $asset_meta = ezmam_asset_metadata_get($album, $asset);
    if ($asset_meta['record_type'] == 'camslide' || $asset_meta['record_type'] == 'cam') {
        $asset_meta['high_cam_src'] = get_link_to_media($album, $asset, 'high_cam');
        $asset_meta['low_cam_src'] = get_link_to_media($album, $asset, 'low_cam');
        // #t=$timecode stands for W3C temporal Media Fragments URI (working in Firefox and Chrome)
        $asset_meta['src'] = $asset_meta['low_cam_src'] . '&origin=' . $appname . "#t=" . $timecode;
    }
    if ($asset_meta['record_type'] == 'camslide' || $asset_meta['record_type'] == 'slide') {
        $asset_meta['high_slide_src'] = get_link_to_media($album, $asset, 'high_slide');
        $asset_meta['low_slide_src'] = get_link_to_media($album, $asset, 'low_slide');
        if ($asset_meta['record_type'] == 'slide') {
            // #t=$timecode stands for W3C temporal Media Fragments URI (working in Firefox and Chrome)
            $asset_meta['src'] = $asset_meta['low_slide_src'] . "#t=" . $timecode;
        }
    }
    // user is logged and has acces to the selected album
    if ($is_bookmark) {
        $asset_bookmarks = user_prefs_asset_bookmarks_list_get($_SESSION['user_login'], $album, $asset);
        // sorts the bookmarks following user's prefs
        $order = acl_value_get("bookmarks_order");
        if (isset($order) && $order != '' && $order != $default_bookmarks_order) {
            $asset_bookmarks = array_reverse($asset_bookmarks);
        }
    }
    $toc_bookmarks = toc_asset_bookmark_list_get($album, $asset);
    // sorts the bookmarks following user's prefs
    $order = acl_value_get("toc_order");
    if (isset($order) && $order != '' && $order != $default_toc_order) {
        $toc_bookmarks = array_reverse($toc_bookmarks);
    }
    log_append('view_asset_bookmark: album = ' . $album . ", asset = " . $asset);
    $_SESSION['ezplayer_mode'] = 'view_asset_bookmark';
    // used in 'div_left_details.php'
    $_SESSION['album'] = $album;
    $_SESSION['asset'] = $asset;
    $_SESSION['timecode'] = $timecode;
    $_SESSION['current_thread'] = $thread_id;
    $_SESSION['loaded_type'] = $input['type'];
    if ($refresh_center) {
        if (acl_display_threads()) {
            if (isset($thread_id)) {
                // click from lvl 2 on a discussion
                $threads = threads_select_by_asset($album, $asset);
                $thread = thread_details_update(false);
                $_SESSION['thread_display'] = 'details';
            } else {
                // click from lvl 2 on a bookmark
                $threads = threads_select_by_asset($album, $asset);
                $_SESSION['thread_display'] = 'list';
            }
        }
        if ($input['click']) {
            // refresh the center of the page (local link)
            // lvl, action, album, asset, timecode, targeted type (cam|slide), record type (cam|slide|camslide), permissions (view official | add personal), origin
            trace_append(array('3', 'view_asset_timecode', $album, $asset, $timecode, $_SESSION['loaded_type'], $asset_meta['record_type'], $is_bookmark ? 'view_and_add' : 'view_only', 'from_ezplayer'));
            include_once template_getpath('div_assets_center.php');
        } else {
            // refresh the whole page (shared link)
            trace_append(array('3', 'view_asset_timecode', $album, $asset, $timecode, $_SESSION['loaded_type'], $asset_meta['record_type'], $is_bookmark ? 'view_and_add' : 'view_only', 'from_external'));
            include_once template_getpath('main.php');
        }
    } else {
        // refresh the right panel (import / export / edition / deletion / ...)
        include_once template_getpath('div_side_details.php');
    }
}
示例#3
0
/**
 * Deletes the file containing all bookmarks of the given album
 * @param type $user the user
 * @param type $album the album 
 * @return boolean true if the file has been deleted; false otherwise
 */
function user_prefs_album_bookmarks_delete_all($user, $album)
{
    // Sanity check
    if (!isset($user) || $user == '') {
        return false;
    }
    if (!ezmam_album_exists($album)) {
        return false;
    }
    // 1) set the repository path
    $user_files_path = user_prefs_repository_path();
    if ($user_files_path === false) {
        return false;
    }
    // set user's file path
    $user_path = $user_files_path . '/' . $user;
    unlink($user_path . "/bookmarks_{$album}.xml");
    return true;
}
示例#4
0
/**
 * Deletes the file that contains the bookmarks
 * @param type $album the album containing bookmarks
 * @return boolean true if the file has been deleted; false otherwise
 */
function toc_album_bookmarks_delete_all($album)
{
    // Sanity check
    if (!ezmam_album_exists($album)) {
        return false;
    }
    // 1) set the repository path
    $toc_path = ezmam_repository_path();
    if ($toc_path === false) {
        return false;
    }
    // set user's file path
    $toc_path = $toc_path . '/' . $album;
    unlink($toc_path . "/_bookmarks.xml");
    return true;
}
示例#5
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');
}
示例#6
0
$recording_metadata = metadata2assoc_array($recording_dir . "/metadata.xml");
if ($recording_metadata === false) {
    myerror("bad xml or read problem on  {$recording_dir}" . "/metadata.xml");
}
//log to file
// 'course_name' 'origin' 'record_date' 'description' 'record_type' 'moderation'
$record_type = $recording_metadata['record_type'];
$course_name = $recording_metadata['course_name'];
$record_date = $recording_metadata['record_date'];
//check for album existance
if ($recording_metadata['moderation'] == "false") {
    $album_name = $course_name . "-pub";
} else {
    $album_name = $course_name . "-priv";
}
if (!ezmam_album_exists($album_name)) {
    print "ERROR: album does not exist! {$album_name}\n";
    exit(0);
}
//initialize asset metadata and media metadata
$asset_meta['author'] = $recording_metadata['author'];
$asset_meta['title'] = $recording_metadata['title'];
$asset_meta['origin'] = $recording_metadata['origin'];
$asset_meta['description'] = $recording_metadata['description'];
$asset_meta['record_date'] = $recording_metadata['record_date'];
$asset_meta['record_type'] = $recording_metadata['record_type'];
$asset_meta['status'] = 'processing';
$asset_meta['tags'] = "";
$asset_meta['language'] = "français";
$asset_meta['super_highres'] = $recording_metadata['super_highres'];
if (isset($recording_metadata['submitted_cam'])) {
示例#7
0
/**
 * Resets the token of a specific album, and tokens of all the assets within
 * @param type $album 
 * @return bool error status
 */
function ezmam_album_token_reset($album)
{
    // Sanity checks
    $repository_path = ezmam_repository_path();
    if ($repository_path == false) {
        ezmam_last_error("Please call ezmam_repository_path() before anything else");
        return false;
    }
    if (!ezmam_album_exists($album)) {
        ezmam_last_error("ezmam_album_token_reset: Album {$album} does not exist");
        return false;
    }
    $old_token = ezmam_album_token_get($album);
    // Resetting the album token
    $res = ezmam_album_token_create($album);
    if (!$res) {
        ezmam_last_error('ezmam_album_token_reset: Unable to change token');
        return false;
    }
    $assets = ezmam_asset_list($album);
    foreach ($assets as $asset) {
        ezmam_asset_token_reset($album, $asset, false);
    }
    // Resetting the RSS feed
    ezmam_rss_generate($album, "high");
    ezmam_rss_generate($album, "low");
    // Logging the operation
    log_append('album_token_reset', 'album ' . $album . ', old token: ' . $old_token . ', new token: ' . $res);
    return true;
}
示例#8
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;
}
示例#9
0
/**
 * 
 * @param type $album
 * @param type $asset
 */
function acl_is_archived($album, $asset)
{
    $album_exists = ezmam_album_exists($album);
    if ($album_exists) {
        return !ezmam_asset_exists($album, $asset);
    }
    return true;
}