aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-03-11 21:55:40 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-03-11 21:55:40 -0500
commit2f57bfb6f297e9711bacb607faf6e33ab516db33 (patch)
tree8fbe5f7359b96129abc095c546748862e775b71e
parent81d281f9e51d90742ef3a27d7ad831f0980c4e54 (diff)
parentac9019068202efde7c532462ca5fce8523956db7 (diff)
downloadforums-2f57bfb6f297e9711bacb607faf6e33ab516db33.tar
forums-2f57bfb6f297e9711bacb607faf6e33ab516db33.tar.gz
forums-2f57bfb6f297e9711bacb607faf6e33ab516db33.tar.bz2
forums-2f57bfb6f297e9711bacb607faf6e33ab516db33.tar.xz
forums-2f57bfb6f297e9711bacb607faf6e33ab516db33.zip
Merge branch 'ticket/bantu/9970' into develop-olympus
* ticket/bantu/9970: [ticket/9970] Rename validate_language() to validate_language_iso_name(). [ticket/9970] Do not allow switching to languages not installed on reg. page. [ticket/9970] Check whether language pack is installed. [ticket/9970] User language input is checked for existance
-rw-r--r--phpBB/includes/functions_user.php25
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php2
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
3 files changed, 28 insertions, 3 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 0420aa70ab..8a204995aa 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1422,6 +1422,31 @@ function validate_match($string, $optional = false, $match = '')
}
/**
+* Validate Language Pack ISO Name
+*
+* Tests whether a language name is valid and installed
+*
+* @param string $lang_iso The language string to test
+*
+* @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_iso_name($lang_iso)
+{
+ global $db;
+
+ $sql = 'SELECT lang_id
+ FROM ' . LANG_TABLE . "
+ WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'";
+ $result = $db->sql_query($sql);
+ $lang_id = (int) $db->sql_fetchfield('lang_id');
+ $db->sql_freeresult($result);
+
+ return ($lang_id) ? false : 'WRONG_DATA';
+}
+
+/**
* Check to see if the username has been taken, or if it is disallowed.
* Also checks if it includes the " character, which we don't allow in usernames.
* Used for registering, changing names, and posting anonymously with a username
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index cc8565e69d..13167b2b3d 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -65,7 +65,7 @@ class ucp_prefs
$error = validate_data($data, array(
'dateformat' => array('string', false, 1, 30),
- 'lang' => array('match', false, '#^[a-z0-9_\-]{2,}$#i'),
+ 'lang' => array('language_iso_name'),
'tz' => array('num', false, -14, 14),
));
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 7fd99da55a..13b9945851 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -56,7 +56,7 @@ class ucp_register
{
$use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang);
- if (file_exists($user->lang_path . $use_lang . '/'))
+ if (!validate_language_iso_name($use_lang))
{
if ($change_lang)
{
@@ -210,7 +210,7 @@ class ucp_register
array('email')),
'email_confirm' => array('string', false, 6, 60),
'tz' => array('num', false, -14, 14),
- 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'),
+ 'lang' => array('language_iso_name'),
));
if (!check_form_key('ucp_register'))