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 // BEGIN PHP\n";
282 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
283 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
284 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
285 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
286 $tplcontent .=
"} // Not already loaded\n";
287 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
288 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
289 $tplcontent .=
"// END PHP ?>\n";
291 $tplcontent .= $objectpage->content;
295 $result = file_put_contents($filetpl, $tplcontent);
324 $indexcontent =
'<?php'.
"\n";
325 $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";
326 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
327 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
328 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
329 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
330 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
331 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
332 $indexcontent .=
"}\n";
333 $indexcontent .=
"include_once './".basename($filetpl).
"'\n";
334 $indexcontent .=
'// END PHP ?>'.
"\n";
336 $result1 = file_put_contents($fileindex, $indexcontent);
342 $objectpage->fetch(
$object->fk_default_home);
345 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
347 $dirname = dirname($fileindex);
348 foreach (explode(
',',
$object->otherlang) as $sublang) {
350 if (empty(trim($sublang))) {
353 $fileindexsub = $dirname.
'/'.$sublang.
'/index.php';
357 $indexcontent =
'<?php'.
"\n";
358 $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";
359 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
360 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once '".$relpath.
"/master.inc.php'; } // Load master if not already loaded\n";
361 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
362 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
363 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
364 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
365 $indexcontent .=
"}\n";
366 $indexcontent .=
"include_once '".$relpath.
"/".basename($filetpl).
"'\n";
367 $indexcontent .=
'// END PHP ?>'.
"\n";
368 $result = file_put_contents($fileindexsub, $indexcontent);
369 if ($result ===
false) {
370 dol_syslog(
"Failed to write file ".$fileindexsub, LOG_WARNING);
383 $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.
'/website/samples/wrapper.php');
385 $result2 = file_put_contents($filewrapper, $wrappercontent);
391 return ($result1 && $result2);
404 global $pathofwebsite;
406 dol_syslog(
"Save html header into ".$filehtmlheader);
409 $result = file_put_contents($filehtmlheader, $htmlheadercontent);
424 global $pathofwebsite;
429 $result = file_put_contents($filecss, $csscontent);
444 global $pathofwebsite;
449 $result = file_put_contents($filejs, $jscontent);
464 global $pathofwebsite;
466 dol_syslog(
"Save robot file into ".$filerobot);
469 $result = file_put_contents($filerobot, $robotcontent);
484 global $pathofwebsite;
486 dol_syslog(
"Save htaccess file into ".$filehtaccess);
489 $result = file_put_contents($filehtaccess, $htaccess);
504 global $pathofwebsite;
506 dol_syslog(
"Save manifest.js.php file into ".$file);
509 $result = file_put_contents($file, $content);
524 global $pathofwebsite;
526 dol_syslog(
"Save README.md file into ".$file);
529 $result = file_put_contents($file, $content);
544 global $pathofwebsite;
549 $result = file_put_contents($file, $content);
563 global $conf, $langs, $form, $user;
565 $dirthemes = array(
'/doctemplates/websites');
573 $dirthemes = array_unique($dirthemes);
578 print
'<!-- For website template import -->'.
"\n";
579 print
'<table class="noborder centpercent">';
582 print
'<tr class="liste_titre"><th class="titlefield">';
583 print $form->textwithpicto($langs->trans(
"Templates"), $langs->trans(
"ThemeDir").
' : '.implode(
", ", $dirthemes));
585 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&importsite=1" rel="noopener noreferrer external">';
589 print
'<th class="right">';
590 $url =
'https://www.dolistore.com/43-web-site-templates';
591 print
'<a href="'.$url.
'" target="_blank" rel="noopener noreferrer external">';
592 print
img_picto(
'',
'globe',
'class="pictofixedwidth"').$langs->trans(
'DownloadMoreSkins');
596 print
'<tr><td colspan="'.$colspan.
'">';
598 print
'<table class="nobordernopadding centpercent"><tr><td><div class="display-flex">';
600 if (count($dirthemes)) {
602 foreach ($dirthemes as $dir) {
603 if (preg_match(
'/^\/doctemplates\//', $dir)) {
604 $dirtheme = DOL_DATA_ROOT.$dir;
608 if (is_dir($dirtheme)) {
609 $handle = opendir($dirtheme);
610 if (is_resource($handle)) {
611 while (($subdir = readdir($handle)) !==
false) {
613 if (is_file($dirtheme.
"/".$subdir) && substr($subdir, 0, 1) !=
'.' && substr($subdir, 0, 3) !=
'CVS' && preg_match(
'/\.zip$/i', $subdir)) {
614 $subdirwithoutzip = preg_replace(
'/\.zip$/i',
'', $subdir);
617 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2 && preg_match(
'/_dev$/i', $subdir)) {
620 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1 && preg_match(
'/_exp$/i', $subdir)) {
624 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;">';
626 $templatedir = $dirtheme.
"/".$subdir;
627 $file = $dirtheme.
"/".$subdirwithoutzip.
".jpg";
628 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.
".jpg";
630 if (!file_exists($file)) {
631 $url = DOL_URL_ROOT.
'/public/theme/common/nophoto.png';
634 $originalfile = basename($file);
635 $entity = $conf->entity;
636 $modulepart =
'doctemplateswebsite';
642 if (!empty($urladvanced)) {
643 $ret .=
'<a class="'.$urladvanced[
'css'].
'" target="'.$urladvanced[
'target'].
'" mime="'.$urladvanced[
'mime'].
'" href="'.$urladvanced[
'url'].
'">';
645 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.((int) $entity).
'&file='.urlencode($originalfile).
'&cache='.((int) $cache).
'">';
648 print
'<img class="img-skinthumb shadow" src="'.$url.
'" border="0" alt="'.$title.
'" title="'.$title.
'" style="margin-bottom: 5px;">';
655 if ($user->hasRight(
'website',
'delete')) {
656 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?action=deletetemplate&token='.newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'">'.
img_picto(
'',
'delete').
'</a>';
658 print
'<br><a href="'.$_SERVER[
"PHP_SELF"].
'?action=importsiteconfirm&token='.newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'" class="button">'.$langs->trans(
"Load").
'</a>';
664 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>';
665 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>';
666 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>';
667 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>';
668 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>';
673 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
676 print
'</div></td></tr></table>';
695 global $langs, $user;
699 if (empty($phpfullcodestringold) && empty($phpfullcodestring)) {
704 if ($phpfullcodestringold != $phpfullcodestring) {
705 if (!$error && !$user->hasRight(
'website',
'writephp')) {
707 setEventMessages($langs->trans(
"NotAllowedToAddDynamicContent"),
null,
'errors');
713 $forbiddenphpcommands = array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id");
715 $forbiddenphpcommands = array_merge($forbiddenphpcommands, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen",
"eval",
"dol_eval",
"executeCLI"));
718 $forbiddenphpcommands = array_merge($forbiddenphpcommands, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"unlink",
"mkdir",
"rmdir",
"symlink",
"touch",
"umask"));
720 foreach ($forbiddenphpcommands as $forbiddenphpcommand) {
721 if (preg_match(
'/'.$forbiddenphpcommand.
'\s*\(/ms', $phpfullcodestring)) {
723 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand),
null,
'errors');
731 $forbiddenphpchars = array();
733 $forbiddenphpchars = array(
"`");
735 foreach ($forbiddenphpchars as $forbiddenphpchar) {
736 if (preg_match(
'/'.$forbiddenphpchar.
'/ms', $phpfullcodestring)) {
738 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar),
null,
'errors');
746 if (preg_match(
'/[}\]]\(/ims', $phpfullcodestring)) {
748 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
']('),
null,
'errors');
754 if (preg_match(
'/\$[a-z0-9_\-\/\*]+\(/ims', $phpfullcodestring)) {
756 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
'$...('),
null,
'errors');
763 if ($phpfullcodestringold != $phpfullcodestring) {
765 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
766 $allowimportsite =
true;
767 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
768 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
769 $allowimportsite =
false;
772 if (!$allowimportsite) {
777 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
780 $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($srcfile, $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).
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.