67 dol_syslog(
"dolSavePageAlias We regenerate the alias page filealias=".$filealias.
" and a wrapper into all language subdirectories");
69 $aliascontent =
'<?php'.
"\n";
70 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
71 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
72 $aliascontent .=
'if (empty($dolibarr_main_data_root)) $res=include \'./page'.$objectpage->id.
'.tpl.php\'; ';
73 $aliascontent .=
'else $res=include $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
74 $aliascontent .=
'if ($res === false) { http_response_code(500); print \'Failed to make include\'; }'.
"\n";
75 $aliascontent .=
'?>'.
"\n";
76 $result = file_put_contents($filealias, $aliascontent);
77 if ($result ===
false) {
78 dol_syslog(
"Failed to write file ".$filealias, LOG_WARNING);
83 if ($objectpage->lang && in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
84 $dirname = dirname($filealias);
85 $filename = basename($filealias);
86 $filealiassub = $dirname.
'/'.$objectpage->lang.
'/'.$filename;
88 dol_mkdir($dirname.
'/'.$objectpage->lang, DOL_DATA_ROOT);
90 $aliascontent =
'<?php'.
"\n";
91 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
92 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
93 $aliascontent .=
'if (empty($dolibarr_main_data_root)) $res=include \'../page'.$objectpage->id.
'.tpl.php\'; ';
94 $aliascontent .=
'else $res=include $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
95 $aliascontent .=
'if ($res === false) { http_response_code(500); print \'Failed to make include\'; }'.
"\n";
96 $aliascontent .=
'?>'.
"\n";
97 $result = file_put_contents($filealiassub, $aliascontent);
98 if ($result ===
false) {
99 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
102 } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
105 $dirname = dirname($filealias);
106 $filename = basename($filealias);
107 foreach (explode(
',',
$object->otherlang) as $sublang) {
109 if (empty(trim($sublang))) {
112 $filealiassub = $dirname.
'/'.$sublang.
'/'.$filename;
114 $aliascontent =
'<?php'.
"\n";
115 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
116 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
117 $aliascontent .=
'if (empty($dolibarr_main_data_root)) $res=include \'../page'.$objectpage->id.
'.tpl.php\'; ';
118 $aliascontent .=
'else $res=include $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
119 $aliascontent .=
'if ($res === false) { http_response_code(500); print \'Failed to make include\'; }'.
"\n";
120 $aliascontent .=
'?>'.
"\n";
123 $result = file_put_contents($filealiassub, $aliascontent);
124 if ($result ===
false) {
125 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
132 return ($result ?
true :
false);
152 dol_syslog(
"dolSavePageContent We regenerate the tpl page filetpl=".$filetpl);
154 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
168 if ($objectpage->lang) {
169 $shortlangcode = substr($objectpage->lang, 0, 2);
171 if (empty($shortlangcode)) {
173 $shortlangcode = substr(
$object->lang, 0, 2);
176 if (!empty($objectpage->type_container) && in_array($objectpage->type_container, array(
'library',
'service'))) {
177 $originalcontentonly = 1;
181 if (!isset($originalcontentonly)) {
183 $tplcontent .=
"<?php // BEGIN PHP\n";
184 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
185 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
186 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
187 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
188 if ($objectpage->disable_waf !=
'all') {
189 if (strpos($objectpage->disable_waf,
'NOSCANAUDIOFORINJECTION') !==
false) {
190 $tplcontent .=
' define(\'NOSCANAUDIOFORINJECTION\', 1);'.
"\n";
192 if (strpos($objectpage->disable_waf,
'NOSCANIFRAMEFORINJECTION') !==
false) {
193 $tplcontent .=
' define(\'NOSCANIFRAMEFORINJECTION\', 1);'.
"\n";
195 if (strpos($objectpage->disable_waf,
'NOSCANOBJECTFORINJECTION') !==
false) {
196 $tplcontent .=
' define(\'NOSCANOBJECTFORINJECTION\', 1);'.
"\n";
198 $tplcontent .=
' require_once DOL_DOCUMENT_ROOT.\'/waf.inc.php\';'.
"\n";
200 $tplcontent .=
"}\n";
201 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
202 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
203 if (in_array($objectpage->type_container, array(
'page',
'blogpost',
'service'))) {
204 $tplcontent .=
'dol_syslog("--- Prepare content of page '.((int) $objectpage->id).
' - '.preg_replace(
'/[^\w_-]/',
'', $objectpage->pageurl).
'");'.
"\n";
206 $tplcontent .=
"ob_start();\n";
207 $tplcontent .=
"try {\n";
208 $tplcontent .=
"// END PHP ?>\n";
210 $tplcontent .=
"<!DOCTYPE html>\n";
213 $tplcontent .=
'<html'.($objectpage->lang ?
' lang="'.preg_replace(
'/[^a-z]/i',
'', substr($objectpage->lang, 0, 2)).
'"' :
'<?php echo $weblangs->shortlang ? \' lang="\'.$weblangs->shortlang.\'"\' : \'\' ?>').
'>'.
"\n";
214 $tplcontent .=
'<head>'.
"\n";
215 $tplcontent .=
'<title>'.dol_string_nohtmltag($objectpage->title, 1,
'UTF-8').
'</title>'.
"\n";
216 $tplcontent .=
'<meta charset="utf-8">'.
"\n";
217 $tplcontent .=
'<meta http-equiv="content-type" content="text/html; charset=utf-8" />'.
"\n";
218 $tplcontent .=
'<meta name="robots" content="'.($objectpage->index ?
'index' :
'noindex').
', '.($objectpage->follow ?
'follow' :
'nofollow').
'" />'.
"\n";
219 $tplcontent .=
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
220 $tplcontent .=
'<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords, 1,
'UTF-8').
'" />'.
"\n";
221 $tplcontent .=
'<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 1,
'UTF-8').
'" />'.
"\n";
222 $tplcontent .=
'<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 1,
'UTF-8').
'" />'.
"\n";
223 $tplcontent .=
'<meta name="generator" content="'.DOL_APPLICATION_TITLE.
' '.DOL_VERSION.
' (https://www.dolibarr.org)" />'.
"\n";
224 $tplcontent .=
'<meta name="dolibarr:pageid" content="'.((int) $objectpage->id).
'" />'.
"\n";
228 $htmlheader = file_get_contents($htmldeaderindestdir);
229 if (in_array($objectpage->type_container, array(
'page',
'blogpost')) && !preg_match(
'/'.preg_quote(
'rel="icon"',
'/').
'/', $htmlheader)) {
230 $tplcontent .=
'<link rel="icon" type="image/png" href="/favicon.png" />'.
"\n";
233 $listofaltlang =
$object->otherlang;
238 $canonicalurladdidlang =
'';
239 if ($objectpage->lang) {
240 $canonicalurl = (($objectpage->id ==
$object->fk_default_home) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$shortlangcode :
'').
'/'.$objectpage->pageurl.
'.php'));
242 $canonicalurl =
'/'.$objectpage->pageurl.
'.php';
244 if (
$object->lang && $listofaltlang) {
246 $canonicalurladdidlang =
'?__SEO_CANONICAL_URL_PARAMS__';
247 $canonicalurladdidlang .=
'&l=__SEO_CANONICAL_LANG__';
250 $canonicalurladdidlang =
'?__SEO_CANONICAL_URL_PARAMS__';
254 $tplcontent .=
'<link rel="canonical" href="<?php echo $website->virtualhost; ?>'.$canonicalurl.$canonicalurladdidlang.
'" />'.
"\n";
257 if ($listofaltlang) {
258 if ($objectpage->lang) {
260 $translationof = $objectpage->fk_page;
261 if ($translationof) {
262 $tmppage =
new WebsitePage($db);
263 $tmppage->fetch($translationof);
264 if ($tmppage->id > 0) {
265 $tmpshortlangcode =
'';
266 if ($tmppage->lang) {
267 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
269 if (empty($tmpshortlangcode)) {
270 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
272 if ($tmpshortlangcode != $shortlangcode) {
273 $tplcontent .=
'<link rel="alternate" hreflang="'.$tmpshortlangcode.
'" href="<?php echo $website->virtualhost; ?>'.(
$object->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php').
'" />'.
"\n";
279 $sql =
"SELECT rowid as id, lang, pageurl from ".MAIN_DB_PREFIX.
'website_page where fk_page IN ('.$db->sanitize($objectpage->id.($translationof ?
", ".$translationof :
'')).
")";
280 $resql = $db->query($sql);
282 $num_rows = $db->num_rows($resql);
284 while ($obj = $db->fetch_object($resql)) {
285 $tmpshortlangcode =
'';
287 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $obj->lang);
289 if ($tmpshortlangcode != $shortlangcode) {
290 $tplcontent .=
'<link rel="alternate" hreflang="'.$tmpshortlangcode.
'" href="<?php echo $website->virtualhost; ?>'.(
$object->fk_default_home == $obj->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$obj->pageurl.
'.php').
'" />'.
"\n";
295 dol_print_error($db);
299 $tplcontent .=
'<?php if ($_SERVER["PHP_SELF"] == "'.(($object->fk_default_home == $objectpage->id) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$shortlangcode :
'')).
'/'.$objectpage->pageurl.
'.php") { ?>'.
"\n";
300 $tplcontent .=
'<link rel="alternate" hreflang="'.$shortlangcode.
'" href="<?php echo $website->virtualhost; ?>'.((
$object->fk_default_home == $objectpage->id) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$shortlangcode :
'').
'/'.$objectpage->pageurl.
'.php').
'" />'.
"\n";
302 $tplcontent .=
'<?php } ?>'.
"\n";
304 $canonicalurl =
'/'.$objectpage->pageurl.
'.php';
305 $arrayofaltlang = explode(
',', $listofaltlang);
307 foreach ($arrayofaltlang as $altlang) {
309 $canonicalurladdidlang =
'?__SEO_CANONICAL_URL_PARAMS__';
310 $canonicalurladdidlang .=
'&l='.$altlang;
311 $tplcontent .=
'<link rel="alternate" hreflang="'.$altlang.
'" href="<?php echo $website->virtualhost; ?>'.$canonicalurl.$canonicalurladdidlang.
'" />'.
"\n";
314 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
315 $canonicalurladdidlang =
'?__SEO_CANONICAL_URL_PARAMS__';
316 $canonicalurladdidlang .=
'&l='.$tmpshortlangcode;
317 $tplcontent .=
'<link rel="alternate" hreflang="'.$tmpshortlangcode.
'" href="<?php echo $website->virtualhost; ?>'.$canonicalurl.$canonicalurladdidlang.
'" />'.
"\n";
323 $tplcontent .=
'<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'.
"\n";
326 $tplcontent .=
'<!-- Include HTML header from common file -->'.
"\n";
327 $tplcontent .=
'<?php if (file_exists(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")) include DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html"; ?>'.
"\n";
328 $tplcontent .=
'<!-- Include HTML header from page header block -->'.
"\n";
329 $tplcontent .= preg_replace(
'/<\/?html>/ims',
'', $objectpage->htmlheader).
"\n";
332 $tplcontent .=
'<!-- Include link to common CSS file -->'.
"\n";
333 $tplcontent .=
'<link rel="stylesheet" href="/styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'.
"\n";
336 $tplcontent .=
'<!-- Include link to common JS file -->'.
"\n";
337 $tplcontent .=
'<script nonce="'.getNonce().
'" async src="/javascript.js.php?website=<?php echo $websitekey; ?>"></script>'.
"\n";
338 $tplcontent .=
'</head>'.
"\n";
342 $tplcontent .=
'<!-- File content defined in Dolibarr website module editor -->'.
"\n";
343 $tplcontent .=
'<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
346 if ($objectpage->type_container ==
'setup') {
348 $content .=
'<?php'.
"\n";
349 $content .=
'require_once DOL_DOCUMENT_ROOT.\'/core/class/html.formsetup.class.php\';'.
"\n";
350 $content .=
'$formSetup = new FormSetup($db);'.
"\n";
351 $content .=
'?>'.
"\n";
352 $tplcontent .= $content.
"\n";
355 $tplcontent .= $objectpage->content.
"\n";
358 if ($objectpage->type_container ==
'setup') {
359 $content =
'<div id="websitetemplateconfigpage">'.
"\n";
360 $content .=
'<?php'.
"\n";
361 $content .=
'/*' .
"\n";
362 $content .=
' * Actions' .
"\n";
363 $content .=
' */' .
"\n";
364 $content .=
'$websitetemplateconf = GETPOSTINT(\'websitetemplateconf\');' .
"\n";
365 $content .=
'include DOL_DOCUMENT_ROOT.\'/core/actions_setmoduleoptions.inc.php\';' .
"\n";
366 $content .=
'' .
"\n";
367 $content .=
'/*' .
"\n";
368 $content .=
' * View' .
"\n";
369 $content .=
' */' .
"\n";
370 $content .=
'print load_fiche_titre($langs->trans(\'SetupAndProperties\'), \'\', \'title_setup\');' .
"\n";
371 $content .=
'' .
"\n";
372 $content .=
'if (!empty($message)) {' .
"\n";
373 $content .=
' print $message;' .
"\n";
374 $content .=
'}' .
"\n";
375 $content .=
'' .
"\n";
376 $content .=
'if (!empty($formSetup->items)) {' .
"\n";
377 $content .=
' $html = \'\';' .
"\n";
378 $content .=
'' .
"\n";
379 $content .=
' $html .= \'<form action="config.php" method="POST">\';' .
"\n";
380 $content .=
' // Generate hidden values from $formSetup->formHiddenInputs' .
"\n";
381 $content .=
' if (!empty($formSetup->formHiddenInputs) && is_array($formSetup->formHiddenInputs)) {' .
"\n";
382 $content .=
' foreach ($formSetup->formHiddenInputs as $hiddenKey => $hiddenValue) {' .
"\n";
383 $content .=
' $html .= \'<input type="hidden" name="\' . dol_escape_htmltag($hiddenKey) . \'" value="\' . dol_escape_htmltag($hiddenValue) . \'">\';' .
"\n";
384 $content .=
' }' .
"\n";
385 $content .=
' }' .
"\n";
386 $content .=
'' .
"\n";
387 $content .=
' // Generate output table' .
"\n";
388 $content .=
' $html .= $formSetup->generateTableOutput(true);' .
"\n";
389 $content .=
'' .
"\n";
390 $content .=
' // Submit button' .
"\n";
391 $content .=
' $html .= \'<input type="hidden" name="action" value="preview">\';' .
"\n";
392 $content .=
' $html .= \'<input type="hidden" name="websitetemplateconf" value="1">\';' .
"\n";
393 $content .=
' $html .= \'<br>\';' .
"\n";
394 $content .=
' $html .= \'<div class="form-setup-button-container center">\';' .
"\n";
395 $content .=
' $html .= \'<input class="button button-submit" type="submit" value="\' . $langs->trans("Save") . \'">\';' .
"\n";
396 $content .=
' $html .= \'</div>\';' .
"\n";
397 $content .=
' $html .= \'</form>\';' .
"\n";
398 $content .=
'' .
"\n";
399 $content .=
' print $html;' .
"\n";
400 $content .=
'}' .
"\n";
401 $content .=
'?>' .
"\n";
402 $content .=
'</div>' .
"\n";
403 $tplcontent .= $content.
"\n";
407 $tplcontent .=
'</body>'.
"\n";
408 $tplcontent .=
'</html>'.
"\n";
410 $tplcontent .=
'<?php // BEGIN PHP'.
"\n";
411 $tplcontent .=
'} catch(Exception $e) { print $e->getMessage(); }'.
"\n";
412 $tplcontent .=
'$tmp = ob_get_contents(); ob_end_clean();'.
"\n";
414 $tplcontent .=
"// Now fix the content for SEO or multilanguage\n";
416 if (strpos($objectpage->content,
'$__PAGE__KEYWORDS__') !==
false) {
417 $tplcontent .=
'$tmp = preg_replace("/^<meta name=\"keywords\" content=\".*?\" \/>/ms", "<meta name=\"keywords\" content=\"" . dolPrintHTMLForAttribute($__PAGE__KEYWORDS__ ?? "", 1) . "\" />", $tmp);'.
"\n";
419 if (strpos($objectpage->content,
'$__PAGE__TITLE__') !==
false) {
420 $tplcontent .=
'$tmp = preg_replace("/^<title>.*?<\/title>/ms", "<title>" . dolPrintHTMLForAttribute($__PAGE__TITLE__ ?? "", 1) . "</title>", $tmp);'.
"\n";
421 $tplcontent .=
'$tmp = preg_replace("/^<meta name=\"title\" content=\".*?\" \/>/ms", "<meta name=\"title\" content=\"" . dolPrintHTMLForAttribute($__PAGE__TITLE__ ?? "", 1) . "\" />", $tmp);'.
"\n";
423 if (strpos($objectpage->content,
'$__PAGE__DESC__') !==
false) {
424 $tplcontent .=
'$tmp = preg_replace("/^<meta name=\"description\" content=\".*?\" \/>/ms", "<meta name=\"description\" content=\"" . dolPrintHTMLForAttribute($__PAGE__DESC__ ?? "", 1) . "\" />", $tmp);'.
"\n";
427 if (strpos($objectpage->content,
'define("__SEO_PAGE_LANG__"') !==
false) {
428 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
429 $tplcontent .=
'$tmp = preg_replace("/^<html lang=\"[a-z]+\"/ms", "<html lang=\"" . dolPrintHTMLForAttribute(defined("__SEO_PAGE_LANG__") ? preg_replace(\'/\[_-\].*$/\', "", constant("__SEO_PAGE_LANG__")) : (empty($weblangs->shortlang) ? "'.$tmpshortlangcode.
'" : $weblangs->shortlang), 1) . "\"", $tmp);'.
"\n";
431 if (strpos($objectpage->content,
'define("__SEO_PAGE_KEYWORDS__"') !==
false) {
432 $tplcontent .=
'$tmp = preg_replace("/^<meta name=\"keywords\" content=\".*?\" \/>/ms", "<meta name=\"keywords\" content=\"" . dolPrintHTMLForAttribute(constant("__SEO_PAGE_KEYWORDS__"), 1) . "\" />", $tmp);'.
"\n";
434 if (strpos($objectpage->content,
'define("__SEO_PAGE_TITLE__"') !==
false) {
435 $tplcontent .=
'$tmp = preg_replace("/^<title>.*?<\/title>/ms", "<title>" . dolPrintHTMLForAttribute(defined("__SEO_PAGE_TITLE__") ? constant("__SEO_PAGE_TITLE__") : "", 1) . "</title>", $tmp);'.
"\n";
436 $tplcontent .=
'$tmp = preg_replace("/^<meta name=\"title\" content=\".*?\" \/>/ms", "<meta name=\"title\" content=\"" . dolPrintHTMLForAttribute(defined("__SEO_PAGE_TITLE__") ? constant("__SEO_PAGE_TITLE__") : "", 1) . "\" />", $tmp);'.
"\n";
438 if (strpos($objectpage->content,
'define("__SEO_PAGE_DESC__"') !==
false) {
439 $tplcontent .=
'$tmp = preg_replace("/^<meta name=\"description\" content=\".*?\" \/>/ms", "<meta name=\"description\" content=\"" . dolPrintHTMLForAttribute(constant("__SEO_PAGE_DESC__"), 1) . "\" />", $tmp);'.
"\n";
441 if (empty($objectpage->lang)) {
442 $tplcontent .=
'defined("__SEO_CANONICAL_URL_PARAMS__") ? ($tmp = preg_replace("/__SEO_CANONICAL_URL_PARAMS__/", dolPrintHTMLForAttributeUrl(constant("__SEO_CANONICAL_URL_PARAMS__")), $tmp)) : ($tmp = preg_replace("/\?__SEO_CANONICAL_URL_PARAMS__\"/", "\"", preg_replace("/\?__SEO_CANONICAL_URL_PARAMS__&/", "?", $tmp)));'.
"\n";
444 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
445 $tplcontent .=
'$tmp = preg_replace("/__SEO_CANONICAL_LANG__/", (defined("__SEO_PAGE_LANG__") ? preg_replace(\'/\[_-\].*$/\', "", constant("__SEO_PAGE_LANG__")) : (empty($weblangs->shortlang) ? "'.$tmpshortlangcode.
'" : $weblangs->shortlang)), $tmp);'.
"\n";
452 $tplcontent .=
"// Let modules rewrite the final page content (hook)\n";
453 $tplcontent .=
'global $hookmanager;'.
"\n";
454 $tplcontent .=
'if (is_object($hookmanager)) {'.
"\n";
455 $tplcontent .=
' $hookmanager->initHooks(array(\'websitepagecontent\'));'.
"\n";
456 $tplcontent .=
' $parameters = array(\'tmp\' => &$tmp);'.
"\n";
457 $tplcontent .=
' $hookmanager->executeHooks(\'printWebsitePageContent\', $parameters, $websitepage);'.
"\n";
458 $tplcontent .=
'}'.
"\n";
460 $tplcontent .=
"// Now output the generated page content\n";
461 $tplcontent .=
'dolWebsiteOutput($tmp, "html", '.((int) $objectpage->id).
'); dolWebsiteIncrementCounter('.((int)
$object->id).
', "'.preg_replace(
'/[^\w\-]/',
'', (
string) $objectpage->type_container).
'", '.((int) $objectpage->id).
');'.
"\n";
462 $tplcontent .=
"// END PHP ?>\n";
464 $tplcontent .=
"<?php // BEGIN PHP\n";
465 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
466 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
467 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
468 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
469 if ($objectpage->disable_waf !=
'all') {
470 if (strpos($objectpage->disable_waf,
'NOSCANAUDIOFORINJECTION') !==
false) {
471 $tplcontent .=
' define(\'NOSCANAUDIOFORINJECTION\', 1);'.
"\n";
473 if (strpos($objectpage->disable_waf,
'NOSCANIFRAMEFORINJECTION') !==
false) {
474 $tplcontent .=
' define(\'NOSCANIFRAMEFORINJECTION\', 1);'.
"\n";
476 if (strpos($objectpage->disable_waf,
'NOSCANOBJECTFORINJECTION') !==
false) {
477 $tplcontent .=
' define(\'NOSCANOBJECTFORINJECTION\', 1);'.
"\n";
479 $tplcontent .=
' require_once DOL_DOCUMENT_ROOT.\'/waf.inc.php\';'.
"\n";
481 $tplcontent .=
"}\n";
482 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
483 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
484 if (in_array($objectpage->type_container, array(
'page',
'blogpost',
'service'))) {
485 $tplcontent .=
'dol_syslog("--- Prepare content of page '.((int) $objectpage->id).
' - '.preg_replace(
'/[^\w_-]/',
'', $objectpage->pageurl).
'");'.
"\n";
487 $tplcontent .=
"// END PHP ?>\n";
489 $tplcontent .= $objectpage->content;
493 $result = file_put_contents($filetpl, $tplcontent);
515 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
524 $indexcontent =
'<?php'.
"\n";
525 $indexcontent .=
"// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
526 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
527 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
528 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
529 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
530 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
531 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
532 $indexcontent .=
"}\n";
533 $indexcontent .=
"include_once './".basename($filetpl).
"'\n";
534 $indexcontent .=
'// END PHP ?>'.
"\n";
536 $result1 = file_put_contents($fileindex, $indexcontent);
541 $objectpage =
new WebsitePage($db);
542 $objectpage->fetch(
$object->fk_default_home);
545 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
547 $dirname = dirname($fileindex);
548 foreach (explode(
',',
$object->otherlang) as $sublang) {
550 if (empty(trim($sublang))) {
553 $fileindexsub = $dirname.
'/'.$sublang.
'/index.php';
557 $indexcontent =
'<?php'.
"\n";
558 $indexcontent .=
"// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
559 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
560 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once '".$relpath.
"/master.inc.php'; } // Load master if not already loaded\n";
561 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
562 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
563 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
564 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
565 $indexcontent .=
"}\n";
566 $indexcontent .=
"include_once '".$relpath.
"/".basename($filetpl).
"'\n";
567 $indexcontent .=
'// END PHP ?>'.
"\n";
568 $result = file_put_contents($fileindexsub, $indexcontent);
569 if ($result ===
false) {
570 dol_syslog(
"Failed to write file ".$fileindexsub, LOG_WARNING);
583 $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.
'/website/samples/wrapper.php');
585 $result2 = file_put_contents($filewrapper, $wrappercontent);
591 return ($result1 && $result2);
764 global
$conf, $langs, $form, $user;
768 $dirthemes = array(
'/doctemplates/websites');
771 $arrayoftemplatesfound = array();
773 if (count($dirthemes)) {
776 foreach ($dirthemes as $dir) {
777 $dirtheme = DOL_DATA_ROOT.$dir;
779 if (is_dir($dirtheme)) {
780 $handle = opendir($dirtheme);
781 if (is_resource($handle)) {
782 while (($subdir = readdir($handle)) !==
false) {
784 if (
dol_is_file($dirtheme.
"/".$subdir) && substr($subdir, 0, 1) !=
'.' && substr($subdir, 0, 3) !=
'CVS' && preg_match(
'/\.zip$/i', $subdir)) {
785 $subdirwithoutzip = preg_replace(
'/\.zip$/i',
'', $subdir);
786 $subdirwithoutzipwithoutver = preg_replace(
'/(_exp|_dev)$/i',
'', $subdirwithoutzip);
789 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2 && preg_match(
'/_dev$/i', $subdirwithoutzip)) {
792 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1 && preg_match(
'/_exp$/i', $subdirwithoutzip)) {
796 $arrayoftemplatesfound[$subdirwithoutzip] = array(
'id' => $subdirwithoutzip);
805 $arrayofsourcetemplates =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/install/doctemplates/websites',
'directories', 0,
'website_.*$');
806 $arrayofsourcetemplatesnotdeployed = array();
807 foreach ($arrayofsourcetemplates as $val) {
809 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2 && preg_match(
'/_dev$/i', $val[
'relativename'])) {
812 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1 && preg_match(
'/_exp$/i', $val[
'relativename'])) {
816 if (empty($arrayoftemplatesfound[$val[
'relativename']])) {
819 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/websites/'.$val[
'name'];
820 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$val[
'name'];
827 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
829 dol_syslog(
"Error in compress of dir ".$src, LOG_ERR);
832 $srcfile = DOL_DOCUMENT_ROOT.
'/install/doctemplates/websites/'.preg_replace(
'/(_exp|_dev)$/',
'', $val[
'name']).
'.jpg';
833 $destfile = DOL_DATA_ROOT.
'/doctemplates/websites/'.preg_replace(
'/(_exp|_dev)$/',
'', $val[
'name']).
'.jpg';
837 $arrayofsourcetemplatesnotdeployed[$val[
'relativename']] = $val;
842 if (count($arrayofsourcetemplatesnotdeployed)) {
843 $warningtoshow = img_picto($langs->trans(
"WarningTemplatesFoundNotDeployedClickRefresh").
': '.implode(
', ', array_keys($arrayofsourcetemplatesnotdeployed)).
'. '.$langs->trans(
"WarningTemplatesFoundNotDeployedClickRefresh2"),
'warning',
'class="valignmiddle paddingright"');
849 $importButtonIsDisabled = 0;
851 global $dolibarr_website_allow_custom_php;
852 if (!empty($dolibarr_website_allow_custom_php) && $dolibarr_website_allow_custom_php == 1) {
853 $notdisabledsystemfunction =
'';
854 $systemfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"popen",
"proc_open");
855 foreach ($systemfunctions as $systemfunction) {
857 if (function_exists($systemfunction)) {
858 $notdisabledsystemfunction .= ($notdisabledsystemfunction ?
', ' :
'').$systemfunction;
861 if ($notdisabledsystemfunction) {
862 print
'<div class="warning">';
863 print $langs->trans(
"ImportOfWebsiteTemplateIncludingPHPIsAllowedIf",
'warning');
866 $importButtonIsDisabled = 1;
869 if (empty($dolibarr_website_allow_custom_php)) {
870 print
'<div class="warning">';
871 print $langs->trans(
"ImportOfWebsiteTemplateIncludingPHPIsDisabled",
'warning');
874 $importButtonIsDisabled = 1;
877 print
'<!-- For website template import -->'.
"\n";
878 print
'<table class="noborder centpercent">';
881 print
'<tr class="liste_titre"><th class="titlefield">';
882 print $form->textwithpicto($langs->trans(
"Templates"), $langs->trans(
"ThemeDir").
' : '.implode(
", ", $dirthemes));
884 print
'<a class="valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&importsite=2" rel="noopener noreferrer external">';
885 print $warningtoshow;
886 print img_picto($langs->trans(
"Refresh"),
'refresh',
'class="valignmiddle"');
889 print
'<th class="right">';
890 $url =
'https://www.dolistore.com/index.php?cat=84';
891 print
'<a href="'.$url.
'" target="_blank" rel="noopener noreferrer external">';
892 print img_picto(
'',
'globe',
'class="pictofixedwidth"').$langs->trans(
'DownloadMoreSkins');
896 print
'<tr><td colspan="'.$colspan.
'">';
898 print
'<table class="nobordernopadding centpercent"><tr><td><div class="display-flex">';
900 if (count($dirthemes)) {
902 foreach ($dirthemes as $dir) {
903 $dirtheme = DOL_DATA_ROOT.$dir;
905 if (is_dir($dirtheme)) {
906 $handle = opendir($dirtheme);
907 if (is_resource($handle)) {
908 while (($subdir = readdir($handle)) !==
false) {
910 if (
dol_is_file($dirtheme.
"/".$subdir) && substr($subdir, 0, 1) !=
'.' && substr($subdir, 0, 3) !=
'CVS' && preg_match(
'/\.zip$/i', $subdir)) {
911 $subdirwithoutzip = preg_replace(
'/\.zip$/i',
'', $subdir);
912 $subdirwithoutzipwithoutver = preg_replace(
'/(_exp|_dev)$/i',
'', $subdirwithoutzip);
915 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2 && preg_match(
'/_dev$/i', $subdirwithoutzip)) {
918 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1 && preg_match(
'/_exp$/i', $subdirwithoutzip)) {
922 $arrayoftemplatesfound[$subdirwithoutzip] = array(
'id' => $subdirwithoutzip);
924 print
'<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px; margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
926 $templatedir = $dirtheme.
"/".$subdir;
927 $file = $dirtheme.
"/".$subdirwithoutzipwithoutver.
".jpg";
928 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzipwithoutver.
".jpg";
930 if (!file_exists($file)) {
931 $url = DOL_URL_ROOT.
'/public/theme/common/nophoto.png';
934 $originalimgfile = basename($file);
935 $entity =
$conf->entity;
936 $modulepart =
'doctemplateswebsite';
942 if (!empty($urladvanced)) {
943 $ret .=
'<a class="'.$urladvanced[
'css'].
'" target="'.$urladvanced[
'target'].
'" mime="'.$urladvanced[
'mime'].
'" href="'.$urladvanced[
'url'].
'">';
945 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.((int) $entity).
'&file='.urlencode($originalimgfile).
'&cache='.((int) $cache).
'">';
948 print
'<img class="img-skinthumb shadow" src="'.$url.
'" border="0" alt="'.$title.
'" title="'.$title.
'" style="margin-bottom: 5px;">';
955 if ($user->hasRight(
'website',
'delete')) {
956 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?action=deletetemplate&token='.
newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'">'.img_picto(
'',
'delete').
'</a>';
958 print
'<br><a href="'.$_SERVER[
"PHP_SELF"].
'?action=importsiteconfirm&token='.
newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'" class="button'.($importButtonIsDisabled ?
' disabled' :
'').
'">'.$langs->trans(
"Load").
'</a>';
964 print
'<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
965 print
'<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
966 print
'<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
967 print
'<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
968 print
'<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
973 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
976 print
'</div></td></tr></table>';
1000 global $langs, $user;
1004 if (empty($phpfullcodestringold) && empty($phpfullcodestring)) {
1009 if ($phpfullcodestringold != $phpfullcodestring) {
1010 global $dolibarr_website_allow_custom_php;
1011 if (empty($dolibarr_website_allow_custom_php)) {
1013 setEventMessages($langs->trans(
"NotAllowedToAddDynamicContentDisabledGlobaly",
'dolibarr_website_allow_custom_php'),
null,
'errors');
1014 } elseif ($dolibarr_website_allow_custom_php == 1) {
1015 $notdisabledsystemfunction =
'';
1016 $systemfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"popen",
"proc_open");
1017 foreach ($systemfunctions as $systemfunction) {
1019 if (function_exists($systemfunction)) {
1020 $notdisabledsystemfunction .= ($notdisabledsystemfunction ?
', ' :
'').$systemfunction;
1023 if ($notdisabledsystemfunction) {
1025 $langs->load(
"errors");
1026 setEventMessages($langs->trans(
"ErrorDynamicPHPContentNotAllowed",
'dolibarr_website_allow_custom_php'),
null,
'errors');
1030 if (!$error && !$user->hasRight(
'website',
'writephp')) {
1032 setEventMessages($langs->trans(
"NotAllowedToAddDynamicContent"),
null,
'errors');
1036 $phpfullcodestringnew = $phpfullcodestring;
1041 $phpfullcodestring = preg_replace(
'/\$_COOKIE\[/',
'__DOLLARCOOKIE__', $phpfullcodestring);
1042 $phpfullcodestring = preg_replace(
'/\$_FILES\[/',
'__DOLLARFILES__', $phpfullcodestring);
1043 $phpfullcodestring = preg_replace(
'/\$_SESSION\[/',
'__DOLLARSESSION__', $phpfullcodestring);
1044 $forbiddenphpstrings = array(
'$$',
'$_',
'}[');
1046 $forbiddenphpstrings = array(
'$$',
'}[');
1049 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'ReflectionFunction'));
1051 $forbiddenphpfunctions = array();
1053 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
1054 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
1055 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"call_user_func",
"call_user_func_array"));
1062 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"ob_start"));
1065 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"call_user_func",
"call_user_func_array"));
1068 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"preg_replace_callback",
"preg_replace_callback_array",
"header_register_callback"));
1069 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"error_log",
"set_error_handler",
"set_exception_handler",
"libxml_set_external_entity_loader",
"register_shutdown_function",
"register_tick_function",
"unregister_tick_function"));
1070 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"spl_autoload_register",
"spl_autoload_unregister",
"iterator_apply",
"session_set_save_handler"));
1071 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"forward_static_call",
"forward_static_call_array",
"register_postsend_function"));
1072 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"readline_completion_function",
"readline_callback_handler_install"));
1075 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
1076 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"pcntl_alarm",
"pcntl_exec",
"pcntl_fork",
"pcntl_waitpid",
"pcntl_wait",
"pcntl_wifexited",
"pcntl_wifstopped",
"pcntl_wifsignaled",
"pcntl_wifcontinued",
"pcntl_wexitstatus",
"pcntl_wtermsig",
"pcntl_wstopsig",
"pcntl_signal"));
1077 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"pcntl_signal_get_handler",
"pcntl_signal_dispatch",
"pcntl_get_last_error",
"pcntl_strerror",
"pcntl_sigprocmask",
"pcntl_sigwaitinfo",
"pcntl_sigtimedwait",
"pcntl_getpriority",
"pcntl_async_signals",
"pcntl_unshare", ));
1078 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"putenv",
"dl",
"apache_child_terminate",
"apache_setenv"));
1079 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"dol_eval_new",
"dol_eval_standard",
"executeCLI",
"verifCond",
"dolEncrypt",
"dolDecrypt"));
1080 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
1086 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_compress_dir",
"dol_decode",
"dol_dir_list",
"dol_dir_list_in_database",
"dol_delete_file",
"dol_delete_dir",
"dol_delete_dir_recursive",
"dol_copy",
"archiveOrBackupFile"));
1087 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"chdir",
"dir",
"fopen",
"file",
"file_exists",
"file_get_contents",
"file_put_contents",
"fget",
"fgetc",
"fgetcsv",
"flock",
"fputs",
"fputscsv",
"fpassthru",
"fscanf",
"fseek",
"fwrite",
"is_file",
"is_dir",
"is_link",
"mkdir",
"opendir",
"rmdir",
"scandir",
"symlink",
"touch",
"unlink",
"umask"));
1090 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_decode"));
1091 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"file",
"fopen",
"file_get_contents",
"fgets",
"fgetscsv",
"fgetss",
"fread"));
1094 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
1096 foreach ($forbiddenphpstrings as $forbiddenphpstring) {
1097 if (preg_match(
'/'.preg_quote($forbiddenphpstring,
'/').
'/ims', $phpfullcodestring)) {
1099 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpstring),
null,
'errors');
1111 foreach ($forbiddenphpfunctions as $forbiddenphpfunction) {
1113 if (preg_match(
'/\b'.$forbiddenphpfunction.
'(=| class=|\b)/ims', $phpfullcodestring, $reg)) {
1114 if ($reg[1] !=
'=' && $reg[1] !=
' class=') {
1117 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpfunction),
null,
'errors');
1123 foreach ($forbiddenphpmethods as $forbiddenphpmethod) {
1124 if (preg_match(
'/->'.$forbiddenphpmethod.
'/ims', $phpfullcodestring)) {
1126 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpmethod),
null,
'errors');
1134 $forbiddenphpchars = array();
1136 $forbiddenphpchars = array(
"`");
1138 foreach ($forbiddenphpchars as $forbiddenphpchar) {
1139 if (preg_match(
'/'.$forbiddenphpchar.
'/ims', $phpfullcodestring)) {
1141 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar),
null,
'errors');
1149 if (preg_match(
'/\*\/\s*\(/ims', $phpfullcodestring)) {
1151 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
"exec/*...*/ ('ls')"),
null,
'errors');
1157 if (preg_match(
'/[}\]]\s*\(/ims', $phpfullcodestring)) {
1159 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
']('),
null,
'errors');
1165 if (preg_match(
'/\$[a-z0-9_\-\/\*\"]+\s*\(/ims', $phpfullcodestring)) {
1167 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
'$...('),
null,
'errors');
1174 if ($phpfullcodestringold != $phpfullcodestringnew) {
1176 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
1177 $allowimportsite =
true;
1178 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1179 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
1180 $allowimportsite =
false;
1183 if (!$allowimportsite) {
1188 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
1191 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
1193 setEventMessages($message,
null,
'errors');
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined: