function hasMemoryForImage($serverFilename) { // find out how much total memory this script can access $memoryAvailable = return_bytes(@ini_get('memory_limit')); // if memory is unlimited, it will return -1 and we don’t need to worry about it if ($memoryAvailable == -1) { return true; } // find out how much memory we are already using $memoryUsed = memory_get_usage(); $imgsize = @getimagesize($serverFilename); // find out how much memory this image needs for processing, probably only works for jpegs // from comments on http://www.php.net/imagecreatefromjpeg if (is_array($imgsize) && isset($imgsize['bits']) && isset($imgsize['channels'])) { $memoryNeeded = round(($imgsize[0] * $imgsize[1] * $imgsize['bits'] * $imgsize['channels'] / 8 + Pow(2, 16)) * 1.65); $memorySpare = $memoryAvailable - $memoryUsed - $memoryNeeded; if ($memorySpare > 0) { // we have enough memory to load this file return true; } else { // not enough memory to load this file $image_info = sprintf('%.2fKB, %d × %d %d bits %d channels', filesize($serverFilename) / 1024, $imgsize[0], $imgsize[1], $imgsize['bits'], $imgsize['channels']); Log::addMediaLog('Cannot create thumbnail ' . $serverFilename . ' (' . $image_info . ') memory avail: ' . $memoryAvailable . ' used: ' . $memoryUsed . ' needed: ' . $memoryNeeded . ' spare: ' . $memorySpare); return false; } } else { // assume there is enough memory // TODO find out how to check memory needs for gif and png return true; } }
/** * Set the site’s configuration settings. * * @param string $setting_name * @param string|int|bool $setting_value * * @return void */ public static function setPreference($setting_name, $setting_value) { // Only need to update the database if the setting has actually changed. if (self::getPreference($setting_name) != $setting_value) { WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))")->execute(array($setting_name, $setting_value)); self::$setting[$setting_name] = $setting_value; Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"'); } }
public static function send(WT_Tree $tree, $to_email, $to_name, $replyto_email, $replyto_name, $subject, $message) { try { $mail = new Zend_Mail('UTF-8'); $mail->setSubject($subject)->setBodyHtml($message)->setBodyText(WT_Filter::unescapeHtml($message))->setFrom(WT_Site::getPreference('SMTP_FROM_NAME'), $tree->preference('title'))->addTo($to_email, $to_name)->setReplyTo($replyto_email, $replyto_name)->send(WT_Mail::transport()); } catch (Exception $ex) { Log::addErrorLog('Mail: ' . $ex->getMessage()); return false; } return true; }
public static function preference($setting_name, $setting_value = null) { // There are lots of settings, and we need to fetch lots of them on every page // so it is quicker to fetch them all in one go. if (self::$setting === null) { self::$setting = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`")->fetchAssoc(); } // If $setting_value is null, then GET the setting if ($setting_value === null) { // If parameter two is not specified, GET the setting if (!array_key_exists($setting_name, self::$setting)) { self::$setting[$setting_name] = null; } return self::$setting[$setting_name]; } else { // If parameter two is specified, then SET the setting if (self::preference($setting_name) != $setting_value) { // Audit log of changes Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"'); } WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))")->execute(array($setting_name, $setting_value)); self::$setting[$setting_name] = $setting_value; } }
private function config() { require WT_ROOT . 'includes/functions/functions_edit.php'; $action = WT_Filter::post('action'); $controller = new WT_Controller_Page(); $controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Google Maps™'))->pageHeader()->addInlineJavascript('jQuery("#tabs").tabs();'); if ($action == 'update') { $this->setSetting('GM_MAP_TYPE', WT_Filter::post('NEW_GM_MAP_TYPE')); $this->setSetting('GM_USE_STREETVIEW', WT_Filter::post('NEW_GM_USE_STREETVIEW')); $this->setSetting('GM_MIN_ZOOM', WT_Filter::post('NEW_GM_MIN_ZOOM')); $this->setSetting('GM_MAX_ZOOM', WT_Filter::post('NEW_GM_MAX_ZOOM')); $this->setSetting('GM_XSIZE', WT_Filter::post('NEW_GM_XSIZE')); $this->setSetting('GM_YSIZE', WT_Filter::post('NEW_GM_YSIZE')); $this->setSetting('GM_PRECISION_0', WT_Filter::post('NEW_GM_PRECISION_0')); $this->setSetting('GM_PRECISION_1', WT_Filter::post('NEW_GM_PRECISION_1')); $this->setSetting('GM_PRECISION_2', WT_Filter::post('NEW_GM_PRECISION_2')); $this->setSetting('GM_PRECISION_3', WT_Filter::post('NEW_GM_PRECISION_3')); $this->setSetting('GM_PRECISION_4', WT_Filter::post('NEW_GM_PRECISION_4')); $this->setSetting('GM_PRECISION_5', WT_Filter::post('NEW_GM_PRECISION_5')); $this->setSetting('GM_COORD', WT_Filter::post('NEW_GM_COORD')); $this->setSetting('GM_PLACE_HIERARCHY', WT_Filter::post('NEW_GM_PLACE_HIERARCHY')); $this->setSetting('GM_PH_XSIZE', WT_Filter::post('NEW_GM_PH_XSIZE')); $this->setSetting('GM_PH_YSIZE', WT_Filter::post('NEW_GM_PH_YSIZE')); $this->setSetting('GM_PH_MARKER', WT_Filter::post('NEW_GM_PH_MARKER')); $this->setSetting('GM_DISP_SHORT_PLACE', WT_Filter::post('NEW_GM_DISP_SHORT_PLACE')); for ($i = 1; $i <= 9; $i++) { $this->setSetting('GM_PREFIX_' . $i, WT_Filter::post('NEW_GM_PREFIX_' . $i)); $this->setSetting('GM_POSTFIX_' . $i, WT_Filter::post('NEW_GM_POSTFIX_' . $i)); } Log::addConfigurationLog('Googlemap config updated'); } ?> <table id="gm_config"> <tr> <th> <a class="current" href="module.php?mod=googlemap&mod_action=admin_config"> <?php echo WT_I18N::translate('Google Maps™ preferences'); ?> </a> </th> <th> <a href="module.php?mod=googlemap&mod_action=admin_places"> <?php echo WT_I18N::translate('Geographic data'); ?> </a> </th> <th> <a href="module.php?mod=googlemap&mod_action=admin_placecheck"> <?php echo WT_I18N::translate('Place check'); ?> </a> </th> </tr> </table> <form method="post" name="configform" action="module.php?mod=googlemap&mod_action=admin_config"> <input type="hidden" name="action" value="update"> <div id="tabs"> <ul> <li><a href="#gm_basic"><span><?php echo WT_I18N::translate('Basic'); ?> </span></a></li> <li><a href="#gm_advanced"><span><?php echo WT_I18N::translate('Advanced'); ?> </span></a></li> <li><a href="#gm_ph"><span><?php echo WT_I18N::translate('Place hierarchy'); ?> </span></a></li> </ul> <div id="gm_basic"> <table class="gm_edit_config"> <tr> <th><?php echo WT_I18N::translate('Default map type'); ?> </th> <td> <select name="NEW_GM_MAP_TYPE"> <option value="ROADMAP" <?php if ($this->getSetting('GM_MAP_TYPE') == 'ROADMAP') { echo "selected=\"selected\""; } ?> ><?php echo WT_I18N::translate('Map'); ?> </option> <option value="SATELLITE" <?php if ($this->getSetting('GM_MAP_TYPE') == 'SATELLITE') { echo "selected=\"selected\""; } ?> ><?php echo WT_I18N::translate('Satellite'); ?> </option> <option value="HYBRID" <?php if ($this->getSetting('GM_MAP_TYPE') == 'HYBRID') { echo "selected=\"selected\""; } ?> ><?php echo WT_I18N::translate('Hybrid'); ?> </option> <option value="TERRAIN" <?php if ($this->getSetting('GM_MAP_TYPE') == 'TERRAIN') { echo "selected=\"selected\""; } ?> ><?php echo WT_I18N::translate('Terrain'); ?> </option> </select> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Google Street View™'); ?> </th> <td><?php echo radio_buttons('NEW_GM_USE_STREETVIEW', array(false => WT_I18N::translate('hide'), true => WT_I18N::translate('show')), $this->getSetting('GM_USE_STREETVIEW')); ?> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Size of map (in pixels)'); ?> </th> <td> <?php echo WT_I18N::translate('Width'); ?> <input type="text" name="NEW_GM_XSIZE" value="<?php echo $this->getSetting('GM_XSIZE'); ?> " size="10"> <?php echo WT_I18N::translate('Height'); ?> <input type="text" name="NEW_GM_YSIZE" value="<?php echo $this->getSetting('GM_YSIZE'); ?> " size="10"> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Zoom level of map'), help_link('GM_MAP_ZOOM', 'googlemap'); ?> </th> <td> <?php echo WT_I18N::translate('minimum'); ?> : <select name="NEW_GM_MIN_ZOOM"> <?php for ($j = 1; $j < 15; $j++) { ?> <option value="<?php echo $j, "\""; if ($this->getSetting('GM_MIN_ZOOM') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('maximum'); ?> : <select name="NEW_GM_MAX_ZOOM"> <?php for ($j = 1; $j < 21; $j++) { ?> <option value="<?php echo $j, "\""; if ($this->getSetting('GM_MAX_ZOOM') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> </td> </tr> </table> </div> <div id="gm_advanced"> <table class="gm_edit_config"> <tr> <th colspan="2"><?php echo WT_I18N::translate('Precision of the latitude and longitude'), help_link('GM_PRECISION', 'googlemap'); ?> </th> <td> <table> <tr> <td><?php echo WT_I18N::translate('Country'); ?> </td> <td><select name="NEW_GM_PRECISION_0"> <?php for ($j = 0; $j < 10; $j++) { ?> <option value="<?php echo $j; ?> "<?php if ($this->getSetting('GM_PRECISION_0') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('digits'); ?> </td> </tr> <tr> <td><?php echo WT_I18N::translate('State'); ?> </td> <td><select name="NEW_GM_PRECISION_1"> <?php for ($j = 0; $j < 10; $j++) { ?> <option value="<?php echo $j; ?> "<?php if ($this->getSetting('GM_PRECISION_1') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('digits'); ?> </td> </tr> <tr> <td><?php echo WT_I18N::translate('City'); ?> </td> <td><select name="NEW_GM_PRECISION_2"> <?php for ($j = 0; $j < 10; $j++) { ?> <option value="<?php echo $j; ?> "<?php if ($this->getSetting('GM_PRECISION_2') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('digits'); ?> </td> </tr> <tr><td><?php echo WT_I18N::translate('Neighborhood'); ?> </td> <td><select name="NEW_GM_PRECISION_3"> <?php for ($j = 0; $j < 10; $j++) { ?> <option value="<?php echo $j; ?> "<?php if ($this->getSetting('GM_PRECISION_3') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('digits'); ?> </td> </tr> <tr><td><?php echo WT_I18N::translate('House'); ?> </td> <td><select name="NEW_GM_PRECISION_4"> <?php for ($j = 0; $j < 10; $j++) { ?> <option value="<?php echo $j; ?> "<?php if ($this->getSetting('GM_PRECISION_4') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('digits'); ?> </td> </tr> <tr><td><?php echo WT_I18N::translate('Max'); ?> </td> <td><select name="NEW_GM_PRECISION_5"> <?php for ($j = 0; $j < 10; $j++) { ?> <option value="<?php echo $j; ?> "<?php if ($this->getSetting('GM_PRECISION_5') == $j) { echo " selected=\"selected\""; } echo ">", $j; ?> </option> <?php } ?> </select> <?php echo WT_I18N::translate('digits'); ?> </td> </tr> </table> </td> <td> </td> </tr> <th class="gm_prefix" colspan="3"><?php echo WT_I18N::translate('Optional prefixes and suffixes'), help_link('GM_NAME_PREFIX_SUFFIX', 'googlemap'); ?> </th> </tr> <tr id="gm_level_titles"> <th> </th> <th><?php echo WT_I18N::translate('Prefixes'); ?> </th> <th><?php echo WT_I18N::translate('Suffixes'); ?> </th> <?php for ($level = 1; $level < 10; $level++) { ?> <tr class="gm_levels"> <th> <?php if ($level == 1) { echo WT_I18N::translate('Country'); } else { echo WT_I18N::translate('Level'), " ", $level; } ?> </th> <td><input type="text" size="30" name="NEW_GM_PREFIX_<?php echo $level; ?> " value="<?php echo $this->getSetting('GM_PREFIX_' . $level); ?> "></td> <td><input type="text" size="30" name="NEW_GM_POSTFIX_<?php echo $level; ?> " value="<?php echo $this->getSetting('GM_POSTFIX_' . $level); ?> "></td> </tr> <?php } ?> </table> </div> <div id="gm_ph"> <table class="gm_edit_config"> <tr> <th><?php echo WT_I18N::translate('Use Google Maps™ for the place hierarchy'); ?> </th> <td><?php echo edit_field_yes_no('NEW_GM_PLACE_HIERARCHY', $this->getSetting('GM_PLACE_HIERARCHY')); ?> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Size of map (in pixels)'); ?> </th> <td> <?php echo WT_I18N::translate('Width'); ?> <input type="text" name="NEW_GM_PH_XSIZE" value="<?php echo $this->getSetting('GM_PH_XSIZE'); ?> " size="10"> <?php echo WT_I18N::translate('Height'); ?> <input type="text" name="NEW_GM_PH_YSIZE" value="<?php echo $this->getSetting('GM_PH_YSIZE'); ?> " size="10"> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Type of place markers in Place Hierarchy'); ?> </th> <td> <select name="NEW_GM_PH_MARKER"> <option value="G_DEFAULT_ICON" <?php if ($this->getSetting('GM_PH_MARKER') == "G_DEFAULT_ICON") { echo "selected=\"selected\""; } ?> ><?php echo WT_I18N::translate('Standard'); ?> </option> <option value="G_FLAG" <?php if ($this->getSetting('GM_PH_MARKER') == "G_FLAG") { echo "selected=\"selected\""; } ?> ><?php echo WT_I18N::translate('Flag'); ?> </option> </select> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Display short placenames'), help_link('GM_DISP_SHORT_PLACE', 'googlemap'); ?> </th> <td><?php echo edit_field_yes_no('NEW_GM_DISP_SHORT_PLACE', $this->getSetting('GM_DISP_SHORT_PLACE')); ?> </td> </tr> <tr> <th><?php echo WT_I18N::translate('Display map coordinates'), help_link('GM_COORD', 'googlemap'); ?> </th> <td><?php echo edit_field_yes_no('NEW_GM_COORD', $this->getSetting('GM_COORD')); ?> </td> </tr> </table> </div> </div> <p> <input type="submit" value="<?php echo WT_I18N::translate('save'); ?> "> </p> </form> <?php }
<?php // Log out from the current session // // webtrees: Web based Family History software // Copyright (C) 2014 webtrees development team. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use WT\Auth; use WT\Log; define('WT_SCRIPT_NAME', 'logout.php'); require './includes/session.php'; if (Auth::id()) { Log::addAuthenticationLog('Logout: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName()); Auth::logout(); } header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH);
/** * get image properties * * @param string $which specify either 'main' or 'thumb' * @param int $addWidth amount to add to width * @param int $addHeight amount to add to height * * @return array */ public function getImageAttributes($which = 'main', $addWidth = 0, $addHeight = 0) { global $THUMBNAIL_WIDTH; $var = $which . 'imagesize'; if (!empty($this->{$var})) { return $this->{$var}; } $imgsize = array(); if ($this->fileExists($which)) { $imgsize = @getimagesize($this->getServerFilename($which)); // [0]=width [1]=height [2]=filetype ['mime']=mimetype if (is_array($imgsize) && !empty($imgsize['0'])) { // this is an image $imgsize[0] = $imgsize[0] + 0; $imgsize[1] = $imgsize[1] + 0; $imgsize['adjW'] = $imgsize[0] + $addWidth; // adjusted width $imgsize['adjH'] = $imgsize[1] + $addHeight; // adjusted height $imageTypes = array('', 'GIF', 'JPG', 'PNG', 'SWF', 'PSD', 'BMP', 'TIFF', 'TIFF', 'JPC', 'JP2', 'JPX', 'JB2', 'SWC', 'IFF', 'WBMP', 'XBM'); $imgsize['ext'] = $imageTypes[0 + $imgsize[2]]; // this is for display purposes, always show non-adjusted info $imgsize['WxH'] = WT_I18N::translate('%1$s × %2$s pixels', WT_I18N::number($imgsize['0']), WT_I18N::number($imgsize['1'])); $imgsize['imgWH'] = ' width="' . $imgsize['adjW'] . '" height="' . $imgsize['adjH'] . '" '; if ($which == 'thumb' && $imgsize['0'] > $THUMBNAIL_WIDTH) { // don’t let large images break the dislay $imgsize['imgWH'] = ' width="' . $THUMBNAIL_WIDTH . '" '; } } } if (!is_array($imgsize) || empty($imgsize['0'])) { // this is not an image, OR the file doesn’t exist OR it is a url $imgsize[0] = 0; $imgsize[1] = 0; $imgsize['adjW'] = 0; $imgsize['adjH'] = 0; $imgsize['ext'] = ''; $imgsize['mime'] = ''; $imgsize['WxH'] = ''; $imgsize['imgWH'] = ''; if ($this->isExternal($which)) { // don’t let large external images break the dislay $imgsize['imgWH'] = ' width="' . $THUMBNAIL_WIDTH . '" '; } } if (empty($imgsize['mime'])) { // this is not an image, OR the file doesn’t exist OR it is a url // set file type equal to the file extension - can’t use parse_url because this may not be a full url $exp = explode('?', $this->file); $pathinfo = pathinfo($exp[0]); $imgsize['ext'] = @strtoupper($pathinfo['extension']); // all mimetypes we wish to serve with the media firewall must be added to this array. $mime = array('DOC' => 'application/msword', 'MOV' => 'video/quicktime', 'MP3' => 'audio/mpeg', 'PDF' => 'application/pdf', 'PPT' => 'application/vnd.ms-powerpoint', 'RTF' => 'text/rtf', 'SID' => 'image/x-mrsid', 'TXT' => 'text/plain', 'XLS' => 'application/vnd.ms-excel', 'WMV' => 'video/x-ms-wmv'); if (empty($mime[$imgsize['ext']])) { // if we don’t know what the mimetype is, use something ambiguous $imgsize['mime'] = 'application/octet-stream'; if ($this->fileExists($which)) { // alert the admin if we cannot determine the mime type of an existing file // as the media firewall will be unable to serve this file properly Log::addMediaLog('Media Firewall error: >Unknown Mimetype< for file >' . $this->file . '<'); } } else { $imgsize['mime'] = $mime[$imgsize['ext']]; } } $this->{$var} = $imgsize; return $this->{$var}; }
private static function getActiveModulesByComponent($component, $ged_id, $access_level) { $module_names = WT_DB::prepare("SELECT SQL_CACHE module_name" . " FROM `##module`" . " JOIN `##module_privacy` USING (module_name)" . " WHERE gedcom_id=? AND component=? AND status='enabled' AND access_level>=?" . " ORDER BY CASE component WHEN 'menu' THEN menu_order WHEN 'sidebar' THEN sidebar_order WHEN 'tab' THEN tab_order ELSE 0 END, module_name")->execute(array($ged_id, $component, $access_level))->fetchOneColumn(); $array = array(); foreach ($module_names as $module_name) { if (file_exists(WT_ROOT . WT_MODULES_DIR . $module_name . '/module.php')) { require_once WT_ROOT . WT_MODULES_DIR . $module_name . '/module.php'; $class = $module_name . '_WT_Module'; $array[$module_name] = new $class(); } else { // Module has been deleted from disk? Disable it. Log::addConfigurationLog("Module {$module_name} has been deleted from disk - disabling it"); WT_DB::prepare("UPDATE `##module` SET status='disabled' WHERE module_name=?")->execute(array($module_name)); } } if ($component != 'menu' && $component != 'sidebar' && $component != 'tab') { uasort($array, create_function('$x,$y', 'return WT_I18N::strcasecmp((string)$x, (string)$y);')); } return $array; }
public function deleteRecord() { // Create a pending change WT_DB::prepare("INSERT INTO `##change` (gedcom_id, xref, old_gedcom, new_gedcom, user_id) VALUES (?, ?, ?, '', ?)")->execute(array($this->gedcom_id, $this->xref, $this->getGedcom(), Auth::id())); // Accept this pending change if (Auth::user()->getSetting('auto_accept')) { accept_all_changes($this->xref, $this->gedcom_id); } // Clear the cache self::$gedcom_record_cache = null; self::$pending_record_cache = null; Log::addEditLog('Delete: ' . static::RECORD_TYPE . ' ' . $this->xref); }
function accept_all_changes($xref, $ged_id) { $changes = WT_DB::prepare("SELECT change_id, gedcom_name, old_gedcom, new_gedcom" . " FROM `##change` c" . " JOIN `##gedcom` g USING (gedcom_id)" . " WHERE c.status='pending' AND xref=? AND gedcom_id=?" . " ORDER BY change_id")->execute(array($xref, $ged_id))->fetchAll(); foreach ($changes as $change) { if (empty($change->new_gedcom)) { // delete update_record($change->old_gedcom, $ged_id, true); } else { // add/update update_record($change->new_gedcom, $ged_id, false); } WT_DB::prepare("UPDATE `##change`" . " SET status='accepted'" . " WHERE status='pending' AND xref=? AND gedcom_id=?")->execute(array($xref, $ged_id)); Log::addEditLog("Accepted change {$change->change_id} for {$xref} / {$change->gedcom_name} into database"); } }
chmod($serverFileName, WT_PERM_FILE); Log::addMediaLog('Media file ' . $serverFileName . ' uploaded'); } else { WT_FlashMessages::addMessage(WT_I18N::translate('There was an error uploading your file.') . '<br>' . file_upload_error_text($_FILES['mediafile' . $i]['error'])); $filename = ''; break; } // Now copy the (optional thumbnail) if (!empty($_FILES['thumbnail' . $i]['name']) && preg_match('/^image\\/(png|gif|jpeg)/', $_FILES['thumbnail' . $i]['type'], $match)) { $extension = $match[1]; $thumbFile = preg_replace('/\\.[a-z0-9]{3,5}$/', '.' . $extension, $fileName); $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile; if (move_uploaded_file($_FILES['thumbnail' . $i]['tmp_name'], $serverFileName)) { WT_FlashMessages::addMessage(WT_I18N::translate('The file %s was uploaded.', '<span class="filename">' . $serverFileName . '</span>')); chmod($serverFileName, WT_PERM_FILE); Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded'); } } } } } } $controller->pageHeader(); $mediaFolders = WT_Query_Media::folderListAll(); // Determine file size limit // TODO: do we need to check post_max_size size too? $filesize = ini_get('upload_max_filesize'); if (empty($filesize)) { $filesize = "2M"; } // Print the form
} } } $i = 0; foreach ($toarray as $indexval => $to) { $message = array(); $message['to'] = $to; $message['from'] = $from; if (!empty($from_name)) { $message['from_name'] = $from_name; $message['from_email'] = $from_email; } $message['subject'] = $subject; $message['body'] = $body; $message['created'] = WT_TIMESTAMP; $message['method'] = $method; $message['url'] = $url; if ($i > 0) { $message['no_from'] = true; } if (addMessage($message)) { WT_FlashMessages::addMessage(WT_I18N::translate('Message successfully sent to %s', WT_Filter::escapeHtml($to))); } else { WT_FlashMessages::addMessage(WT_I18N::translate('Message was not sent')); Log::addErrorLog('Unable to send message. FROM:' . $from . ' TO:' . $to . ' (failed to send)'); } $i++; } $controller->pageHeader()->addInlineJavascript('window.opener.location.reload(); window.close();'); break; }
public static function checkCsrf() { if (WT_Filter::post('csrf') !== WT_Filter::getCsrfToken()) { // Oops. Something is not quite right Log::addAuthenticationLog('CSRF mismatch - session expired or malicious attack'); WT_FlashMessages::addMessage(WT_I18N::translate('This form has expired. Try again.')); return false; } return true; }
/** * Preforms a search and replace */ function SearchAndReplace() { global $STANDARD_NAME_FACTS, $ADVANCED_NAME_FACTS; $this->sgeds = array(WT_GED_ID => WT_GEDCOM); $this->srindi = 'yes'; $this->srfams = 'yes'; $this->srsour = 'yes'; $this->srnote = 'yes'; $oldquery = $this->query; $this->GeneralSearch(); //-- don't try to make any changes if nothing was found if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) { return; } Log::addEditLog("Search And Replace old:" . $oldquery . " new:" . $this->replace); // Include edit functions. require_once WT_ROOT . 'includes/functions/functions_edit.php'; $adv_name_tags = preg_split("/[\\s,;: ]+/", $ADVANCED_NAME_FACTS); $name_tags = array_unique(array_merge($STANDARD_NAME_FACTS, $adv_name_tags)); $name_tags[] = '_MARNM'; foreach ($this->myindilist as $id => $record) { $oldRecord = $record->getGedcom(); $newRecord = $oldRecord; if ($this->replaceAll) { $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); } else { if ($this->replaceNames) { foreach ($name_tags as $tag) { $newRecord = preg_replace("~(\\d) " . $tag . " (.*)" . $oldquery . "(.*)~i", "\$1 " . $tag . " \$2" . $this->replace . "\$3", $newRecord); } } if ($this->replacePlaces) { if ($this->replacePlacesWord) { $newRecord = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $oldquery . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $newRecord); } else { $newRecord = preg_replace("~(\\d) PLAC (.*)" . $oldquery . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $newRecord); } } } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { $record->updateRecord($newRecord, true); } else { unset($this->myindilist[$id]); } } foreach ($this->myfamlist as $id => $record) { $oldRecord = $record->getGedcom(); $newRecord = $oldRecord; if ($this->replaceAll) { $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); } else { if ($this->replacePlaces) { if ($this->replacePlacesWord) { $newRecord = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $oldquery . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $newRecord); } else { $newRecord = preg_replace("~(\\d) PLAC (.*)" . $oldquery . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $newRecord); } } } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { $record->updateRecord($newRecord, true); } else { unset($this->myfamlist[$id]); } } foreach ($this->mysourcelist as $id => $record) { $oldRecord = $record->getGedcom(); $newRecord = $oldRecord; if ($this->replaceAll) { $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); } else { if ($this->replaceNames) { $newRecord = preg_replace("~(\\d) TITL (.*)" . $oldquery . "(.*)~i", "\$1 TITL \$2" . $this->replace . "\$3", $newRecord); $newRecord = preg_replace("~(\\d) ABBR (.*)" . $oldquery . "(.*)~i", "\$1 ABBR \$2" . $this->replace . "\$3", $newRecord); } if ($this->replacePlaces) { if ($this->replacePlacesWord) { $newRecord = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $oldquery . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $newRecord); } else { $newRecord = preg_replace("~(\\d) PLAC (.*)" . $oldquery . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $newRecord); } } } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { $record->updateRecord($newRecord, true); } else { unset($this->mysourcelist[$id]); } } foreach ($this->mynotelist as $id => $record) { $oldRecord = $record->getGedcom(); $newRecord = $oldRecord; if ($this->replaceAll) { $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { $record->updateRecord($newRecord, true); } else { unset($this->mynotelist[$id]); } } }
break; case 'undoall': WT_DB::prepare("UPDATE `##change`" . " SET status='rejected'" . " WHERE status='pending' AND gedcom_id=?")->execute(array(WT_GED_ID)); break; case 'acceptall': $changes = WT_DB::prepare("SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" . " FROM `##change` c" . " JOIN `##gedcom` g USING (gedcom_id)" . " WHERE c.status='pending' AND gedcom_id=?" . " ORDER BY change_id")->execute(array(WT_GED_ID))->fetchAll(); foreach ($changes as $change) { if (empty($change->new_gedcom)) { // delete update_record($change->old_gedcom, $change->gedcom_id, true); } else { // add/update update_record($change->new_gedcom, $change->gedcom_id, false); } WT_DB::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database"); } break; } $changed_gedcoms = WT_DB::prepare("SELECT g.gedcom_name" . " FROM `##change` c" . " JOIN `##gedcom` g USING (gedcom_id)" . " WHERE c.status='pending'" . " GROUP BY g.gedcom_name")->fetchOneColumn(); if ($changed_gedcoms) { $changes = WT_DB::prepare("SELECT c.*, u.user_name, u.real_name, g.gedcom_name, new_gedcom, old_gedcom" . " FROM `##change` c" . " JOIN `##user` u USING (user_id)" . " JOIN `##gedcom` g USING (gedcom_id)" . " WHERE c.status='pending'" . " ORDER BY gedcom_id, c.xref, c.change_id")->fetchAll(); $output = '<br><br><table class="list_table">'; $prev_xref = null; $prev_gedcom_id = null; foreach ($changes as $change) { preg_match('/^0 @' . WT_REGEX_XREF . '@ (' . WT_REGEX_TAG . ')/', $change->old_gedcom . $change->new_gedcom, $match); switch ($match[1]) { case 'INDI': $record = new WT_Individual($change->xref, $change->old_gedcom, $change->new_gedcom, $change->gedcom_id); break;
function imagettftextErrorHandler($errno, $errstr, $errfile, $errline) { global $useTTF, $serverFilename; // log the error Log::addErrorLog("Media Firewall error: >" . $errstr . "< in file >" . $serverFilename . "<"); // change value of useTTF to false so the fallback watermarking can be used. $useTTF = false; return true; }
/** * If the Facebook username or email is associated with an account, login to it. Otherwise, register a new account. * * @param object $facebookUser Facebook user * @param string $url (optional) URL to redirect to afterwards. */ private function login_or_register(&$facebookUser, $url = '') { $REQUIRE_ADMIN_AUTH_REGISTRATION = WT_Site::getPreference('REQUIRE_ADMIN_AUTH_REGISTRATION'); if ($this->getSetting('require_verified', 1) && empty($facebookUser->verified)) { $this->error_page(WT_I18N::translate('Only verified Facebook accounts are authorized. Please verify your account on Facebook and then try again')); } if (empty($facebookUser->username)) { $facebookUser->username = $facebookUser->id; } $user_id = $this->get_user_id_from_facebook_username($facebookUser->username); if (!$user_id) { if (!isset($facebookUser->email)) { $this->error_page(WT_I18N::translate('You must grant access to your email address via Facebook in order to use this website. Please uninstall the application on Facebook and try again.')); } $user = User::findByIdentifier($facebookUser->email); if ($user) { $user_id = $user->getUserId(); } } if ($user_id) { // This is an existing user so log them in if they are approved $login_result = $this->login($user_id); $message = ''; switch ($login_result) { case -1: // not validated $message = WT_I18N::translate('This account has not been verified. Please check your email for a verification message.'); break; case -2: // not approved $message = WT_I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'); break; default: $user = User::find($user_id); $user->setPreference(self::user_setting_facebook_username, $this->cleanseFacebookUsername($facebookUser->username)); // redirect to the homepage/$url header('Location: ' . WT_SCRIPT_PATH . $url); return; } $this->error_page($message); } else { // This is a new Facebook user who may or may not already have a manual account if (!WT_Site::getPreference('USE_REGISTRATION_MODULE')) { $this->error_page('<p>' . WT_I18N::translate('The administrator has disabled registrations.') . '</p>'); } // check if the username is already in use $username = $this->cleanseFacebookUsername($facebookUser->username); $wt_username = substr($username, 0, 32); // Truncate the username to 32 characters to match the DB. if (User::findByIdentifier($wt_username)) { // fallback to email as username since we checked above that a user with the email didn't exist. $wt_username = $facebookUser->email; $wt_username = substr($wt_username, 0, 32); // Truncate the username to 32 characters to match the DB. } // Generate a random password since the user shouldn't need it and can always reset it. $password = md5(uniqid(rand(), TRUE)); $hashcode = md5(uniqid(rand(), true)); $preApproved = unserialize($this->getSetting('preapproved')); // From login.php: Log::addAuthenticationLog('User registration requested for: ' . $wt_username); if ($user = User::create($wt_username, $facebookUser->name, $facebookUser->email, $password)) { $verifiedByAdmin = !$REQUIRE_ADMIN_AUTH_REGISTRATION || isset($preApproved[$username]); $user->setPreference(self::user_setting_facebook_username, $this->cleanseFacebookUsername($facebookUser->username))->setPreference('language', WT_LOCALE)->setPreference('verified', '1')->setPreference('verified_by_admin', $verifiedByAdmin ? '1' : '0')->setPreference('reg_timestamp', date('U'))->setPreference('reg_hashcode', $hashcode)->setPreference('contactmethod', 'messaging2')->setPreference('visibleonline', '1')->setPreference('editaccount', '1')->setPreference('auto_accept', '0')->setPreference('canadmin', '0')->setPreference('sessiontime', $verifiedByAdmin ? WT_TIMESTAMP : '0')->setPreference('comment', @$facebookUser->birthday . "\n " . "https://www.facebook.com/" . $this->cleanseFacebookUsername($facebookUser->username)); // Apply pre-approval settings if (isset($preApproved[$username])) { $userSettings = $preApproved[$username]; foreach ($userSettings as $gedcom => $userGedcomSettings) { foreach (array('gedcomid', 'rootid', 'canedit') as $userPref) { if (empty($userGedcomSettings[$userPref])) { continue; } // Use a direct DB query instead of $tree->setUserPreference since we // can't get a reference to the WT_Tree since it checks permissions but // we are trying to give the permissions. WT_DB::prepare("REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, LEFT(?, 255))")->execute(array($user->getUserId(), $gedcom, $userPref, $userGedcomSettings[$userPref])); } } // Remove the pre-approval record unset($preApproved[$username]); $this->setSetting('preapproved', serialize($preApproved)); } // We need jQuery below global $controller; $controller = new WT_Controller_Page(); $controller->setPageTitle($this->getTitle())->pageHeader(); echo '<form id="verify-form" name="verify-form" method="post" action="', WT_LOGIN_URL, '" class="ui-autocomplete-loading" style="width:16px;height:16px;padding:0">'; echo $this->hidden_input("action", "verify_hash"); echo $this->hidden_input("user_name", $wt_username); echo $this->hidden_input("user_password", $password); echo $this->hidden_input("user_hashcode", $hashcode); echo WT_Filter::getCsrf(); echo '</form>'; if ($verifiedByAdmin) { $controller->addInlineJavaScript(' function verify_hash_success() { // now the account is approved but not logged in. Now actually login for the user. window.location = "' . $this->getConnectURL($url) . '"; } function verify_hash_failure() { alert("' . WT_I18N::translate("There was an error verifying your account. Contact the site administrator if you are unable to access the site.") . '"); window.location = "' . WT_SCRIPT_PATH . '"; } $(document).ready(function() { $.post("' . WT_LOGIN_URL . '", $("#verify-form").serialize(), verify_hash_success).fail(verify_hash_failure); }); '); } else { echo '<script>document.getElementById("verify-form").submit()</script>'; } } else { Log::addErrorLog("Facebook: Couldn't create the user account"); $this->error_page('<p>' . WT_I18N::translate('Unable to create your account. Please try again.') . '</p>' . '<div class="back"><a href="javascript:history.back()">' . WT_I18N::translate('Back') . '</a></div>'); } } }
$form_email = WT_Filter::postEmail('form_email'); $form_rootid = WT_Filter::post('form_rootid', WT_REGEX_XREF); $form_theme = WT_Filter::post('form_theme', implode('|', $ALL_THEME_DIRS)); $form_language = WT_Filter::post('form_language', implode('|', array_keys(WT_I18N::installed_languages())), WT_LOCALE); $form_contact_method = WT_Filter::post('form_contact_method'); $form_visible_online = WT_Filter::postBool('form_visible_online'); // Respond to form action if ($form_action == 'update' && WT_Filter::checkCsrf()) { if ($form_username != Auth::user()->getUserName() && User::findByIdentifier($form_username)) { WT_FlashMessages::addMessage(WT_I18N::translate('Duplicate user name. A user with that user name already exists. Please choose another user name.')); } elseif ($form_email != Auth::user()->getEmail() && User::findByIdentifier($form_email)) { WT_FlashMessages::addMessage(WT_I18N::translate('Duplicate email address. A user with that email already exists.')); } else { // Change username if ($form_username != WT_USER_NAME) { Log::addAuthenticationLog('User ' . Auth::user()->getUserName() . ' renamed to ' . $form_username); Auth::user()->setUserName($form_username); } // Change password if ($form_pass1 && $form_pass1 == $form_pass2) { Auth::user()->setPassword($form_pass1); } // Change other settings Auth::user()->setRealName($form_realname)->setEmail($form_email)->setSetting('theme', $form_theme)->setSetting('language', $form_language)->setSetting('contactmethod', $form_contact_method)->setSetting('visibleonline', $form_visible_online); $WT_TREE->userPreference(WT_USER_ID, 'rootid', $form_rootid); // Reload page to pick up changes such as theme and user_id header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME); exit; } } $controller = new WT_Controller_Page();
WT_DB::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($user_name, $WT_REQUEST->getClientIp(), $webmaster->getUserId(), $mail1_subject, WT_Filter::unescapeHtml($mail1_body))); } $user->setSetting('verified', 1)->setSetting('reg_timestamp', date("U"))->setSetting('reg_hashcode', null); if (!$REQUIRE_ADMIN_AUTH_REGISTRATION) { set_user_setting($user_id, 'verified_by_admin', 1); } Log::addAuthenticationLog('User ' . $user_name . ' verified their email address'); echo '<br><br>' . WT_I18N::translate('You have confirmed your request to become a registered user.') . '<br><br>'; if ($REQUIRE_ADMIN_AUTH_REGISTRATION && !$user->getSetting('verified_by_admin')) { echo WT_I18N::translate('The administrator has been informed. As soon as he gives you permission to login, you can login with your user name and password.'); } else { echo WT_I18N::translate('You can now login with your user name and password.'); } echo '<br><br>'; } else { Log::addAuthenticationLog('User ' . $user_name . ' failed to verify their email address'); echo '<br><br>'; echo '<span class="warning">'; echo WT_I18N::translate('Data was not correct, please try again'); echo '</span><br><br>'; } } else { echo '<br><br>'; echo '<span class="warning">'; echo WT_I18N::translate('Could not verify the information you entered. Please try again or contact the site administrator for more information.'); echo '</span>'; } echo '</div>'; echo '</div>'; break; }
$record->deleteRecord(); } else { header('HTTP/1.0 406 Not Acceptable'); } break; case 'delete-user': $user = User::find(WT_Filter::postInteger('user_id')); if ($user && Auth::isAdmin() && Auth::user() !== $user) { Log::addAuthenticationLog('Deleted user: '******'masquerade': $user = User::find(WT_Filter::postInteger('user_id')); if ($user && Auth::isAdmin() && Auth::user() !== $user) { Log::addAuthenticationLog('Masquerade as user: '******'HTTP/1.0 406 Not Acceptable'); } break; case 'unlink-media': // Remove links from an individual and their spouse-family records to a media object. // Used by the "unlink" option on the album (lightbox) tab. require WT_ROOT . 'includes/functions/functions_edit.php'; $source = WT_Individual::getInstance(WT_Filter::post('source', WT_REGEX_XREF)); $target = WT_Filter::post('target', WT_REGEX_XREF); if ($source && $source->canShow() && $source->canEdit() && $target) { // Consider the individual and their spouse-family records $sources = $source->getSpouseFamilies(); $sources[] = $source;
$fmt_msg .= "{$i} called from "; $log_msg .= "\n{$i} called from "; } if (isset($backtrace[$i]["line"]) && isset($backtrace[$i]["file"])) { $fmt_msg .= "line <b>{$backtrace[$i]['line']}</b> of file <b>" . basename($backtrace[$i]['file']) . "</b>"; $log_msg .= "line {$backtrace[$i]['line']} of file " . basename($backtrace[$i]['file']); } if ($i < $num - 1) { $fmt_msg .= " in function <b>" . $backtrace[$i + 1]['function'] . "</b>"; $log_msg .= " in function " . $backtrace[$i + 1]['function']; } $fmt_msg .= "<br>"; } } echo $fmt_msg; Log::addErrorLog($log_msg); if ($errno == 1) { die; } } return false; }); // Load our configuration file, so we can connect to the database if (file_exists(WT_ROOT . 'data/config.ini.php')) { $dbconfig = parse_ini_file(WT_ROOT . 'data/config.ini.php'); // Invalid/unreadable config file? if (!is_array($dbconfig)) { header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); exit; } // Down for maintenance?
public function userPreference($user_id, $setting_name, $setting_value = null) { // There are lots of settings, and we need to fetch lots of them on every page // so it is quicker to fetch them all in one go. if (!array_key_exists($user_id, $this->user_preference)) { $this->user_preference[$user_id] = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##user_gedcom_setting` WHERE user_id=? AND gedcom_id=?")->execute(array($user_id, $this->tree_id))->fetchAssoc(); } // If $setting_value is null, then GET the setting if ($setting_value === null) { // If parameter two is not specified, GET the setting if (!array_key_exists($setting_name, $this->user_preference[$user_id])) { $this->user_preference[$user_id][$setting_name] = null; } return $this->user_preference[$user_id][$setting_name]; } else { // If parameter two is specified, then SET the setting. if ($this->preference($setting_name) != $setting_value) { // Audit log of changes Log::addConfigurationLog('Gedcom setting "' . $setting_name . '" set to "' . $setting_value . '"'); } WT_DB::prepare("REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, LEFT(?, 255))")->execute(array($user_id, $this->tree_id, $setting_name, $setting_value)); return $this; } }
<?php if ($ucnt > 0) { ?> <input type="submit" value="<?php echo WT_I18N::translate('continue'); ?> "> <?php } ?> </p> </form><?php break; case 'cleanup2': foreach (User::all() as $user) { if (WT_Filter::post('del_' . $user->getUserId()) == '1') { Log::addAuthenticationLog('Deleted user: '******'Deleted user: '******'<br>'; $user->delete(); } } break; case 'listusers': default: echo '<table id="list">', '<thead>', '<tr>', '<th style="margin:0 -2px 1px 1px; padding:6px 0 5px;"> </th>', '<th> user-id </th>', '<th>', WT_I18N::translate('Username'), '</th>', '<th>', WT_I18N::translate('Real name'), '</th>', '<th>', WT_I18N::translate('Email'), '</th>', '<th> </th>', '<th>', WT_I18N::translate('Language'), '</th>', '<th> date_registered </th>', '<th>', WT_I18N::translate('Date registered'), '</th>', '<th> last_login </th>', '<th>', WT_I18N::translate('Last logged in'), '</th>', '<th>', WT_I18N::translate('Verified'), '</th>', '<th>', WT_I18N::translate('Approved'), '</th>', '<th style="margin:0 -2px 1px 1px; padding:3px 0 4px;"> </th>', '</tr>', '</thead>', '<tbody>', '</tbody>', '</table>'; $controller->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addExternalJavascript(WT_JQUERY_JEDITABLE_URL)->addInlineJavascript(' var oTable = jQuery("#list").dataTable({ dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\', ' . WT_I18N::datatablesI18N() . ', processing: true, serverSide: true, ajax: "' . WT_SCRIPT_NAME . '?action=loadrows",
} } } // Insert the 1 FILE xxx record into the arrays used by function handle_updates() $glevels = array_merge(array('1'), $glevels); $tag = array_merge(array('FILE'), $tag); $islink = array_merge(array(0), $islink); $text = array_merge(array($newFilename), $text); $record = WT_GedcomRecord::getInstance($pid); $newrec = "0 @{$pid}@ OBJE\n"; $newrec = handle_updates($newrec); $record->updateRecord($newrec, $update_CHAN); if ($pid && $linktoid) { $record = WT_GedcomRecord::getInstance($linktoid); $record->createFact('1 OBJE @' . $pid . '@', true); Log::addEditLog('Media ID ' . $pid . " successfully added to {$linktoid}."); } $controller->pageHeader(); if ($messages) { echo '<button onclick="closePopupAndReloadParent();">', WT_I18N::translate('close'), '</button>'; } else { $controller->addInlineJavascript('closePopupAndReloadParent();'); } exit; case 'showmediaform': $controller->setPageTitle(WT_I18N::translate('Create a new media object')); $action = 'create'; break; case 'editmedia': $controller->setPageTitle(WT_I18N::translate('Edit media object')); $action = 'update';