/** * 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'); } }
/** * Uploads a temp file which contains bookmarks to import * @global type $imported_bookmarks * @global type $repository_path * @global type $user_files_path * @global type $bookmarks_validation_file * @global type $album * @global type $asset */ function bookmarks_upload() { global $imported_bookmarks; global $repository_path; global $user_files_path; global $bookmarks_validation_file; global $album; global $asset; $album = $_POST['album']; // the album user wants to import in $asset = $_POST['asset']; // the asset user wants to import in $target = $_POST['target']; // personal bookmarks or table of contents $_SESSION['album'] = $album; $_SESSION['asset'] = $asset; $_SESSION['target'] = $target; // 1) Sanity checks if ($_FILES['XMLbookmarks']['error'] > 0) { error_print_message(template_get_message('upload_error', get_lang())); log_append('error', 'upload_bookmarks: an error occurred during file upload (code ' . $_FILES['XMLbookmarks']['error']); die; } if ($_FILES['XMLbookmarks']['type'] != 'text/xml') { error_print_message(template_get_message('error_mimetype', get_lang())); log_append('warning', 'upload_bookmarks: invalid mimetype for file ' . $_FILES['XMLbookmarks']['tmp_name']); die; } if ($_FILES['XMLbookmarks']['size'] > 2147483) { error_print_message(template_get_message('error_size', get_lang())); log_append('warning', 'upload_bookmarks: file too big ' . $_FILES['XMLbookmarks']['tmp_name']); die; } // 2) Validates the XML file and converts it in associative array if (file_exists($_FILES['XMLbookmarks']['tmp_name'])) { // Validates XML structure $xml_dom = new DOMDocument(); // trim heading and trailing white spaces // because blank lines in top and end of XML file lead to // validation error file_put_contents($_FILES['XMLbookmarks']['tmp_name'], trim(file_get_contents($_FILES['XMLbookmarks']['tmp_name']))); $xml_dom->load($_FILES['XMLbookmarks']['tmp_name']); if (!$xml_dom->schemaValidate($bookmarks_validation_file)) { include_once template_getpath('div_import_bookmarks.php'); error_print_message(template_get_message('error_structure', get_lang())); } // Converts XML file in SimpleXMLElement $xml = simplexml_load_file($_FILES['XMLbookmarks']['tmp_name']); $imported_bookmarks = xml_file2assoc_array($xml, 'bookmark'); } // init paths ezmam_repository_path($repository_path); user_prefs_repository_path($user_files_path); // Keeps only bookmarks from existing assets foreach ($imported_bookmarks as $index => $bookmark) { if (!ezmam_asset_exists($bookmark['album'], $bookmark['asset'])) { unset($imported_bookmarks[$index]); } } log_append('upload_bookmarks: file imported'); // lvl, action, album, asset, target (in official|personal bookmarks), number of bookmarks uploaded trace_append(array($asset != '' ? '3' : '2', 'bookmarks_upload', $album, $asset != '' ? $asset : '-', $target, count($imported_bookmarks))); echo '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>'; // echo "<script language='javascript' type='text/javascript'>window.top.window.document.getElementById('popup_import_bookmarks').innerHTML='$lapin';</script>"; include_once template_getpath('div_import_bookmarks.php'); }
/** * Adds a list of bookmarks in the bookmarks file. * @param type $user the user * @param type $bookmarks an array of bookmarks * @return boolean true if the bookmarks have been added; false otherwise */ function user_prefs_album_bookmarks_add($user, $bookmarks) { // Sanity check if (!isset($user) || $user == '') { return false; } if (!isset($bookmarks) || count($bookmarks) == 0) { return false; } $album = $bookmarks[0]['album']; if (!ezmam_album_exists($album)) { return false; } // 1) set the repository path $user_files_path = user_prefs_repository_path(); if ($user_files_path === false) { return false; } // if the user's directory doesn't exist yet, we create it if (!file_exists($user_path)) { mkdir($user_path, 0755, true); } // set user's file path $user_path = $user_files_path . '/' . $user; // Get the bookmarks list $bookmarks_list = user_prefs_album_bookmarks_list_get($user, $album); if (!isset($bookmarks_list) || $bookmarks_list == false) { $bookmarks_list = array(); } foreach ($bookmarks as $bookmark) { if ($bookmark['album'] == $album && ezmam_asset_exists($album, $bookmark['asset']) && $bookmark['timecode'] >= 0) { $count = count($bookmarks_list); $index = 0; if ($count > 0) { $index = -1; $asset_ref = $bookmarks_list[0]['asset']; $timecode_ref = $bookmarks_list[0]['timecode']; // loop while the asset is older than the reference asset while ($index < $count && $bookmark['asset'] < $asset_ref) { ++$index; $asset_ref = $bookmarks_list[$index]['asset']; $timecode_ref = $bookmarks_list[$index]['timecode']; } // if the asset already contains bookmarks, loop while // timecode is bigger than reference timecode while ($index < $count && $bookmark['asset'] == $asset_ref && $bookmark['timecode'] >= $timecode_ref) { ++$index; $timecode_ref = $bookmarks_list[$index]['timecode']; $asset_ref = $bookmarks_list[$index]['asset']; } if ($index < 0) { // no bookmark yet $index = 0; } if ($index > $count) { // add in last index --$index; } if ($bookmark['asset'] == $bookmarks_list[$index - 1]['asset'] && $bookmark['timecode'] == $bookmarks_list[$index - 1]['timecode']) { $bookmarks_list[$index - 1] = $bookmark; } else { // add a bookmark at the specified index in the albums list array_splice($bookmarks_list, $index, 0, array(null)); $bookmarks_list[$index] = $bookmark; } } else { $bookmarks_list[0] = $bookmark; } } } return assoc_array2xml_file($bookmarks_list, $user_path . "/bookmarks_{$album}.xml", "bookmarks", "bookmark"); }
/** * Adds a list of bookmarks in the bookmarks file. * @param type $bookmarks an array of bookmarks * @return boolean true if the bookmarks have been added; false otherwise */ function toc_album_bookmarks_add($bookmarks) { // Sanity check if (!isset($bookmarks) || count($bookmarks) == 0) { return false; } $album = $bookmarks[0]['album']; if (!ezmam_album_exists($album)) { return false; } // 1) set the repository path $toc_path = ezmam_repository_path(); if ($toc_path === false) { return false; } $toc_path = $toc_path . '/' . $album; // Get the bookmarks list $bookmarks_list = toc_album_bookmarks_list_get($album); if (!isset($bookmarks_list) || $bookmarks_list == false) { $bookmarks_list = array(); } foreach ($bookmarks as $bookmark) { if ($bookmark['album'] == $album && ezmam_asset_exists($album, $bookmark['asset']) && $bookmark['timecode'] >= 0) { $count = count($bookmarks_list); $index = 0; if ($count > 0) { $index = -1; $asset_ref = $bookmarks_list[0]['asset']; $timecode_ref = $bookmarks_list[0]['timecode']; // loop while the asset is older than the reference asset while ($index < $count && $bookmark['asset'] > $asset_ref) { ++$index; $asset_ref = $bookmarks_list[$index]['asset']; $timecode_ref = $bookmarks_list[$index]['timecode']; } // if the asset already contains bookmarks, loop while // timecode is bigger than reference timecode while ($index < $count && $bookmark['asset'] == $asset_ref && $bookmark['timecode'] >= $timecode_ref) { ++$index; $timecode_ref = $bookmarks_list[$index]['timecode']; $asset_ref = $bookmarks_list[$index]['asset']; } if ($index < 0) { // no bookmark yet $index = 0; } if ($index > $count) { // add in last index --$index; } if ($bookmark['asset'] == $bookmarks_list[$index - 1]['asset'] && $bookmark['timecode'] == $bookmarks_list[$index - 1]['timecode']) { $bookmarks_list[$index - 1] = $bookmark; } else { // add a bookmark at the specified index in the albums list array_splice($bookmarks_list, $index, 0, array(null)); $bookmarks_list[$index] = $bookmark; } } else { $bookmarks_list[0] = $bookmark; } } } return assoc_array2xml_file($bookmarks_list, $toc_path . "/_bookmarks.xml", "bookmarks", "bookmark"); }
} if (isset($recording_metadata['add_title'])) { $asset_meta['add_title'] = $recording_metadata['add_title']; } $asset_meta['ratio'] = isset($recording_metadata['ratio']) ? $recording_metadata['ratio'] : 'auto'; if (isset($recording_metadata['downloadable'])) { // if the recording has been submitted $asset_meta['downloadable'] = $recording_metadata['downloadable']; } else { // the recording comes from EZrecorder $album_meta = ezmam_album_metadata_get($album_name); $asset_meta['downloadable'] = isset($album_meta['downloadable']) ? $album_meta['downloadable'] : $default_downloadable; } //create asset if not exists! $asset_name = $record_date; if (!ezmam_asset_exists($album_name, $asset_name)) { ezmam_asset_new($album_name, $asset_name, $asset_meta); } //do we have a cam movie? if (strpos($record_type, "cam") !== false) { //insert original cam media in asset with attention to file extension/mimetype originals_mam_insert_media($album_name, $asset_name, 'cam', $recording_metadata, $recording_dir); } //do we have a slide movie? if (strpos($record_type, "slide") !== false) { //insert original slide media in asset with attention to file extension/mimetype $res1 = originals_mam_insert_media($album_name, $asset_name, 'slide', $recording_metadata, $recording_dir); } //media(s) inserted into mam, so move the processing directory to mam_inserted $inserted_recording_dir = dirname(dirname($recording_dir)) . '/mam_inserted/' . basename($recording_dir); rename($recording_dir, $inserted_recording_dir);
/** * Displays the popup with the ulb code to copypaste * @global type $input * @global type $repository_path * @global type $url */ function popup_ulb_code() { global $input; global $repository_path; $asset_name = $input['asset']; 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&popup=ulb_code&album=ALBUM&asset=ASSET&media=MEDIA'; die; } if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) { error_print_message(ezmam_last_error()); die; } $ulb_code = get_code_to_media($input['album'], $input['asset'], $input['media']); // Displaying the popup require_once template_getpath('popup_ulb_code.php'); }
ezmam_repository_path($repository_path); /* * This program handles media cam,slide,upload movies and asset's metadata and ask a remote machine to render the video * as intro - title - movie * then inserts the result as a media in the repository (via lib_ezmam) * This means: build a work directory, send it via ssh to the render client , get info back and finally add/update media */ if ($argc != 4) { echo "\nusage: " . $argv[0] . "<album_name> <asset_name> <processing_dir>\n"; die; } $album = $argv[1]; $asset = $argv[2]; $render_dir = $argv[3]; //check if given asset exists if (!ezmam_asset_exists($album, $asset)) { myerror("ezmam did not find referenced asset: {$album}, {$asset}"); } //check if intro-title-movie had done its job var_dump($render_dir . "/processing.xml"); $resultprocessing_assoc = metadata2assoc_array($render_dir . "/processing.xml"); if (!is_array($resultprocessing_assoc)) { myerror("could not get result metadata"); } $status = $resultprocessing_assoc['status']; if ($status != "processed") { myerror("processing return status: {$status}"); } //intro-title-movie and compress high/low done, so lets insert them in our asset $media_files = glob("{$render_dir}/*.mov"); //scan for all rendered medias (starting with 'high_' or 'low_' and continues with 'slide_' or 'cam_')
/** * 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; }
function thread_is_archive($album, $asset) { return !ezmam_asset_exists($album, $asset); }
/** * Returns a special code that contains information about the media * @global type $url * @param string $album * @param string $asset * @param string $media * @return string Media */ function get_code_to_media($album, $asset, $media) { global $ezmanager_url; global $distribute_url; global $repository_path; ezmam_repository_path($repository_path); // // Usual sanity checks // if (!ezmam_album_exists($album)) { error_print_message('get_link_to_media: Album ' . $album . ' does not exist'); return false; } if (!ezmam_asset_exists($album, $asset)) { error_print_message('get_link_to_media: Asset ' . $asset . ' does not exist'); return false; } // We take the asset's token if it exists. // If not, then we use the album's token instead. $token = ezmam_asset_token_get($album, $asset); if (!$token) { $token = ezmam_album_token_get($album); } if (!$token) { error_print_message('get_link_to_media: ' . ezmam_last_error()); return false; } $media_infos = explode('_', $media); // 'media' is like high_cam, so we want to extract the "high" part (quality) and the "cam" part (type) $quality = $media_infos[0]; $type = $media_infos[1]; return $album . '/' . $asset . '/' . $type . '/' . $quality . '/' . $token; }
/** * * @param type $album * @param type $asset */ function acl_is_archived($album, $asset) { $album_exists = ezmam_album_exists($album); if ($album_exists) { return !ezmam_asset_exists($album, $asset); } return true; }