diff options
| author | spiderr <spider@viovio.com> | 2010-12-28 17:02:46 -0500 |
|---|---|---|
| committer | spiderr <spider@viovio.com> | 2010-12-28 17:02:46 -0500 |
| commit | 4f70f78a534da6966771d29da969c0df13e161eb (patch) | |
| tree | d39b0d6fcec2379521f9cb31171fb9e1c6bc99e0 | |
| parent | 4ccb1bbe5c5e60131ae46d0ab29896c7f3dadc99 (diff) | |
| download | fisheye-4f70f78a534da6966771d29da969c0df13e161eb.tar.gz fisheye-4f70f78a534da6966771d29da969c0df13e161eb.tar.bz2 fisheye-4f70f78a534da6966771d29da969c0df13e161eb.zip | |
bounds checking on the width and height - corrupt photos can be ridiculously huge or negative; add some original file searching
| -rw-r--r-- | FisheyeImage.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/FisheyeImage.php b/FisheyeImage.php index c2afe38..d5fa576 100644 --- a/FisheyeImage.php +++ b/FisheyeImage.php @@ -1,6 +1,5 @@ <?php /** - * @version $Header$ * @package fisheye */ @@ -131,9 +130,12 @@ class FisheyeImage extends FisheyeBase { if( empty( $this->mInfo['height'] ) || empty( $this->mInfo['height'] ) ) { $details = $this->getImageDetails(); - $this->mInfo['width'] = $details['width']; - $this->mInfo['height'] = $details['height']; - $this->mDb->query( "UPDATE `".BIT_DB_PREFIX."fisheye_image` SET `width`=?, `height`=? WHERE `content_id`=?", array( $this->mInfo['width'], $this->mInfo['height'], $this->mContentId ) ); + // bounds checking on the width and height - corrupt photos can be ridiculously huge or negative + if( $details['width'] > 0 AND $details['width'] < 9999 AND $details['height'] > 0 AND $details['height'] < 9999 ) { + $this->mInfo['width'] = $details['width']; + $this->mInfo['height'] = $details['height']; + $this->mDb->query( "UPDATE `".BIT_DB_PREFIX."fisheye_image` SET `width`=?, `height`=? WHERE `content_id`=?", array( $this->mInfo['width'], $this->mInfo['height'], $this->mContentId ) ); + } } } } else { @@ -546,7 +548,13 @@ class FisheyeImage extends FisheyeBase { if( file_exists( $pFilePath ) ) { $checkFiles = array( $pFilePath, dirname( $pFilePath ).'/original.jpg' ); } else { + $sourceFile = $this->getSourceFile(); $checkFiles = array( $this->getSourceFile() ); + // was an original file created? + $originalFile = dirname( $sourceFile ).'/original.jpg'; + if( file_exists( $originalFile ) && !is_link( $originalFile ) ) { + $checkFiles[] = $originalFile; + } } foreach( $checkFiles as $cf ) { @@ -555,6 +563,7 @@ class FisheyeImage extends FisheyeBase { $info['width'] = $info[0]; $info['height'] = $info[1]; $info['size'] = filesize( $cf ); + break; } } } |
