/** * Handles the language specific aspect. * The language can be changed by setting the $_GET['Language'] & $_GET['setLang'] together. This will also change the language entry of the user in the db. * Cookies are also being used in case the user isn't logged in. * * @return returns the parsed content of the language .ini file related to the users language setting. */ public static function handle_language() { global $DEFAULT_LANGUAGE; global $AMS_TRANS; // if user wants to change the language if (isset($_GET['Language']) && isset($_GET['setLang'])) { // The ingame client sometimes sends full words, derive those! switch ($_GET['Language']) { case "English": $lang = "en"; break; case "French": $lang = "fr"; break; default: $lang = $_GET['Language']; } // if the file exists en the setLang = true if (file_exists($AMS_TRANS . '/' . $lang . '.ini') && $_GET['setLang'] == "true") { // set a cookie & session var and incase logged in write it to the db! setcookie('Language', $lang, time() + 60 * 60 * 24 * 30); $_SESSION['Language'] = $lang; if (WebUsers::isLoggedIn()) { WebUsers::setLanguage($_SESSION['id'], $lang); } } else { $_SESSION['Language'] = $DEFAULT_LANGUAGE; } } else { // if the session var is not set yet if (!isset($_SESSION['Language'])) { // check if a cookie already exists for it if (isset($_COOKIE['Language'])) { $_SESSION['Language'] = $_COOKIE['Language']; // else use the default language } else { $_SESSION['Language'] = $DEFAULT_LANGUAGE; } } } if ($_SESSION['Language'] == "") { $_SESSION['Language'] = $DEFAULT_LANGUAGE; } return parse_ini_file($AMS_TRANS . '/' . $_SESSION['Language'] . '.ini', true); }