35 dol_syslog(
"We regenerate the master.inc.php file");
39 $mastercontent =
'<?php'.
"\n";
40 $mastercontent .=
'// File generated to link to the master file - DO NOT MODIFY - It is just an include'.
"\n";
41 $mastercontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
42 $mastercontent .=
" if (! defined('USEEXTERNALSERVER')) define('USEEXTERNALSERVER', 1);\n";
43 $mastercontent .=
" require_once '".DOL_DOCUMENT_ROOT.
"/master.inc.php';\n";
44 $mastercontent .=
"}\n";
45 $mastercontent .=
'?>'.
"\n";
46 $result = file_put_contents($filemaster, $mastercontent);
65 dol_syslog(
"dolSavePageAlias We regenerate the alias page filealias=".$filealias.
" and a wrapper into all language subdirectories");
67 $aliascontent =
'<?php'.
"\n";
68 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
69 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
70 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.
'.tpl.php\'; ';
71 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
72 $aliascontent .=
'?>'.
"\n";
73 $result = file_put_contents($filealias, $aliascontent);
74 if ($result ===
false) {
75 dol_syslog(
"Failed to write file ".$filealias, LOG_WARNING);
80 if ($objectpage->lang && in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
81 $dirname = dirname($filealias);
82 $filename = basename($filealias);
83 $filealiassub = $dirname.
'/'.$objectpage->lang.
'/'.$filename;
85 dol_mkdir($dirname.
'/'.$objectpage->lang, DOL_DATA_ROOT);
87 $aliascontent =
'<?php'.
"\n";
88 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
89 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
90 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'../page'.$objectpage->id.
'.tpl.php\'; ';
91 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
92 $aliascontent .=
'?>'.
"\n";
93 $result = file_put_contents($filealiassub, $aliascontent);
94 if ($result ===
false) {
95 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
98 } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
101 $dirname = dirname($filealias);
102 $filename = basename($filealias);
103 foreach (explode(
',',
$object->otherlang) as $sublang) {
105 if (empty(trim($sublang))) {
108 $filealiassub = $dirname.
'/'.$sublang.
'/'.$filename;
110 $aliascontent =
'<?php'.
"\n";
111 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
112 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
113 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'../page'.$objectpage->id.
'.tpl.php\'; ';
114 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
115 $aliascontent .=
'?>'.
"\n";
118 $result = file_put_contents($filealiassub, $aliascontent);
119 if ($result ===
false) {
120 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
127 return ($result ?
true :
false);
147 dol_syslog(
"dolSavePageContent We regenerate the tpl page filetpl=".$filetpl);
149 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
163 if ($objectpage->lang) {
164 $shortlangcode = substr($objectpage->lang, 0, 2);
166 if (empty($shortlangcode)) {
167 $shortlangcode = substr(
$object->lang, 0, 2);
170 if (!empty($objectpage->type_container) && in_array($objectpage->type_container, array(
'library',
'service'))) {
171 $originalcontentonly = 1;
175 if (!isset($originalcontentonly)) {
176 $tplcontent .=
"<?php // BEGIN PHP\n";
177 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
178 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
179 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
180 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
181 $tplcontent .=
"} // Not already loaded\n";
182 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
183 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
184 $tplcontent .=
"ob_start();\n";
185 $tplcontent .=
"// END PHP ?>\n";
187 $tplcontent .=
"<!DOCTYPE html>\n";
189 $tplcontent .=
'<html'.($shortlangcode ?
' lang="'.$shortlangcode.
'"' :
'').
'>'.
"\n";
190 $tplcontent .=
'<head>'.
"\n";
191 $tplcontent .=
'<title>'.dol_string_nohtmltag($objectpage->title, 0,
'UTF-8').
'</title>'.
"\n";
192 $tplcontent .=
'<meta charset="utf-8">'.
"\n";
193 $tplcontent .=
'<meta http-equiv="content-type" content="text/html; charset=utf-8" />'.
"\n";
194 $tplcontent .=
'<meta name="robots" content="index, follow" />'.
"\n";
195 $tplcontent .=
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
196 $tplcontent .=
'<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).
'" />'.
"\n";
197 $tplcontent .=
'<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0,
'UTF-8').
'" />'.
"\n";
198 $tplcontent .=
'<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0,
'UTF-8').
'" />'.
"\n";
199 $tplcontent .=
'<meta name="generator" content="'.DOL_APPLICATION_TITLE.
' '.DOL_VERSION.
' (https://www.dolibarr.org)" />'.
"\n";
200 $tplcontent .=
'<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag((
string) $objectpage->id).
'" />'.
"\n";
203 if ($objectpage->id ==
$object->fk_default_home) {
204 $tplcontent .=
'<link rel="icon" type="image/png" href="/favicon.png" />'.
"\n";
209 $tplcontent .=
'<link rel="canonical" href="'.(($objectpage->id ==
$object->fk_default_home) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$shortlangcode :
'').
'/'.$objectpage->pageurl.
'.php')).
'" />'.
"\n";
214 $translationof = $objectpage->fk_page;
215 if ($translationof) {
217 $tmppage->fetch($translationof);
218 if ($tmppage->id > 0) {
219 $tmpshortlangcode =
'';
220 if ($tmppage->lang) {
221 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
223 if (empty($tmpshortlangcode)) {
224 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
226 if ($tmpshortlangcode != $shortlangcode) {
227 $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";
233 $sql =
"SELECT rowid as id, lang, pageurl from ".MAIN_DB_PREFIX.
'website_page where fk_page IN ('.$db->sanitize($objectpage->id.($translationof ?
", ".$translationof :
'')).
")";
234 $resql = $db->query($sql);
236 $num_rows = $db->num_rows($resql);
238 while ($obj = $db->fetch_object($resql)) {
239 $tmpshortlangcode =
'';
241 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $obj->lang);
243 if ($tmpshortlangcode != $shortlangcode) {
244 $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";
253 $tplcontent .=
'<?php if ($_SERVER["PHP_SELF"] == "'.(($object->fk_default_home == $objectpage->id) ?
'/' : (($shortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$shortlangcode :
'')).
'/'.$objectpage->pageurl.
'.php") { ?>'.
"\n";
254 $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";
256 $tplcontent .=
'<?php } ?>'.
"\n";
259 $tplcontent .=
'<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'.
"\n";
260 $tplcontent .=
'<!-- Include link to CSS file -->'.
"\n";
262 $tplcontent .=
'<link rel="stylesheet" href="/styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'.
"\n";
263 $tplcontent .=
'<!-- Include link to JS file -->'.
"\n";
264 $tplcontent .=
'<script nonce="'.getNonce().
'" async src="/javascript.js.php?website=<?php echo $websitekey; ?>"></script>'.
"\n";
266 $tplcontent .=
'<!-- Include HTML header from common file -->'.
"\n";
267 $tplcontent .=
'<?php if (file_exists(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")) include DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html"; ?>'.
"\n";
268 $tplcontent .=
'<!-- Include HTML header from page header block -->'.
"\n";
269 $tplcontent .= preg_replace(
'/<\/?html>/ims',
'', $objectpage->htmlheader).
"\n";
270 $tplcontent .=
'</head>'.
"\n";
272 $tplcontent .=
'<!-- File generated by Dolibarr website module editor -->'.
"\n";
273 $tplcontent .=
'<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
274 $tplcontent .= $objectpage->content.
"\n";
275 $tplcontent .=
'</body>'.
"\n";
276 $tplcontent .=
'</html>'.
"\n";
278 $tplcontent .=
'<?php // BEGIN PHP'.
"\n";
279 $tplcontent .=
'$tmp = ob_get_contents(); ob_end_clean();'.
"\n";
280 if (strpos($objectpage->content,
'$__PAGE__TITLE__') !==
false) {
281 $tplcontent .=
'$tmp = preg_replace("/<title>.*?<\/title>/s", "<title>" . dol_escape_htmltag($__PAGE__TITLE__) . "</title>", $tmp);'.
"\n";
282 $tplcontent .=
'$tmp = preg_replace("/<meta name=\"title\" content=\".*?\" \/>/s", "<meta name=\"title\" content=\"" . dol_string_nohtmltag($__PAGE__TITLE__) . "\" />", $tmp);';
284 if (strpos($objectpage->content,
'$__PAGE__KEYWORDS__') !==
false) {
285 $tplcontent .=
'$tmp = preg_replace("/<meta name=\"keywords\" content=\".*?\" \/>/s", "<meta name=\"keywords\" content=\"" . dol_string_nohtmltag($__PAGE__KEYWORDS__) . "\" />", $tmp);';
287 if (strpos($objectpage->content,
'$__PAGE__DESC__') !==
false) {
288 $tplcontent .=
'$tmp = preg_replace("/<meta name=\"description\" content=\".*?\" \/>/s", "<meta name=\"description\" content=\"" . dol_string_nohtmltag($__PAGE__DESC__) . "\" />", $tmp);';
290 $tplcontent .=
'dolWebsiteOutput($tmp, "html", '.$objectpage->id.
'); dolWebsiteIncrementCounter('.
$object->id.
', "'.$objectpage->type_container.
'", '.$objectpage->id.
');'.
"\n";
291 $tplcontent .=
"// END PHP ?>\n";
293 $tplcontent .=
"<?php // BEGIN PHP\n";
294 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
295 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
296 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
297 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
298 $tplcontent .=
"} // Not already loaded\n";
299 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
300 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
301 $tplcontent .=
"// END PHP ?>\n";
303 $tplcontent .= $objectpage->content;
307 $result = file_put_contents($filetpl, $tplcontent);
336 $indexcontent =
'<?php'.
"\n";
337 $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";
338 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
339 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
340 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
341 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
342 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
343 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
344 $indexcontent .=
"}\n";
345 $indexcontent .=
"include_once './".basename($filetpl).
"'\n";
346 $indexcontent .=
'// END PHP ?>'.
"\n";
348 $result1 = file_put_contents($fileindex, $indexcontent);
354 $objectpage->fetch(
$object->fk_default_home);
357 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
359 $dirname = dirname($fileindex);
360 foreach (explode(
',',
$object->otherlang) as $sublang) {
362 if (empty(trim($sublang))) {
365 $fileindexsub = $dirname.
'/'.$sublang.
'/index.php';
369 $indexcontent =
'<?php'.
"\n";
370 $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";
371 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
372 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once '".$relpath.
"/master.inc.php'; } // Load master if not already loaded\n";
373 $indexcontent .=
'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'.
"\n";
374 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
375 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
376 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
377 $indexcontent .=
"}\n";
378 $indexcontent .=
"include_once '".$relpath.
"/".basename($filetpl).
"'\n";
379 $indexcontent .=
'// END PHP ?>'.
"\n";
380 $result = file_put_contents($fileindexsub, $indexcontent);
381 if ($result ===
false) {
382 dol_syslog(
"Failed to write file ".$fileindexsub, LOG_WARNING);
395 $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.
'/website/samples/wrapper.php');
397 $result2 = file_put_contents($filewrapper, $wrappercontent);
403 return ($result1 && $result2);
416 global $pathofwebsite;
418 dol_syslog(
"Save html header into ".$filehtmlheader);
421 $result = file_put_contents($filehtmlheader, $htmlheadercontent);
436 global $pathofwebsite;
441 $result = file_put_contents($filecss, $csscontent);
456 global $pathofwebsite;
461 $result = file_put_contents($filejs, $jscontent);
476 global $pathofwebsite;
478 dol_syslog(
"Save robot file into ".$filerobot);
481 $result = file_put_contents($filerobot, $robotcontent);
496 global $pathofwebsite;
498 dol_syslog(
"Save htaccess file into ".$filehtaccess);
501 $result = file_put_contents($filehtaccess, $htaccess);
516 global $pathofwebsite;
518 dol_syslog(
"Save manifest.js.php file into ".$file);
521 $result = file_put_contents($file, $content);
536 global $pathofwebsite;
538 dol_syslog(
"Save README.md file into ".$file);
541 $result = file_put_contents($file, $content);
556 global $pathofwebsite;
561 $result = file_put_contents($file, $content);
575 global
$conf, $langs, $form, $user;
577 $dirthemes = array(
'/doctemplates/websites');
585 $dirthemes = array_unique($dirthemes);
590 print
'<!-- For website template import -->'.
"\n";
591 print
'<table class="noborder centpercent">';
594 print
'<tr class="liste_titre"><th class="titlefield">';
595 print $form->textwithpicto($langs->trans(
"Templates"), $langs->trans(
"ThemeDir").
' : '.implode(
", ", $dirthemes));
597 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&importsite=1" rel="noopener noreferrer external">';
601 print
'<th class="right">';
602 $url =
'https://www.dolistore.com/43-web-site-templates';
603 print
'<a href="'.$url.
'" target="_blank" rel="noopener noreferrer external">';
604 print
img_picto(
'',
'globe',
'class="pictofixedwidth"').$langs->trans(
'DownloadMoreSkins');
608 print
'<tr><td colspan="'.$colspan.
'">';
610 print
'<table class="nobordernopadding centpercent"><tr><td><div class="display-flex">';
612 if (count($dirthemes)) {
614 foreach ($dirthemes as $dir) {
615 if (preg_match(
'/^\/doctemplates\//', $dir)) {
616 $dirtheme = DOL_DATA_ROOT.$dir;
620 if (is_dir($dirtheme)) {
621 $handle = opendir($dirtheme);
622 if (is_resource($handle)) {
623 while (($subdir = readdir($handle)) !==
false) {
625 if (is_file($dirtheme.
"/".$subdir) && substr($subdir, 0, 1) !=
'.' && substr($subdir, 0, 3) !=
'CVS' && preg_match(
'/\.zip$/i', $subdir)) {
626 $subdirwithoutzip = preg_replace(
'/\.zip$/i',
'', $subdir);
629 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2 && preg_match(
'/_dev$/i', $subdir)) {
632 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1 && preg_match(
'/_exp$/i', $subdir)) {
636 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;">';
638 $templatedir = $dirtheme.
"/".$subdir;
639 $file = $dirtheme.
"/".$subdirwithoutzip.
".jpg";
640 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.
".jpg";
642 if (!file_exists($file)) {
643 $url = DOL_URL_ROOT.
'/public/theme/common/nophoto.png';
646 $originalfile = basename($file);
647 $entity =
$conf->entity;
648 $modulepart =
'doctemplateswebsite';
654 if (!empty($urladvanced)) {
655 $ret .=
'<a class="'.$urladvanced[
'css'].
'" target="'.$urladvanced[
'target'].
'" mime="'.$urladvanced[
'mime'].
'" href="'.$urladvanced[
'url'].
'">';
657 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.((int) $entity).
'&file='.urlencode($originalfile).
'&cache='.((int) $cache).
'">';
660 print
'<img class="img-skinthumb shadow" src="'.$url.
'" border="0" alt="'.$title.
'" title="'.$title.
'" style="margin-bottom: 5px;">';
667 if ($user->hasRight(
'website',
'delete')) {
668 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?action=deletetemplate&token='.
newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'">'.
img_picto(
'',
'delete').
'</a>';
670 print
'<br><a href="'.$_SERVER[
"PHP_SELF"].
'?action=importsiteconfirm&token='.
newToken().
'&website='.urlencode($website->ref).
'&templateuserfile='.urlencode($subdir).
'" class="button">'.$langs->trans(
"Load").
'</a>';
676 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>';
677 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>';
678 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>';
679 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>';
680 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>';
685 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
688 print
'</div></td></tr></table>';
707 global $langs, $user;
711 if (empty($phpfullcodestringold) && empty($phpfullcodestring)) {
716 if ($phpfullcodestringold != $phpfullcodestring) {
717 if (!$error && !$user->hasRight(
'website',
'writephp')) {
719 setEventMessages($langs->trans(
"NotAllowedToAddDynamicContent"),
null,
'errors');
725 $forbiddenphpstrings = array(
'$$',
'}[');
726 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'ReflectionFunction'));
728 $forbiddenphpfunctions = array();
729 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
730 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
731 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"call_user_func"));
734 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
735 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
736 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
739 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
742 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
744 foreach ($forbiddenphpstrings as $forbiddenphpstring) {
745 if (preg_match(
'/'.preg_quote($forbiddenphpstring,
'/').
'/ms', $phpfullcodestring)) {
747 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpstring),
null,
'errors');
751 foreach ($forbiddenphpfunctions as $forbiddenphpcommand) {
752 if (preg_match(
'/'.$forbiddenphpcommand.
'\s*\(/ms', $phpfullcodestring)) {
754 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand),
null,
'errors');
758 foreach ($forbiddenphpmethods as $forbiddenphpmethod) {
759 if (preg_match(
'/->'.$forbiddenphpmethod.
'/ms', $phpfullcodestring)) {
761 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpmethod),
null,
'errors');
769 $forbiddenphpchars = array();
771 $forbiddenphpchars = array(
"`");
773 foreach ($forbiddenphpchars as $forbiddenphpchar) {
774 if (preg_match(
'/'.$forbiddenphpchar.
'/ms', $phpfullcodestring)) {
776 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar),
null,
'errors');
784 if (preg_match(
'/[}\]]\(/ims', $phpfullcodestring)) {
786 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
']('),
null,
'errors');
792 if (preg_match(
'/\$[a-z0-9_\-\/\*]+\(/ims', $phpfullcodestring)) {
794 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction",
'$...('),
null,
'errors');
801 if ($phpfullcodestringold != $phpfullcodestring) {
803 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
804 $allowimportsite =
true;
805 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
806 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
807 $allowimportsite =
false;
810 if (!$allowimportsite) {
815 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
818 $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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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 a 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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.