27include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
36if (isset($_SERVER[
"HTTP_USER_AGENT"]) && is_object($conf) && empty($conf->browser->name)) {
38 $conf->browser->name = $tmp[
'browsername'];
39 $conf->browser->os = $tmp[
'browseros'];
40 $conf->browser->version = $tmp[
'browserversion'];
41 $conf->browser->layout = $tmp[
'layout'];
44 if ($conf->browser->layout ==
'phone') {
45 $conf->dol_no_mouse_hover = 1;
49if (!is_object($website)) {
51 $website->fetch(0, $websitekey);
54if (empty($pageid) && !empty($websitepagefile)) {
55 $pageid = str_replace(array(
'.tpl.php',
'page'), array(
'',
''), basename($websitepagefile));
56 if ($pageid ==
'index.php') {
57 $pageid = $website->fk_default_home;
60if (!is_object($websitepage)) {
64if (!is_object($weblangs)) {
67if (!is_object($pagelangs)) {
71 $websitepage->fetch($pageid);
73 $weblangs->setDefaultLang(GETPOSTISSET(
'lang') ?
GETPOST(
'lang',
'aZ09') : (empty($_COOKIE[
'weblangs-shortcode']) ?
'auto' : preg_replace(
'/[^a-zA-Z0-9_\-]/',
'', $_COOKIE[
'weblangs-shortcode'])));
74 $pagelangs->setDefaultLang($websitepage->lang ? $websitepage->lang : $weblangs->shortlang);
76 if (!defined(
'USEDOLIBARREDITOR') && (in_array($websitepage->type_container, array(
'menu',
'other')) || empty($websitepage->status) && !defined(
'USEDOLIBARRSERVER'))) {
77 $weblangs->load(
"website");
82 header(
"X-Content-Type-Options: nosniff");
85 if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
86 header(
"X-Frame-Options: SAMEORIGIN");
90 http_response_code(404);
91 print
'<center><br><br>'.$weblangs->trans(
"YouTryToAccessToAFileThatIsNotAWebsitePage", $websitepage->pageurl, $websitepage->type_container, $websitepage->status).
'</center>';
96if (!defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
100 header(
"X-Content-Type-Options: nosniff");
103 if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
104 header(
"X-Frame-Options: SAMEORIGIN");
111 if (!defined(
'WEBSITE_MAIN_SECURITY_FORCECSPRO')) {
124 if (!is_object($hookmanager)) {
125 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
128 $hookmanager->initHooks(array(
"main"));
130 $parameters = array(
'contentsecuritypolicy'=>$contentsecuritypolicy,
'mode'=>
'reportonly');
131 $result = $hookmanager->executeHooks(
'setContentSecurityPolicy', $parameters);
133 $contentsecuritypolicy = $hookmanager->resPrint;
135 $contentsecuritypolicy .= $hookmanager->resPrint;
138 if (!empty($contentsecuritypolicy)) {
139 header(
"Content-Security-Policy-Report-Only: ".$contentsecuritypolicy);
144 if (!defined(
'WEBSITE_MAIN_SECURITY_FORCECSP')) {
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'=>
'active');
164 $result = $hookmanager->executeHooks(
'setContentSecurityPolicy', $parameters);
166 $contentsecuritypolicy = $hookmanager->resPrint;
168 $contentsecuritypolicy .= $hookmanager->resPrint;
171 if (!empty($contentsecuritypolicy)) {
172 header(
"Content-Security-Policy: ".$contentsecuritypolicy);
177 if (!defined(
'WEBSITE_MAIN_SECURITY_FORCERP')) {
181 $referrerpolicy =
getDolGlobalString(
'WEBSITE_MAIN_SECURITY_FORCERP',
"strict-origin-when-cross-origin");
183 header(
"Referrer-Policy: ".$referrerpolicy);
187 if (!defined(
'WEBSITE_MAIN_SECURITY_FORCESTS')) {
193 header(
"Strict-Transport-Security: ".$sts);
198 if (!defined(
'WEBSITE_MAIN_SECURITY_FORCEPP')) {
204 header(
"Permissions-Policy: ".$pp);
211 $weblangs->setDefaultLang(
GETPOST(
'l',
'aZ09'));
214if ($_SERVER[
'PHP_SELF'] != DOL_URL_ROOT.
'/website/index.php') {
217 $sql =
"SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page";
218 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp";
219 $sql .=
" WHERE wp.fk_website = ".((int) $website->id);
220 $sql .=
" AND (wp.fk_page = ".((int) $pageid).
" OR wp.rowid = ".((int) $pageid);
221 if (is_object($websitepage) && $websitepage->fk_page > 0) {
222 $sql .=
" OR wp.fk_page = ".((int) $websitepage->fk_page).
" OR wp.rowid = ".((int) $websitepage->fk_page);
225 $sql .=
" AND wp.lang = '".$db->escape(
GETPOST(
'l',
'aZ09')).
"'";
227 $resql = $db->query($sql);
229 $obj = $db->fetch_object($resql);
231 $newpageid = $obj->rowid;
232 if ($newpageid != $pageid) {
233 if (defined(
'USEDOLIBARRSERVER')) {
234 header(
"Location: ".DOL_URL_ROOT.
'/public/website/index.php?website='.$websitekey.
'&pageid='.$newpageid.
'&l='.
GETPOST(
'l',
'aZ09'));
237 $newpageref = $obj->pageurl;
238 header(
"Location: ".(($obj->lang && $obj->lang != $website->lang) ?
'/'.$obj->lang.
'/' :
'/').$newpageref.
'.php?l='.
GETPOST(
'l',
'aZ09'));
248if (!defined(
'USEDOLIBARREDITOR') && empty($website->status)) {
252 header(
"X-Content-Type-Options: nosniff");
255 if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
256 header(
"X-Frame-Options: SAMEORIGIN");
259 $weblangs->load(
"website");
262 http_response_code(503);
263 print
'<center><br><br>'.$weblangs->trans(
"SorryWebsiteIsCurrentlyOffLine").
'</center>';
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 dolibarr global constant string value.