Add option to ask users for personal information on first login.
[squirrelmail.git] / include / languages.php
index 342b9336af15c1cfeb299c036017d61004a64eb8..e79764290f169c53cf1690d3092ed79931900d7f 100644 (file)
@@ -9,7 +9,12 @@
  * Internally the output character set is used. Other characters are
  * encoded using Unicode entities according to HTML 4.0.
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * Before 1.5.2 functions were stored in functions/i18n.php. Script is moved
+ * because it executes some code in order to detect functions supported by
+ * existing PHP installation and implements fallback functions when required
+ * functions are not available. Scripts in functions/ directory should not
+ * setup anything when they are loaded.
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -72,11 +77,11 @@ function sq_textdomain($domain) {
  * @see http://www.php.net/setlocale
  */
 function sq_setlocale($category,$locale) {
-    // string with only one locale
-    if (is_string($locale))
-        return setlocale($category,$locale);
-
-    if (! check_php_version(4,3)) {
+    if (is_string($locale)) {
+        // string with only one locale
+        $ret = setlocale($category,$locale);
+    } elseif (! check_php_version(4,3)) {
+        // older php version (second setlocale argument must be string)
         $ret=false;
         $index=0;
         while ( ! $ret && $index<count($locale)) {
@@ -87,6 +92,17 @@ function sq_setlocale($category,$locale) {
         // php 4.3.0 or better, use entire array
         $ret=setlocale($category,$locale);
     }
+
+    /* safety checks */
+    if (preg_match("/^.*\/.*\/.*\/.*\/.*\/.*$/",$ret)) {
+        /**
+         * Welcome to We-Don't-Follow-Own-Fine-Manual department
+         * OpenBSD 3.8, 3.9-current and maybe later versions 
+         * return invalid response to setlocale command.
+         * SM bug report #1427512.
+         */
+        $ret = false;
+    }
     return $ret;
 }
 
@@ -191,7 +207,7 @@ function charset_decode ($charset, $string, $force_decode=false, $save_html=fals
  * @param string $string
  * @param string $charset
  * @param boolean $htmlencode keep htmlspecialchars encoding
- * @param string
+ * @return string
  */
 function charset_encode($string,$charset,$htmlencode=true) {
     global $default_charset;
@@ -1087,4 +1103,3 @@ elseif ($gettext_flags == 0) {
         }
     }
 }
-?>
\ No newline at end of file