dolibarr 21.0.3
website2.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
32function dolSaveMasterFile($filemaster)
33{
34 // Now generate the master.inc.php page
35 dol_syslog("We regenerate the master.inc.php file");
36
37 dol_delete_file($filemaster);
38
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);
47 dolChmod($filemaster);
48
49 return $result;
50}
51
62function dolSavePageAlias($filealias, $object, $objectpage)
63{
64 // Now create the .tpl file
65 dol_syslog("dolSavePageAlias We regenerate the alias page filealias=".$filealias." and a wrapper into all language subdirectories");
66
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);
76 }
77 dolChmod($filealias);
78
79 // Save also alias into language subdirectory if it is not a main language
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;
84
85 dol_mkdir($dirname.'/'.$objectpage->lang, DOL_DATA_ROOT);
86
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);
96 }
97 dolChmod($filealiassub);
98 } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) {
99 // Save also alias into all language subdirectories if it is a main language
100 if (!getDolGlobalString('WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR') && !empty($object->otherlang)) {
101 $dirname = dirname($filealias);
102 $filename = basename($filealias);
103 foreach (explode(',', $object->otherlang) as $sublang) {
104 // Avoid to erase main alias file if $sublang is empty string
105 if (empty(trim($sublang))) {
106 continue;
107 }
108 $filealiassub = $dirname.'/'.$sublang.'/'.$filename;
109
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";
116
117 dol_mkdir($dirname.'/'.$sublang);
118 $result = file_put_contents($filealiassub, $aliascontent);
119 if ($result === false) {
120 dol_syslog("Failed to write file ".$filealiassub, LOG_WARNING);
121 }
122 dolChmod($filealiassub);
123 }
124 }
125 }
126
127 return ($result ? true : false);
128}
129
130
142function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold = 0)
143{
144 global $db;
145
146 // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
147 dol_syslog("dolSavePageContent We regenerate the tpl page filetpl=".$filetpl);
148
149 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
150
151 if (dol_is_file($filetpl)) {
152 if ($backupold) {
153 $result = archiveOrBackupFile($filetpl);
154 if (! $result) {
155 return false;
156 }
157 } else {
158 dol_delete_file($filetpl);
159 }
160 }
161
162 $shortlangcode = '';
163 if ($objectpage->lang) {
164 $shortlangcode = substr($objectpage->lang, 0, 2); // en_US or en-US -> en
165 }
166 if (empty($shortlangcode)) {
167 // Take the language of website
168 $shortlangcode = substr($object->lang, 0, 2); // en_US or en-US -> en
169 }
170
171 if (!empty($objectpage->type_container) && in_array($objectpage->type_container, array('library', 'service'))) {
172 $originalcontentonly = 1;
173 }
174
175 $tplcontent = '';
176 if (!isset($originalcontentonly)) {
177 // If we want to generate a page with some code to manage PHP content
178 $tplcontent .= "<?php // BEGIN PHP\n";
179 $tplcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
180 $tplcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
181 $tplcontent .= ' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'."\n";
182 $tplcontent .= ' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'."\n";
183 if (getDolGlobalString("MAIN_ADD_WAF_V22") && empty($objectpage->disable_waf)) {
184 $tplcontent .= ' require_once DOL_DOCUMENT_ROOT.\'/waf.inc.php\';'."\n";
185 }
186 $tplcontent .= "} // Not already loaded\n";
187 $tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
188 $tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
189 if (in_array($objectpage->type_container, array('page', 'blogpost', 'service'))) {
190 $tplcontent .= 'dol_syslog("--- Prepare content of page '.((int) $objectpage->id).' - '.$objectpage->pageurl.'");'."\n";
191 }
192 $tplcontent .= "ob_start();\n";
193 $tplcontent .= "try {\n";
194 $tplcontent .= "// END PHP ?>\n";
195 if (getDolGlobalString('WEBSITE_FORCE_DOCTYPE_HTML5')) {
196 $tplcontent .= "<!DOCTYPE html>\n";
197 }
198 // If a language was forced on page, we use it, else we use the lang of visitor else the lang of web site
199 $tplcontent .= '<html'.($objectpage->lang ? ' lang="'.substr($objectpage->lang, 0, 2).'"' : '<?php echo $weblangs->shortlang ? \' lang="\'.$weblangs->shortlang.\'"\' : \'\' ?>').'>'."\n";
200 $tplcontent .= '<head>'."\n";
201 $tplcontent .= '<title>'.dol_string_nohtmltag($objectpage->title, 1, 'UTF-8').'</title>'."\n";
202 $tplcontent .= '<meta charset="utf-8">'."\n";
203 $tplcontent .= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
204 $tplcontent .= '<meta name="robots" content="index, follow" />'."\n";
205 $tplcontent .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
206 $tplcontent .= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords, 1, 'UTF-8').'" />'."\n";
207 $tplcontent .= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 1, 'UTF-8').'" />'."\n";
208 $tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 1, 'UTF-8').'" />'."\n";
209 $tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
210 $tplcontent .= '<meta name="dolibarr:pageid" content="'.((int) $objectpage->id).'" />'."\n";
211
212 // Add favicon
213 if (in_array($objectpage->type_container, array('page', 'blogpost'))) {
214 $tplcontent .= '<link rel="icon" type="image/png" href="/favicon.png" />'."\n";
215 }
216
217 $listofaltlang = $object->otherlang;
218
219 // Note: $object is website, $objectpage is website page
220 if ($object->virtualhost) {
221 // Add the link of the canonical reference
222 $canonicalurladdidlang = '';
223 if ($objectpage->lang) { // A language is forced on the page, it means we may have other language files with hard links into properties of page
224 $canonicalurl = (($objectpage->id == $object->fk_default_home) ? '/' : (($shortlangcode != substr($object->lang, 0, 2) ? '/'.$shortlangcode : '').'/'.$objectpage->pageurl.'.php'));
225 } else { // No language forced, it means the canonical is the one with params making url unique
226 $canonicalurl = '/'.$objectpage->pageurl.'.php';
227
228 if ($object->lang && $listofaltlang) {
229 // Add parameter ID required to be unique/canonical
230 $canonicalurladdidlang = '?__SEO_CANONICAL_URL_PARAMS__';
231 $canonicalurladdidlang .= '&l=__SEO_CANONICAL_LANG__';
232 } else {
233 // Add parameter ID required to be unique/canonical
234 $canonicalurladdidlang = '?__SEO_CANONICAL_URL_PARAMS__';
235 }
236 }
237
238 $tplcontent .= '<link rel="canonical" href="<?php echo $website->virtualhost; ?>'.$canonicalurl.$canonicalurladdidlang.'" />'."\n";
239
240 // Add the link of alternate translation reference
241 if ($listofaltlang) { // If website has other languages to support
242 if ($objectpage->lang) { // A language is forced on the page, it means we may have other language files with hard links into properties of page
243 // Add page "translation of"
244 $translationof = $objectpage->fk_page;
245 if ($translationof) {
246 $tmppage = new WebsitePage($db);
247 $tmppage->fetch($translationof);
248 if ($tmppage->id > 0) {
249 $tmpshortlangcode = '';
250 if ($tmppage->lang) {
251 $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en
252 }
253 if (empty($tmpshortlangcode)) {
254 $tmpshortlangcode = preg_replace('/[_-].*$/', '', $object->lang); // en_US or en-US -> en
255 }
256 if ($tmpshortlangcode != $shortlangcode) {
257 $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";
258 }
259 }
260 }
261
262 // Add "has translation pages"
263 $sql = "SELECT rowid as id, lang, pageurl from ".MAIN_DB_PREFIX.'website_page where fk_page IN ('.$db->sanitize($objectpage->id.($translationof ? ", ".$translationof : '')).")";
264 $resql = $db->query($sql);
265 if ($resql) {
266 $num_rows = $db->num_rows($resql);
267 if ($num_rows > 0) {
268 while ($obj = $db->fetch_object($resql)) {
269 $tmpshortlangcode = '';
270 if ($obj->lang) {
271 $tmpshortlangcode = preg_replace('/[_-].*$/', '', $obj->lang); // en_US or en-US -> en
272 }
273 if ($tmpshortlangcode != $shortlangcode) {
274 $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";
275 }
276 }
277 }
278 } else {
279 dol_print_error($db);
280 }
281
282 // Add myself
283 $tplcontent .= '<?php if ($_SERVER["PHP_SELF"] == "'.(($object->fk_default_home == $objectpage->id) ? '/' : (($shortlangcode != substr($object->lang, 0, 2)) ? '/'.$shortlangcode : '')).'/'.$objectpage->pageurl.'.php") { ?>'."\n";
284 $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";
285
286 $tplcontent .= '<?php } ?>'."\n";
287 } else { // No language forced, it means the canonical is the one withparams making url unique
288 $canonicalurl = '/'.$objectpage->pageurl.'.php';
289 $arrayofaltlang = explode(',', $listofaltlang);
290
291 foreach ($arrayofaltlang as $altlang) {
292 // Add parameter ID required to be unique/canonical
293 $canonicalurladdidlang = '?__SEO_CANONICAL_URL_PARAMS__';
294 $canonicalurladdidlang .= '&l='.$altlang;
295 $tplcontent .= '<link rel="alternate" hreflang="'.$altlang.'" href="<?php echo $website->virtualhost; ?>'.$canonicalurl.$canonicalurladdidlang.'" />'."\n";
296 }
297
298 $tmpshortlangcode = preg_replace('/[_-].*$/', '', $object->lang); // en_US or en-US -> en
299 $canonicalurladdidlang = '?__SEO_CANONICAL_URL_PARAMS__';
300 $canonicalurladdidlang .= '&l='.$tmpshortlangcode;
301 $tplcontent .= '<link rel="alternate" hreflang="'.$tmpshortlangcode.'" href="<?php echo $website->virtualhost; ?>'.$canonicalurl.$canonicalurladdidlang.'" />'."\n";
302 }
303 }
304 }
305
306 // Add manifest.json. Do we have to add it only on home page ?
307 $tplcontent .= '<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'."\n";
308
309 // Add HTML headers (must be before the Add of the common CSS and js). The common js may content javascript using jquery or a framework loaded by the HTML header.
310 $tplcontent .= '<!-- Include HTML header from common file -->'."\n";
311 $tplcontent .= '<?php if (file_exists(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")) include DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html"; ?>'."\n";
312 $tplcontent .= '<!-- Include HTML header from page header block -->'."\n";
313 $tplcontent .= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
314
315 // Add css
316 $tplcontent .= '<!-- Include link to common CSS file -->'."\n";
317 $tplcontent .= '<link rel="stylesheet" href="/styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
318
319 // Add js
320 $tplcontent .= '<!-- Include link to common JS file -->'."\n";
321 $tplcontent .= '<script nonce="'.getNonce().'" async src="/javascript.js.php?website=<?php echo $websitekey; ?>"></script>'."\n";
322 $tplcontent .= '</head>'."\n";
323
324 // Page content
325 $tplcontent .= '<!-- File generated by Dolibarr website module editor -->'."\n";
326 $tplcontent .= '<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n";
327 $tplcontent .= $objectpage->content."\n";
328 $tplcontent .= '</body>'."\n";
329 $tplcontent .= '</html>'."\n";
330
331 $tplcontent .= '<?php // BEGIN PHP'."\n";
332 $tplcontent .= '} catch(Exception $e) { print $e->getMessage(); }'."\n";
333 $tplcontent .= '$tmp = ob_get_contents(); ob_end_clean();'."\n"; // replace with ob_get_clean ?
334
335 $tplcontent .= "// Now fix the content for SEO or multilanguage\n";
336 // Old method for custom SEO
337 if (strpos($objectpage->content, '$__PAGE__KEYWORDS__') !== false) {
338 $tplcontent .= '$tmp = preg_replace("/^<meta name=\"keywords\" content=\".*?\" \/>/ms", "<meta name=\"keywords\" content=\"" . dolPrintHTMLForAttribute($__PAGE__KEYWORDS__ ?? "", 1) . "\" />", $tmp);'."\n";
339 }
340 if (strpos($objectpage->content, '$__PAGE__TITLE__') !== false) {
341 $tplcontent .= '$tmp = preg_replace("/^<title>.*?<\/title>/ms", "<title>" . dolPrintHTMLForAttribute($__PAGE__TITLE__ ?? "", 1) . "</title>", $tmp);'."\n";
342 $tplcontent .= '$tmp = preg_replace("/^<meta name=\"title\" content=\".*?\" \/>/ms", "<meta name=\"title\" content=\"" . dolPrintHTMLForAttribute($__PAGE__TITLE__ ?? "", 1) . "\" />", $tmp);'."\n";
343 }
344 if (strpos($objectpage->content, '$__PAGE__DESC__') !== false) {
345 $tplcontent .= '$tmp = preg_replace("/^<meta name=\"description\" content=\".*?\" \/>/ms", "<meta name=\"description\" content=\"" . dolPrintHTMLForAttribute($__PAGE__DESC__ ?? "", 1) . "\" />", $tmp);'."\n";
346 }
347 // New method for custom SEO
348 if (strpos($objectpage->content, 'define("__SEO_PAGE_LANG__"') !== false) {
349 $tmpshortlangcode = preg_replace('/[_-].*$/', '', $object->lang); // en_US or en-US -> en
350 $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";
351 }
352 if (strpos($objectpage->content, 'define("__SEO_PAGE_KEYWORDS__"') !== false) {
353 $tplcontent .= '$tmp = preg_replace("/^<meta name=\"keywords\" content=\".*?\" \/>/ms", "<meta name=\"keywords\" content=\"" . dolPrintHTMLForAttribute(constant("__SEO_PAGE_KEYWORDS__"), 1) . "\" />", $tmp);'."\n";
354 }
355 if (strpos($objectpage->content, 'define("__SEO_PAGE_TITLE__"') !== false) {
356 $tplcontent .= '$tmp = preg_replace("/^<title>.*?<\/title>/ms", "<title>" . dolPrintHTMLForAttribute(constant("__SEO_PAGE_TITLE__"), 1) . "</title>", $tmp);'."\n";
357 $tplcontent .= '$tmp = preg_replace("/^<meta name=\"title\" content=\".*?\" \/>/ms", "<meta name=\"title\" content=\"" . dolPrintHTMLForAttribute(constant("__SEO_PAGE_TITLE__"), 1) . "\" />", $tmp);'."\n";
358 }
359 if (strpos($objectpage->content, 'define("__SEO_PAGE_DESC__"') !== false) {
360 $tplcontent .= '$tmp = preg_replace("/^<meta name=\"description\" content=\".*?\" \/>/ms", "<meta name=\"description\" content=\"" . dolPrintHTMLForAttribute(constant("__SEO_PAGE_DESC__"), 1) . "\" />", $tmp);'."\n";
361 }
362 if (empty($objectpage->lang)) { // We may need to use param into the canonical url
363 $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";
364
365 $tmpshortlangcode = preg_replace('/[_-].*$/', '', $object->lang); // en_US or en-US -> en
366 $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";
367 }
368
369 $tplcontent .= "// Now output the generated page content\n";
370 $tplcontent .= 'dolWebsiteOutput($tmp, "html", '.((int) $objectpage->id).'); dolWebsiteIncrementCounter('.((int) $object->id).', "'.$objectpage->type_container.'", '.((int) $objectpage->id).');'."\n";
371 $tplcontent .= "// END PHP ?>\n";
372 } else {
373 $tplcontent .= "<?php // BEGIN PHP\n";
374 $tplcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
375 $tplcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
376 $tplcontent .= ' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'."\n";
377 $tplcontent .= ' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'."\n";
378 if (getDolGlobalString("MAIN_ADD_WAF_V22") && empty($objectpage->disable_waf)) {
379 $tplcontent .= ' require_once DOL_DOCUMENT_ROOT.\'/waf.inc.php\';'."\n";
380 }
381 $tplcontent .= "} // Not already loaded\n";
382 $tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
383 $tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
384 if (in_array($objectpage->type_container, array('page', 'blogpost', 'service'))) {
385 $tplcontent .= 'dol_syslog("--- Prepare content of page '.((int) $objectpage->id).' - '.$objectpage->pageurl.'");'."\n";
386 }
387 $tplcontent .= "// END PHP ?>\n";
388
389 $tplcontent .= $objectpage->content;
390 }
391
392 //var_dump($filetpl);exit;
393 $result = file_put_contents($filetpl, $tplcontent);
394
395 dolChmod($filetpl);
396
397 return $result;
398}
399
400
411function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object = null)
412{
413 global $db;
414
415 $result1 = false;
416 $result2 = false;
417
418 dol_mkdir($pathofwebsite);
419
420 if ($fileindex) {
421 dol_delete_file($fileindex);
422 $indexcontent = '<?php'."\n";
423 $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";
424 $indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
425 $indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
426 $indexcontent .= 'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'."\n";
427 $indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
428 $indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
429 $indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
430 $indexcontent .= "}\n";
431 $indexcontent .= "include_once './".basename($filetpl)."'\n";
432 $indexcontent .= '// END PHP ?>'."\n";
433
434 $result1 = file_put_contents($fileindex, $indexcontent);
435
436 dolChmod($fileindex);
437
438 if (is_object($object) && $object->fk_default_home > 0) {
439 $objectpage = new WebsitePage($db);
440 $objectpage->fetch($object->fk_default_home);
441
442 // Create a version for sublanguages
443 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) {
444 if (!getDolGlobalString('WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR') && is_object($object) && !empty($object->otherlang)) {
445 $dirname = dirname($fileindex);
446 foreach (explode(',', $object->otherlang) as $sublang) {
447 // Avoid to erase main alias file if $sublang is empty string
448 if (empty(trim($sublang))) {
449 continue;
450 }
451 $fileindexsub = $dirname.'/'.$sublang.'/index.php';
452
453 // Same indexcontent than previously but with ../ instead of ./ for master and tpl file include/require_once.
454 $relpath = '..';
455 $indexcontent = '<?php'."\n";
456 $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";
457 $indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
458 $indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once '".$relpath."/master.inc.php'; } // Load master if not already loaded\n";
459 $indexcontent .= 'if (!empty($_GET[\'pageref\']) || !empty($_GET[\'pagealiasalt\']) || !empty($_GET[\'pageid\'])) {'."\n";
460 $indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
461 $indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
462 $indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
463 $indexcontent .= "}\n";
464 $indexcontent .= "include_once '".$relpath."/".basename($filetpl)."'\n"; // use .. instead of .
465 $indexcontent .= '// END PHP ?>'."\n";
466 $result = file_put_contents($fileindexsub, $indexcontent);
467 if ($result === false) {
468 dol_syslog("Failed to write file ".$fileindexsub, LOG_WARNING);
469 }
470 dolChmod($fileindexsub);
471 }
472 }
473 }
474 }
475 } else {
476 $result1 = true;
477 }
478
479 if ($filewrapper) {
480 dol_delete_file($filewrapper);
481 $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.php');
482
483 $result2 = file_put_contents($filewrapper, $wrappercontent);
484 dolChmod($filewrapper);
485 } else {
486 $result2 = true;
487 }
488
489 return ($result1 && $result2);
490}
491
492
500function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
501{
502 global $pathofwebsite;
503
504 dol_syslog("Save html header into ".$filehtmlheader);
505
506 dol_mkdir($pathofwebsite);
507 $result = file_put_contents($filehtmlheader, $htmlheadercontent);
508 dolChmod($filehtmlheader);
509
510 return $result;
511}
512
520function dolSaveCssFile($filecss, $csscontent)
521{
522 global $pathofwebsite;
523
524 dol_syslog("Save css file into ".$filecss);
525
526 dol_mkdir($pathofwebsite);
527 $result = file_put_contents($filecss, $csscontent);
528 dolChmod($filecss);
529
530 return $result;
531}
532
540function dolSaveJsFile($filejs, $jscontent)
541{
542 global $pathofwebsite;
543
544 dol_syslog("Save js file into ".$filejs);
545
546 dol_mkdir($pathofwebsite);
547 $result = file_put_contents($filejs, $jscontent);
548 dolChmod($filejs);
549
550 return $result;
551}
552
560function dolSaveRobotFile($filerobot, $robotcontent)
561{
562 global $pathofwebsite;
563
564 dol_syslog("Save robot file into ".$filerobot);
565
566 dol_mkdir($pathofwebsite);
567 $result = file_put_contents($filerobot, $robotcontent);
568 dolChmod($filerobot);
569
570 return $result;
571}
572
580function dolSaveHtaccessFile($filehtaccess, $htaccess)
581{
582 global $pathofwebsite;
583
584 dol_syslog("Save htaccess file into ".$filehtaccess);
585
586 dol_mkdir($pathofwebsite);
587 $result = file_put_contents($filehtaccess, $htaccess);
588 dolChmod($filehtaccess);
589
590 return $result;
591}
592
600function dolSaveManifestJson($file, $content)
601{
602 global $pathofwebsite;
603
604 dol_syslog("Save manifest.js.php file into ".$file);
605
606 dol_mkdir($pathofwebsite);
607 $result = file_put_contents($file, $content);
608 dolChmod($file);
609
610 return $result;
611}
612
620function dolSaveReadme($file, $content)
621{
622 global $pathofwebsite;
623
624 dol_syslog("Save README.md file into ".$file);
625
626 dol_mkdir($pathofwebsite);
627 $result = file_put_contents($file, $content);
628 dolChmod($file);
629
630 return $result;
631}
632
640function dolSaveLicense($file, $content)
641{
642 global $pathofwebsite;
643
644 dol_syslog("Save LICENSE file into ".$file);
645
646 dol_mkdir($pathofwebsite);
647 $result = file_put_contents($file, $content);
648 dolChmod($file);
649
650 return $result;
651}
652
660{
661 global $conf, $langs, $form, $user;
662
663 // We want only one directory for dir of website templates. If an external module need to provide a template, the template must be copied into this directory
664 // when module is enabled.
665 $dirthemes = array('/doctemplates/websites');
666
667 $colspan = 2;
668
669 print '<!-- For website template import -->'."\n";
670 print '<table class="noborder centpercent">';
671
672 // Title
673 print '<tr class="liste_titre"><th class="titlefield">';
674 print $form->textwithpicto($langs->trans("Templates"), $langs->trans("ThemeDir").' : '.implode(", ", $dirthemes));
675 print ' ';
676 print '<a href="'.$_SERVER["PHP_SELF"].'?website='.urlencode($website->ref).'&importsite=1" rel="noopener noreferrer external">';
677 print img_picto('', 'refresh');
678 print '</a>';
679 print '</th>';
680 print '<th class="right">';
681 $url = 'https://www.dolistore.com/43-web-site-templates';
682 print '<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">';
683 print img_picto('', 'globe', 'class="pictofixedwidth"').$langs->trans('DownloadMoreSkins');
684 print '</a>';
685 print '</th></tr>';
686
687 print '<tr><td colspan="'.$colspan.'">';
688
689 print '<table class="nobordernopadding centpercent"><tr><td><div class="display-flex">';
690
691 if (count($dirthemes)) {
692 $i = 0;
693 foreach ($dirthemes as $dir) {
694 $dirtheme = DOL_DATA_ROOT.$dir;
695
696 if (is_dir($dirtheme)) {
697 $handle = opendir($dirtheme);
698 if (is_resource($handle)) {
699 while (($subdir = readdir($handle)) !== false) {
700 //var_dump($dirtheme.'/'.$subdir);
701 if (dol_is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) != '.' && substr($subdir, 0, 3) != 'CVS' && preg_match('/\.zip$/i', $subdir)) {
702 $subdirwithoutzip = preg_replace('/\.zip$/i', '', $subdir);
703 $subdirwithoutzipwithoutver = preg_replace('/(_exp|_dev)$/i', '', $subdirwithoutzip);
704
705 // Disable not stable themes (dir ends with _exp or _dev)
706 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && preg_match('/_dev$/i', $subdirwithoutzip)) {
707 continue;
708 }
709 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && preg_match('/_exp$/i', $subdirwithoutzip)) {
710 continue;
711 }
712
713 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;">';
714
715 $templatedir = $dirtheme."/".$subdir;
716 $file = $dirtheme."/".$subdirwithoutzipwithoutver.".jpg";
717 $url = DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzipwithoutver.".jpg";
718
719 if (!file_exists($file)) {
720 $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
721 }
722
723 $originalimgfile = basename($file);
724 $entity = $conf->entity;
725 $modulepart = 'doctemplateswebsite';
726 $cache = '';
727 $title = $file;
728
729 $ret = '';
730 $urladvanced = getAdvancedPreviewUrl($modulepart, $originalimgfile, 1, '&entity='.$entity);
731 if (!empty($urladvanced)) {
732 $ret .= '<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
733 } else {
734 $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.urlencode($modulepart).'&entity='.((int) $entity).'&file='.urlencode($originalimgfile).'&cache='.((int) $cache).'">';
735 }
736 print $ret;
737 print '<img class="img-skinthumb shadow" src="'.$url.'" border="0" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
738 print '</a>';
739
740 print '<br>';
741 print $subdir;
742 print '<br>';
743 print '<span class="opacitymedium">'.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).' - '.dol_print_date(dol_filemtime($templatedir), 'dayhour', 'tzuserrel').'</span>';
744 if ($user->hasRight('website', 'delete')) {
745 print ' <a href="'.$_SERVER["PHP_SELF"].'?action=deletetemplate&token='.newToken().'&website='.urlencode($website->ref).'&templateuserfile='.urlencode($subdir).'">'.img_picto('', 'delete').'</a>';
746 }
747 print '<br><a href="'.$_SERVER["PHP_SELF"].'?action=importsiteconfirm&token='.newToken().'&website='.urlencode($website->ref).'&templateuserfile='.urlencode($subdir).'" class="button">'.$langs->trans("Load").'</a>';
748 print '</div>';
749
750 $i++;
751 }
752 }
753 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>';
754 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>';
755 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>';
756 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>';
757 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>';
758 }
759 }
760 }
761 } else {
762 print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
763 }
764
765 print '</div></td></tr></table>';
766
767 print '</td></tr>';
768 print '</table>';
769}
770
771
782function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
783{
784 global $langs, $user;
785
786 $error = 0;
787
788 if (empty($phpfullcodestringold) && empty($phpfullcodestring)) {
789 return 0;
790 }
791
792 // First check permission
793 if ($phpfullcodestringold != $phpfullcodestring) {
794 if (!$error && !$user->hasRight('website', 'writephp')) {
795 $error++;
796 setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors');
797 }
798 }
799
800 $phpfullcodestringnew = $phpfullcodestring;
801
802 // Then check forbidden commands
803 if (!$error) {
804 if (getDolGlobalString("WEBSITE_DISALLOW_DOLLAR_UNDERSCORE")) {
805 $phpfullcodestring = preg_replace('/\$_COOKIE\[/', '__DOLLARCOOKIE__', $phpfullcodestring);
806 $phpfullcodestring = preg_replace('/\$_FILES\[/', '__DOLLARFILES__', $phpfullcodestring);
807 $phpfullcodestring = preg_replace('/\$_SESSION\[/', '__DOLLARSESSION__', $phpfullcodestring);
808 $forbiddenphpstrings = array('$$', '$_', '}[');
809 } else {
810 $forbiddenphpstrings = array('$$', '}[');
811 }
812 //$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_FILES', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST', 'ReflectionFunction'));
813 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', 'ReflectionFunction'));
814
815 $forbiddenphpfunctions = array();
816 //$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64"."_"."decode", "rawurl"."decode", "url"."decode", "str"."_rot13", "hex"."2bin")); // name of forbidden functions are split to avoid false positive
817 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("override_function", "session_id", "session_create_id", "session_regenerate_id"));
818 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("get_defined_functions", "get_defined_vars", "get_defined_constants", "get_declared_classes"));
819 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("call_user_func", "call_user_func_array"));
820 //$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include", "require_once", "include_once"));
821 if (!getDolGlobalString('WEBSITE_PHP_ALLOW_EXEC')) { // If option is not on, we disallow functions to execute commands
822 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("exec", "passthru", "shell_exec", "system", "proc_open", "popen"));
823 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_eval", "executeCLI", "verifCond")); // native dolibarr functions
824 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities
825 }
826 if (!getDolGlobalString('WEBSITE_PHP_ALLOW_WRITE')) { // If option is not on, we disallow functions to write files
827 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_decode", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions
828 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
829 }
830 //$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include"));
831
832 $forbiddenphpmethods = array('invoke', 'invokeArgs'); // Method of ReflectionFunction to execute a function
833
834 foreach ($forbiddenphpstrings as $forbiddenphpstring) {
835 if (preg_match('/'.preg_quote($forbiddenphpstring, '/').'/ims', $phpfullcodestring)) {
836 $error++;
837 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpstring), null, 'errors');
838 break;
839 }
840 }
841 /* replaced with next block
842 foreach ($forbiddenphpfunctions as $forbiddenphpfunction) { // Check "function(" but also "'function'(" and "function ("
843 if (preg_match('/'.$forbiddenphpfunction.'[\'\s]*\‍(/ims', $phpfullcodestring)) {
844 $error++;
845 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpfunction), null, 'errors');
846 break;
847 }
848 }*/
849 foreach ($forbiddenphpfunctions as $forbiddenphpfunction) { // Check "function" whatever is "function(" or "function'(" or "function (" or "function"
850 if (preg_match('/\b'.$forbiddenphpfunction.'\b/ims', $phpfullcodestring)) {
851 $error++;
852 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpfunction), null, 'errors');
853 break;
854 }
855 }
856
857 foreach ($forbiddenphpmethods as $forbiddenphpmethod) {
858 if (preg_match('/->'.$forbiddenphpmethod.'/ims', $phpfullcodestring)) {
859 $error++;
860 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpmethod), null, 'errors');
861 break;
862 }
863 }
864 }
865
866 // This char can be used to execute RCE for example by using echo `ls`
867 if (!$error) {
868 $forbiddenphpchars = array();
869 if (!getDolGlobalString('WEBSITE_PHP_ALLOW_DANGEROUS_CHARS')) { // If option is not on, we disallow functions to execute commands
870 $forbiddenphpchars = array("`");
871 }
872 foreach ($forbiddenphpchars as $forbiddenphpchar) {
873 if (preg_match('/'.$forbiddenphpchar.'/ims', $phpfullcodestring)) {
874 $error++;
875 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar), null, 'errors');
876 break;
877 }
878 }
879 }
880
881 // Deny code to call a function obfuscated with comment, like "exec/*...*/ ('ls')";
882 if (!$error) {
883 if (preg_match('/\*\/\s*\‍(/ims', $phpfullcodestring)) {
884 $error++;
885 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", "exec/*...*/ ('ls')"), null, 'errors');
886 }
887 }
888
889 // Deny dynamic functions '${a}(' or '$a[b](' => So we refuse '}(' and ']('
890 if (!$error) {
891 if (preg_match('/[}\]]\s*\‍(/ims', $phpfullcodestring)) {
892 $error++;
893 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", ']('), null, 'errors');
894 }
895 }
896
897 // Deny dynamic functions '$xxx(' or '$xxx (' or '$xxx" ('
898 if (!$error) {
899 if (preg_match('/\$[a-z0-9_\-\/\*\"]+\s*\‍(/ims', $phpfullcodestring)) {
900 $error++;
901 setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", '$...('), null, 'errors');
902 }
903 }
904
905 // No need to block $conf->global->aaa() because PHP try to run the method aaa of $conf->global and not the function into $conf->global->aaa.
906
907 // Then check if installmodules.lock does not block dynamic PHP code change.
908 if ($phpfullcodestringold != $phpfullcodestringnew) {
909 if (!$error) {
910 $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
911 $allowimportsite = true;
912 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
913 if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
914 $allowimportsite = false;
915 }
916
917 if (!$allowimportsite) {
918 $error++;
919 // Blocked by installmodules.lock
920 if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
921 // Show clean corporate message
922 $message = $langs->trans('InstallModuleFromWebHasBeenDisabledContactUs');
923 } else {
924 // Show technical generic message
925 $message = $langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock');
926 }
927 setEventMessages($message, null, 'errors');
928 }
929 }
930 }
931
932 return $error;
933}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class Website.
Class Websitepage.
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, $allowothertags=array())
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_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...
Definition member.php:79
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.