Beispiel #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');
    }
}
function update_originals_meta($album, $asset, $qtinfo_filepath)
{
    $qtinfo_assoc = metadata2assoc_array($qtinfo_filepath);
    //dig media name according to qtinfo filename
    $qtinfofile = basename($qtinfo_filepath);
    list($quality, $type, $qtinfo) = explode("_", $qtinfofile);
    // first part is high/low
    $media = 'original_' . $type;
    $media_meta = ezmam_media_metadata_get($album, $asset, $media);
    $media_meta['duration'] = $qtinfo_assoc['duration'];
    $media_meta['height'] = $qtinfo_assoc['height'];
    $media_meta['width'] = $qtinfo_assoc['width'];
    if (isset($qtinfo_assoc['videoCodec'])) {
        $media_meta['videocodec'] = $qtinfo_assoc['videoCodec'];
    }
    if (isset($qtinfo_assoc['audioCodec'])) {
        $media_meta['audiocodec'] = $qtinfo_assoc['audioCodec'];
    }
    //update  originals meta
    print "update media metadata {$album} {$asset} {$media}\n";
    ezmam_media_metadata_set($album, $asset, $media, $media_meta);
}
Beispiel #3
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&amp;popup=embed_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;
    }
    // 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&amp;album=' . $input['album'] . '&amp;asset=' . $input['asset'] . '&amp;type=' . $type . '&amp;quality=' . $quality . '&amp;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');
}
Beispiel #4
0
/**
 *
 * @param string $album
 * @param string $asset
 * @param string $media
 * @param bool(true) $relative return path relative to repository or absolute
 * @return string
 */
function ezmam_media_getpath($album, $asset, $media, $relative = true)
{
    $repository_path = ezmam_repository_path();
    if ($repository_path === false) {
        return false;
    }
    if (!ezmam_album_exists($album)) {
        return false;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        return false;
    }
    if (!ezmam_media_exists($album, $asset, $media)) {
        return false;
    }
    $media_metadata = ezmam_media_metadata_get($album, $asset, $media);
    if ($relative) {
        $media_path = $album . "/" . $asset . "/" . $media;
    } else {
        $media_path = $repository_path . "/" . $album . "/" . $asset . "/" . $media;
    }
    //check if media is a file or multifiles
    if (isset($media_metadata['disposition']) && $media_metadata['disposition'] == 'file' && isset($media_metadata['filename'])) {
        //it's a single file so return a path to the file instead of directory
        $media_path = $media_path . "/" . $media_metadata['filename'];
    }
    return $media_path;
}