aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-07-01 10:08:27 +0000
committerrvelices <rv-github@modusoptimus.com>2008-07-01 10:08:27 +0000
commitbc601ec5862bae9a91d956ca19a9e70f053e5c89 (patch)
tree6ee5c78caa1ff4c78298f89edc818706d364fade
parentd91d0ac444a08c664d05c00a8593fc88fbb0c605 (diff)
- put back browser language (deleted by error during my last commit - was working on an old version)
git-svn-id: http://piwigo.org/svn/trunk@2411 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_user.inc.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index abbff998c..56127dd0e 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -838,7 +838,32 @@ function get_default_template()
*/
function get_default_language()
{
- return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE);
+ global $conf;
+ if (isset($conf['browser_language']) and $conf['browser_language'])
+ {
+ return get_browser_language();
+ }
+ else
+ {
+ return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE);
+ }
+}
+
+/**
+ * Returns the browser language value
+ *
+ */
+function get_browser_language()
+{
+ $browser_language = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
+ foreach (get_languages() as $language_code => $language_name)
+ {
+ if (substr($language_code, 0, 2) == $browser_language)
+ {
+ return $language_code;
+ }
+ }
+ return PHPWG_DEFAULT_LANGUAGE;
}
/**
@@ -898,6 +923,7 @@ function create_user_infos($arg_id, $override_values = null)
{
$status = 'normal';
}
+ $default_user['language'] = get_default_language();
$insert = array_merge(
$default_user,
@@ -948,7 +974,7 @@ SELECT name
/**
* returns the auto login key or false on error
* @param int user_id
- * @param time_t time
+ * @param time_t time
* @param string [out] username
*/
function calculate_auto_login_key($user_id, $time, &$username)
@@ -1026,7 +1052,7 @@ function auto_login() {
if ( isset( $_COOKIE[$conf['remember_me_name']] ) )
{
$cookie = explode('-', stripslashes($_COOKIE[$conf['remember_me_name']]));
- if ( count($cookie)===3
+ if ( count($cookie)===3
and is_numeric(@$cookie[0]) /*user id*/
and is_numeric(@$cookie[1]) /*time*/
and time()-$conf['remember_me_length']<=@$cookie[1]