From 3d6965fb524e5c1889fc7c1da8353752d1ada5c5 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Pourrez <46094001+kazimentou@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:47:35 +0200 Subject: [PATCH] plxAdmin::getFileStatique() always returns a string (#827) PLX_DEBUG is set to "true" In plxPlugins::__construct(), error is ignored in some cases : - PLX_DEBUG is false - $error['file'] is empty - $error['type'] < E_DEPRECATED ( not warnings ) Co-authored-by: Jean-Pierre Pourrez --- core/lib/class.plx.admin.php | 9 +++++---- core/lib/class.plx.plugins.php | 3 ++- core/lib/config.php | 2 +- readme/CHANGELOG | 5 +++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/lib/class.plx.admin.php b/core/lib/class.plx.admin.php index e91d944cd..add914a88 100644 --- a/core/lib/class.plx.admin.php +++ b/core/lib/class.plx.admin.php @@ -840,14 +840,15 @@ public function getFileStatique($num) { # Emplacement de la page $filename = PLX_ROOT.$this->aConf['racine_statiques'].$num.'.'.$this->aStats[ $num ]['url'].'.php'; if(file_exists($filename) AND filesize($filename) > 0) { - if($f = fopen($filename, 'r')) { - $content = fread($f, filesize($filename)); - fclose($f); + $content = file_get_contents($filename); + if(is_string($content)) { # On retourne le contenu return $content; + } else { + return implode(PHP_EOL, array('

', "\t" . L_UNKNOWN_ERROR, '

')); } } - return null; + return implode(PHP_EOL, array('

', "\t" . L_STATICS_NEW_PAGE, '

')); } /** diff --git a/core/lib/class.plx.plugins.php b/core/lib/class.plx.plugins.php index be4f3c5c5..198199c70 100644 --- a/core/lib/class.plx.plugins.php +++ b/core/lib/class.plx.plugins.php @@ -26,7 +26,7 @@ public function __construct($default_lang='') { register_shutdown_function(function() { $error = error_get_last(); - if($error != null) { + if($error != null and !empty($error['file']) and (PLX_DEBUG or $error['type'] < E_DEPRECATED)) { # error['type'] < 8192 # For hiding sensitive informations $documentRoot = realpath($_SERVER['DOCUMENT_ROOT']); # resolve symbolic link with Linux $filename = $error['file']; @@ -79,6 +79,7 @@ public function __construct($default_lang='') { User : Profil : PluXml version : +PLX_DEBUG : PHP version : About this server : diff --git a/core/lib/config.php b/core/lib/config.php index 739d998a2..5dd50b4a9 100644 --- a/core/lib/config.php +++ b/core/lib/config.php @@ -1,6 +1,6 @@