From: tomsommer Date: Tue, 27 Dec 2005 12:13:48 +0000 (+0000) Subject: Fixed bug which broke thumbnail generation with Imagemagick when safe-mode was ON X-Git-Tag: 1.0~207 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=862fb5a9a1151fed67001942ca6a2345a10e6cb5;p=s9y.git Fixed bug which broke thumbnail generation with Imagemagick when safe-mode was ON --- diff --git a/docs/NEWS b/docs/NEWS index be07d95..e95646b 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.0 () ------------------------------------------------------------------------ + * Fixed bug which broke thumbnail generation with Imagemagick when + safe-mode was ON (tomsommer) + * New Smarty template preview_iframe.tpl for creating the entry's preview in the backend panel (garvinhicking) diff --git a/include/functions_images.inc.php b/include/functions_images.inc.php index 845c1f2..953420a 100644 --- a/include/functions_images.inc.php +++ b/include/functions_images.inc.php @@ -59,7 +59,7 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order $directorysql .= " AND name like '%" . serendipity_db_escape_string($filename) . "%'"; } } - + $perm = $permsql = ''; if (isset($serendipity['authorid']) && !serendipity_checkPermission('adminImagesViewOthers')) { $perm = " (i.authorid = 0 OR i.authorid = " . (int)$serendipity['authorid'] . ")"; @@ -68,8 +68,8 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order } else { $directorysql .= " AND $perm"; } - $permsql = " WHERE $perm"; - } + $permsql = " WHERE $perm"; + } $query = "SELECT i.*, a.realname AS authorname FROM {$serendipity['dbPrefix']}images AS i LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a ON i.authorid = a.authorid $directorysql ORDER BY $order $ordermode $limitsql"; $rs = serendipity_db_query($query, false, 'assoc'); @@ -165,7 +165,7 @@ function serendipity_deleteImage($id) { foreach($dThumb as $thumb) { $dfnThumb = $file['path'] . $file['name'] . (!empty($dThumb['fthumb']) ? '.' . $dThumb['fthumb'] : '') . '.' . $file['extension']; $dfThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dfnThumb; - + if (@unlink($dfThumb)) { printf(DELETE_THUMBNAIL . '
', $dfnThumb); } @@ -400,7 +400,7 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb if ($size === false) { $size = $serendipity['thumbSize']; } - + if ($thumbname === false) { $thumbname = $serendipity['thumbSuffix']; } @@ -423,10 +423,12 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb $r = array($size, $size); $newSize = $size . 'x' . $size; if ($fdim['mime'] == 'application/pdf') { - $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile . '.png'); + $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -flatten -scale '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile . '.png'); } else { - $newSize .= '>'; // Tell imagemagick to not enlarge small images - $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -resize '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile); + if ( serendipity_ini_bool(ini_get('safe_mode')) === false ) { + $newSize .= '>'; // Tell imagemagick to not enlarge small images, only works if safe_mode is off (safe_mode turns > in to \>) + } + $cmd = escapeshellcmd($serendipity['convert']) . ' -antialias -resize '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile); } exec($cmd, $output, $result); if ( $result != 0 ) { @@ -1487,7 +1489,7 @@ function serendipity_uploadSecure($var, $strip_paths = true, $append_slash = fal } $var = preg_replace('@^(/+)@', '', $var); - + if ($append_slash) { if (!empty($var) && substr($var, -1, 1) != '/') { $var .= '/';