mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/9970] Check whether language pack is installed.
PHPBB3-9970
This commit is contained in:
parent
f7723b3e95
commit
405ef39828
1 changed files with 14 additions and 19 deletions
|
@ -1422,33 +1422,28 @@ function validate_match($string, $optional = false, $match = '')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate Language string
|
* Validate Language Pack ISO Name
|
||||||
*
|
*
|
||||||
* Tests whether a language string is valid and exists on the disk
|
* Tests whether a language name is valid and installed
|
||||||
* This is the same criteria used to determine whether to include it or not.
|
|
||||||
*
|
*
|
||||||
* @param $lang - The language string to test
|
* @param string $lang The language string to test
|
||||||
*
|
*
|
||||||
* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
|
* @return bool|string Either false if validation succeeded or
|
||||||
|
* a string which will be used as the error message
|
||||||
|
* (with the variable name appended)
|
||||||
*/
|
*/
|
||||||
function validate_language($lang)
|
function validate_language($lang)
|
||||||
{
|
{
|
||||||
global $phpbb_root_path;
|
global $db;
|
||||||
|
|
||||||
// Note: Two language strings are identical here because the English
|
$sql = 'SELECT lang_id
|
||||||
// version "Language you specified is not valid" is correct for both
|
FROM ' . LANG_TABLE . "
|
||||||
// cases
|
WHERE lang_iso = '" . $db->sql_escape($lang) . "'";
|
||||||
if (!preg_match('#^[a-z_\-]{2,}$#i', $lang))
|
$result = $db->sql_query($sql);
|
||||||
{
|
$lang_id = (int) $db->sql_fetchfield('lang_id');
|
||||||
return 'WRONG_DATA';
|
$db->sql_freeresult($result);
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists($phpbb_root_path . 'language/' . $lang . '/'))
|
return ($lang_id) ? false : 'WRONG_DATA';
|
||||||
{
|
|
||||||
return 'WRONG_DATA';
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue