check if the used froxlor version has already iso-codes in the language-table for this will output undefined variables after updating the files before updating the database in the panel

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-03-10 10:23:24 +01:00
parent 4b872399ac
commit 47481aab56
2 changed files with 29 additions and 25 deletions

View File

@@ -276,7 +276,13 @@ $result = $db->query($query);
while($row = $db->fetch_array($result))
{
$langs[$row['language']][] = $row;
$iso[$row['iso']] = $row['language'];
// check for row[iso] cause older froxlor
// versions didn't have that and it will
// lead to a lot of undfined variables
// before the admin can even update
if (isset($row['iso'])) {
$iso[$row['iso']] = $row['language'];
}
}
// buildup $languages for the login screen
@@ -285,43 +291,40 @@ foreach($langs as $key => $value)
$languages[$key] = $key;
}
if (isset($userinfo['language']) && isset($languages[$userinfo['language']]))
{
// set default langauge before anything else to
// ensure that we can display messages
$language = $settings['panel']['standardlanguage'];
if (isset($userinfo['language']) && isset($languages[$userinfo['language']])) {
// default: use language from session, #277
$language = $userinfo['language'];
}
else
{
if(!isset($userinfo['def_language'])
|| !isset($languages[$userinfo['def_language']]))// this will always evaluat true, since it is the above statement inverted. @todo remove
{
if(isset($_GET['language'])
&& isset($languages[$_GET['language']]))
{
} else {
if (!isset($userinfo['def_language'])
|| !isset($languages[$userinfo['def_language']]) // this will always evaluat true, since it is the above statement inverted. @todo remove
) {
if (isset($_GET['language'])
&& isset($languages[$_GET['language']])
) {
$language = $_GET['language'];
}
else
{
} else {
$accept_langs = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
for($i = 0; $i<count($accept_langs); $i++) {
# this only works for most common languages. some (uncommon) languages have a 3 letter iso-code.
# to be able to use these also, we would have to depend on the intl extension for php (using Locale::lookup or similar)
# as long as froxlor does not support any of these languages, we can leave it like that.
if(isset($iso[substr($accept_langs[$i],0,2)])) {
// this only works for most common languages. some (uncommon) languages have a 3 letter iso-code.
// to be able to use these also, we would have to depend on the intl extension for php (using Locale::lookup or similar)
// as long as froxlor does not support any of these languages, we can leave it like that.
if (isset($iso[substr($accept_langs[$i],0,2)])) {
$language=$iso[substr($accept_langs[$i],0,2)];
break;
}
}
unset($iso);
// if HTTP_ACCEPT_LANGUAGES has no valid langs, use default (very unlikely)
if(!strlen($language)>0) {
if (!strlen($language)>0) {
$language = $settings['panel']['standardlanguage'];
}
}
}
else
{
} else {
$language = $userinfo['def_language'];
}
}