]> git.mjollnir.org Git - s9y.git/commitdiff
Fixed bug which broke thumbnail generation with Imagemagick when safe-mode was ON
authortomsommer <tomsommer>
Tue, 27 Dec 2005 12:13:48 +0000 (12:13 +0000)
committertomsommer <tomsommer>
Tue, 27 Dec 2005 12:13:48 +0000 (12:13 +0000)
docs/NEWS
include/functions_images.inc.php

index be07d953fa5a589b0c71904b6ce54f5416292b33..e95646b361ae4a2e56c59f8e350298ae7f91c9f0 100644 (file)
--- 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)
 
index 845c1f254885d84704b9f008c29c203f7f59e9c8..953420a39ed316bcef43cd3d34979f35dab215dd 100644 (file)
@@ -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 . '<br />', $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 .= '/';