/** * Displays the list of all assets from the selected album * @refresh_center determines if we need to refresh the whole page / the center * of the page or another part of the page (mainly the right side) * @global type $input * @global type $repository_path * @global type $ezplayer_url * @global type $assets_list * @global string $panel_display */ function view_album_assets($refresh_center = true) { global $input; global $repository_path; global $ezplayer_url; // used in a popup window global $user_files_path; global $assets_list; global $album; global $album_bookmarks; global $toc_bookmarks; global $error_path; // used to display an error on the main page global $login_error; // used to display error when anonymous user login global $default_bookmarks_order; global $default_toc_order; global $cache_limit; // if reloaded is set, the whole page has to be refreshed if ($_SESSION['reloaded']) { unset($input['click']); unset($_SESSION['reloaded']); $refresh_center = true; } $error_path = ''; if (isset($input['album'])) { $album = $input['album']; } else { $album = $_SESSION['album']; } if (isset($input['token'])) { $token = $input['token']; } else { $token = $_SESSION['token']; } ezmam_repository_path($repository_path); user_prefs_repository_path($user_files_path); // 0) Sanity checks if (!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_album_assets: tried to access non-existant album ' . $input['album']); exit; } // Authorization check if (!ezmam_album_token_check($album, $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_album_assets: tried to access album ' . $input['album'] . ' with invalid token ' . $input['token']); die; } // 1) Retrieving all assets' metadata $assets_list = ezmam_asset_list_metadata($album); $count = count($assets_list); // add the asset token to the metadata for ($index = 0; $index < $count; $index++) { $assets_list[$index]['token'] = ezmam_asset_token_get($album, $assets_list[$index]['name']); } // 2) Save current album log_append('view_album_assets: ' . $album); $_SESSION['ezplayer_mode'] = 'view_album_assets'; // used in 'div_assets_center.php' $_SESSION['album'] = $album; // used in search $_SESSION['asset'] = ''; $_SESSION['token'] = $token; // 3) Add current album to the album list // and load album bookmarks // $album_name = get_album_title($album); $album_token = array('title' => $album_name, 'album' => $album, 'token' => $token); if (!token_array_contains($_SESSION['acl_album_tokens'], $album_token)) { if (acl_user_is_logged()) { // logged user : consulted albums are stored in file user_prefs_token_add($_SESSION['user_login'], $album, $album_name, $token); log_append('view_album_assets: album token added - ' . $album); trace_append(array('2', 'album_token_add', $album)); // lvl, action, album } else { // anonymous user : consulted albums are stored in session var $_SESSION['acl_album_tokens'][] = $album_token; } acl_update_permissions_list(); } if (acl_user_is_logged()) { // bookmarks to display in 'div_side_assets.php' $album_bookmarks = user_prefs_album_bookmarks_list_get($_SESSION['user_login'], $album); // sorts the bookmarks following user's prefs $order = acl_value_get("bookmarks_order"); if (isset($order) && $order != '' && $order != $default_bookmarks_order) { $album_bookmarks = array_reverse($album_bookmarks); } } // 4) table of contents to display in 'div_side_assets.php' $toc_bookmarks = toc_album_bookmarks_list_get($album); // 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); } if ($refresh_center) { if (acl_display_threads()) { $threads = threads_select_by_album($album, $cache_limit); foreach ($threads as &$thread) { if (!thread_is_archive($thread['albumName'], $thread['assetName'])) { $threads_list[] = $thread; } } } if ($input['click']) { // called by a local link // lvl, action, album, origin trace_append(array('2', 'view_album_assets', $album, 'from_ezplayer')); include_once template_getpath('div_assets_center.php'); } else { // accessed by the UV or shared link // lvl, action, album, origin trace_append(array('2', 'view_album_assets', $album, 'from_external')); include_once template_getpath('main.php'); } } else { // refresh only the side panel (after import / export / deletion / ...) include_once template_getpath('div_side_assets.php'); } }
function view_player() { global $input; global $template_folder; global $appname; // 0) Sanity checks if (!ezmam_album_exists($input['album'])) { error_print_http(404); log_append('warning', 'view_player: tried to access non-existant album ' . $input['album']); exit; } if (!ezmam_album_token_check($input['album'], $input['token'])) { error_print_http(403); log_append('warning', 'view_player: tried to acces album ' . $input['album'] . ' with invalid token ' . $input['token']); die; } // 1) Retrieving all assets' metadata $asset_list = ezmam_asset_list_metadata($input['album']); // 2) Add links to each asset foreach ($asset_list as &$asset) { $high_cam_link = ''; $low_cam_link = ''; $high_slide_link = ''; $low_slide_link = ''; if ($asset['metadata']['record_type'] == 'camslide' || $asset['metadata']['record_type'] == 'cam') { $high_cam_link = get_link_to_media($input['album'], $asset['name'], 'high_cam') . "&origin=" . $appname; $low_cam_link = get_link_to_media($input['album'], $asset['name'], 'low_cam') . "&origin=" . $appname; } if ($asset['metadata']['record_type'] == 'camslide' || $asset['metadata']['record_type'] == 'slide') { $high_slide_link = get_link_to_media($input['album'], $asset['name'], 'high_slide') . "&origin=" . $appname; $low_slide_link = get_link_to_media($input['album'], $asset['name'], 'low_slide') . "&origin=" . $appname; } $asset['links'] = array('high_cam' => $high_cam_link, 'low_cam' => $low_cam_link, 'high_slide' => $high_slide_link, 'low_slide' => $low_slide_link); } template_repository_path($template_folder . get_lang()); require_once template_getpath('player_header.php'); require_once template_getpath('player_content.php'); require_once template_getpath('player_footer.php'); }
/** * counts the processed assets from a given album * @param type $album * @return int */ function ezmam_asset_count($album) { $asset_list = ezmam_asset_list_metadata($album); $count = 0; foreach ($asset_list as $asset) { if ($asset['metadata']['status'] == 'processed') { ++$count; } } return $count; }
/** * Displays the album passed in GET or POST "album" parameter, if it exists and is managable by the user. */ function view_album() { // Initialization: we retrieve various variable we'll need later on global $input; global $repository_path; global $ezmanager_url; // Website URL, defined in config.inc global $distribute_url; global $ezplayer_url; if (isset($input['album'])) { $album = $input['album']; } else { $album = $_SESSION['podman_album']; } ezmam_repository_path($repository_path); // // 0) Sanity checks // if (!acl_has_album_permissions($album)) { error_print_message(template_get_message('Unauthorized', get_lang())); log_append('warning', "view_album: tried to access album " . $album . ' without permission'); die; } // // 1) We retrieve the metadata relating to the album // $metadata = ezmam_album_metadata_get($album); // // 2) We set the variables used in the template with the correct values // $album_name_full = $album; // complete album name, used for div identification $album_name = suffix_remove($album); // "user-friendly" album name, used for display $description = $metadata['description']; $public_album = album_is_public($album); // Whether the album is public; used to display the correct options $hd_rss_url = $distribute_url . '?action=rss&album=' . $album . '&quality=high&token=' . ezmam_album_token_get($album); $sd_rss_url = $distribute_url . '?action=rss&album=' . $album . '&quality=low&token=' . ezmam_album_token_get($album); $hd_rss_url_web = $distribute_url . '?action=rss&album=' . $album . '&quality=high&token=' . ezmam_album_token_get($album); $sd_rss_url_web = $distribute_url . '?action=rss&album=' . $album . '&quality=low&token=' . ezmam_album_token_get($album); $player_full_url = $ezplayer_url . "?action=view_album_assets&album=" . $album . "&token=" . ezmam_album_token_get($album); $assets = ezmam_asset_list_metadata($album_name_full); // // 3) We save the current album view in a session var // $_SESSION['podman_mode'] = 'view_album'; $_SESSION['podman_album'] = $album; // // 4) Then we display the album // include template_getpath('div_album_header.php'); include template_getpath('div_asset_list.php'); }
function ezmam_rss_generate($album, $type) { global $distribute_url; global $ezplayer_safe_url; $url = $distribute_url; if ($type != 'high' && $type != 'low' && $type != 'ezplayer') { ezmam_last_error('ezmam_rss_generate: only album qualities to be allowed are high and low'); return false; } // 1) XML code creation $xml = ezmam_rss_new($album, $type); if (!$xml) { ezmam_last_error('ezmam_rss_generate: unable to open XML'); return false; } $xmlh = new SimpleXMLElement($xml); $token = ezmam_album_token_get($album); if ($token === false) { ezmam_last_error('ezmam_rss_generate: unable to get token'); return false; } // 2) We scan all the assets for the album $assets = ezmam_asset_list_metadata($album); foreach ($assets as $asset) { $metadata = $asset['metadata']; if ($type == 'ezplayer') { $ezplayer_link = $ezplayer_safe_url . '/index.php?action=view_asset_bookmark' . '&album=' . $album . '&asset=' . $metadata['record_date'] . '&t=0'; add_item_to_rss($xmlh, $metadata['title'], $metadata['description'], $metadata['author'], get_RFC822_date($metadata['record_date']), $ezplayer_link, false); } else { // Don't forget to add both videos if it was a camslide! if ($metadata['record_type'] == 'camslide') { // Camera $title = isset($metadata['title']) ? $metadata['title'] : $metadata['description']; $arguments = '?action=media&album=' . $album . '&asset=' . $asset['name'] . '&type=cam&quality=' . $type . '&token=' . $token . "&origin=rss"; // An asset may exist but only contain an original (no high or low) // So, since we don't want our RSS feed to contain empty assets, we have to check // that at least one media is available if (ezmam_media_exists($album, $asset['name'], 'high_cam') || ezmam_media_exists($album, $asset['name'], 'low_cam')) { add_item_to_rss($xmlh, $title . ' (camera)', $metadata['description'] . ' (prise de vue caméra)', $metadata['author'], get_RFC822_date($metadata['record_date']), $url . $arguments, $url . '/cam.m4v' . $arguments); } // Slides $arguments = '?action=media&album=' . $album . '&asset=' . $asset['name'] . '&type=slide&quality=' . $type . '&token=' . $token . "&origin=rss"; // See above if (ezmam_media_exists($album, $asset['name'], 'high_slide') || ezmam_media_exists($album, $asset['name'], 'low_slide')) { add_item_to_rss($xmlh, $title . ' (slides)', $metadata['description'] . ' (slides et commentaires)', $metadata['author'], get_RFC822_date($metadata['record_date']), $url . $arguments, $url . '/slide.m4v' . $arguments); } } else { $title = isset($metadata['title']) ? $metadata['title'] : $metadata['description']; $arguments = '?action=media&album=' . $album . '&asset=' . $asset['name'] . '&type=' . $metadata['record_type'] . '&quality=' . $type . '&token=' . $token . "&origin=rss"; // Filter for empty assets (see above) if (ezmam_media_exists($album, $asset['name'], 'high_' . $metadata['record_type']) || ezmam_media_exists($album, $asset['name'], 'low_' . $metadata['record_type'])) { add_item_to_rss($xmlh, $title, $metadata['description'], $metadata['author'], get_RFC822_date($metadata['record_date']), $url . $arguments, $url . '/' . $metadata['record_type'] . '.m4v' . $arguments); } } } } // 3) We dump the result in a file $regfile = ezmam_repository_path() . '/' . $album . '/_rss_' . $type . '.xml'; $res = file_put_contents($regfile, $xmlh->asXML()); if ($res === false) { ezmam_last_error('ezmam_rss_generate: unable to write into XML file ' . $regfile); return false; } return true; }