Replacing HTML "script" element deprecated attribute "language".
[squirrelmail.git] / functions / strings.php
index df511b32f36e5fec1cdf682a8fa134e62f1f8f9c..2493b135878aa31dc74ff2c6d164959c92113a28 100644 (file)
@@ -6,7 +6,7 @@
  * This code provides various string manipulation functions that are
  * used by the rest of the SquirrelMail code.
  *
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright © 1999-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -35,6 +35,12 @@ $SQM_INTERNAL_VERSION = array(1,5,1);
  */
 include_once(SM_PATH . 'functions/global.php');
 
+/**
+ * Include Compatibility plugin if available.
+ */
+if (file_exists(SM_PATH . 'plugins/compatibility/functions.php'))
+    include_once(SM_PATH . 'plugins/compatibility/functions.php');
+
 /**
  * Appends citation markers to the string.
  * Also appends a trailing space.
@@ -477,6 +483,29 @@ function readShortMailboxName($haystack, $needle) {
     return( $elem );
 }
 
+/**
+ * Find out where SquirrelMail lives and try to be smart about it.
+ * The only problem would be when SquirrelMail lives in directories
+ * called "src", "functions", or "plugins", but people who do that need
+ * to be beaten with a steel pipe anyway.
+ *
+ * @return string the base uri of SquirrelMail installation.
+ * @since 1.2.6
+ */
+function sqm_baseuri(){
+    global $base_uri, $PHP_SELF;
+    /**
+     * If it is in the session, just return it.
+     */
+    if (isset($base_uri)){
+        return $base_uri;
+    }
+    $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
+    $repl = array('', '', '');
+    $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
+    return $base_uri;
+}
+
 /**
  * get_location
  *
@@ -1145,9 +1174,10 @@ function sq_strlen($str, $charset=null){
 
     // use automatic charset detection, if function call asks for it
     if ($charset=='auto') {
-        global $default_charset;
+        global $default_charset, $squirrelmail_language;
         set_my_charset();
         $charset=$default_charset;
+        if ($squirrelmail_language=='ja_JP') $charset='euc-jp';
     }
 
     // Use mbstring only with listed charsets
@@ -1212,9 +1242,10 @@ function sq_str_pad($string, $width, $pad, $padtype, $charset='') {
 function sq_substr($string,$start,$length,$charset='auto') {
     // use automatic charset detection, if function call asks for it
     if ($charset=='auto') {
-        global $default_charset;
+        global $default_charset, $squirrelmail_language;
         set_my_charset();
         $charset=$default_charset;
+        if ($squirrelmail_language=='ja_JP') $charset='euc-jp';
     }
     $charset = strtolower($charset);
     if (function_exists('mb_internal_encoding') &&
@@ -1242,9 +1273,10 @@ function sq_substr($string,$start,$length,$charset='auto') {
 function sq_strpos($haystack,$needle,$offset,$charset='auto') {
     // use automatic charset detection, if function call asks for it
     if ($charset=='auto') {
-        global $default_charset;
+        global $default_charset, $squirrelmail_language;
         set_my_charset();
         $charset=$default_charset;
+        if ($squirrelmail_language=='ja_JP') $charset='euc-jp';
     }
     $charset = strtolower($charset);
     if (function_exists('mb_internal_encoding') &&
@@ -1270,9 +1302,10 @@ function sq_strpos($haystack,$needle,$offset,$charset='auto') {
 function sq_strtoupper($string,$charset='auto') {
     // use automatic charset detection, if function call asks for it
     if ($charset=='auto') {
-        global $default_charset;
+        global $default_charset,$squirrelmail_language;
         set_my_charset();
         $charset=$default_charset;
+        if ($squirrelmail_language=='ja_JP') $charset='euc-jp';
     }
     $charset = strtolower($charset);
     if (function_exists('mb_strtoupper') &&
@@ -1298,4 +1331,4 @@ function sq_count8bit($string) {
     return $count;
 }
 
-?>
\ No newline at end of file
+?>