From 7403fd7c87afe22af89618b29137906fb36213a0 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 24 Dec 2010 20:44:38 +0000 Subject: [PATCH] Revert "checks for files without extensions, from AtomicDryad" This seems to break something, such that uploading a jpeg results in image size 0x0 (other bits seem to work though o_O) Will take a look at what's up and re-commit later... This reverts commit ead87d3934ad7d29394fd39e309bd75f5eb78fbb. --- core/extension.class.php | 21 +-------------------- ext/handle_pixel/main.php | 11 ----------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/core/extension.class.php b/core/extension.class.php index 5c3cfc71..49f73b73 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -132,25 +132,7 @@ abstract class DataHandlerExtension implements Extension { public function receive_event(Event $event) { if(is_null($this->theme)) $this->theme = get_theme_object($this); - if($event instanceof DataUploadEvent) { - $valid=FALSE; // TRUE = skip check_contents() - $USEHEADERSALWAYS=FALSE; //TRUE; // STUB - make option - if ( is_null($event->type) || ($event->type == "") || ( $USEHEADERSALWAYS ) ) { - if (is_callable(array($this,'find_ext'))) { - // find_ext should always return false or a valid str, so: - if(!$ext=$this->find_ext($event->tmpname)) return; // pass off to the next listener and avoid ext=NULL mysql insert - $valid=TRUE; // or avoid calling check_contents() needlessly - $event->type = $ext; - $event->metadata['extension']=$ext; - log_info("core-extension", get_class($this)." has renamed '".$event->metadata['filename']."' to '".$event->metadata['filename'].".$ext'"); - $event->metadata['filename']=$event->metadata['filename'].".$ext"; - } else { if(!$USEHEADERSALWAYS) return; } // no ext + valid check_contents = mysql error. - } - - - - if( ($valid) || ($this->check_contents($event->tmpname)) ) { - + if(($event instanceof DataUploadEvent) && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); $image = $this->create_image_from_data(warehouse_path("images", $event->hash), $event->metadata); @@ -161,7 +143,6 @@ abstract class DataHandlerExtension implements Extension { send_event($iae); $event->image_id = $iae->image->id; } - } if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) { $this->create_thumb($event->hash); diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index d86998dc..53a18988 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -32,17 +32,6 @@ class PixelFileHandler extends DataHandlerExtension { return $image; } - protected function find_ext($file) { - $phpimgexts = array ( 1=> 'gif', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'tiff', - 'jpc', 'jp2', 'jpf', 'jb2', 'swc', 'aiff', 'wbmp', 'xbm'); // const, do not change. Less overhead / PITA than image_type_to_extension($info[2]) - - if(!file_exists($file)) return false; - $info = getimagesize($file); - $exts = array("jpg", "jpeg", "gif", "png"); - $ret=$phpimgexts[$info[2]]; - return (in_array($ret,$exts)?$ret:false); - } - protected function check_contents($file) { $valid = Array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG); if(!file_exists($file)) return false;