plugins/gallery/fetcher.php
changeset 26 023a21c8f47c
parent 25 d9f37d2ea2cf
child 27 3d8ec1f7d191
--- a/plugins/gallery/fetcher.php	Sat Feb 23 16:02:15 2008 -0500
+++ b/plugins/gallery/fetcher.php	Thu May 15 21:09:04 2008 -0400
@@ -34,7 +34,7 @@
   // sleep(5);
   
   $type = $paths->getParam(0);
-  if ( !in_array($type, array('thumb', 'preview', 'full')) )
+  if ( !in_array($type, array('thumb', 'preview', 'full', 'embed')) )
   {
     die('Hack attempt');
   }
@@ -87,6 +87,32 @@
         default: $mimetype = 'application/octet-stream';
       }
       break;
+    case 'embed':
+      if ( !isset($_GET['width']) || !isset($_GET['height']) )
+      {
+        die('Missing width or height.');
+      }
+      $src_filename  = ENANO_ROOT . '/files/' . $row['img_filename'];
+      $dest_filename = ENANO_ROOT . '/cache/' . $row['img_filename'] . "-embed-$width-$height.$ext";
+      $filename =& $dest_filename;
+      $ext = get_file_extension($filename);
+      
+      $width = intval($_GET['width']);
+      $height = intval($_GET['height']);
+      if ( empty($width) || empty($height) || $width > 2048 || $height > 2048 )
+      {
+        die('Bad width or height');
+      }
+      
+      if ( !file_exists($dest_filename) )
+      {
+        if ( !scale_image($src_filename, $dest_filename, $width, $height, false) )
+        {
+          die('Image scaling process failed.');
+        }
+      }
+      
+      break;
     default:
       die('PHP...insane...');
       break;