1
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2025-08-07 17:42:53 +03:00

improve langauge checks (remove unnecessary is_string check)

This commit is contained in:
David Goodwin
2020-04-01 21:29:40 +01:00
parent 531a52e053
commit dec4b38f35

View File

@@ -180,13 +180,9 @@ function check_language($use_post = true) {
$lang = Config::read_string('default_language');
// If not, did the browser give us any hint(s)?
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang_array = preg_split('/(\s*,\s*)/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($lang_array as $value) {
if (!is_string($value)) {
continue;
}
$lang_next = strtolower(trim($value));
$lang_next = preg_replace('/;.*$/', '', $lang_next); # remove things like ";q=0.8"
if (array_key_exists($lang_next, $supported_languages)) {