diff --git a/config.php b/config.php index 42cefed89ffa1eaceace08a8afd50ba3761f91d4..efe6d801a60e9b4def4816ef8229ccd9ea8517c1 100644 --- a/config.php +++ b/config.php @@ -14,21 +14,33 @@ $legalNotice = +// Trouver une façon de définir $rootURL sans faire ça : + +if ($_SERVER['SERVER_NAME'] == 'localhost') { + + $rootURL = '/www/cesium-website'; + +} else { + + $rootURL = ''; + +} + /* ====== i18n ====== */ function checkAvailableLanguages ($langList) { - foreach ($langList as $k => $v) { + foreach ($langList as $isoCode => $l) { - $loc = setlocale(LC_ALL, $langList[$k]['folder'], ($langList[$k]['folder'] . '.utf8')); + $loc = setlocale(LC_ALL, $l['folder'], ($l['folder'] . '.utf8')); if ($loc === false) { - $langList[$k] = NULL; + unset($langList[$isoCode]); } else { - $langList[$k]['localeCode'] = $loc; + $langList[$isoCode]['localeCode'] = $loc; } } @@ -85,18 +97,6 @@ bindTextDomains($textDomains); -// Trouver une façon de définir $rootURL sans faire ça : - -if ($_SERVER['SERVER_NAME'] == 'localhost') { - - $rootURL = '/www/cesium-website'; - -} else { - - $rootURL = '/'; - -} - include('inc/functions.php'); include('inc/display.php'); diff --git a/inc/functions.php b/inc/functions.php index d468b7a30b95db22f6201c170adb47d232deb32c..4df84cc687f1b306a530ef7ac1bb383c6055edab 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -30,7 +30,8 @@ function getUserIpAddress () } else if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { - return array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])); + $a = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); + return array_pop($a); } else { diff --git a/inc/lang.php b/inc/lang.php index 6102ef634882eb8a12ae7060c2e8d23376360852..cffea41edbfcd69da644f9ad3112198c6a2e8b56 100644 --- a/inc/lang.php +++ b/inc/lang.php @@ -24,10 +24,17 @@ function getLangFolder ($isoCode) function defineLang () { global $availableLanguages; + global $rootURL; if (isset($_GET['lang'])) { /* From URL */ $lang = $_GET['lang']; + + + if (!in_array($lang, array_keys($availableLanguages))) { + + header('Location: '. $rootURL . '/'. DEFAULT_LANG . '/'); + } } else { /* From browser (if visiting root page /) */