]> dev.renevier.net Git - syp.git/commitdiff
fixes: upgrade did not run correctly when gd extension is not present
authorarno <arenevier@fdn.fr>
Sat, 8 Aug 2009 12:04:07 +0000 (14:04 +0200)
committerarno <arenevier@fdn.fr>
Sat, 8 Aug 2009 12:13:37 +0000 (14:13 +0200)
api.php
inc/templates_upgrade.php
inc/utils.php

diff --git a/api.php b/api.php
index 052b5145a47e5aef5701b72648896a3c08367369..2054350084a29108e54982d3de468354805b33da 100644 (file)
--- a/api.php
+++ b/api.php
@@ -100,17 +100,9 @@ function save_uploaded_file ($file, $con) {
         }
         $mini_dest = getthumbsdir () . "/mini_" . basename_safe ($dest);
 
-        try {
-            $thumbnail_ok = create_thumbnail ($dest, $mini_dest);
-        } catch (Exception $e) {
-            $thumbnail_ok = false;
-        }
-        if (!$thumbnail_ok) {
-            if (!copy ($dest, $mini_dest)) {
-                server_error ();
-            }
+        if (!create_thumbnail_or_copy ($dest, $mini_dest)) {
+            server_error ();
         }
-
     }
     return basename_safe ($dest);
 }
index 1a69b68584b159af5e4a15d13fdf9aa49a3e3bea..a636145e67bec5eec6c86ac604ae8348b6153034 100644 (file)
                 $thumbfilename = getthumbsdir () .  "/mini_" . $feature->imgpath;
                 if ((file_exists ($imgfilename)) && 
                     (!(file_exists ($thumbfilename)))) {
-                    try {
-                        create_thumbnail ($imgfilename, $thumbfilename);
-                    } catch (Exception $e) {
-                        return false;
-                    }
+                        create_thumbnail_or_copy ($imgfilename, $thumbfilename);
                 }
             }
         }
index 12c85c673dfd321a9b1d1a955103aa93f5895d2c..a55e8794296c3ce6c90c4cc22e649b3a8077fb60 100644 (file)
@@ -101,7 +101,25 @@ function full_url_from_path ($path) {
     return "$proto://$host$port$path";
 }
 
+function create_thumbnail_or_copy ($filename, $destfile) { 
+    try {   
+        $thumbnail_ok = create_thumbnail ($filename, $destfile);
+    } catch (Exception $e) {
+        $thumbnail_ok = false;
+    }
+    if (!$thumbnail_ok) {
+        if (!copy ($filename, $destfile)) {
+            return false; 
+        }
+    }   
+    return true;
+}
+
 function create_thumbnail ($filename, $destfile) {
+    if (!function_exists ("imagecreatefromjpeg")
+        || !function_exists ("imagecreatefrompng")) {
+        return false;
+    }
     $ext = strtolower (ext_safe ($filename));
     if ($ext == "jpg" || $ext == "jpeg") {
         $image = imagecreatefromjpeg ($filename);