예제 #1
0
 /**
  * Manage updates sent from the AdminConfig@index form.
  */
 protected function update()
 {
     if (Auth::isAdmin()) {
         $this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
         $this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
         if ($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
             $this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
         }
         if ($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
             $this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
         }
         // Only accept valid color for MAJ_WM_FONT_COLOR
         $MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');
         if ($MAJ_WM_FONT_COLOR) {
             $this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
         }
         // Only accept valid folders for MAJ_CERT_ROOTDIR
         $MAJ_CERT_ROOTDIR = preg_replace('/[\\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
         if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
             $MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
         }
         if ($MAJ_CERT_ROOTDIR) {
             if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
                 $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
             } elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
                 $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
                 FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
             } else {
                 FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
             }
         }
         FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
         return;
     }
 }
$action = Filter::get('action', 'download');
$convert = Filter::get('convert', 'yes|no', 'no');
$zip = Filter::get('zip', 'yes|no', 'no');
$conv_path = Filter::get('conv_path');
$privatize_export = Filter::get('privatize_export', 'none|visitor|user|gedadmin');
if ($action === 'download') {
    $exportOptions = array('privatize' => $privatize_export, 'toANSI' => $convert, 'path' => $conv_path);
    // What to call the downloaded file
    $download_filename = $WT_TREE->getName();
    if (strtolower(substr($download_filename, -4, 4)) != '.ged') {
        $download_filename .= '.ged';
    }
    if ($zip === 'yes') {
        $temp_dir = WT_DATA_DIR . 'tmp-' . $WT_TREE->getName() . '-' . date('YmdHis') . '/';
        $zip_file = $download_filename . '.zip';
        if (!File::mkdir($temp_dir)) {
            echo "Error : Could not create temporary path!";
            return;
        }
        // Create the unzipped GEDCOM on disk, so we can ZIP it.
        $stream = fopen($temp_dir . $download_filename, "w");
        FunctionsExport::exportGedcom($WT_TREE, $stream, $exportOptions);
        fclose($stream);
        // Create a ZIP file containing the GEDCOM file.
        $comment = "Created by " . WT_WEBTREES . " " . WT_VERSION . " on " . date("r") . ".";
        $archive = new PclZip($temp_dir . $zip_file);
        $v_list = $archive->add($temp_dir . $download_filename, \PCLZIP_OPT_COMMENT, $comment, \PCLZIP_OPT_REMOVE_PATH, $temp_dir);
        if ($v_list == 0) {
            echo "Error : " . $archive->errorInfo(true);
        } else {
            header('Content-Type: application/zip');
예제 #3
0
 public function pageData()
 {
     $path = WT_DATA_DIR . '/ftv_cache/';
     if (!file_exists($path)) {
         File::mkdir($path);
     }
     $filename = $path . 'fancy-treeview-tmp.txt';
     $content = Filter::post('pdfContent');
     // make our datafile if it does not exist.
     if (!file_exists($filename)) {
         $handle = fopen($filename, 'w');
         fclose($handle);
         chmod($filename, 0644);
     }
     // Let's make sure the file exists and is writable first.
     if (is_writable($filename)) {
         if (!($handle = @fopen($filename, 'w'))) {
             exit;
         }
         // Write the pdfContent to our data.txt file.
         if (fwrite($handle, $content) === FALSE) {
             exit;
         }
         fclose($handle);
     }
 }
예제 #4
0
파일: Media.php 프로젝트: jflash/webtrees
 /**
  * Get the filename on the server - for those (very few!) functions which actually
  * need the filename, such as mediafirewall.php and the PDF reports.
  *
  * @param string $which
  *
  * @return string
  */
 public function getServerFilename($which = 'main')
 {
     $MEDIA_DIRECTORY = $this->tree->getPreference('MEDIA_DIRECTORY');
     $THUMBNAIL_WIDTH = $this->tree->getPreference('THUMBNAIL_WIDTH');
     if ($this->isExternal() || !$this->file) {
         // External image, or (in the case of corrupt GEDCOM data) no image at all
         return $this->file;
     } elseif ($which == 'main') {
         // Main image
         return WT_DATA_DIR . $MEDIA_DIRECTORY . $this->file;
     } else {
         // Thumbnail
         $file = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $this->file;
         // Does the thumbnail exist?
         if (file_exists($file)) {
             return $file;
         }
         // Does a user-generated thumbnail exist?
         $user_thumb = preg_replace('/\\.[a-z0-9]{3,5}$/i', '.png', $file);
         if (file_exists($user_thumb)) {
             return $user_thumb;
         }
         // Does the folder exist for this thumbnail?
         if (!is_dir(dirname($file)) && !File::mkdir(dirname($file))) {
             Log::addMediaLog('The folder ' . dirname($file) . ' could not be created for ' . $this->getXref());
             return $file;
         }
         // Is there a corresponding main image?
         $main_file = WT_DATA_DIR . $MEDIA_DIRECTORY . $this->file;
         if (!file_exists($main_file)) {
             Log::addMediaLog('The file ' . $main_file . ' does not exist for ' . $this->getXref());
             return $file;
         }
         // Try to create a thumbnail automatically
         try {
             $imgsize = getimagesize($main_file);
             // Image small enough to be its own thumbnail?
             if ($imgsize[0] > 0 && $imgsize[0] <= $THUMBNAIL_WIDTH) {
                 try {
                     copy($main_file, $file);
                     Log::addMediaLog('Thumbnail created for ' . $main_file . ' (copy of main image)');
                 } catch (\ErrorException $ex) {
                     Log::addMediaLog('Thumbnail could not be created for ' . $main_file . ' (copy of main image)');
                 }
             } else {
                 if (FunctionsMedia::hasMemoryForImage($main_file)) {
                     try {
                         switch ($imgsize['mime']) {
                             case 'image/png':
                                 $main_image = imagecreatefrompng($main_file);
                                 break;
                             case 'image/gif':
                                 $main_image = imagecreatefromgif($main_file);
                                 break;
                             case 'image/jpeg':
                                 $main_image = imagecreatefromjpeg($main_file);
                                 break;
                             default:
                                 return $file;
                                 // Nothing else we can do :-(
                         }
                         if ($main_image) {
                             // How big should the thumbnail be?
                             $width = $THUMBNAIL_WIDTH;
                             $height = round($imgsize[1] * ($width / $imgsize[0]));
                             $thumb_image = imagecreatetruecolor($width, $height);
                             // Create a transparent background, instead of the default black one
                             imagesavealpha($thumb_image, true);
                             imagefill($thumb_image, 0, 0, imagecolorallocatealpha($thumb_image, 0, 0, 0, 127));
                             // Shrink the image
                             imagecopyresampled($thumb_image, $main_image, 0, 0, 0, 0, $width, $height, $imgsize[0], $imgsize[1]);
                             switch ($imgsize['mime']) {
                                 case 'image/png':
                                     imagepng($thumb_image, $file);
                                     break;
                                 case 'image/gif':
                                     imagegif($thumb_image, $file);
                                     break;
                                 case 'image/jpeg':
                                     imagejpeg($thumb_image, $file);
                                     break;
                             }
                             imagedestroy($main_image);
                             imagedestroy($thumb_image);
                             Log::addMediaLog('Thumbnail created for ' . $main_file);
                         }
                     } catch (\ErrorException $ex) {
                         Log::addMediaLog('Failed to create thumbnail for ' . $main_file);
                     }
                 } else {
                     Log::addMediaLog('Not enough memory to create thumbnail for ' . $main_file);
                 }
             }
         } catch (\ErrorException $ex) {
             // Not an image, or not a valid image?
         }
         return $file;
     }
 }
예제 #5
0
namespace Fisharebest\Webtrees;

use Fisharebest\Webtrees\Controller\PageController;
use Fisharebest\Webtrees\Functions\FunctionsEdit;
define('WT_SCRIPT_NAME', 'admin_site_config.php');
require './includes/session.php';
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin());
switch (Filter::post('action')) {
    case 'site':
        if (Filter::checkCsrf()) {
            $INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
            if (substr($INDEX_DIRECTORY, -1) !== '/') {
                $INDEX_DIRECTORY .= '/';
            }
            if (File::mkdir($INDEX_DIRECTORY)) {
                Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
            } else {
                FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
            }
            Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
            Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
            Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
            Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
            Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
            Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
            Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
            Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
예제 #6
0
 /**
  * Check if thumbnails from cache should be recreated
  * 
  * @param type $mediaobject
  * @return string filename
  */
 private function getThumbnail(Media $mediaobject)
 {
     $cache_dir = $this->cacheDir();
     if (!file_exists($cache_dir)) {
         File::mkdir($cache_dir);
     }
     if (file_exists($mediaobject->getServerFilename())) {
         $cache_filename = $this->cacheFileName($mediaobject);
         if (!is_file($cache_filename)) {
             $thumbnail = $this->fancyThumb($mediaobject);
             $mimetype = $mediaobject->mimeType();
             if ($mimetype === 'image/jpeg') {
                 imagejpeg($thumbnail, $cache_filename);
             } elseif ($mimetype === 'image/png') {
                 imagepng($thumbnail, $cache_filename);
             } else {
                 return;
             }
         }
         return $cache_filename;
     }
 }
예제 #7
0
 if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
     if (Auth::isManager($WT_TREE)) {
         if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
             FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)));
         } else {
             FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)), 'danger');
             break;
         }
     } else {
         // Regular users should not have seen this option - so no need for an error message.
         break;
     }
 }
 // The media folder exists. Now create a thumbnail folder to match it.
 if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
     if (!File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
         FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)), 'danger');
         break;
     }
 }
 // Validate the media path and filename
 if (preg_match('/^https?:\\/\\//i', $filename, $match)) {
     // External media needs no further validation
     $fileName = $filename;
     $folderName = '';
     unset($_FILES['mediafile'], $_FILES['thumbnail']);
 } elseif (preg_match('/([\\/\\\\<>])/', $filename, $match)) {
     // Local media files cannot contain certain special characters
     FlashMessages::addMessage(I18N::translate('Filenames are not allowed to contain the character “%s”.', $match[1]));
     break;
 } elseif (preg_match('/(\\.(php|pl|cgi|bash|sh|bat|exe|com|htm|html|shtml))$/i', $filename, $match)) {
예제 #8
0
 $WT_TREE->setPreference('THEME_DIR', Filter::post('THEME_DIR'));
 $WT_TREE->setPreference('THUMBNAIL_WIDTH', Filter::post('THUMBNAIL_WIDTH'));
 $WT_TREE->setPreference('USE_SILHOUETTE', Filter::postBool('USE_SILHOUETTE'));
 $WT_TREE->setPreference('WATERMARK_THUMB', Filter::postBool('WATERMARK_THUMB'));
 $WT_TREE->setPreference('WEBMASTER_USER_ID', Filter::post('WEBMASTER_USER_ID'));
 $WT_TREE->setPreference('WEBTREES_EMAIL', Filter::post('WEBTREES_EMAIL'));
 $WT_TREE->setPreference('title', Filter::post('title'));
 // Only accept valid folders for MEDIA_DIRECTORY
 $MEDIA_DIRECTORY = preg_replace('/[\\/\\\\]+/', '/', Filter::post('MEDIA_DIRECTORY') . '/');
 if (substr($MEDIA_DIRECTORY, 0, 1) === '/') {
     $MEDIA_DIRECTORY = substr($MEDIA_DIRECTORY, 1);
 }
 if ($MEDIA_DIRECTORY) {
     if (is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
         $WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
     } elseif (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
         $WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
         FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'info');
     } else {
         FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
     }
 }
 $gedcom = Filter::post('gedcom');
 if ($gedcom && $gedcom !== $WT_TREE->getName()) {
     try {
         Database::prepare("UPDATE `##gedcom` SET gedcom_name = ? WHERE gedcom_id = ?")->execute(array($gedcom, $WT_TREE->getTreeId()));
         Database::prepare("UPDATE `##site_setting` SET setting_value = ? WHERE setting_name='DEFAULT_GEDCOM' AND setting_value = ?")->execute(array($gedcom, $WT_TREE->getName()));
     } catch (\Exception $ex) {
         // Probably a duplicate name.
     }
 }
예제 #9
0
파일: I18N.php 프로젝트: bxbroze/webtrees
 /**
  * Initialise the translation adapter with a locale setting.
  *
  * @param string|null $code Use this locale/language code, or choose one automatically
  *
  * @return string $string
  */
 public static function init($code = null)
 {
     global $WT_TREE;
     mb_internal_encoding('UTF-8');
     if ($code !== null) {
         // Create the specified locale
         self::$locale = Locale::create($code);
     } else {
         // Negotiate a locale, but if we can't then use a failsafe
         self::$locale = new LocaleEnUs();
         if (Session::has('locale')) {
             // Previously used
             self::$locale = Locale::create(Session::get('locale'));
         } else {
             // Browser negotiation
             $default_locale = new LocaleEnUs();
             try {
                 if ($WT_TREE) {
                     $default_locale = Locale::create($WT_TREE->getPreference('LANGUAGE'));
                 }
             } catch (\Exception $ex) {
             }
             self::$locale = Locale::httpAcceptLanguage($_SERVER, self::installedLocales(), $default_locale);
         }
     }
     $cache_dir_exists = File::mkdir(WT_DATA_DIR . 'cache');
     $cache_file = WT_DATA_DIR . 'cache/language-' . self::$locale->languageTag() . '-cache.php';
     if (file_exists($cache_file)) {
         $filemtime = filemtime($cache_file);
     } else {
         $filemtime = 0;
     }
     // Load the translation file(s)
     // Note that glob() returns false instead of an empty array when open_basedir_restriction
     // is in force and no files are found.  See PHP bug #47358.
     if (defined('GLOB_BRACE')) {
         $translation_files = array_merge(array(WT_ROOT . 'language/' . self::$locale->languageTag() . '.mo'), glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.{csv,php,mo}', GLOB_BRACE) ?: array(), glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.{csv,php,mo}', GLOB_BRACE) ?: array());
     } else {
         // Some servers do not have GLOB_BRACE - see http://php.net/manual/en/function.glob.php
         $translation_files = array_merge(array(WT_ROOT . 'language/' . self::$locale->languageTag() . '.mo'), glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.csv') ?: array(), glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.php') ?: array(), glob(WT_MODULES_DIR . '*/language/' . self::$locale->languageTag() . '.mo') ?: array(), glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.csv') ?: array(), glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.php') ?: array(), glob(WT_DATA_DIR . 'language/' . self::$locale->languageTag() . '.mo') ?: array());
     }
     // Rebuild files after one hour
     $rebuild_cache = time() > $filemtime + 3600;
     // Rebuild files if any translation file has been updated
     foreach ($translation_files as $translation_file) {
         if (filemtime($translation_file) > $filemtime) {
             $rebuild_cache = true;
             break;
         }
     }
     if ($rebuild_cache) {
         $translations = array();
         foreach ($translation_files as $translation_file) {
             $translation = new Translation($translation_file);
             $translations = array_merge($translations, $translation->asArray());
         }
         if ($cache_dir_exists) {
             // During setup, we may not have been able to create it.
             file_put_contents($cache_file, '<' . '?php return ' . var_export($translations, true) . ';');
         }
     } else {
         $translations = (include $cache_file);
     }
     // Create a translator
     self::$translator = new Translator($translations, self::$locale->pluralRule());
     // Alphabetic sorting sequence (upper-case letters), used by webtrees to sort strings
     list(, self::$alphabet_upper) = explode('=', self::$translator->translate('ALPHABET_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ'));
     // Alphabetic sorting sequence (lower-case letters), used by webtrees to sort strings
     list(, self::$alphabet_lower) = explode('=', self::$translator->translate('ALPHABET_lower=abcdefghijklmnopqrstuvwxyz'));
     self::$list_separator = self::translate(', ');
     return self::$locale->languageTag();
 }
예제 #10
0
    echo $icon_success;
} else {
    echo $icon_failure;
    // Guess why we might have failed...
    if (preg_match('/^https:/', $download_url) && !in_array('ssl', stream_get_transports())) {
        echo '<br>', I18N::translate('This server does not support secure downloads using HTTPS.');
    }
}
echo '</li>';
////////////////////////////////////////////////////////////////////////////////
// Unzip the file - this checks we have enough free disk space, that the .zip
// file is valid, etc.
////////////////////////////////////////////////////////////////////////////////
echo '<li>', I18N::translate('Unzip %s to a temporary folder…', Html::filename(basename($download_url)));
File::delete($zip_dir);
File::mkdir($zip_dir);
$archive = new PclZip($zip_file);
$res = $archive->properties();
if (!is_array($res) || $res['status'] != 'ok') {
    echo '<br>', I18N::translate('An error occurred when unzipping the file.'), $icon_failure;
    echo '<br>', $archive->errorInfo(true);
    echo '</li></ul></form>';
    return;
}
$num_files = $res['nb'];
reset_timeout();
$start_time = microtime(true);
$res = $archive->extract(\PCLZIP_OPT_PATH, $zip_dir, \PCLZIP_OPT_REMOVE_PATH, 'webtrees', \PCLZIP_OPT_REPLACE_NEWER);
$end_time = microtime(true);
if (is_array($res)) {
    foreach ($res as $result) {
예제 #11
0
 /**
  * Check if thumbnails from cache should be recreated
  *
  * @param type $mediaobject
  * @return string filename
  */
 private function getThumbnail(Media $mediaobject)
 {
     $cache_dir = $this->cacheDir();
     if (!file_exists($cache_dir)) {
         File::mkdir($cache_dir);
     }
     if (file_exists($mediaobject->getServerFilename())) {
         $cache_filename = $this->cacheFileName($mediaobject);
         if (!is_file($cache_filename)) {
             if ($this->options('resize_thumbs')) {
                 $thumbnail = $this->fancyThumb($mediaobject);
                 $mimetype = $mediaobject->mimeType();
                 if ($mimetype === 'image/jpeg') {
                     imagejpeg($thumbnail, $cache_filename);
                 } elseif ($mimetype === 'image/png') {
                     imagepng($thumbnail, $cache_filename);
                 } else {
                     return;
                 }
             } else {
                 // if we are using the original webtrees thumbnails, copy them to the ftv_cache folder
                 // so we can cache them either and output them in the same way we would output the fancy thumbnail.
                 try {
                     copy($mediaobject->getServerFilename('thumb'), $cache_filename);
                 } catch (Exception $ex) {
                     // something went wrong while copying the default webtrees image to the ftv cache folder
                     // there is a fallback in the function printThumbnail(): output $mediaobject->displayImage();
                 }
             }
         }
         return $cache_filename;
     }
 }
예제 #12
0
    }
}
// send headers for the image
header('Content-Type: ' . $mimetype);
header('Content-Disposition: filename="' . addslashes(basename($media->getFilename())) . '"');
if ($generatewatermark) {
    // generate the watermarked image
    $imCreateFunc = 'imagecreatefrom' . $type;
    $imSendFunc = 'image' . $type;
    if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
        $im = $imCreateFunc($serverFilename);
        $im = applyWatermark($im, $WT_TREE);
        // save the image, if preferences allow
        if ($which === 'thumb' && $WT_TREE->getPreference('SAVE_WATERMARK_THUMB') || $which === 'main' && $WT_TREE->getPreference('SAVE_WATERMARK_IMAGE')) {
            // make sure the folder exists
            File::mkdir(dirname($watermarkfile));
            // save the image
            $imSendFunc($im, $watermarkfile);
        }
        // send the image
        $imSendFunc($im);
        imagedestroy($im);
        return;
    } else {
        // this image is defective. log it
        Log::addMediaLog('Media Firewall error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage());
        // set usewatermark to false so image will simply be passed through below
        $usewatermark = false;
    }
}
// pass the image through without manipulating it
예제 #13
0
 /** {@inheritdoc} */
 public function modAction($mod_action)
 {
     switch ($mod_action) {
         case 'admin_config':
             if (Filter::postBool('save') && Filter::checkCsrf()) {
                 $this->setSetting('FTV_PDF_ACCESS_LEVEL', Filter::postInteger('NEW_FTV_PDF_ACCESS_LEVEL'));
                 Log::addConfigurationLog($this->getTitle() . ' config updated');
             }
             $template = new AdminTemplate();
             return $template->pageContent();
         case 'full_pdf':
             echo $this->module()->printPage(0);
             break;
         case 'write_pdf':
             $tmp_dir = WT_DATA_DIR . 'ftv_pdf_tmp/';
             if (file_exists($tmp_dir)) {
                 File::delete($tmp_dir);
             }
             File::mkdir($tmp_dir);
             $template = new PdfTemplate();
             return $template->pageBody();
         case 'output_pdf':
             $file = WT_DATA_DIR . 'ftv_pdf_tmp/' . Filter::get('title') . '.pdf';
             if (file_exists($file)) {
                 ob_start();
                 header('Content-Description: File Transfer');
                 header('Content-Type: application/pdf');
                 header('Content-Disposition: attachment; filename="' . basename($file) . '"');
                 header('Content-Transfer-Encoding: binary');
                 header('Expires: 0');
                 header('Cache-Control: must-revalidate');
                 header('Pragma: public');
                 ob_clean();
                 ob_end_flush();
                 readfile($file);
                 File::delete(dirname($file));
             } else {
                 FlashMessages::addMessage(I18N::translate('The file %s could not be created.', basename($file)), 'danger');
                 Header('Location:' . WT_BASE_URL . 'module.php?mod=fancy_treeview&mod_action=page&rootid=' . Filter::get('rootid') . '&ged=' . Filter::get('ged'));
             }
             break;
         default:
             http_response_code(404);
             break;
     }
 }