/** * 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'); } }
/** * 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'); } }