1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-12 09:34:54 +02:00

CoreImage: API rework

This commit is contained in:
Nick Liu
2020-03-23 22:40:28 -05:00
parent 76bb9f6ad8
commit b425b4e45d
7 changed files with 331 additions and 323 deletions

View File

@@ -16,12 +16,33 @@ require_once("e_file_inspector_interface.php");
*/
abstract class e_file_inspector implements e_file_inspector_interface
{
protected $database;
protected $currentVersion;
private $validatedBitmask;
protected $defaultDirsCache;
protected $customDirsCache;
/**
* e_file_inspector constructor
* @param string $database The database from which integrity data may be read or to which integrity data may be
* written. This should be an URL or absolute file path for most implementations.
*/
public function __construct($database)
{
$this->database = $database;
$this->loadDatabase();
}
/**
* Prepare the provided database for reading or writing
*
* Should tolerate a non-existent database and try to create it if a write operation is executed.
*
* @return void
*/
abstract public function loadDatabase();
/**
* Check the integrity of the provided path
*

View File

@@ -17,11 +17,21 @@ class e_file_inspector_json extends e_file_inspector
* @param $jsonFilePath string Absolute path to the file inspector database
*/
public function __construct($jsonFilePath = null)
{
parent::__construct($jsonFilePath);
}
/**
* @inheritDoc
*/
public function loadDatabase()
{
global $core_image;
if ($jsonFilePath === null) $jsonFilePath = e_ADMIN . "core_image.php";
require($jsonFilePath);
$this->coreImage = self::array_slash(json_decode($core_image, true));
@include($this->database);
$this->coreImage = json_decode($core_image, true);
if (!is_array($this->coreImage)) $this->coreImage = [];
$this->coreImage = self::array_slash($this->coreImage);
if (!$this->coreImage) $this->coreImage = [];
unset($core_image);
}

View File

@@ -14,13 +14,19 @@ class e_file_inspector_sqlphar extends e_file_inspector
private $coreImage;
/**
* e_file_inspector_sqlphar constructor.
* @param $pharFilePath string Absolute path to the file inspector database
*/
public function __construct($pharFilePath = null)
{
if ($pharFilePath === null) $pharFilePath = e_ADMIN . "core_image.php";
Phar::loadPhar($pharFilePath, "core_image.phar");
parent::__construct($pharFilePath);
}
/**
* @inheritDoc
*/
public function loadDatabase()
{
Phar::loadPhar($this->database, "core_image.phar");
$tmpFile = tmpfile();
$tmpFilePath = stream_get_meta_data($tmpFile)['uri'];
$this->copyUrlToResource("phar://core_image.phar/core_image.sqlite", $tmpFile);
@@ -84,7 +90,6 @@ class e_file_inspector_sqlphar extends e_file_inspector
}
/**
* Copy file to destination with low memory footprint
* @param $source string URL of the source