Only in minigal/: cache
diff -u MiniGal Nano 0.3.5//config_default.php minigal//config_default.php
--- MiniGal Nano 0.3.5//config_default.php	2010-11-28 23:36:00.000000000 +0100
+++ minigal//config_default.php	2011-04-15 22:33:41.214881000 +0200
@@ -37,7 +37,7 @@
 $label_loading 			= "Loading..."; //Thumbnail loading text
 
 //ADVANCED SETTINGS
+$img_size			= 1024; // Image size
 $thumb_size 			= 120; //Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly! 
 $label_max_length 		= 30; //Maximum chars of a folder name that will be displayed on the folder thumbnail  
 $display_exif			= 0;
-?>
\ No newline at end of file
diff -u MiniGal Nano 0.3.5//createthumb.php minigal//createthumb.php
--- MiniGal Nano 0.3.5//createthumb.php	2010-12-06 10:45:00.000000000 +0100
+++ minigal//createthumb.php	2011-04-15 22:25:49.694881003 +0200
@@ -22,8 +22,16 @@
 //	error_reporting(E_ALL);
 
 if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) header('Content-type: image/jpeg');
-if (preg_match("/.gif$/i", $_GET['filename'])) header('Content-type: image/gif');
-if (preg_match("/.png$/i", $_GET['filename'])) header('Content-type: image/png');
+elseif (preg_match("/.gif$/i", $_GET['filename'])) header('Content-type: image/gif');
+elseif (preg_match("/.png$/i", $_GET['filename'])) header('Content-type: image/png');
+else die("Not supported image type");
+
+// Cache for 14 days
+$expires = 60*60*24*14;
+header("Pragma: public");
+header("Cache-Control: maxage=".$expires);
+header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
+$_GET['filename'] = str_replace("/..", "", $_GET['filename']);
 
 	// Display error image if file isn't found
 	if (!is_file($_GET['filename'])) {
@@ -31,62 +39,104 @@
 		$errorimage = ImageCreateFromJPEG('images/questionmark.jpg');
 		ImageJPEG($errorimage,null,90);
 	}
-	
+
+	$nocrop = "";
+	if (isset($_GET['nocrop']))
+		$nocrop = "-nocrop";
+
+	$cachefile = "cache/" . (int)$_GET['size'] . "$nocrop/" . $_GET['filename'];
+	if (is_file($cachefile)) {
+		echo file_get_contents($cachefile);
+		exit();
+	}
+	elseif(is_writeable("cache/")) {
+		$outfile = $cachefile;
+
+		$old = umask(0);
+		mkdir(dirname($cachefile), 0777, true);
+		umask($old);
+	}
+	else
+		$outfile = null;
+
+
 	// Display error image if file exists, but can't be opened
 	if (substr(decoct(fileperms($_GET['filename'])), -1, strlen(fileperms($_GET['filename']))) < 4 OR substr(decoct(fileperms($_GET['filename'])), -3,1) < 4) {
 		header('Content-type: image/jpeg');
 		$errorimage = ImageCreateFromJPEG('images/cannotopen.jpg');
 		ImageJPEG($errorimage,null,90);
 	}
-	
+
+
 	// Define variables
 	$target = "";
 	$xoord = 0;
 	$yoord = 0;
 
-    if ($_GET['size'] == "") $_GET['size'] = 120; //
-       $imgsize = GetImageSize($_GET['filename']);
-       $width = $imgsize[0];
-       $height = $imgsize[1];
-      if ($width > $height) { // If the width is greater than the height it’s a horizontal picture
-        $xoord = ceil(($width-$height)/2);
-        $width = $height;      // Then we read a square frame that  equals the width
-      } else {
-        $yoord = ceil(($height-$width)/2);
-        $height = $width;
-      }
+	if ($_GET['size'] == "")
+		$_GET['size'] = 120; //
 
-    // Rotate JPG pictures
-    if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
+	$imgsize = GetImageSize($_GET['filename']);
+	$width = $imgsize[0];
+	$height = $imgsize[1];
+
+	if (isset($_GET['nocrop'])) {
+		$size_w = $_GET['size'];
+		$size_h = (($_GET['size']/$width)*$height);
+	}
+	else {
+		$size_w = $size_h = $_GET['size'];
+		if ($width > $height) { // If the width is greater than the height it’s a horizontal picture
+			$xoord = ceil(($width-$height)/2);
+			$width = $height;      // Then we read a square frame that  equals the width
+		} else {
+			$yoord = ceil(($height-$width)/2);
+			$height = $width;
+		}
+	}
+
+	$target = ImageCreatetruecolor($size_w, $size_h);
+	if (preg_match("/.jpg$/i", $_GET['filename'])) $source = ImageCreateFromJPEG($_GET['filename']);
+	if (preg_match("/.gif$/i", $_GET['filename'])) $source = ImageCreateFromGIF($_GET['filename']);
+	if (preg_match("/.png$/i", $_GET['filename'])) $source = ImageCreateFromPNG($_GET['filename']);
+	imagecopyresampled($target,$source,0,0,$xoord,$yoord,$size_w,$size_h,$width,$height);
+	imagedestroy($source);
+
+	// Rotate JPG pictures
+	if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
 		if (function_exists('exif_read_data') && function_exists('imagerotate')) {
 			$exif = exif_read_data($_GET['filename']);
 			$ort = $exif['IFD0']['Orientation'];
+
+			if(!is_int($ort) || $ort < 1)
+				$ort = $exif['Orientation'];
+
 			$degrees = 0;
-		    switch($ort)
-		    {
-		        case 6: // 90 rotate right
-		            $degrees = 270;
-		        break;
-		        case 8:    // 90 rotate left
-		            $degrees = 90;
-		        break;
-		    }
-			if ($degrees != 0)	$target = imagerotate($target, $degrees, 0);
+			switch($ort)
+			{
+			case 3: // rotate around
+				$degrees = 180;
+				break;
+			case 6: // 90 rotate right
+				$degrees = 270;
+				break;
+			case 8:    // 90 rotate left
+				$degrees = 90;
+				break;
+			}
+			if ($degrees != 0)
+				$target = imagerotate($target, $degrees, 0);
 		}
 	}
-	
-         $target = ImageCreatetruecolor($_GET['size'],$_GET['size']);
-         if (preg_match("/.jpg$/i", $_GET['filename'])) $source = ImageCreateFromJPEG($_GET['filename']);
-         if (preg_match("/.gif$/i", $_GET['filename'])) $source = ImageCreateFromGIF($_GET['filename']);
-         if (preg_match("/.png$/i", $_GET['filename'])) $source = ImageCreateFromPNG($_GET['filename']);
-         imagecopyresampled($target,$source,0,0,$xoord,$yoord,$_GET['size'],$_GET['size'],$width,$height);
-		 imagedestroy($source);
-
-         if (preg_match("/.jpg$/i", $_GET['filename'])) ImageJPEG($target,null,90);
-         if (preg_match("/.gif$/i", $_GET['filename'])) ImageGIF($target,null,90);
-         if (preg_match("/.png$/i", $_GET['filename'])) ImageJPEG($target,null,90); // Using ImageJPEG on purpose
-         imagedestroy($target);
+
+	if (preg_match("/.jpg$/i", $_GET['filename'])) ImageJPEG($target,$outfile,90);
+	if (preg_match("/.gif$/i", $_GET['filename'])) ImageGIF($target,$outfile,90);
+	if (preg_match("/.png$/i", $_GET['filename'])) ImageJPEG($target,$outfile,90); // Using ImageJPEG on purpose
+	imagedestroy($target);
+
+	 if ($outfile)
+		 echo file_get_contents($outfile);
 
 
 
-?>
\ No newline at end of file
+?>
Common subdirectories: MiniGal Nano 0.3.5//css and minigal//css
Common subdirectories: MiniGal Nano 0.3.5//images and minigal//images
diff -u MiniGal Nano 0.3.5//index.php minigal//index.php
--- MiniGal Nano 0.3.5//index.php	2010-12-06 10:22:00.000000000 +0100
+++ minigal//index.php	2011-04-15 21:47:07.194881001 +0200
@@ -214,7 +214,7 @@
 			  				"name" => $file,
 							"date" => filemtime($currentdir . "/" . $file),
 							"size" => filesize($currentdir . "/" . $file),
-				  			"html" => "<li><a href='" . $currentdir . "/" . $file . "' rel='lightbox[billeder]' title='$img_captions[$file]'><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=" . $thumbdir . "/" . $file . "&amp;size=$thumb_size' alt='$label_loading' /></a></li>");
+				  			"html" => "<li><a href='" . GALLERY_ROOT . "createthumb.php?filename=" . $currentdir . "/" . $file . "&amp;nocrop&amp;size=$img_size' rel='lightbox[billeder]' title='$img_captions[$file]'><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=" . $thumbdir . "/" . $file . "&amp;size=$thumb_size' /></a></li>");
 		  			}
 					// Other filetypes
 					$extension = "";
@@ -238,7 +238,7 @@
      			}   		
 	}
   closedir($handle);
-  } else die("ERROR: Could not open $currentdir for reading!");
+  } else die("ERROR: Could not open ".htmlspecialchars(stripslashes($currentdir))." for reading!");
 
 //-----------------------
 // SORT FILES AND FOLDERS
Common subdirectories: MiniGal Nano 0.3.5//js and minigal//js
Common subdirectories: MiniGal Nano 0.3.5//photos and minigal//photos
Common subdirectories: MiniGal Nano 0.3.5//templates and minigal//templates
