<?php
require_once __DIR__ . "/Febe.php";
$febe = new Febe;
$queryString = "";
$language = $_GET["intgrtn_language"] ?? null;
$country = $_GET["country"] ?? null;
$ipCountryIso = $_SERVER['HTTP_PX_IPCOUNTRYISO'] ?? null;

if (!empty($_SERVER['QUERY_STRING'])) {
	$queryString = '?' . $_SERVER['QUERY_STRING'];
}

if ($language) {
	header('Location: ' . $febe->returnLanguageByLanguage($language) . '/index.php' . $queryString);
	exit();
}
if ($country) {
	header('Location: ' . $febe->returnLanguageByCountry($country) . '/index.php' . $queryString);
	exit();
}
if ($ipCountryIso) {
	header('Location: ' . $febe->returnLanguageByIpCountryIso($ipCountryIso) . '/index.php' . $queryString);
	exit();
}

header('Location: ' . $febe->getFallbackLanguage() . '/index.php' . $queryString);
exit();
