36include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
37include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
45if (isset($_SERVER[
"HTTP_USER_AGENT"]) && is_object($conf) && empty($conf->browser->name)) {
47 $conf->browser->name = $tmp[
'browsername'];
48 $conf->browser->os = $tmp[
'browseros'];
49 $conf->browser->version = $tmp[
'browserversion'];
50 $conf->browser->layout = $tmp[
'layout'];
53 if ($conf->browser->layout ==
'phone') {
54 $conf->dol_no_mouse_hover = 1;
58if (is_null($website)) {
60 $website->fetch(0, $websitekey);
63if (empty($pageid) && !empty($websitepagefile)) {
64 $pageid = str_replace(array(
'.tpl.php',
'page'), array(
'',
''), basename($websitepagefile));
65 if ($pageid ==
'index.php') {
66 $pageid = $website->fk_default_home;
69if (is_null($websitepage)) {
70 $websitepage =
new WebsitePage($db);
73if (is_null($weblangs)) {
76if (is_null($pagelangs)) {
79if (!empty($pageid) && $pageid > 0) {
80 $websitepage->fetch($pageid);
87 $srclang = GETPOSTISSET(
'lang') ?
GETPOST(
'lang',
'aZ09') :
'';
88 if (empty($srclang)) {
89 $srclang = (empty($_COOKIE[
'weblangs-shortcode']) ?
'' : preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
'weblangs-shortcode']));
91 if (empty($srclang)) {
94 if (defined(
'USEDOLIBARRSERVER') && !empty($_GET[
'pageref']) && preg_match(
'/^\/?(\w\w)\//', $_GET[
'pageref'], $reg) && $reg[1] !=
'js') {
98 if (defined(
'USEEXTERNALSERVER') && !empty($_SERVER[
'PHP_SELF']) && preg_match(
'/^\/?(\w\w)\//', $_SERVER[
'PHP_SELF'], $reg) && $reg[1] !=
'js') {
102 if (empty($srclang)) {
105 $weblangs->setDefaultLang($srclang);
107 $pagelangs->setDefaultLang($websitepage->lang ? $websitepage->lang : $weblangs->shortlang);
109 if (!defined(
'USEDOLIBARREDITOR') && (in_array($websitepage->type_container, array(
'menu',
'setup',
'other')) || empty($websitepage->status) && !defined(
'USEDOLIBARRSERVER'))) {
110 $weblangs->load(
"website");
115 header(
"X-Content-Type-Options: nosniff");
118 if (empty($websitepage->allowed_in_frames) && !
getDolGlobalString(
'WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES')) {
119 header(
"X-Frame-Options: SAMEORIGIN");
123 http_response_code(404);
124 print
'<center><br><br>'.$weblangs->trans(
"YouTryToAccessToAFileThatIsNotAWebsitePage", $websitepage->pageurl, $websitepage->type_container, $websitepage->status).
'</center>';
129if (!defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
133 header(
"X-Content-Type-Options: nosniff");
136 if (empty($websitepage->allowed_in_frames) && !
getDolGlobalString(
'WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES')) {
137 header(
"X-Frame-Options: SAMEORIGIN");
144 if (!defined(
'WEBSITE_'.$website->id.
'_SECURITY_FORCECSPRO')) {
155 $contentsecuritypolicy =
getDolGlobalString(
'WEBSITE_'.$website->id.
'_SECURITY_FORCECSPRO');
157 if (!is_object($hookmanager)) {
158 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
161 $hookmanager->initHooks(array(
"main"));
163 $parameters = array(
'contentsecuritypolicy'=>$contentsecuritypolicy,
'mode'=>
'reportonly');
164 $result = $hookmanager->executeHooks(
'setContentSecurityPolicy', $parameters);
166 $contentsecuritypolicy = $hookmanager->resPrint;
168 $contentsecuritypolicy .= $hookmanager->resPrint;
171 if (!empty($contentsecuritypolicy)) {
172 header(
"Content-Security-Policy-Report-Only: ".$contentsecuritypolicy);
177 if (!defined(
'WEBSITE_'.$website->id.
'_SECURITY_FORCECSP')) {
188 $contentsecuritypolicy =
getDolGlobalString(
'WEBSITE_'.$website->id.
'_SECURITY_FORCECSP');
190 if (!is_object($hookmanager)) {
191 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
194 $hookmanager->initHooks(array(
"main"));
196 $parameters = array(
'contentsecuritypolicy'=>$contentsecuritypolicy,
'mode'=>
'active');
197 $result = $hookmanager->executeHooks(
'setContentSecurityPolicy', $parameters);
199 $contentsecuritypolicy = $hookmanager->resPrint;
201 $contentsecuritypolicy .= $hookmanager->resPrint;
204 if (!empty($contentsecuritypolicy)) {
205 header(
"Content-Security-Policy: ".$contentsecuritypolicy);
210 if (!defined(
'WEBSITE_'.$website->id.
'_SECURITY_FORCERP')) {
214 $referrerpolicy =
getDolGlobalString(
'WEBSITE_'.$website->id.
'_SECURITY_FORCERP',
"strict-origin-when-cross-origin");
216 header(
"Referrer-Policy: ".$referrerpolicy);
220 if (!defined(
'WEBSITE_'.$website->id.
'_SECURITY_FORCESTS')) {
226 header(
"Strict-Transport-Security: ".$sts);
231 if (!defined(
'WEBSITE_'.$website->id.
'_SECURITY_FORCEPP')) {
237 header(
"Permissions-Policy: ".$pp);
244 $weblangs->setDefaultLang(
GETPOST(
'l',
'aZ09'));
247if ($_SERVER[
'PHP_SELF'] != DOL_URL_ROOT.
'/website/index.php') {
250 $sql =
"SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page";
251 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp";
252 $sql .=
" WHERE wp.fk_website = ".((int) $website->id);
253 $sql .=
" AND (wp.fk_page = ".((int) $pageid).
" OR wp.rowid = ".((int) $pageid);
254 if (is_object($websitepage) && $websitepage->fk_page > 0) {
255 $sql .=
" OR wp.fk_page = ".((int) $websitepage->fk_page).
" OR wp.rowid = ".((int) $websitepage->fk_page);
258 $sql .=
" AND wp.lang = '".$db->escape(
GETPOST(
'l',
'aZ09')).
"'";
260 $resql = $db->query($sql);
262 $obj = $db->fetch_object($resql);
264 $newpageid = $obj->rowid;
265 if ($newpageid != $pageid) {
266 if (defined(
'USEDOLIBARRSERVER')) {
267 header(
"Location: ".DOL_URL_ROOT.
'/public/website/index.php?website='.$websitekey.
'&pageid='.$newpageid.
'&l='.
GETPOST(
'l',
'aZ09'));
270 $newpageref = $obj->pageurl;
271 header(
"Location: ".(($obj->lang && $obj->lang != $website->lang) ?
'/'.$obj->lang.
'/' :
'/').$newpageref.
'.php?l='.
GETPOST(
'l',
'aZ09'));
281if (!defined(
'USEDOLIBARREDITOR') && empty($website->status)) {
285 header(
"X-Content-Type-Options: nosniff");
288 if (empty($websitepage->allowed_in_frames) && !
getDolGlobalString(
'WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES')) {
289 header(
"X-Frame-Options: SAMEORIGIN");
292 $weblangs->load(
"website");
295 http_response_code(503);
296 print
'<center><br><br>'.$weblangs->trans(
"SorryWebsiteIsCurrentlyOffLine").
'</center>';
302$prefix = dol_getprefix(
'');
303$sessionname =
'DOLSESSID_'.$prefix;
308global $dolibarr_website_allow_custom_php;
309if (!empty($dolibarr_website_allow_custom_php) && $dolibarr_website_allow_custom_php == 1) {
310 $systemfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"popen",
"proc_open");
311 foreach ($systemfunctions as $systemfunction) {
315 if (function_exists($systemfunction)) {
316 print
'<center><br><br>';
317 print
'Website features are DISABLED if the PHP system functions ('.implode(
',', $systemfunctions).
') are NOT disabled for the website context.<br>';
318 print
'The value "'.$systemfunction.
'" has NOT been found into the <b>current disable_functions</b>=<br>';
319 print
'<textarea cols="100" rows="5">';
320 print ini_get(
'disable_functions');
324 print
'You can fix this by changing setup of your PHP ini (changing this in a virtual host with php_admin_value is not effective):<br>';
325 print
'disable_functions="exec,passthru,shell_exec,system,popen,proc_open,..."<br>';
326 print
'but WARNING, this may also break features for:<br>';
327 print
'- cron tasks calling command line tools.<br>';
328 print
'- and for the backup feature running the database dump tool.<br>';
329 print
'- and for the command line antivirus check ran when uploading a file.<br>';
331 print
'If you don\'t use this 3 feature, change your php.ini, if you need at least one, you can bypass this protection by setting $dolibarr_website_allow_custom_php to 2 in your dolibarr config file.';
339$_COOKIE[$sessionname] =
'obfuscatedcookie';
340unset($conf->file->instance_unique_id);
342unset($dolibarr_main_instance_unique_id);
345unset($dolibarr_main_db_host);
346unset($dolibarr_main_db_port);
347unset($dolibarr_main_db_name);
348unset($dolibarr_main_db_user);
349unset($dolibarr_main_db_pass);
350unset($dolibarr_main_db_type);
351unset($dolibarr_main_document_root);
352unset($dolibarr_main_document_root_alt);
Class to manage translations.
getBrowserInfo($user_agent)
Return information about user browser.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.