/nasmail/functions/strings.phpstrings.php
This code provides various string manipulation functions that are used by the rest of the SquirrelMail code.
This script contains modifications ported from SquirrelMail 1.4.9+. See commits tagged with SM-PATCH keyword. Modifications are copyrighted by the SquirrelMail Project Team. Copyright (c) 2007 The SquirrelMail Project Team
include_once
(SM_PATH.'plugins/compatibility/functions.php')
(line 51)
NaSMail compatibility plugin include
include_once
(SM_PATH.'functions/global.php')
(line 46)
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.
GenerateRandomString (line 535)
Generates a random string from the caracter set you pass in
get_location (line 274)
get_location
Determines the location to forward to, relative to your server. This is used in HTTP Location: redirects. If set, it uses $config_location_base as the first part of the URL, specifically, the protocol, hostname and port parts. The path is always autodetected.
nsm_addslashes (line 963)
PHP addslashes replacement that does not depend on correct magic_quotes_sybase setting.
nsm_cstrcasecmp (line 948)
Locale insensitive strcasecmp
Function compares two strings in LC_CTYPE=C locale. Arguments and return values are the same as in standard PHP strcasecmp().
nsm_cstrtolower (line 911)
Locale insensitive strtolower
Function converts string to lower case in LC_CTYPE=C locale
nsm_cstrtoupper (line 927)
Locale insensitive strtoupper
Function converts string to upper case in LC_CTYPE=C locale
nsm_process_upload_errors (line 1006)
Converts PHP 4.2+ upload error codes to human readable (and translated) string
Function always runs in NaSMail gettext domain. Don't use it to detect upload errors. Function only provides error message _after_ upload error is detected.
nsm_setint_u32 (line 1060)
Makes sure that number is 32bit unsigned integer
Primary function use - sanitizing of passed_id value.
nsm_string_compare (line 1084)
Compares two strings
Function fixes PHP quirk, when "0" is treated as integer and string evaluation checks return unpredicted results.
nsm_str_pad (line 980)
Multibyte aware string padding
Currently code allows only ascii symbols in $pad_string. If pad is not in ascii, code won't be able to calculate correct pad string.
OneTimePadCreate (line 486)
Creates encryption key
Creates an encryption key for encrypting the password stored in the cookie. The encryption key itself is stored in the session.
OneTimePadDecrypt (line 381)
Decrypts a password from the cookie
Decrypts a password from the cookie, encrypted by OneTimePadEncrypt. This uses the encryption key that is stored in the session.
OneTimePadEncrypt (line 351)
Encrypts password
These functions are used to encrypt the password before it is stored in a cookie. The encryption key is generated by OneTimePadCreate();
php_self (line 220)
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.
quoteimap (line 568)
Escapes special characters for use in IMAP commands.
readShortMailboxName (line 199)
If $haystack is a full mailbox name and $needle is the mailbox separator character, returns the last part of the mailbox name.
RemoveSlashes (line 601)
Removes slashes from every element in the array
Slashes are removed from array keys and values
show_readable_size (line 503)
Returns a string showing the size of the message/attachment.
sm_print_r (line 630)
Print variable
sm_print_r($some_variable, [$some_other_variable [, ...]]);
Debugging function - does the same as print_r, but makes sure special characters are converted to htmlentities first. This will allow values like <some@email.address> to be displayed. If variable is object, object methods are printed. The output is wrapped in <pre> and </pre> tags.
sqm_baseuri (line 249)
Find out where scripts live and try to be smart about it.
The only problem would be when scripts live in directories called "src", "functions", or "plugins", but people who do that need to be beaten with a steel pipe anyway.
sqUnWordWrap (line 115)
Does the opposite of sqWordWrap()
sqWordWrap (line 67)
Wraps text at $wrap characters
Has a problem with special HTML characters, so call this before you do character translation.
Specifically, ' comes up as 5 characters instead of 1. This should not add newlines to the end of lines.
sq_fwrite (line 663)
version of fwrite which checks for failure
sq_is8bit (line 681)
Tests if string contains 8bit symbols.
If charset is not set, function defaults to utf-8.
sq_lowercase_array_vals (line 823)
Callback function used to lowercase array values.
sq_mb_list_encodings (line 753)
Replacement of mb_list_encodings function
This function provides replacement for function that is available only in php 5.x. Function does not test all mbstring encodings.
Supported strings are stored in session in order to reduce number of mb_internal_encoding function calls.
If mb_list_encodings() function is present, code uses it. Main difference from original function behaviour - array values are lowercased in order to simplify use of returned array in in_array() checks.
If you want to test all mbstring encodings - fill $list_of_encodings array.
sq_mt_randomize (line 443)
Init random number generator
This function initializes the random number generator fairly well. It also only initializes it once, so you don't accidentally get the same 'random' numbers twice in one session.
sq_mt_seed (line 413)
Randomizes the mt_rand() function.
Toss this in strings or integers and it will seed the generator appropriately. With strings, it is better to get them long. Use md5() to lengthen smaller strings.
sq_strlen (line 710)
Function returns number of characters in string.
Returned number might be different from number of bytes in string, if $charset is multibyte charset. Detection depends on mbstring functions. If mbstring does not support tested multibyte charset, vanilla string length function is used.
sq_strpos (line 882)
Wrapper that is used to switch between vanilla and multibyte strpos functions.
sq_substr (line 847)
Wrapper that is used to switch between vanilla and multibyte substr functions.
sq_trim_value (line 831)
Callback function to trim whitespace from a value, to be used in array_walk
TrimArray (line 579)
Trims array
Trims every element in the array, ie. remove the first char of each element Obsolete: will probably removed soon
truncateWithEntities (line 152)
Truncates a string and take care of html encoded characters
Documentation generated on Sun, 22 Nov 2009 17:36:51 +0200 by phpDocumentor 1.4.3