".i18n::translate('Directory could not be created')." [".$destdir."]"; return false; } } if (!rename($src, $dest)) { echo "
".i18n::translate('Media file could not be moved.')." [".$src."]
"; return false; } echo "
".i18n::translate('Media file moved.')." [".$src."]
"; return true; } /** * Recursively moves files from standard media directory to the protected media directory * and vice-versa. Operates directly on the filesystem, does not use the db. */ function move_files($path, $protect) { global $MEDIA_FIREWALL_THUMBS, $starttime; $timelimit=get_site_setting('MAX_EXECUTION_TIME'); if ($dir=@opendir($path)) { while (($element=readdir($dir))!== false) { $exectime = time() - $starttime; if (($timelimit != 0) && ($timelimit - $exectime) < 3) { // bail now to ensure nothing is lost echo "
".i18n::translate('The execution time limit was reached. Try the command again to move the rest of the files.')."
"; return; } // do not move certain files... if ($element!= "." && $element!= ".." && $element!=".svn" && $element!="watermark" && $element!="thumbs" && $element!=".htaccess" && $element!="index.php" && $element!="MediaInfo.txt" && $element!="ThumbsInfo.txt") { $filename = $path."/".$element; if (is_dir($filename)) { // call this function recursively on this directory move_files($filename, $protect); } else { if ($protect) { // Move single file and optionally its corresponding thumbnail to protected dir if (file_exists($filename)) { move_file($filename, get_media_firewall_path($filename)); } if ($MEDIA_FIREWALL_THUMBS) { $thumbnail = thumbnail_file($filename, false); if (file_exists($thumbnail)) { move_file($thumbnail, get_media_firewall_path($thumbnail)); } } } else { // Move single file and its corresponding thumbnail to standard dir $filename = get_media_standard_path($filename); if (file_exists(get_media_firewall_path($filename))) { move_file(get_media_firewall_path($filename), $filename); } $thumbnail = thumbnail_file($filename, false); if (file_exists(get_media_firewall_path($thumbnail))) { move_file(get_media_firewall_path($thumbnail), $thumbnail); } } } } } echo ""; $action="filter"; closedir($dir); } return; } /** * Recursively sets the permissions on files * Operates directly on the filesystem, does not use the db. */ function set_perms($path) { global $MEDIA_FIREWALL_ROOTDIR, $MEDIA_DIRECTORY, $starttime; if (preg_match("'^($MEDIA_FIREWALL_ROOTDIR)?$MEDIA_DIRECTORY'", $path."/")==0) { return false; } $timelimit=get_site_setting('MAX_EXECUTION_TIME'); if ($dir=@opendir($path)) { while (($element=readdir($dir))!== false) { $exectime = time() - $starttime; if (($timelimit != 0) && ($timelimit - $exectime) < 3) { // bail now to ensure nothing is lost echo "
".i18n::translate('The execution time limit was reached. Try the command again on a smaller directory.')."
"; return; } // do not set perms on certain files... if ($element!= "." && $element!= ".." && $element!=".svn") { $fullpath = $path."/".$element; if (is_dir($fullpath)) { if (@chmod($fullpath, WT_PERM_EXE)) { echo "
".i18n::translate('Permissions Set')." [".decoct(WT_PERM_EXE)."] [".$fullpath."]
"; } else { echo "
".i18n::translate('Permissions Not Set')." [".decoct(WT_PERM_EXE)."] [".$fullpath."]
"; } // call this function recursively on this directory set_perms($fullpath); } else { if (@chmod($fullpath, WT_PERM_FILE)) { echo "
".i18n::translate('Permissions Set')." [".decoct(WT_PERM_FILE)."] [".$fullpath."]
"; } else { echo "
".i18n::translate('Permissions Not Set')." [".decoct(WT_PERM_FILE)."] [".$fullpath."]
"; } } } } closedir($dir); } return; } // global var used by recursive functions $starttime = time(); // TODO Determine source and validation requirements for these variables $filename=safe_REQUEST($_REQUEST, 'filename'); $directory=safe_REQUEST($_REQUEST, 'directory', WT_REGEX_NOSCRIPT, $MEDIA_DIRECTORY); $movetodir=safe_REQUEST($_REQUEST, 'movetodir'); $movefile=safe_REQUEST($_REQUEST, 'movefile'); $action=safe_REQUEST($_REQUEST, 'action', WT_REGEX_ALPHA, 'filter'); $subclick=safe_REQUEST($_REQUEST, 'subclick', WT_REGEX_ALPHA, 'none'); $media=safe_REQUEST($_REQUEST, 'media'); $filter=safe_REQUEST($_REQUEST, 'filter', WT_REGEX_NOSCRIPT); $sortby=safe_REQUEST($_REQUEST, 'sortby', 'file', 'title'); $level=safe_REQUEST($_REQUEST, 'level', WT_REGEX_INTEGER, 0); $showthumb=safe_REQUEST($_REQUEST, 'showthumb'); $all=safe_REQUEST($_REQUEST, 'all', 'yes', 'no'); if (isset($_REQUEST['xref'])) $xref = $_REQUEST['xref']; if (count($_POST) == 0) $showthumb = true; $thumbget = ""; if ($showthumb) $thumbget = "&showthumb=true"; //-- prevent script from accessing an area outside of the media directory //-- and keep level consistency if (($level < 0) || ($level > $MEDIA_DIRECTORY_LEVELS)) { $directory = $MEDIA_DIRECTORY; $level = 0; } elseif (preg_match("'^$MEDIA_DIRECTORY'", $directory)==0) { $directory = $MEDIA_DIRECTORY; $level = 0; } $thumbdir = str_replace($MEDIA_DIRECTORY, $MEDIA_DIRECTORY."thumbs/", $directory); $directory_fw = get_media_firewall_path($directory); $thumbdir_fw = get_media_firewall_path($thumbdir); //-- only allow users with Admin privileges to access script. if (!WT_USER_IS_ADMIN || !$ALLOW_EDIT_GEDCOM) { header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.'login.php?url='.WT_SCRIPT_NAME); exit; } //-- TODO add check for -- admin can manipulate files $fileaccess = false; if (WT_USER_IS_ADMIN) { $fileaccess = true; } // echo the header of the page print_header(i18n::translate('Manage multimedia')); ?> "; // Check if Media Directory is writeable or if Media features are enabled // If one of these is not true then do not continue if (!dir_is_writable($MEDIA_DIRECTORY) || !$MULTI_MEDIA) { echo ""; echo i18n::translate('Uploading media files is not allowed because multi-media items have been disabled or because the media directory is not writable.'); echo "
"; } else { show_mediaUpload_form('media.php', $showthumb); // We have the green light to upload media, echo the form } echo "
"; ob_start(); // Save output until action table has been printed if ($action == "deletedir") { echo ""; echo "
"; // Check if media directory and thumbs directory are empty $clean = false; $files = array(); $thumbfiles = array(); $files_fw = array(); $thumbfiles_fw = array(); $resdir = false; $resthumb = false; // Media directory check if (@is_dir(filename_decode($directory))) { $handle = opendir(filename_decode($directory)); $files = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $files[] = $file; } } else { echo "
".$directory." ".i18n::translate('Directory does not exist.')."
"; AddToLog('Directory does not exist.'.$directory, 'media'); } // Thumbs directory check if (@is_dir(filename_decode($thumbdir))) { $handle = opendir(filename_decode($thumbdir)); $thumbfiles = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $thumbfiles[] = $file; } closedir($handle); } // Media Firewall Media directory check if (@is_dir(filename_decode($directory_fw))) { $handle = opendir(filename_decode($directory_fw)); $files_fw = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $files_fw[] = $file; } } // Media Firewall Thumbs directory check if (@is_dir(filename_decode($thumbdir_fw))) { $handle = opendir(filename_decode($thumbdir_fw)); $thumbfiles_fw = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $thumbfiles_fw[] = $file; } closedir($handle); } if (!isset($error)) { if (count($files) > 0 ) { echo "
".$directory." -- ".i18n::translate('Directory not empty.')."
"; AddToLog($directory." -- ".i18n::translate('Directory not empty.'), 'media'); $clean = false; } if (count($thumbfiles) > 0) { echo "
".$thumbdir." -- ".i18n::translate('Directory not empty.')."
"; AddToLog($thumbdir." -- ".i18n::translate('Directory not empty.'), 'media'); $clean = false; } if (count($files_fw) > 0 ) { echo "
".$directory_fw." -- ".i18n::translate('Directory not empty.')."
"; AddToLog($directory_fw." -- ".i18n::translate('Directory not empty.'), 'media'); $clean = false; } if (count($thumbfiles_fw) > 0) { echo "
".$thumbdir_fw." -- ".i18n::translate('Directory not empty.')."
"; AddToLog($thumbdir_fw." -- ".i18n::translate('Directory not empty.'), 'media'); $clean = false; } else $clean = true; } // Only start deleting if all directories are empty if ($clean) { $resdir = true; $resthumb = true; $resdir_fw = true; $resthumb_fw = true; if (file_exists(filename_decode($directory."index.php"))) @unlink(filename_decode($directory."index.php")); if (@is_dir(filename_decode($directory))) $resdir = @rmdir(filename_decode(substr($directory, 0, -1))); if (file_exists(filename_decode($thumbdir."index.php"))) @unlink(filename_decode($thumbdir."index.php")); if (@is_dir(filename_decode($thumbdir))) $resthumb = @rmdir(filename_decode(substr($thumbdir, 0, -1))); if (file_exists(filename_decode($directory_fw."index.php"))) @unlink(filename_decode($directory_fw."index.php")); if (@is_dir(filename_decode($directory_fw))) $resdir_fw = @rmdir(filename_decode(substr($directory_fw, 0, -1))); if (file_exists(filename_decode($thumbdir_fw."index.php"))) @unlink(filename_decode($thumbdir_fw."index.php")); if (@is_dir(filename_decode($thumbdir_fw))) $resthumb_fw = @rmdir(filename_decode(substr($thumbdir_fw, 0, -1))); if ($resdir && $resthumb && $resdir_fw && $resthumb_fw) { echo i18n::translate('Media and thumbnail directories successfully removed.'); AddToLog($directory." -- ".i18n::translate('Media and thumbnail directories successfully removed.'), 'media'); } else { if (!$resdir) { echo "
".i18n::translate('Media directory not removed.')."
"; AddToLog($directory." -- ".i18n::translate('Media directory not removed.'), 'media'); } else if (!$resdir_fw) { echo "
".i18n::translate('Media directory not removed.')."
"; AddToLog($directory_fw." -- ".i18n::translate('Media directory not removed.'), 'media'); } else { echo i18n::translate('Media directory successfully removed.'); AddToLog($directory." -- ".i18n::translate('Media directory successfully removed.'), 'media'); } if (!$resthumb) { echo "
".i18n::translate('Thumbnail directory not removed.')."
"; AddToLog($thumbdir." -- ".i18n::translate('Thumbnail directory not removed.'), 'media'); } else if (!$resthumb_fw) { echo "
".i18n::translate('Thumbnail directory not removed.')."
"; AddToLog($thumbdir_fw." -- ".i18n::translate('Thumbnail directory not removed.'), 'media'); } else { echo i18n::translate('Thumbnail directory successfully removed.'); AddToLog($thumbdir." -- ".i18n::translate('Thumbnail directory successfully removed.'), 'media'); } } } // Back up to this directory's parent $i = strrpos(substr($directory, 0, -1), '/'); $directory = trim(substr($directory, 0, $i), '/').'/'; $action="filter"; echo "
"; } /** * This action generates a thumbnail for the file * * @name $action->thumbnail */ if ($action == "thumbnail") { echo ""; echo "
"; // TODO: add option to generate thumbnails for all images on page // Cycle through $medialist and skip all exisiting thumbs // Check if $all is true, if so generate thumbnails for all files that do // not yet have any thumbnails created. Otherwise only the file specified. if ($all == 'yes') { $medialist = get_medialist(true, $directory); foreach ($medialist as $key => $media) { if (!($MEDIA_EXTERNAL && isFileExternal($filename))) { // why doesn't this use thumbnail_file?? $thumbnail = str_replace("$MEDIA_DIRECTORY", $MEDIA_DIRECTORY."thumbs/", check_media_depth($media["FILE"], "NOTRUNC")); if (!$media["THUMBEXISTS"]) { if (generate_thumbnail($media["FILE"], $thumbnail)) { echo i18n::translate('Thumbnail %s generated automatically.', $thumbnail); AddToLog("Thumbnail {$thumbnail} generated automatically.", 'edit'); } else { echo ""; echo i18n::translate('Thumbnail %s could not be generated automatically.', $thumbnail); echo ""; AddToLog("Thumbnail {$thumbnail} could not be generated automatically.", 'edit'); } echo "
"; } } } } else if ($all != 'yes') { if (!($MEDIA_EXTERNAL && isFileExternal($filename))) { $thumbnail = str_replace("$MEDIA_DIRECTORY", $MEDIA_DIRECTORY."thumbs/", check_media_depth($filename, "NOTRUNC")); if (generate_thumbnail($filename, $thumbnail)) { echo i18n::translate('Thumbnail %s generated automatically.', $thumbnail); AddToLog("Thumbnail {$thumbnail} generated automatically.", 'edit'); } else { echo ""; echo i18n::translate('Thumbnail %s could not be generated automatically.', $thumbnail); echo ""; AddToLog("Thumbnail {$thumbnail} could not be generated automatically.", 'edit'); } } } $action = "filter"; echo "
"; } // Move single file and optionally its corresponding thumbnail to protected dir if ($action == "moveprotected") { echo ""; echo "
"; if (strpos($filename, "../") !== false) { // don't allow user to access directories outside of media dir echo "
".i18n::translate('Blank name or illegal characters in name')."
"; } else { if (file_exists($filename)) { move_file($filename, get_media_firewall_path($filename)); } if ($MEDIA_FIREWALL_THUMBS) { $thumbnail = thumbnail_file($filename, false); if (file_exists($thumbnail)) { move_file($thumbnail, get_media_firewall_path($thumbnail)); } } } echo "
"; $action="filter"; } // Move single file and its corresponding thumbnail to standard dir if ($action == "movestandard") { echo ""; echo "
"; if (strpos($filename, "../") !== false) { // don't allow user to access directories outside of media dir echo "
".i18n::translate('Blank name or illegal characters in name')."
"; } else { if (file_exists(get_media_firewall_path($filename))) { move_file(get_media_firewall_path($filename), $filename); } $thumbnail = thumbnail_file($filename, false); if (file_exists(get_media_firewall_path($thumbnail))) { move_file(get_media_firewall_path($thumbnail), $thumbnail); } } echo "
"; $action="filter"; } // Move entire dir and all subdirs to protected dir if ($action == "movedirprotected") { echo ""; echo "
"; echo "".i18n::translate('Move to protected')."
"; move_files(substr($directory, 0, -1), true); echo "
"; $action="filter"; } // Move entire dir and all subdirs to standard dir if ($action == "movedirstandard") { echo ""; echo "
"; echo "".i18n::translate('Move to standard')."
"; move_files(substr(get_media_firewall_path($directory), 0, -1), false); echo "
"; $action="filter"; } if ($action == "setpermsfix") { echo ""; echo "
"; echo "".i18n::translate('Correct read/write/execute permissions')."
"; set_perms(substr($directory, 0, -1)); set_perms(substr(get_media_firewall_path($directory), 0, -1)); echo "
"; $action="filter"; } // Upload media items if ($action == "upload") { process_uploadMedia_form(); $medialist = get_medialist(); $action = "filter"; } $allowDelete = true; $removeObject = true; // Remove object: same as Delete file, except file isn't deleted if ($action == "removeobject") { $action = "deletefile"; $allowDelete = false; $removeObject = true; } // Remove link: same as Delete file, except file isn't deleted if ($action == "removelinks") { $action = "deletefile"; $allowDelete = false; $removeObject = false; } // Delete file if ($action == "deletefile") { echo ""; echo "
"; $xrefs = array($xref); $onegedcom = true; //-- get all of the XREFS associated with this record //-- and check if the file is used in multiple gedcoms $myFile = str_replace($MEDIA_DIRECTORY, "", $filename); //-- figure out how many levels are in this file $mlevels = preg_split("~[/\\\]~", $filename); $statement=WT_DB::prepare("SELECT * FROM `##media` WHERE m_file LIKE ?")->execute(array("%{$myFile}")); while ($row=$statement->fetch(PDO::FETCH_ASSOC)) { $rlevels = preg_split("~[/\\\]~", $row["m_file"]); //-- make sure we only delete a file at the same level of directories //-- see 1825257 $match = true; $k=0; $i=count($rlevels)-1; $j=count($mlevels)-1; while ($i>=0 && $j>=0) { if ($rlevels[$i] != $mlevels[$j]) { $match = false; break; } $j--; $i--; $k++; if ($k>$MEDIA_DIRECTORY_LEVELS) break; } if ($match) { if ($row["m_gedfile"]!=WT_GED_ID) $onegedcom = false; else $xrefs[] = $row["m_media"]; } } $statement->closeCursor(); $xrefs = array_unique($xrefs); $finalResult = true; if ($allowDelete) { if (!$onegedcom) { echo "".i18n::translate('This file is linked to another genealogical database on this server. It cannot be deleted, moved, or renamed until these links have been removed.')."

".i18n::translate('Media file could not be deleted.')."

"; $finalResult = false; } if (isFileExternal($filename)) { echo "".i18n::translate('This media object does not exist as a file on this server. It cannot be deleted, moved, or renamed.')."

".i18n::translate('Media file could not be deleted.')."

"; $finalResult = false; } if ($finalResult) { // Check if file exists. If so, delete it $server_filename = get_server_filename($filename); if (file_exists($server_filename) && $allowDelete) { if (@unlink($server_filename)) { echo i18n::translate('Media file successfully deleted.')."
"; AddToLog($server_filename." -- ".i18n::translate('Media file successfully deleted.'), 'edit'); } else { $finalResult = false; echo "".i18n::translate('Media file could not be deleted.')."
"; AddToLog($server_filename." -- ".i18n::translate('Media file could not be deleted.'), 'edit'); } } // Check if thumbnail exists. If so, delete it. $thumbnail = str_replace("$MEDIA_DIRECTORY", $MEDIA_DIRECTORY."thumbs/", $filename); $server_thumbnail = get_server_filename($thumbnail); if (file_exists($server_thumbnail) && $allowDelete) { if (@unlink($server_thumbnail)) { echo i18n::translate('Thumbnail file successfully deleted.')."
"; AddToLog($server_thumbnail." -- ".i18n::translate('Thumbnail file successfully deleted.'), 'edit'); } else { $finalResult = false; echo "".i18n::translate('Thumbnail file could not be deleted.')."
"; AddToLog($server_thumbnail." -- ".i18n::translate('Thumbnail file could not be deleted.'), 'edit'); } } } } //-- loop through all of the found xrefs and delete any references to them foreach ($xrefs as $ind=>$xref) { // Remove references to media file from gedcom and database // Check for XREF if ($xref != "") { $links = get_media_relations($xref); foreach ($links as $pid=>$type) { $gedrec = find_gedcom_record($pid, WT_GED_ID, true); $gedrec = remove_subrecord($gedrec, "OBJE", $xref, -1); replace_gedrec($pid, WT_GED_ID, $gedrec); echo i18n::translate('Record %s successfully updated.', $pid), '
'; } // Remove media object from gedcom if (find_gedcom_record($xref, WT_GED_ID)) { delete_gedrec($xref, WT_GED_ID); echo i18n::translate('Record %s successfully removed from GEDCOM.', $xref), '
'; } else { echo "".i18n::translate('This media object does not exist as a file on this server. It cannot be deleted, moved, or renamed.')."
"; $finalResult = false; } /* I've commented this out, as I have no idea what it is supposed to do. We've just deleted a * file, so why are we creating a new media object for it??? // Record changes to the Media object accept_all_changes($xref, WT_GED_ID); $objerec = find_gedcom_record($xref, WT_GED_ID); // Add the same file as a new object if ($finalResult && !$removeObject && $objerec!="") { $xref = get_new_xref("OBJE"); $objerec = preg_replace("/0 @.*@ OBJE/", "0 @".$xref."@ OBJE", $objerec); if (append_gedrec($objerec, WT_GED_ID)) { echo i18n::translate('Record %s successfully added to GEDCOM.', $xref); } else { $finalResult = false; echo ""; echo i18n::translate('Record %s could not be added to GEDCOM.', $xref); echo ""; } echo "
"; } */ } } if ($finalResult) echo i18n::translate('Update successful'); $action = "filter"; echo "
"; } /** * Generate link flyout menu * * @param string $mediaid */ function print_link_menu($mediaid) { global $TEXT_DIRECTION; $classSuffix = ""; if ($TEXT_DIRECTION=="rtl") $classSuffix = "_rtl"; // main link displayed on page $menu = new Menu(); // GEDFact assistant Add Media Links ======================= if (file_exists('modules/GEDFact_assistant/_MEDIA/media_1_ctrl.php')) { $menu->addLabel(i18n::translate('Manage links')); $menu->addOnclick("return ilinkitem('$mediaid', 'manage')"); $menu->addClass("", "", "submenu"); $menu->addFlyout("left"); // Do not echo submunu } else { $menu->addLabel(i18n::translate('Set link')); $menu->addOnclick("return ilinkitem('$mediaid', 'person')"); $submenu = new Menu(i18n::translate('To Person')); $submenu->addClass("submenuitem".$classSuffix, "submenuitem_hover".$classSuffix); $submenu->addOnclick("return ilinkitem('$mediaid', 'person')"); $menu->addSubMenu($submenu); $submenu = new Menu(i18n::translate('To Family')); $submenu->addClass("submenuitem".$classSuffix, "submenuitem_hover".$classSuffix); $submenu->addOnclick("return ilinkitem('$mediaid', 'family')"); $menu->addSubMenu($submenu); $submenu = new Menu(i18n::translate('To Source')); $submenu->addClass("submenuitem".$classSuffix, "submenuitem_hover".$classSuffix); $submenu->addOnclick("return ilinkitem('$mediaid', 'source')"); $menu->addSubMenu($submenu); } echo $menu->getMenu(); } $savedOutput = ob_get_clean(); ?>
> > ".i18n::translate('Upload media files').""; ?>
> 0) { $folders = get_media_folders(); echo "
"; } else echo ""; // Text field for filter ?>
   
>
> onclick="submit();" /> >
filter */ // Show link to previous folder $levels = explode('/', $directory); $pdir = ''; for ($i=0; $i"; if ($TEXT_DIRECTION=="rtl") $uplink .= getLRM(); $uplink .= $pdir; if ($TEXT_DIRECTION=="rtl") $uplink .= getLRM(); $uplink .= ""; $uplink2 = "\"\""; } // Start of media directory table echo ""; // Tell the user where he is echo ""; echo ""; echo ""; // display the directory list if (count($dirs) || $pdir != '') { sort($dirs); if ($pdir != '') { echo ""; echo ""; echo ""; echo ""; } foreach ($dirs as $indexval => $dir) { if ($dir{0}!=".") { echo ""; echo ""; echo ""; echo ""; } } } echo "
"; echo i18n::translate('Current directory'); echo "
"; if ($USE_MEDIA_FIREWALL) { echo $MEDIA_FIREWALL_ROOTDIR; } echo PrintReady(substr($directory, 0, -1)); echo "
"; // Calculation to determine whether files are protected or not ------------------------- // Check if media directory and thumbs directory are empty $clean = false; $files = array(); $thumbfiles = array(); $files_fw = array(); $thumbfiles_fw = array(); $resdir = false; $resthumb = false; // Media directory check if (@is_dir(filename_decode($directory))) { $handle = opendir(filename_decode($directory)); $files = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $files[] = $file; } } else { echo "
".$directory." ".i18n::translate('Directory does not exist.')."
"; AddToLog('Directory does not exist.'.$directory, 'media'); } // Thumbs directory check if (@is_dir(filename_decode($thumbdir))) { $handle = opendir(filename_decode($thumbdir)); $thumbfiles = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $thumbfiles[] = $file; } closedir($handle); } // Media Firewall Media directory check if (@is_dir(filename_decode($directory_fw))) { $handle = opendir(filename_decode($directory_fw)); $files_fw = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $files_fw[] = $file; } } // Media Firewall Thumbs directory check if (@is_dir(filename_decode($thumbdir_fw))) { $handle = opendir(filename_decode($thumbdir_fw)); $thumbfiles_fw = array(); while (false !== ($file = readdir($handle))) { if (!in_array($file, $BADMEDIA)) $thumbfiles_fw[] = $file; } closedir($handle); } $protected_files = count($files_fw); $standard_files = count($files); echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if ($USE_MEDIA_FIREWALL) { if ($protected_files < $standard_files) { echo '
'; echo i18n::translate('The media Firewall is ENABLED but your media may still be located in the Standard Media Directory').'
'; echo i18n::translate('Choose either').'
'; echo i18n::translate('(a) Click the "Move ALL to Protected" button to move your media to the protected directory').'
'; echo i18n::translate('or').'
'; echo i18n::translate('(b) Disable The Media Firewall Directory in the GEDCOM configuration section').'

'; echo '
'; } echo ""; echo ""; echo help_link('move_mediadirs'); echo "
"; } if (!$USE_MEDIA_FIREWALL && is_dir($MEDIA_FIREWALL_ROOTDIR.$MEDIA_DIRECTORY)) { if ($protected_files > $standard_files) { echo '
'; echo i18n::translate('The media Firewall is DISABLED but your media may still be located in the Protected Media Directory').'
'; echo i18n::translate('Choose either').'
'; echo i18n::translate('(a) Click the "Move ALL to Standard" button to move your media to the standard directory').'
'; echo i18n::translate('or').'
'; echo i18n::translate('(b) Re-enable The Media Firewall Directory in the GEDCOM configuration section').'

'; echo '
'; echo ""; echo ""; echo help_link('move_mediadirs'); echo "
"; } } echo ""; echo help_link('setperms'); echo "
"; echo "
"; echo $uplink2; echo ""; echo $uplink; echo "
"; // directory options echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if ($USE_MEDIA_FIREWALL) { echo "
"; echo "
"; } echo "
"; echo "
"; echo ""; if ($TEXT_DIRECTION=="rtl") echo getRLM(); echo $dir; if ($TEXT_DIRECTION=="rtl") echo getRLM(); echo ""; echo "
"; echo "
"; // display the images if (count($medialist) && ($subclick=='search' || $subclick=='all')) { if (WT_USE_LIGHTBOX) { // Get Lightbox config variables require WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; require WT_ROOT.'modules/lightbox/functions/lb_call_js.php'; } // Sort the media list according to the user's wishes $sortedMediaList = $medialist; // Default sort (by title) has already been done if ($sortby=='file') uasort($sortedMediaList, 'filesort'); // Set up for two passes, the first showing URLs, the second normal files ?>
$media) { while (true) { if (!filterMedia($media, $filter, $httpFilter)) break; $isExternal = isFileExternal($media["FILE"]); if ($passCount==1 && !$isExternal) break; if ($passCount==2 && $isExternal) break; $imgsize = findImageSize($media["FILE"]); $imgwidth = $imgsize[0]+40; $imgheight = $imgsize[1]+150; $changeClass = ""; if ($media["CHANGE"]=="delete") $changeClass = "change_old"; if ($media["CHANGE"]=="replace") $changeClass = "change_new"; if ($media["CHANGE"]=="append") $changeClass = "change_new"; // Show column with file operations options $printDone = true; echo ""; $name = trim($media["TITL"]); // Get media item Notes $haystack = $media["GEDCOM"]; $needle = "1 NOTE"; $before = substr($haystack, 0, strpos($haystack, $needle)); $after = substr(strstr($haystack, $needle), strlen($needle)); $worked = str_replace("1 NOTE", "1 NOTE
", $after); $final = $before.$needle.$worked; $notes = PrintReady(htmlspecialchars(addslashes(print_fact_notes($final, 1, true, true)))); // Get info on how to handle this media file $mediaInfo = mediaFileInfo($media["FILE"], $media["THUMB"], $media["XREF"], $name, $notes); //-- Thumbnail field if ($showthumb) { echo "'; } //-- name and size field echo ""; break; } } if ($passCount==1 && $printDone) echo ""; } ?>
"; if ($media["CHANGE"]!="delete") { // Edit File $tempURL = "addmedia.php?action="; if ($media["XREF"] != "") { $tempURL .= "editmedia&pid={$media['XREF']}&linktoid="; if (!$media["LINKED"]) { $tempURL .= "new"; } else { foreach ($media["LINKS"] as $linkToID => $temp) break; $tempURL .= $linkToID; } } else { $tempURL .= 'showmediaform&filename='.rawurlencode($media['FILE']).'&linktoid=new'; } echo "", i18n::translate('Edit'), "
"; // Edit Raw if ($media["XREF"] != "") { echo "".i18n::translate('Edit raw GEDCOM record')."
"; } // Delete File // don't delete external files // don't delete files linked to more than 1 object $objectCount = 0; if (!$isExternal) { foreach ($medialist as $tempMedia) { if ($media["EXISTS"] && $media["FILE"]==$tempMedia["FILE"]) $objectCount++; } unset($tempMedia); } if (!$isExternal && $objectCount<2) { $tempURL = "media.php?"; if (!empty($filter)) $tempURL.= "filter=".rawurlencode($filter)."&"; $tempURL .= "action=deletefile&showthumb={$showthumb}&sortby={$sortby}&filter={$filter}&subclick={$subclick}&filename=".rawurlencode($media['FILE'])."&directory={$directory}&level={$level}&xref={$media['XREF']}&gedfile={$media['GEDFILE']}"; echo "".i18n::translate('Delete file')."
"; } // Remove Object if (!empty($media["XREF"])) { $tempURL = "media.php?"; if (!empty($filter)) $tempURL .= "filter={$filter}&"; $tempURL .= "action=removeobjectamp;&showthumb={$showthumb}amp;&sortby={$sortby}amp;&filter={$filter}amp;&subclick={$subclick}amp;&filename=".rawurlencode($media['FILE'])."amp;&directory={$directory}amp;&level={$level}amp;&xref={$media['XREF']}amp;&gedfile={$media['GEDFILE']}"; echo "".i18n::translate('Remove object')."
"; } // Remove links if ($media["LINKED"]) { $tempURL = "media.php?"; if (!empty($filter)) $tempURL .= "filter={$filter}&"; $tempURL .= "action=removelinks&showthumb={$showthumb}&sortby={$sortby}&filter={$filter}&subclick={$subclick}&filename=".urlencode($media['FILE'])."&directory={$directory}&level={$level}&xref={$media['XREF']}&gedfile={$media['GEDFILE']}"; } // Add or Remove Links // Only add or remove links to media that is in the DB if ($media["XREF"] != "") { print_link_menu($media["XREF"]); } // Move image between standard and protected directories if ($USE_MEDIA_FIREWALL && ($media["EXISTS"] > 1)) { $tempURL = "media.php?"; if ($media["EXISTS"] == 2) { $tempURL .= "action=moveprotected"; $message=i18n::translate('Move to protected directory'); } if ($media["EXISTS"] == 3) { $tempURL .= "action=movestandard"; $message=i18n::translate('Move to standard directory'); } $tempURL .= "&showthumb={$showthumb}&sortby={$sortby}&filename=".rawurlencode($media['FILE'])."&directory=".rawurlencode($directory)."&level={$level}&xref={$media['XREF']}&gedfile=".rawurlencode($media["GEDFILE"]); echo "".$message."
"; } // Generate thumbnail if (!$isExternal && (empty($media["THUMB"]) || !$media["THUMBEXISTS"])) { $ct = preg_match("/\.([^\.]+)$/", $media["FILE"], $match); if ($ct>0) $ext = strtolower(trim($match[1])); if ($ext=="jpg" || $ext=="jpeg" || $ext=="gif" || $ext=="png") { $tempURL = "media.php?"; if (!empty($filter)) $tempURL .= "filter={$filter}&"; $tempURL .= "action=thumbnail&all=no&sortby={$sortby}&level={$level}&directory=".rawurlencode($directory)."&filename=".rawurlencode($media["FILE"]).$thumbget; echo "".i18n::translate('Create thumbnail').""; } } } // NOTE: Close column for file operations echo "
"; // if Streetview object if (strpos($media["FILE"], 'http://maps.google.')===0) { echo ''; } else { echo '
'; echo '', $name, '
'; } echo '
"; if ($media["TITL"]!="" && begRTLText($media["TITL"]) && $TEXT_DIRECTION=="ltr") { if (!empty($media["XREF"])) { echo "(".$media["XREF"].")"; echo "   "; } if ($media["TITL"]!="") echo "".PrintReady($media["TITL"])."
"; } else { if ($media["TITL"]!="") echo "".PrintReady($media["TITL"])."   "; if (!empty($media["XREF"])) { if ($TEXT_DIRECTION=="rtl") echo getRLM(); echo "(".$media["XREF"].")"; if ($TEXT_DIRECTION=="rtl") echo getRLM(); echo "
"; } } if (!$isExternal && !$media["EXISTS"]) echo "".PrintReady($media["FILE"])."
".i18n::translate('The filename entered does not exist.')."
"; else { if (substr($mediaInfo['type'], 0, 4) == 'url_') $tempText = 'URL'; else $tempText = PrintReady($media["FILE"]); if (!empty($media["XREF"])) { echo '', $tempText, '
'; } else { echo '', $tempText, '
'; } } if (substr($mediaInfo['type'], 0, 4) != 'url_' && !empty($imgsize[0])) { echo "  ".i18n::translate('Image Dimensions')." -- ".$imgsize[0]."x".$imgsize[1]."
"; } print_fact_notes($media["GEDCOM"], 1); print_fact_sources($media["GEDCOM"], 1); if ($media["LINKED"]) { PrintMediaLinks($media["LINKS"], "normal"); } else { echo "
".i18n::translate('This media object is not linked to any GEDCOM record.'); } if ($USE_MEDIA_FIREWALL) { echo "

"; if ($media["EXISTS"]) { switch ($media["EXISTS"]) { case 1: echo i18n::translate('This media object is located on an external server'); break; case 2: echo i18n::translate('This media object is in the standard media directory'); break; case 3: echo i18n::translate('This media object is in the protected media directory'); break; } echo '
'; } if ($media["THUMBEXISTS"]) { switch ($media["EXISTS"]) { case 1: echo i18n::translate('This thumbnail is located on an external server'); break; case 2: echo i18n::translate('This thumbnail is in the standard media directory'); break; case 3: echo i18n::translate('This thumbnail is in the protected media directory'); break; } echo '
'; } } echo "