mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 04:32:01 +02:00
e_file_inspector: No longer conflate insecure files and cached old files
Related ticket: https://github.com/e107inc/e107/issues/4312
This commit is contained in:
parent
5438da3764
commit
2eebd4f0ca
@ -139,7 +139,7 @@ class admin_start
|
||||
|
||||
// Files that can cause comflicts and problems.
|
||||
$fileInspector = e107::getFileInspector();
|
||||
$this->deprecated = $fileInspector->insecureFiles;
|
||||
$this->deprecated = $fileInspector::getCachedDeprecatedFiles();
|
||||
|
||||
$this->checkCoreVersion();
|
||||
|
||||
|
@ -53,6 +53,11 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
||||
private $existingInsecureFiles = array();
|
||||
private $existingInsecureDirectories = array();
|
||||
|
||||
/**
|
||||
* @var null|resource File pointer resource opened in write mode or null if not initialized yet
|
||||
*/
|
||||
private $deprecatedLogFileHandle = null;
|
||||
|
||||
/**
|
||||
* e_file_inspector constructor
|
||||
* @param string $database The database from which integrity data may be read or to which integrity data may be
|
||||
@ -62,8 +67,6 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
||||
{
|
||||
$this->database = $database;
|
||||
|
||||
$this->checkDeprecatedFilesLog();
|
||||
|
||||
$appRoot = e107::getInstance()->file_path;
|
||||
$this->undeterminable = array_map(function ($path)
|
||||
{
|
||||
@ -86,27 +89,27 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate insecureFiles list if deprecatedFiles.log found.
|
||||
* @return void
|
||||
* Get a list of deprecated files cached in deprecatedFiles.log from the last File Inspector scan
|
||||
* @return array
|
||||
*/
|
||||
private function checkDeprecatedFilesLog()
|
||||
public static function getCachedDeprecatedFiles()
|
||||
{
|
||||
$log = e_LOG.'fileinspector/deprecatedFiles.log';
|
||||
|
||||
if(!file_exists($log))
|
||||
{
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
|
||||
$content = file_get_contents($log);
|
||||
|
||||
if(empty($content))
|
||||
{
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
|
||||
$tmp = explode("\n", $content);
|
||||
$this->insecureFiles = [];
|
||||
$cachedDeprecatedFiles = [];
|
||||
foreach($tmp as $line)
|
||||
{
|
||||
if(empty($line))
|
||||
@ -114,10 +117,10 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->insecureFiles[] = e_BASE.$line;
|
||||
$cachedDeprecatedFiles[] = e_BASE.$line;
|
||||
}
|
||||
|
||||
|
||||
return $cachedDeprecatedFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,14 +214,19 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
||||
|
||||
$message = $relativePath."\n";
|
||||
|
||||
$logPath = e_LOG."fileinspector/";
|
||||
|
||||
if(!is_dir($logPath))
|
||||
if (!is_resource($this->deprecatedLogFileHandle))
|
||||
{
|
||||
mkdir($logPath, 0775);
|
||||
$logPath = e_LOG."fileinspector/";
|
||||
|
||||
if(!is_dir($logPath))
|
||||
{
|
||||
mkdir($logPath, 0775);
|
||||
}
|
||||
|
||||
$this->deprecatedLogFileHandle = fopen($logPath."deprecatedFiles.log", 'w');
|
||||
}
|
||||
|
||||
file_put_contents($logPath."deprecatedFiles.log", $message, FILE_APPEND);
|
||||
fwrite($this->deprecatedLogFileHandle, $message);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user