34 dol_syslog(
"We regenerate the master.inc.php file");
38 $mastercontent =
'<?php'.
"\n";
39 $mastercontent .=
'// File generated to link to the master file - DO NOT MODIFY - It is just an include'.
"\n";
40 $mastercontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
41 $mastercontent .=
" if (! defined('USEEXTERNALSERVER')) define('USEEXTERNALSERVER', 1);\n";
42 $mastercontent .=
" require_once '".DOL_DOCUMENT_ROOT.
"/master.inc.php';\n";
43 $mastercontent .=
"}\n";
44 $mastercontent .=
'?>'.
"\n";
45 $result = file_put_contents($filemaster, $mastercontent);
64 dol_syslog(
"dolSavePageAlias We regenerate the alias page filealias=".$filealias.
" and a wrapper into all language subdirectories");
66 $aliascontent =
'<?php'.
"\n";
67 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
68 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
69 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.
'.tpl.php\'; ';
70 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
71 $aliascontent .=
'?>'.
"\n";
72 $result = file_put_contents($filealias, $aliascontent);
73 if ($result ===
false) {
74 dol_syslog(
"Failed to write file ".$filealias, LOG_WARNING);
79 if ($objectpage->lang && in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
80 $dirname = dirname($filealias);
81 $filename = basename($filealias);
82 $filealiassub = $dirname.
'/'.$objectpage->lang.
'/'.$filename;
84 dol_mkdir($dirname.
'/'.$objectpage->lang, DOL_DATA_ROOT);
86 $aliascontent =
'<?php'.
"\n";
87 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
88 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
89 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'../page'.$objectpage->id.
'.tpl.php\'; ';
90 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
91 $aliascontent .=
'?>'.
"\n";
92 $result = file_put_contents($filealiassub, $aliascontent);
93 if ($result ===
false) {
94 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
97 } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
100 $dirname = dirname($filealias);
101 $filename = basename($filealias);
102 foreach (explode(
',',
$object->otherlang) as $sublang) {
104 if (empty(trim($sublang))) {
107 $filealiassub = $dirname.
'/'.$sublang.
'/'.$filename;
109 $aliascontent =
'<?php'.
"\n";
110 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
111 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
112 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'../page'.$objectpage->id.
'.tpl.php\'; ';
113 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
114 $aliascontent .=
'?>'.
"\n";
117 $result = file_put_contents($filealiassub, $aliascontent);
118 if ($result ===
false) {
119 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
126 return ($result ?
true :
false);
146 dol_syslog(
"dolSavePageContent We regenerate the tpl page filetpl=".$filetpl);
148 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
162 if ($objectpage->lang) {
163 $shortlangcode = substr($objectpage->lang, 0, 2);
165 if (empty($shortlangcode)) {
166 $shortlangcode = substr(
$object->lang, 0, 2);
169 if (!empty($objectpage->type_container) && in_array($objectpage->type_container, array(
'library',
'service'))) {
170 $originalcontentonly = 1;
174 if (!isset($originalcontentonly)) {
175 $tplcontent .=
"<?php // BEGIN PHP\n";
176 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
177 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
178 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
179 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
180 $tplcontent .=
"} // Not already loaded\n";
181 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
182 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
183 $tplcontent .=
"ob_start();\n";
184 $tplcontent .=
"// END PHP ?>\n";
186 $tplcontent .=
"<!DOCTYPE html>\n";
188 $tplcontent .=
'<html'.($shortlangcode ?
' lang="'.$shortlangcode.
'"' :
'').
'>'.
"\n";
189 $tplcontent .=
'<head>'.
"\n";
190 $tplcontent .=
'<title>'.dol_string_nohtmltag($objectpage->title, 0,
'UTF-8').
'</title>'.
"\n";
191 $tplcontent .=
'<meta charset="utf-8">'.
"\n";
192 $tplcontent .=
'<meta http-equiv="content-type" content="text/html; charset=utf-8" />'.
"\n";
193 $tplcontent .=
'<meta name="robots" content="index, follow" />'.
"\n";
194 $tplcontent .=
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
195 $tplcontent .=
'<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).
'" />'.
"\n";
196 $tplcontent .=
'<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0,
'UTF-8').
'" />'.
"\n";
197 $tplcontent .=
'<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0,
'UTF-8').
'" />'.
"\n";
198 $tplcontent .=
'<meta name="generator" content="'.DOL_APPLICATION_TITLE.
' '.DOL_VERSION.
' (https://www.dolibarr.org)" />'.
"\n";
199 $tplcontent .=
'<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).
'" />'.
"\n";
202 if ($objectpage->id ==
$object->fk_default_home) {
203 $tplcontent .=
'<link rel="icon" type="image/png" href="/favicon.png" />'.
"\n";
208 $tplcontent .=
'<link rel="canonical" href="'.(($objectpage->id ==
$object->fk_default_home) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$shortlangcode :
'').
'/'.$objectpage->pageurl.
'.php')).
'" />'.
"\n";
213 $translationof = $objectpage->fk_page;
214 if ($translationof) {
216 $tmppage->fetch($translationof);
217 if ($tmppage->id > 0) {
218 $tmpshortlangcode =
'';
219 if ($tmppage->lang) {
220 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
222 if (empty($tmpshortlangcode)) {
223 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
225 if ($tmpshortlangcode != $shortlangcode) {
226 $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";
232 $sql =
"SELECT rowid as id, lang, pageurl from ".MAIN_DB_PREFIX.
'website_page where fk_page IN ('.$db->sanitize($objectpage->id.($translationof ?
", ".$translationof :
'')).
")";
233 $resql = $db->query($sql);
235 $num_rows = $db->num_rows($resql);
237 while ($obj = $db->fetch_object($resql)) {
238 $tmpshortlangcode =
'';
240 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $obj->lang);
242 if ($tmpshortlangcode != $shortlangcode) {
243 $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";
252 $tplcontent .=
'<?php if ($_SERVER["PHP_SELF"] == "'.(($object->fk_default_home == $objectpage->id) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$shortlangcode :
'')).
'/'.$objectpage->pageurl.
'.php") { ?>'.
"\n";
253 $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";
255 $tplcontent .=
'<?php } ?>'.
"\n";
258 $tplcontent .=
'<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'.
"\n";
259 $tplcontent .=
'<!-- Include link to CSS file -->'.
"\n";
261 $tplcontent .=
'<link rel="stylesheet" href="/styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'.
"\n";
262 $tplcontent .=
'<!-- Include link to JS file -->'.
"\n";
263 $tplcontent .=
'<script nonce="'.getNonce().
'" async src="/javascript.js.php?website=<?php echo $websitekey; ?>"></script>'.
"\n";
265 $tplcontent .=
'<!-- Include HTML header from common file -->'.
"\n";
266 $tplcontent .=
'<?php if (file_exists(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")) include DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html"; ?>'.
"\n";
267 $tplcontent .=
'<!-- Include HTML header from page header block -->'.
"\n";
268 $tplcontent .= preg_replace(
'/<\/?html>/ims',
'', $objectpage->htmlheader).
"\n";
269 $tplcontent .=
'</head>'.
"\n";
271 $tplcontent .=
'<!-- File generated by Dolibarr website module editor -->'.
"\n";
272 $tplcontent .=
'<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
273 $tplcontent .= $objectpage->content.
"\n";
274 $tplcontent .=
'</body>'.
"\n";
275 $tplcontent .=
'</html>'.
"\n";
277 $tplcontent .=
'<?php // BEGIN PHP'.
"\n";
278 $tplcontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.
'); dolWebsiteIncrementCounter('.
$object->id.
', "'.$objectpage->type_container.
'", '.$objectpage->id.
');'.
"\n";
279 $tplcontent .=
"// END PHP ?>\n";
281 $tplcontent .=
"<?php\n// This is a library page.\n?>\n";
282 $tplcontent .= $objectpage->content;
286 $result = file_put_contents($filetpl, $tplcontent);
315 $indexcontent =
'<?php'.
"\n";
316 $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";
317 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
318 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
319 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
320 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
321 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
322 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
323 $indexcontent .=
"}\n";
324 $indexcontent .=
"include_once './".basename($filetpl).
"'\n";
325 $indexcontent .=
'// END PHP ?>'.
"\n";
327 $result1 = file_put_contents($fileindex, $indexcontent);
333 $objectpage->fetch(
$object->fk_default_home);
336 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
338 $dirname = dirname($fileindex);
339 foreach (explode(
',',
$object->otherlang) as $sublang) {
341 if (empty(trim($sublang))) {
344 $fileindexsub = $dirname.
'/'.$sublang.
'/index.php';
348 $indexcontent =
'<?php'.
"\n";
349 $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";
350 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
351 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once '".$relpath.
"/master.inc.php'; } // Load master if not already loaded\n";
352 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
353 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
354 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
355 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
356 $indexcontent .=
"}\n";
357 $indexcontent .=
"include_once '".$relpath.
"/".basename($filetpl).
"'\n";
358 $indexcontent .=
'// END PHP ?>'.
"\n";
359 $result = file_put_contents($fileindexsub, $indexcontent);
360 if ($result ===
false) {
361 dol_syslog(
"Failed to write file ".$fileindexsub, LOG_WARNING);
374 $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.
'/website/samples/wrapper.php');
376 $result2 = file_put_contents($filewrapper, $wrappercontent);
382 return ($result1 && $result2);
395 global $pathofwebsite;
397 dol_syslog(
"Save html header into ".$filehtmlheader);
400 $result = file_put_contents($filehtmlheader, $htmlheadercontent);
415 global $pathofwebsite;
420 $result = file_put_contents($filecss, $csscontent);
435 global $pathofwebsite;
440 $result = file_put_contents($filejs, $jscontent);
455 global $pathofwebsite;
457 dol_syslog(
"Save robot file into ".$filerobot);
460 $result = file_put_contents($filerobot, $robotcontent);
475 global $pathofwebsite;
477 dol_syslog(
"Save htaccess file into ".$filehtaccess);
480 $result = file_put_contents($filehtaccess, $htaccess);
495 global $pathofwebsite;
497 dol_syslog(
"Save manifest.js.php file into ".$file);
500 $result = file_put_contents($file, $content);
515 global $pathofwebsite;
517 dol_syslog(
"Save README.md file into ".$file);
520 $result = file_put_contents($file, $content);
535 global $pathofwebsite;
540 $result = file_put_contents($file, $content);
554 global $conf, $langs, $form, $user;
556 $dirthemes = array(
'/doctemplates/websites');
564 $dirthemes = array_unique($dirthemes);
569 print
'<!-- For website template import -->'.
"\n";
570 print
'<table class="noborder centpercent">';
573 print
'<tr class="liste_titre"><th class="titlefield">';
574 print $form->textwithpicto($langs->trans(
"Templates"), $langs->trans(
"ThemeDir").
' : '.implode(
", ", $dirthemes));
576 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&importsite=1" rel="noopener noreferrer external">';
580 print
'<th class="right">';
581 $url =
'https://www.dolistore.com/43-web-site-templates';
582 print
'<a href="'.$url.
'" target="_blank" rel="noopener noreferrer external">';
583 print
img_picto(
'',
'globe',
'class="pictofixedwidth"').$langs->trans(
'DownloadMoreSkins');
587 print
'<tr><td colspan="'.$colspan.
'">';
589 print
'<table class="nobordernopadding centpercent"><tr><td><div class="display-flex">';
591 if (count($dirthemes)) {
593 foreach ($dirthemes as $dir) {
594 if (preg_match(
'/^\/doctemplates\//', $dir)) {
595 $dirtheme = DOL_DATA_ROOT.$dir;
599 if (is_dir($dirtheme)) {
600 $handle = opendir($dirtheme);
601 if (is_resource($handle)) {
602 while (($subdir = readdir($handle)) !==
false) {
604 if (is_file($dirtheme.
"/".$subdir) && substr($subdir, 0, 1) !=
'.' && substr($subdir, 0, 3) !=
'CVS' && preg_match(
'/\.zip$/i', $subdir)) {
605 $subdirwithoutzip = preg_replace(
'/\.zip$/i',
'', $subdir);
608 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2 && preg_match(
'/_dev$/i', $subdir)) {
611 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1 && preg_match(
'/_exp$/i', $subdir)) {
615 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;">';
617 $templatedir = $dirtheme.
"/".$subdir;
618 $file = $dirtheme.
"/".$subdirwithoutzip.
".jpg";
619 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.
".jpg";
621 if (!file_exists($file)) {
622 $url = DOL_URL_ROOT.
'/public/theme/common/nophoto.png';
625 $originalfile = basename($file);
626 $entity = $conf->entity;
627 $modulepart =
'doctemplateswebsite';
633 if (!empty($urladvanced)) {
634 $ret .=
'<a class="'.$urladvanced[
'css'].
'" target="'.$urladvanced[
'target'].
'" mime="'.$urladvanced[
'mime'].
'" href="'.$urladvanced[
'url'].
'">';
636 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.((int) $entity).
'&file='.urlencode($originalfile).
'&cache='.((int) $cache).
'">';
639 print
'<img class="img-skinthumb shadow" src="'.$url.
'" border="0" alt="'.$title.
'" title="'.$title.
'" style="margin-bottom: 5px;">';
646 if ($user->hasRight(
'website',
'delete')) {
647 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?action=deletetemplate&token='.
newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'">'.
img_picto(
'',
'delete').
'</a>';
649 print
'<br><a href="'.$_SERVER[
"PHP_SELF"].
'?action=importsiteconfirm&token='.
newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'" class="button">'.$langs->trans(
"Load").
'</a>';
655 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>';
656 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>';
657 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>';
658 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>';
659 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>';
664 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
667 print
'</div></td></tr></table>';
686 global $langs, $user;
690 if (empty($phpfullcodestringold) && empty($phpfullcodestring)) {
695 if ($phpfullcodestringold != $phpfullcodestring) {
696 if (!$error && !$user->hasRight(
'website',
'writephp')) {
698 setEventMessages($langs->trans(
"NotAllowedToAddDynamicContent"),
null,
'errors');
704 $forbiddenphpstrings = array(
'$$',
'}[');
705 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'ReflectionFunction'));
707 $forbiddenphpfunctions = array();
708 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
709 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
710 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"call_user_func"));
713 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
714 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
715 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
718 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
721 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
723 foreach ($forbiddenphpstrings as $forbiddenphpstring) {
724 if (preg_match(
'/'.preg_quote($forbiddenphpstring,
'/').
'/ms', $phpfullcodestring)) {
726 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpstring),
null,
'errors');
730 foreach ($forbiddenphpfunctions as $forbiddenphpcommand) {
731 if (preg_match(
'/'.$forbiddenphpcommand.
'\s*\(/ms', $phpfullcodestring)) {
733 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand),
null,
'errors');
737 foreach ($forbiddenphpmethods as $forbiddenphpmethod) {
738 if (preg_match(
'/->'.$forbiddenphpmethod.
'/ms', $phpfullcodestring)) {
740 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpmethod),
null,
'errors');
748 $forbiddenphpchars = array();
750 $forbiddenphpchars = array(
"`");
752 foreach ($forbiddenphpchars as $forbiddenphpchar) {
753 if (preg_match(
'/'.$forbiddenphpchar.
'/ms', $phpfullcodestring)) {
755 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar),
null,
'errors');
763 if (preg_match(
'/[}\]]\(/ims', $phpfullcodestring)) {
765 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
']('),
null,
'errors');
771 if (preg_match(
'/\$[a-z0-9_\-\/\*]+\(/ims', $phpfullcodestring)) {
773 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
'$...('),
null,
'errors');
780 if ($phpfullcodestringold != $phpfullcodestring) {
782 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
783 $allowimportsite =
true;
784 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
785 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
786 $allowimportsite =
false;
789 if (!$allowimportsite) {
794 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
797 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
archiveOrBackupFile($filetpl, $max_versions=5, $archivedir='', $suffix="v", $moveorcopy='move')
Manage backup versions for a given file, ensuring only a maximum number of versions are kept.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dolSaveMasterFile($filemaster)
Save content of a page on disk.
showWebsiteTemplates(Website $website)
Show list of themes.
dolSaveLicense($file, $content)
Save content of a page on disk.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check a new string containing only php code (including <php tag)
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
dolSaveReadme($file, $content)
Save content of a page on disk.
dolSaveManifestJson($file, $content)
Save content of a page on disk.
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object=null)
Save content of the index.php and/or the wrapper.php page.
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold=0)
Save content of a page on disk (page name is generally ID_of_page.php).
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.