From 58fba457f5e2f3073b6eb29f7b9333e6d092b951 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 29 Apr 2020 19:18:23 +0200 Subject: [PATCH] LSsession :: includeFile : allow inclusion of external file with include path search support --- public_html/includes/class/class.LSsession.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 90888e31..1789ee51 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -100,9 +100,21 @@ class LSsession { */ public static function includeFile($file, $external=false) { $path = ($external?'':LS_ROOT_DIR."/").$file; - $local_path = ($external?'':LS_ROOT_DIR."/").LS_LOCAL_DIR.'/'.$file; + $local_path = ($external?'':LS_ROOT_DIR."/").LS_LOCAL_DIR.$file; $path = (file_exists($local_path)?$local_path:$path); - if (!file_exists($path)) { + if ($path[0] != '/') { + $found = stream_resolve_include_path($path); + if ($found === false) { + LSlog :: debug("includeFile($file, external=$external) : file $path not found in include path."); + return; + } + else { + LSlog :: debug("includeFile($file, external=$external) : file '$path' found in include path as '$found'."); + $path = $found; + } + } + else if (!file_exists($path)) { + LSlog :: debug("includeFile($file, external=$external) : file not found ($local_path / $path)"); return; } return include_once($path);