/** * 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&album=ALBUM&asset=ASSET&type=TYPE&quality=QUALITY&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&album=' . $input['album'] . '&asset=' . $input['asset'] . '&type=' . $input['type'] . '&quality=' . $input['quality'] . '&token=' . $input['token'] . '&width=' . $width . '&height=' . $height . '&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'); } }
/** * This function shows the asset details div for the asset passed by POST, GET or SESSION * @global type $input * @global type $repository_path */ function view_asset_details() { global $input; global $repository_path; global $ezmanager_url; // 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']; } ezmam_repository_path($repository_path); // // 0) Sanity checks // if (!isset($album) || !ezmam_album_exists($album)) { error_print_message(template_get_message('Non-existant_album', get_lang())); log_append('warning', 'view_asset_details: tried to access album ' . $album . ' which does not exist'); die; } if (!ezmam_asset_exists($album, $asset)) { error_print_message(template_get_message('Non-existant_asset', get_lang())); log_append('warning', 'view_asset_details: tried to access asset ' . $asset . ' of album ' . $album . ' which does not exist'); die; } if (!acl_has_album_permissions($album)) { error_print_message(template_get_message('Unauthorized', get_lang())); log_append('warning', 'view_asset_details: tried to access album ' . $album . ' without permission'); die; } // // 1) We retrieve the metadata for the asset and its media // $asset_metadata = ezmam_asset_metadata_get($album, $asset); $media_metadata = ezmam_media_list_metadata_assoc($album, $asset); // // 2) Now we can set up the variables used in the template // $asset_name = $asset; // "Technical" asset name $author = $asset_metadata['author']; // Asset author $title = $asset_metadata['title']; // "user-friendly" asset name (title) $description = $asset_metadata['description']; // Asset description $date = get_user_friendly_date($asset_metadata['record_date'], ' ', true, get_lang(), true); // Recording date, i.e. asset creation date $origin = $asset_metadata['origin']; $status = $asset_metadata['status']; $public_album = album_is_public($album); // Whether the album the asset is public or not $has_cam = strpos($asset_metadata['record_type'], 'cam') !== false; // Whether or not the asset has a "live-action" video $has_slides = strpos($asset_metadata['record_type'], 'slide') !== false; // Whether or not the asset has slides $created_albums_list_with_descriptions = acl_authorized_albums_list_created(true); // List of all the created albums (used for asset move) $asset_token = ezmam_asset_token_get($album, $asset); // Asset token, used for embedded media player (preview) // Filling in the data about the media // all you want to know about high res camera video if (isset($media_metadata['high_cam'])) { $filesize_cam['HD'] = $media_metadata['high_cam']['file_size']; $dimensions_cam['HD'] = $media_metadata['high_cam']['width'] . ' x ' . $media_metadata['high_cam']['height']; $format_cam = $media_metadata['high_cam']['codec']; } // Everything about the low-res version of the camera video if (isset($media_metadata['low_cam'])) { $filesize_cam['SD'] = $media_metadata['low_cam']['file_size']; $dimensions_cam['SD'] = $media_metadata['low_cam']['width'] . ' x ' . $media_metadata['low_cam']['height']; } // Everything about the high-res slides video if (isset($media_metadata['high_slide'])) { $filesize_slides['HD'] = $media_metadata['high_slide']['file_size']; $dimensions_slides['HD'] = $media_metadata['high_slide']['width'] . ' x ' . $media_metadata['high_slide']['height']; $format_slides = $media_metadata['high_slides']['codec']; } // Everything about the low-res slides if (isset($media_metadata['low_slide'])) { $filesize_slides['SD'] = $media_metadata['low_slide']['file_size']; $dimensions_slides['SD'] = $media_metadata['low_slide']['width'] . ' x ' . $media_metadata['low_slide']['height']; } // To get the duration, we use the high cam media if it exists, or the high_slide // media otherwise. We assume at least one of these exists. $duration = $media_metadata['high_cam']['duration']; if (!isset($duration) || empty($duration)) { $duration = $media_metadata['high_slide']['duration']; } $duration = get_user_friendly_duration($duration); // Finally, we set up the URLs and view counts to the different media if ($has_cam) { $url_cam['HD'] = ezmam_media_geturl($album, $asset, 'high_cam'); $url_cam['SD'] = ezmam_media_geturl($album, $asset, 'low_cam'); // specific code that contains information about the media $code_cam['HD'] = get_code_to_media($album, $asset, 'high_cam'); $code_cam['SD'] = get_code_to_media($album, $asset, 'low_cam'); $view_count_cam = ezmam_media_viewcount_get($album, $asset, 'high_cam') + ezmam_media_viewcount_get($album, $asset, 'low_cam'); } if ($has_slides) { $url_slides['HD'] = ezmam_media_geturl($album, $asset, 'high_slide'); $url_slides['SD'] = ezmam_media_geturl($album, $asset, 'low_slide'); $code_slide['HD'] = get_code_to_media($album, $asset, 'high_slide'); $code_slide['SD'] = get_code_to_media($album, $asset, 'low_slide'); $view_count_slides = ezmam_media_viewcount_get($album, $asset, 'high_slide') + ezmam_media_viewcount_get($album, $asset, 'low_slide'); } $file_name = ''; if ($origin == 'SUBMIT') { if ($asset_metadata['submitted_cam'] != '' && $asset_metadata['submitted_slide'] != '') { $file_name = $asset_metadata['submitted_cam'] . ' & ' . $asset_metadata['submitted_slide']; } else { if ($asset_metadata['submitted_cam'] != '') { $file_name = $asset_metadata['submitted_cam']; } else { $file_name = $asset_metadata['submitted_slide']; } } } // // 3) We save the current state in session vars // $_SESSION['podman_mode'] = 'view_asset_details'; $_SESSION['podman_album'] = $input['album']; $_SESSION['podman_asset'] = $input['asset']; // // 4) Then display the asset and its content // require_once template_getpath('div_asset_details.php'); }