DataObjects/pman.links.ini
[Pman.Core] / Images.php
index 690f5f1..fcae94e 100644 (file)
@@ -144,6 +144,10 @@ class Pman_Core_Images extends Pman
     
     function post()
     {
+        
+        if (!$this->authUser) {
+            $this->jerr("image conversion only allowed by registered users");
+        }
         // converts a posted string (eg.svg)
         // into another type..
         if (empty($_REQUEST['as'])) {
@@ -170,8 +174,16 @@ class Pman_Core_Images extends Pman
         require_once 'File/Convert.php';
         $cv = new File_Convert($tmp, $this->mimetype);
         
-        $cv->convert($this->as_mimetype);
-        $cv->serve();
+        $fn = $cv->convert(
+                $this->as_mimetype ,
+                empty($_REQUEST['width']) ? 0 : $_REQUEST['width'],
+                empty($_REQUEST['height']) ? 0 : $_REQUEST['height']
+        );
+        if (!empty($_REQUEST['as_data'])) {
+            $this->jok(base64_encode(file_get_contents($fn)));
+        }
+        
+        $cv->serve('attachment');
         exit;
         
         
@@ -201,7 +213,14 @@ class Pman_Core_Images extends Pman
         }
         //echo "SKALING?  $this->size";
         // acutally if we generated the image, then we do not need to validate the size..
-        $this->validateSize();
+        
+        // if the mimetype is not converted..
+        // then the filename should be original.{size}.jpeg
+        $fn = $img->getStoreName() . '.'. $this->size . '.jpeg'; // thumbs are currenly all jpeg.!???
+      // var_dump($fn);
+        if (!file_exists($fn)) {
+            $this->validateSize();
+        }
         
         $x->convert( $this->as_mimetype, $this->size);
         $x->serve();