So yeah, new uploader broke on everything but zip files. Fixed that. default tip
authorDan Fuhry <dan@enanocms.org>
Sun, 19 Sep 2010 03:51:00 -0400
changeset 45 740bbe1f4dd5
parent 44 17cfc3da0dcc
So yeah, new uploader broke on everything but zip files. Fixed that.
plugins/gallery/functions.php
plugins/gallery/upload.php
--- a/plugins/gallery/functions.php	Sat Aug 21 23:51:10 2010 -0400
+++ b/plugins/gallery/functions.php	Sun Sep 19 03:51:00 2010 -0400
@@ -434,22 +434,29 @@
  * @return int image ID
  */
 
-function snapr_insert_image($path, $folder_id = NULL)
+function snapr_insert_image($path, $folder_id = NULL, $orig_filename = false)
 {
 	global $db, $session, $paths, $template, $plugins; // Common objects
 	
-	$ext = get_file_extension($path);
+	$usename = $orig_filename ? $orig_filename : $path;
+	$ext = get_file_extension($usename);
 	$ourfilename = gallery_make_filename() . "." . strtolower($ext);
 	if ( !snapr_extension_allowed($ext) )
+	{
+		echo "Banned extension: $ext";
 		return false;
+	}
 	
 	// copy the file to the storage folder
 	if ( !rename($path, ENANO_ROOT . "/files/$ourfilename") )
+	{
+		echo "Rename failed: $path -&gt; files/$ourfilename";
 		return false;
+	}
 	
 	// insert the image into the database
 	$folder = $folder_id === NULL ? 'NULL' : strval(intval($folder_id));
-	$title = ucwords(str_replace('_', ' ', basename($path)));
+	$title = ucwords(str_replace('_', ' ', $usename));
 	$title = preg_replace("/\.{$ext}\$/i", '', $title);
 	$sz = serialize(array());
 	$now = time();
--- a/plugins/gallery/upload.php	Sat Aug 21 23:51:10 2010 -0400
+++ b/plugins/gallery/upload.php	Sun Sep 19 03:51:00 2010 -0400
@@ -205,7 +205,7 @@
 				if ( snapr_extension_allowed($ext) )
 				{
 					// normal image
-					$result = snapr_insert_image($files['tmp_name'][$i], $destfolder);
+					$result = snapr_insert_image($files['tmp_name'][$i], $destfolder, $files['name'][$i]);
 					if ( $result !== false )
 						$idlist[] = $result;
 				}