GenerateRandomString (line
614)
Generates a random string from the caracter set you pass in
string
GenerateRandomString
(int $size, string $chars, [int $flags = 0])
-
int
$size: size the size of the string to generate
-
string
$chars: chars a string containing the characters to use
-
int
$flags: flags a flag to add a specific set to the characters to use: Flags:
- = add lowercase a-z to $chars
- = add uppercase A-Z to $chars
4 = add numbers 0-9 to $chars
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.
string
get_location
()
makeComposeLink (line
704)
Create compose link
Returns a link to the compose-page, taking in consideration the compose_in_new and javascript settings.
string
makeComposeLink
(string $url, [string $text = null], [ $target = ''])
-
string
$url: url the URL to the compose page
-
string
$text: text the link text, default "Compose"
-
$target
OneTimePadCreate (line
565)
Creates encryption key
Creates an encryption key for encrypting the password stored in the cookie. The encryption key itself is stored in the session.
string
OneTimePadCreate
([int $length = 100])
-
int
$length: length optional, length of the string to generate
OneTimePadDecrypt (line
460)
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.
string
OneTimePadDecrypt
(string $string, string $epad)
-
string
$string: string the string to decrypt
-
string
$epad: epad the encryption key from the session
OneTimePadEncrypt (line
430)
Encrypts password
These functions are used to encrypt the password before it is stored in a cookie. The encryption key is generated by OneTimePadCreate();
string
OneTimePadEncrypt
(string $string, string $epad)
-
string
$string: string the (password)string to encrypt
-
string
$epad: epad the encryption key
php_self
Attempts to determine the path and filename and any arguments for the currently executing script. This is usually found in $_SERVER['REQUEST_URI'], but some environments may differ, so this function tries to standardize this value.
string
php_self
()
Escapes special characters for use in IMAP commands.
string
quoteimap
(string $str)
-
string
$str: the string to escape
readShortMailboxName (line
240)
If $haystack is a full mailbox name and $needle is the mailbox separator character, returns the last part of the mailbox name.
string
readShortMailboxName
(string $haystack, string $needle)
-
string
$haystack: haystack full mailbox name to search
-
string
$needle: needle the mailbox separator character
Removes slashes from every element in the array
void
RemoveSlashes
( &$array)
show_readable_size (line
582)
Returns a string showing the size of the message/attachment.
string
show_readable_size
(int $bytes)
-
int
$bytes: bytes the filesize in bytes
sm_encode_html_special_chars (line
1496)
Wrapper for PHP's htmlspecialchars() that attempts to add the correct character encoding
string
sm_encode_html_special_chars
(string $string, [int $flags = ENT_COMPAT], [string $encoding = NULL], [boolean $double_encode = TRUE])
-
string
$string: The string to be converted
-
int
$flags: A bitmask that controls the behavior of htmlspecialchars() (See http://php.net/manual/function.htmlspecialchars.php ) (OPTIONAL; default ENT_COMPAT)
-
string
$encoding: The character encoding to use in the conversion (OPTIONAL; default automatic detection)
-
boolean
$double_encode: Whether or not to convert entities that are already in the string (only supported in PHP 5.2.3+) (OPTIONAL; default TRUE)
sm_generate_security_token (line
1354)
Generates a security token that is then stored in the user's preferences with a timestamp for later verification/use.
NOTE: The administrator can force SquirrelMail to generate a new token every time one is requested (which may increase obscurity through token randomness at the cost of some performance) by adding the following to config/config_local.php: $do_not_use_single_token = TRUE; Otherwise, only one token will be generated per user which will change only after it expires or is used outside of the validity period specified when calling sm_validate_security_token()
WARNING: If the administrator has turned the token system off by setting $disable_security_tokens to TRUE in config/config.php or the configuration tool, this function will not store tokens in the user preferences (but it will still generate and return a random string).
string
sm_generate_security_token
([boolean $force_generate_new = FALSE])
-
boolean
$force_generate_new: When TRUE, a new token will always be created even if current configuration dictates otherwise (OPTIONAL; default FALSE)
sm_get_user_security_tokens (line
1296)
Gathers the list of secuirty tokens currently stored in the user's preferences and optionally purges old ones from the list.
array
sm_get_user_security_tokens
([boolean $purge_old = TRUE])
-
boolean
$purge_old: Indicates if old tokens should be purged from the list ("old" is 2 days or older unless the administrator overrides that value using $max_token_age_days in config/config_local.php) (OPTIONAL; default is to always purge old tokens)
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. The output is wrapped in <pre> and </pre> tags.
void
sm_print_r
()
sm_truncate_string (line
167)
Truncates the given string so that it has at
most $max_chars characters. NOTE that a "character" may be a multibyte character, or (optionally), an HTML entity, so this function is different than using substr() or mb_substr().
NOTE that if $elipses is given and used, the returned number of characters will be $max_chars PLUS the length of $elipses
string
sm_truncate_string
(string $string, int $max_chars, [string $elipses = ''], [boolean $html_entities_as_chars = FALSE])
-
string
$string: The string to truncate
-
int
$max_chars: The maximum allowable characters
-
string
$elipses: A string that will be added to the end of the truncated string (ONLY if it is truncated) (OPTIONAL; default not used)
-
boolean
$html_entities_as_chars: Whether or not to keep HTML entities together (OPTIONAL; default ignore HTML entities)
sm_validate_security_token (line
1426)
Validates a given security token and optionally remove it from the user's preferences if it was valid. If the token is too old but otherwise valid, it will still be rejected.
"Too old" is 2 days or older unless the administrator overrides that value using $max_token_age_days in config/config_local.php
WARNING: If the administrator has turned the token system off by setting $disable_security_tokens to TRUE in config/config.php or the configuration tool, this function will always return TRUE.
boolean
sm_validate_security_token
(string $token, [int $validity_period = 0], [boolean $show_error = FALSE])
-
string
$token: The token to validate
-
int
$validity_period: The number of seconds tokens are valid for (set to zero to remove valid tokens after only one use; use 3600 to allow tokens to be reused for an hour) (OPTIONAL; default is to only allow tokens to be used once) NOTE this is unrelated to $max_token_age_days or rather is an additional time constraint on tokens that allows them to be re-used (or not) within a more narrow timeframe
-
boolean
$show_error: Indicates that if the token is not valid, this function should display a generic error, log the user out and exit - this function will never return in that case. (OPTIONAL; default FALSE)
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.
string
sqm_baseuri
()
Does the opposite of sqWordWrap()
void
sqUnWordWrap
(string &$body)
-
string
&$body: body the text to un-wordwrap
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.
void
sqWordWrap
( &$line, $wrap, [ $charset = null])
version of fwrite which checks for failure
void
sq_fwrite
( $fp, $string)
Tests if string contains 8bit symbols.
If charset is not set, function defaults to default_charset. $default_charset global must be set correctly if $charset is not used.
bool
sq_is8bit
(string $string, [string $charset = ''])
-
string
$string: tested string
-
string
$charset: charset used in a string
sq_lowercase_array_vals (line
1263)
Callback function used to lowercase array values.
void
sq_lowercase_array_vals
( &$val, mixed $key, string $val)
-
string
$val: array value
-
mixed
$key: array key
-
&$val
sq_mb_list_encodings (line
1186)
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. Only the ones that might be used in SM translations.
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.
array
sq_mb_list_encodings
()
sq_mt_randomize (line
522)
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.
void
sq_mt_randomize
()
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.
void
sq_mt_seed
(mixed $Val)
-
mixed
$Val: val a value to seed the random number generator
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.
integer
sq_strlen
( $string, [string $charset = NULL], string $str)
-
string
$str: string
-
string
$charset: charset
-
$string
This is a replacement for PHP's strpos() that is multibyte-aware.
mixed
sq_strpos
(string $haystack, string $needle, [int $offset = 0], [string $charset = 'auto'])
-
string
$haystack: The string to search within
-
string
$needle: The substring to search for
-
int
$offset: The offset from the beginning of $haystack from which to start searching (OPTIONAL; default none)
-
string
$charset: The charset of the given string. A value of NULL here will force the use of PHP's standard strpos(). (OPTIONAL; default is "auto", which indicates that the user's current charset should be used).
This is a replacement for PHP's substr() that is multibyte-aware.
string
sq_substr
(string $string, int $start, [int $length = NULL], [string $charset = 'auto'])
-
string
$string: The string to operate upon
-
int
$start: The offset at which to begin substring extraction
-
int
$length: The number of characters after $start to return NOTE that if you need to specify a charset but want to achieve normal substr() behavior where $length is not specified, use NULL (OPTIONAL; default from $start to end of string)
-
string
$charset: The charset of the given string. A value of NULL here will force the use of PHP's standard substr(). (OPTIONAL; default is "auto", which indicates that the user's current charset should be used).
sq_substr_replace (line
1074)
This is a replacement for PHP's substr_replace() that is multibyte-aware.
string
sq_substr_replace
(string $string, string $replacement, int $start, [int $length = NULL], [string $charset = 'auto'])
-
string
$string: The string to operate upon
-
string
$replacement: The string to be inserted
-
int
$start: The offset at which to begin substring replacement
-
int
$length: The number of characters after $start to remove NOTE that if you need to specify a charset but want to achieve normal substr_replace() behavior where $length is not specified, use NULL (OPTIONAL; default from $start to end of string)
-
string
$charset: The charset of the given string. A value of NULL here will force the use of PHP's standard substr(). (OPTIONAL; default is "auto", which indicates that the user's current charset should be used).
sq_trim_value (line
1272)
Callback function to trim whitespace from a value, to be used in array_walk
void
sq_trim_value
( &$value, string $value)
-
string
$value: value to trim
-
&$value
Trims array
Trims every element in the array, ie. remove the first char of each element Obsolete: will probably removed soon
void
TrimArray
(array &$array)
-
array
&$array: array the array to trim