Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+27 -26
View File
@@ -10,16 +10,19 @@
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Data\Store;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Definition caching for HTML Purifier not on disk
*/
class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
class HtmlPurifierDefinitionCache extends HTMLPurifier_DefinitionCache
{
/**
* Adds a definition object to the cache
@@ -28,7 +31,7 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return bool
*/
public function add($def, $config)
public function add( mixed $def, mixed $config): bool
{
return $this->set( $def, $config );
}
@@ -40,24 +43,24 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return bool
*/
public function set($def, $config)
public function set( mixed $def, mixed $config): bool
{
/* If invalid type, just return */
if( !$this->checkDefType( $def ) )
{
return;
return FALSE;
}
/* Generate key and store it */
$key = $this->generateKey( $config );
\IPS\Data\Store::i()->$key = base64_encode( \serialize( $def ) );
Store::i()->$key = base64_encode( serialize( $def ) );
/* Store an array of all keys so we can implement flush() and cleanup() */
$currentKeys = \IPS\Data\Store::i()->htmlpurifier_definitions;
$currentKeys = Store::i()->htmlpurifier_definitions;
$currentKeys[ $key ] = $key;
\IPS\Data\Store::i()->htmlpurifier_definitions = $currentKeys;
Store::i()->htmlpurifier_definitions = $currentKeys;
/* Return TRUE */
return TRUE;
@@ -70,7 +73,7 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return bool
*/
public function replace($def, $config)
public function replace( mixed $def, mixed $config): bool
{
return $this->set( $def, $config );
}
@@ -81,13 +84,13 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return mixed FALSE if not found, or the definition object
*/
public function get($config)
public function get( mixed $config ): mixed
{
$key = $this->generateKey( $config );
if( isset( \IPS\Data\Store::i()->$key ) and \IPS\Data\Store::i()->$key !== 0 )
if( isset( Store::i()->$key ) and Store::i()->$key !== 0 )
{
return \unserialize( base64_decode( \IPS\Data\Store::i()->$key ) );
return unserialize( base64_decode( Store::i()->$key ) );
}
else
{
@@ -101,13 +104,13 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return bool
*/
public function remove($config)
public function remove( mixed $config ): bool
{
$key = $this->generateKey( $config );
if( isset( \IPS\Data\Store::i()->$key ) )
if( isset( Store::i()->$key ) )
{
unset( \IPS\Data\Store::i()->$key );
unset( Store::i()->$key );
}
return TRUE;
@@ -119,22 +122,20 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return void
*/
public function flush($config)
public function flush( mixed $config ) : void
{
if( !isset( \IPS\Data\Store::i()->htmlpurifier_definitions ) )
if( !isset( Store::i()->htmlpurifier_definitions ) )
{
\IPS\Data\Store::i()->htmlpurifier_definitions = array();
Store::i()->htmlpurifier_definitions = array();
}
foreach( \IPS\Data\Store::i()->htmlpurifier_definitions as $key )
foreach( Store::i()->htmlpurifier_definitions as $key )
{
if( isset( \IPS\Data\Store::i()->$key ) )
if( isset( Store::i()->$key ) )
{
unset( \IPS\Data\Store::i()->$key );
unset( Store::i()->$key );
}
}
return;
}
/**
@@ -143,8 +144,8 @@ class HtmlPurifierDefinitionCache extends \HTMLPurifier_DefinitionCache
* @param mixed $config HTML Purifier configuration
* @return void
*/
public function cleanup($config)
public function cleanup( mixed $config ) : void
{
return $this->flush( $config );
$this->flush( $config );
}
}