summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiderr <spider@viovio.com>2010-12-28 17:02:46 -0500
committerspiderr <spider@viovio.com>2010-12-28 17:02:46 -0500
commit4f70f78a534da6966771d29da969c0df13e161eb (patch)
treed39b0d6fcec2379521f9cb31171fb9e1c6bc99e0
parent4ccb1bbe5c5e60131ae46d0ab29896c7f3dadc99 (diff)
downloadfisheye-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.php17
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;
}
}
}