/**
* strings.php
*
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* This code provides various string manipulation functions that are
* used by the rest of the SquirrelMail code.
*
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
*/
-/** @ignore */
-if (!defined('SM_PATH')) define('SM_PATH','../');
-
-/**
- * SquirrelMail version number -- DO NOT CHANGE
- */
-global $version;
-$version = '1.5.1 [CVS]';
-
-/**
- * SquirrelMail internal version number -- DO NOT CHANGE
- * $sm_internal_version = array (release, major, minor)
- */
-global $SQM_INTERNAL_VERSION;
-$SQM_INTERNAL_VERSION = array(1,5,1);
-
-/**
- * There can be a circular issue with includes, where the $version string is
- * referenced by the include of global.php, etc. before it's defined.
- * For that reason, bring in global.php AFTER we define the version strings.
- */
-include_once(SM_PATH . 'functions/global.php');
-
/**
* Appends citation markers to the string.
* Also appends a trailing space.
return( $elem );
}
-/**
- * php_self
- *
- * Creates an URL for the page calling this function, using either the PHP global
- * REQUEST_URI, or the PHP global PHP_SELF with QUERY_STRING added.
- *
- * @return string the complete url for this page
- * @since 1.2.3
- */
-function php_self () {
- if ( sqgetGlobalVar('REQUEST_URI', $req_uri, SQ_SERVER) && !empty($req_uri) ) {
- return $req_uri;
- }
-
- if ( sqgetGlobalVar('PHP_SELF', $php_self, SQ_SERVER) && !empty($php_self) ) {
-
- // need to add query string to end of PHP_SELF to match REQUEST_URI
- //
- if ( sqgetGlobalVar('QUERY_STRING', $query_string, SQ_SERVER) && !empty($query_string) ) {
- $php_self .= '?' . $query_string;
- }
-
- return $php_self;
- }
-
- return '';
-}
-
/**
* get_location
// if javascript is on, use onclick event to handle it
if($javascript_on) {
sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
- $compuri = $base_uri.$url;
+ $compuri = SM_BASE_URI.$url;
return "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$compuri','$compose_width','$compose_height')\">$text</a>";
}
* If you want to test all mbstring encodings - fill $list_of_encodings
* array.
* @return array list of encodings supported by php mbstring extension
- * @since 1.5.1
+ * @since 1.5.1 and 1.4.6
*/
function sq_mb_list_encodings() {
if (! function_exists('mb_internal_encoding'))
'windows-1256',
'tis-620',
'iso-2022-jp',
+ 'euc-cn',
'euc-kr',
+ 'euc-tw',
+ 'uhc',
'utf7-imap');
$supported_encodings=array();
* Callback function used to lowercase array values.
* @param string $val array value
* @param mixed $key array key
- * @since 1.5.1
+ * @since 1.5.1 and 1.4.6
*/
function sq_lowercase_array_vals(&$val,$key) {
$val = strtolower($val);
* vanilla string length function is used.
* @param string $str string
* @param string $charset charset
- * @since 1.5.1
+ * @since 1.5.1 and 1.4.6
* @return integer number of characters in string
*/
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
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') &&
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') &&
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') &&
// use vanilla string functions as last option
return strtoupper($string);
}
-$PHP_SELF = php_self();
-?>
\ No newline at end of file
+
+/**
+ * Counts 8bit bytes in string
+ * @param string $string tested string
+ * @return integer number of 8bit bytes
+ */
+function sq_count8bit($string) {
+ $count=0;
+ for ($i=0; $i<strlen($string); $i++) {
+ if (ord($string[$i]) > 127) $count++;
+ }
+ return $count;
+}
+
+/**
+ * Callback function to trim whitespace from a value, to be used in array_walk
+ * @param string $value value to trim
+ * @since 1.5.2 and 1.4.7
+ */
+function sq_trim_value ( &$value ) {
+ $value = trim($value);
+}
+
+?>