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

+31 -22
View File
@@ -11,23 +11,32 @@
namespace IPS\Data\Cache;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DirectoryIterator;
use IPS\Data\Cache;
use IPS\DateTime;
use IPS\Helpers\Form\Text;
use function defined;
use function file_put_contents;
use const IPS\IPS_FILE_PERMISSION;
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;
}
/**
* Test Cache Class
*/
class _Test extends \IPS\Data\Cache
class Test extends Cache
{
/**
* Server supports this method?
*
* @return bool
*/
public static function supported()
public static function supported(): bool
{
return TRUE;
}
@@ -38,15 +47,15 @@ class _Test extends \IPS\Data\Cache
* @param array $configuration Existing settings
* @return array \IPS\Helpers\Form\FormAbstract elements
*/
public static function configuration( $configuration )
public static function configuration( array $configuration ): array
{
return array( 'path' => new \IPS\Helpers\Form\Text( 'datastore_test_path', ( isset( $configuration['path'] ) ) ? $configuration['path'] : '', FALSE ) );
return array( 'path' => new Text( 'datastore_test_path', ( isset( $configuration['path'] ) ) ? $configuration['path'] : '', FALSE ) );
}
/**
* @brief Storage Path
*/
public $_path;
public string $_path;
/**
* Constructor
@@ -54,7 +63,7 @@ class _Test extends \IPS\Data\Cache
* @param array $configuration Configuration
* @return void
*/
public function __construct( $configuration )
public function __construct( array $configuration )
{
$this->_path = rtrim( $configuration['path'], '/' );
}
@@ -62,10 +71,10 @@ class _Test extends \IPS\Data\Cache
/**
* Abstract Method: Get
*
* @param string $key Key
* @param string $key Key
* @return string Value from the _datastore
*/
protected function get( $key )
protected function get( string $key ): string
{
return file_get_contents( $this->_path . '/' . $key . '.txt' );
}
@@ -73,25 +82,25 @@ class _Test extends \IPS\Data\Cache
/**
* Abstract Method: Set
*
* @param string $key Key
* @param string $value Value
* @param \IPS\DateTime|NULL $expire Expreation time, or NULL for no expiration
* @param string $key Key
* @param string $value Value
* @param DateTime|NULL $expire Expreation time, or NULL for no expiration
* @return bool
*/
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
protected function set( string $key, string $value, DateTime $expire = NULL ): bool
{
$return = \file_put_contents( $this->_path . '/' . $key . '.txt', $value );
chmod( $this->_path . '/' . $key . '.txt', \IPS\IPS_FILE_PERMISSION );
$return = file_put_contents( $this->_path . '/' . $key . '.txt', $value );
chmod( $this->_path . '/' . $key . '.txt', IPS_FILE_PERMISSION );
return $return;
}
/**
* Abstract Method: Exists?
*
* @param string $key Key
* @param string $key Key
* @return bool
*/
protected function exists( $key )
protected function exists( string $key ): bool
{
return file_exists( $this->_path . '/' . $key . '.txt' );
}
@@ -99,10 +108,10 @@ class _Test extends \IPS\Data\Cache
/**
* Abstract Method: Delete
*
* @param string $key Key
* @param string $key Key
* @return bool
*/
protected function delete( $key )
protected function delete( string $key ): bool
{
return @unlink( $this->_path . '/' . $key . '.txt' );
}
@@ -112,10 +121,10 @@ class _Test extends \IPS\Data\Cache
*
* @return void
*/
public function clearAll()
public function clearAll() : void
{
parent::clearAll();
foreach ( new \DirectoryIterator( $this->_path ) as $file )
foreach ( new DirectoryIterator( $this->_path ) as $file )
{
if ( !$file->isDot() and $file != 'index.html' )
{