strings.php
This code provides various string manipulation functions that are used by the rest of the SquirrelMail code.
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.
Generates a random string from the caracter set you pass in
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.
Create compose link
Returns a link to the compose-page, taking in consideration the compose_in_new and javascript settings.
Creates encryption key
Creates an encryption key for encrypting the password stored in the cookie. The encryption key itself is stored in the session.
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.
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
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.
Escapes special characters for use in IMAP commands.
If $haystack is a full mailbox name and $needle is the mailbox separator character, returns the last part of the mailbox name.
Removes slashes from every element in the array
Returns a string showing the size of the message/attachment.
Wrapper for PHP's htmlspecialchars() that attempts to add the correct character encoding
Generates a security token that is then stored in the user's preferences with a timestamp for later verification/use (although session-based tokens are not stored in user preferences).
NOTE: By default SquirrelMail will use a single session-based token, but if desired, user tokens can have expiration dates associated with them and become invalid even during the same login session. When in that mode, the note immediately below applies, otherwise it is irrelevant. To enable that mode, the administrator must add the following to config/config_local.php: $use_expiring_security_tokens = TRUE;
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).
Gathers the list of secuirty tokens currently stored in the user's preferences and optionally purges old ones from the list.
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 <[email protected]> to be displayed. The output is wrapped in <pre> and </pre> tags.
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
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
Session-based tokens of course are always reused and are valid for the lifetime of the login session.
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.
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.
Does the opposite of sqWordWrap()
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.
version of fwrite which checks for failure
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.
Callback function used to lowercase array values.
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.
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.
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.
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.
This is a replacement for PHP's strpos() that is multibyte-aware.
This is a replacement for PHP's substr() that is multibyte-aware.
This is a replacement for PHP's substr_replace() that is multibyte-aware.
Callback function to trim whitespace from a value, to be used in array_walk
Trims array
Trims every element in the array, ie. remove the first char of each element Obsolete: will probably removed soon
Documentation generated on Mon, 13 Jan 2020 04:25:22 +0100 by phpDocumentor 1.4.3