Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
+19
-13
@@ -11,7 +11,7 @@
|
||||
namespace IPS;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -32,6 +32,11 @@ abstract class _Image
|
||||
*/
|
||||
public static $imageMimes = array( 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' );
|
||||
|
||||
/**
|
||||
* @brief Allow EXIF processing
|
||||
*/
|
||||
public static $exifEnabled = TRUE;
|
||||
|
||||
/**
|
||||
* Determine if EXIF extraction is supported
|
||||
*
|
||||
@@ -39,7 +44,7 @@ abstract class _Image
|
||||
*/
|
||||
public static function exifSupported()
|
||||
{
|
||||
return function_exists( 'exif_read_data' );
|
||||
return \function_exists( 'exif_read_data' ) and static::$exifEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +76,7 @@ abstract class _Image
|
||||
'89' . '50' . '4e' . '47' . '0d' . '0a' . '1a' . '0a'
|
||||
)
|
||||
);
|
||||
$bytesNeeded = max( array_map( 'strlen', array_map( 'hex2bin', call_user_func_array( 'array_merge', $signatures ) ) ) );
|
||||
$bytesNeeded = max( array_map( 'strlen', array_map( 'hex2bin', array_merge( $signatures['gif'], $signatures['jpeg'], $signatures['png'] ) ) ) );
|
||||
$fileHeader = \substr( $contents, 0, $bytesNeeded );
|
||||
foreach ( $signatures as $type => $_signatures )
|
||||
{
|
||||
@@ -100,8 +105,8 @@ abstract class _Image
|
||||
}
|
||||
$obj->type = $imageType;
|
||||
|
||||
/* Animated? */
|
||||
if ( $obj->type === 'gif' and (boolean) preg_match( '#(\x00\x21\xF9\x04.{4}\x00\x2C.*){2,}#s', $contents ) )
|
||||
/* Animated? @see https://www.php.net/manual/en/function.imagecreatefromgif.php#102915 */
|
||||
if ( $obj->type === 'gif' and (boolean) preg_match( '#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $contents ) )
|
||||
{
|
||||
$obj->isAnimatedGif = TRUE;
|
||||
$obj->contents = $contents;
|
||||
@@ -200,15 +205,15 @@ abstract class _Image
|
||||
*
|
||||
* @param int|NULL $maxWidth Max Width (in pixels) or NULL
|
||||
* @param int|NULL $maxHeight Max Height (in pixels) or NULL
|
||||
* @param bool $retainRatio If TRUE, the image will keep it's current width/height ratio rather than being squashed
|
||||
* @return bool
|
||||
* @param bool $retainRatio If TRUE, the image will keep it's current width/height ratio rather than being squashed
|
||||
* @return bool Returns TRUE if it actually resized, or FALSE if it wasn't necessary
|
||||
*/
|
||||
public function resizeToMax( $maxWidth=NULL, $maxHeight=NULL, $retainRatio=TRUE )
|
||||
{
|
||||
/* If the image is smaller than max we can skip */
|
||||
if( ( $maxWidth == NULL or $this->width < $maxWidth ) and ( $maxHeight == NULL or $this->height < $maxHeight ) )
|
||||
{
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Work out the maximum width/height */
|
||||
@@ -233,10 +238,11 @@ abstract class _Image
|
||||
}
|
||||
|
||||
/* And resize */
|
||||
return $this->resize( $width, $height );
|
||||
$this->resize( $width, $height );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +273,7 @@ abstract class _Image
|
||||
throw new \LogicException( 'NO_EXIF' );
|
||||
}
|
||||
|
||||
if( !in_array( $this->type, array( 'jpeg', 'jpg', 'jpe' ) ) )
|
||||
if( !\in_array( $this->type, array( 'jpeg', 'jpg', 'jpe' ) ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -303,12 +309,12 @@ abstract class _Image
|
||||
/**
|
||||
* Get EXIF data, if possible
|
||||
*
|
||||
* @param string $image Image contents
|
||||
* @param string $contents Image contents
|
||||
* @return void
|
||||
*/
|
||||
public function setExifData( $contents )
|
||||
{
|
||||
if( !in_array( $this->type, array( 'jpeg', 'jpg', 'jpe' ) ) )
|
||||
if( !\in_array( $this->type, array( 'jpeg', 'jpg', 'jpe' ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user