Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
+7
-20
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Data;
|
||||
|
||||
/* 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;
|
||||
@@ -93,7 +93,7 @@ abstract class _Cache extends AbstractData
|
||||
|
||||
if ( \IPS\CACHING_LOG )
|
||||
{
|
||||
$this->log[ microtime(true) ] = array( 'set', $key, version_compare( PHP_VERSION, '5.4.0' ) >= 0 ? json_encode( $value, JSON_PRETTY_PRINT ) : json_encode( $value ), var_export( debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ), TRUE ) );
|
||||
$this->log[ microtime(true) ] = array( 'set', $key, json_encode( $value, JSON_PRETTY_PRINT ), var_export( debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ), TRUE ) );
|
||||
}
|
||||
|
||||
if ( $this->set( $key, $this->encode( $value ), $expire ) )
|
||||
@@ -123,7 +123,7 @@ abstract class _Cache extends AbstractData
|
||||
}
|
||||
|
||||
$data = $this->$key;
|
||||
if( count( $data ) and isset( $data['value'] ) and isset( $data['expires'] ) )
|
||||
if( \count( $data ) and isset( $data['value'] ) and isset( $data['expires'] ) )
|
||||
{
|
||||
/* Is it expired? */
|
||||
if( $data['expires'] AND time() < $data['expires'] )
|
||||
@@ -165,7 +165,7 @@ abstract class _Cache extends AbstractData
|
||||
protected function _encryptionKey()
|
||||
{
|
||||
$password = \IPS\Settings::i()->sql_pass;
|
||||
if ( function_exists( 'openssl_digest' ) and in_array( 'sha256', openssl_get_md_methods() ) )
|
||||
if ( \function_exists( 'openssl_digest' ) and \in_array( 'sha256', openssl_get_md_methods() ) )
|
||||
{
|
||||
$password = openssl_digest( $password, 'sha256', TRUE );
|
||||
}
|
||||
@@ -180,15 +180,7 @@ abstract class _Cache extends AbstractData
|
||||
*/
|
||||
protected function encode( $value )
|
||||
{
|
||||
$value = json_encode( $value );
|
||||
|
||||
if ( function_exists( 'openssl_encrypt' ) and in_array( 'aes-256-ctr', openssl_get_cipher_methods() ) )
|
||||
{
|
||||
$iv = \IPS\Login::generateRandomString( 16 );
|
||||
$value = $iv . openssl_encrypt( $value, 'aes-256-ctr', $this->_encryptionKey(), OPENSSL_RAW_DATA, $iv );
|
||||
}
|
||||
|
||||
return $value;
|
||||
return \IPS\Text\Encrypt::fromPlaintext( json_encode( $value ) )->tag();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,12 +191,7 @@ abstract class _Cache extends AbstractData
|
||||
*/
|
||||
protected function decode( $value )
|
||||
{
|
||||
if ( function_exists( 'openssl_encrypt' ) and in_array( 'aes-256-ctr', openssl_get_cipher_methods() ) )
|
||||
{
|
||||
$value = @openssl_decrypt( \substr( $value, 16 ), 'aes-256-ctr', $this->_encryptionKey(), OPENSSL_RAW_DATA, \substr( $value, 0, 16 ) );
|
||||
}
|
||||
|
||||
return json_decode( $value, TRUE );
|
||||
return json_decode( \IPS\Text\Encrypt::fromTag( $value )->decrypt(), TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +204,7 @@ abstract class _Cache extends AbstractData
|
||||
{
|
||||
if ( parent::__isset( $key ) )
|
||||
{
|
||||
return ( is_array( $this->$key ) or $this->$key === 0 ) ? true : (bool) $this->$key;
|
||||
return ( \is_array( $this->$key ) or $this->$key === 0 ) ? true : (bool) $this->$key;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user