27 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
28 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
36 if (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;
49 if (!is_object($website)) {
51 $website->fetch(0, $websitekey);
54 if (!$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;
60 if (!is_object($websitepage)) {
64 if (!is_object($weblangs)) {
67 if (!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");
78 http_response_code(404);
79 print
'<center><br><br>'.$weblangs->trans(
"YouTryToAccessToAFileThatIsNotAWebsitePage", $websitepage->pageurl, $websitepage->type_container, $websitepage->status).
'</center>';
84 if (!defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
85 header(
"X-Content-Type-Options: nosniff");
86 if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
87 header(
"X-Frame-Options: SAMEORIGIN");
93 $weblangs->setDefaultLang(
GETPOST(
'l',
'aZ09'));
96 if ($_SERVER[
'PHP_SELF'] != DOL_URL_ROOT.
'/website/index.php') {
99 $sql =
"SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp";
101 $sql .=
" WHERE wp.fk_website = ".((int) $website->id);
102 $sql .=
" AND (wp.fk_page = ".((int) $pageid).
" OR wp.rowid = ".((int) $pageid);
103 if (is_object($websitepage) && $websitepage->fk_page > 0) {
104 $sql .=
" OR wp.fk_page = ".((int) $websitepage->fk_page).
" OR wp.rowid = ".((int) $websitepage->fk_page);
107 $sql .=
" AND wp.lang = '".$db->escape(
GETPOST(
'l',
'aZ09')).
"'";
109 $resql = $db->query($sql);
111 $obj = $db->fetch_object(
$resql);
113 $newpageid = $obj->rowid;
114 if ($newpageid != $pageid) {
115 if (defined(
'USEDOLIBARRSERVER')) {
116 header(
"Location: ".DOL_URL_ROOT.
'/public/website/index.php?website='.$websitekey.
'&pageid='.$newpageid.
'&l='.
GETPOST(
'l',
'aZ09'));
119 $newpageref = $obj->pageurl;
120 header(
"Location: ".(($obj->lang && $obj->lang != $website->lang) ?
'/'.$obj->lang.
'/' :
'/').$newpageref.
'.php?l='.
GETPOST(
'l',
'aZ09'));
130 if (!defined(
'USEDOLIBARREDITOR') && empty($website->status)) {
131 $weblangs->load(
"website");
132 http_response_code(503);
133 print
'<center><br><br>'.$weblangs->trans(
"SorryWebsiteIsCurrentlyOffLine").
'</center>';