Ejemplo n.º 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');
    }
}
Ejemplo n.º 2
0
/**
 * Deletes the media from the asset
 * @param type $album
 * @param type $asset
 * @param type $media
 * @return type 
 */
function ezmam_media_delete($album_name, $asset_name, $media_name)
{
    $repository_path = ezmam_repository_path();
    if ($repository_path === false) {
        return false;
    }
    if (!ezmam_album_exists($album_name)) {
        ezmam_last_error("Trying to delete {$album_name} which doesn't exist!");
        return false;
    }
    if (!ezmam_asset_exists($album_name, $asset_name)) {
        ezmam_last_error("Trying to delete {$asset_name} which doesn't exist!");
        return false;
    }
    if (!ezmam_media_exists($album_name, $asset_name, $media_name)) {
        ezmam_last_error("Trying to delete {$media_name} which doesn't exist!");
        return false;
    }
    $path = ezmam_repository_path() . '/' . ezmam_media_getpath($album_name, $asset_name, $media_name);
    if (is_file($path)) {
        $path = dirname($path);
    }
    // First we empty the directory
    $dir = opendir($path);
    if ($dir === false) {
        ezmam_last_error("Unable to open folder {$path}");
        return false;
    }
    while (($file = readdir($dir)) !== false) {
        if ($file != "." && $file != "..") {
            if (is_dir($path . '/' . $file)) {
                exec('rm -rf ' . $path . '/' . $file);
            } else {
                unlink($path . '/' . $file);
            }
            //single file media
        }
    }
    // Then we delete it
    $res = rmdir($path);
    if (!$res) {
        ezmam_last_error("Unable to delete folder {$path}");
        return false;
    }
    return true;
}