From 2f68e94cfdb13d7425e1ef47bfb48a6c292bcbdf Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Fri, 15 Nov 2024 23:03:25 +0100 Subject: [PATCH] fix include for website library pages (#31891) --- htdocs/core/lib/website.lib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index b96ad5f8bdd..c44bb31b429 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -597,9 +597,10 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri * It outputs content of file sanitized from html and body part. * * @param string $containerref Path to file to include (must be a page from website root. Example: 'mypage.php' means 'mywebsite/mypage.php') + * @param int $once If set to 1, we use include_once. * @return void */ -function includeContainer($containerref) +function includeContainer($containerref, $once = 0) { global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running included containers. global $includehtmlcontentopened; @@ -630,7 +631,11 @@ function includeContainer($containerref) //print preg_replace(array('/^.*]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ ob_start(); - $res = @include $fullpathfile; // Include because we want to execute code content + if ($once) { + $res = @include_once $fullpathfile; + } else { + $res = @include $fullpathfile; + } $tmpoutput = ob_get_contents(); ob_end_clean();