fix(i18n): switch le domaine si le server_name n'est pas trouvée dans l'url déclarée

This commit is contained in:
François Poulain 2020-04-18 18:06:54 +02:00
parent 14e8a6ebd6
commit 4c24f4e48d

View File

@ -55,13 +55,19 @@ $server_names= array('expolibre.org', 'www.expolibre.org', 'libreexpo.org', 'www
if (!isset ($_SERVER['HTTP_REFERER']) or (
strrpos ($_SERVER['HTTP_REFERER'], 'expolibre.org') === false and
strrpos ($_SERVER['HTTP_REFERER'], 'libreexpo.org') === false)) {
# if we are deep in the tree we don't upgrade language: it may be choosen
if ($current_dir == "expolibre.org") {
$current_dir= $registered_languages['fr']['loc'];
$prefered_dir= $registered_languages[prefered_language ()]['loc'];
if (basename($current_dir) != basename ($prefered_dir)) {
header ("Location: " . url_translate ($_SERVER['REQUEST_URI'], prefered_language ()));
}
# if we are not on the good domain
if ($prefered_dir and false === strpos($prefered_dir, $_SERVER['SERVER_NAME'])) {
header ("Location: " . url_translate ($_SERVER['REQUEST_URI'], prefered_language ()));
}
}
}
?>
?>