squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

strings.php File Reference

Go to the source code of this file.

Namespaces

 squirrelmail
 

Functions

if(file_exists(SM_PATH . 'plugins/compatibility/functions.php')) sqWordWrap (&$line, $wrap, $charset=null)
 
 sqUnWordWrap (&$body)
 
 sm_truncate_string ($string, $max_chars, $elipses='', $html_entities_as_chars=FALSE)
 
 readShortMailboxName ($haystack, $needle)
 
 php_self ()
 
 sqm_baseuri ()
 
 get_location ()
 
 OneTimePadEncrypt ($string, $epad)
 
 OneTimePadDecrypt ($string, $epad)
 
 sq_mt_seed ($Val)
 
 sq_mt_randomize ()
 
 OneTimePadCreate ($length=100)
 
 show_readable_size ($bytes)
 
 GenerateRandomString ($size, $chars, $flags=0)
 
 quoteimap ($str)
 
 TrimArray (&$array)
 
 RemoveSlashes (&$array)
 
 makeComposeLink ($url, $text=null, $target='')
 
 sm_print_r ()
 
 sq_fwrite ($fp, $string)
 
 sq_is8bit ($string, $charset='')
 
 sq_strlen ($string, $charset=NULL)
 
 sq_strpos ($haystack, $needle, $offset=0, $charset='auto')
 
 sq_substr ($string, $start, $length=NULL, $charset='auto')
 
 sq_substr_replace ($string, $replacement, $start, $length=NULL, $charset='auto')
 
 sq_mb_list_encodings ()
 
 sq_lowercase_array_vals (&$val, $key)
 
 sq_trim_value (&$value)
 
 sm_get_user_security_tokens ($purge_old=TRUE)
 
 sm_generate_security_token ()
 
 sm_validate_security_token ($token, $validity_period=0, $show_error=FALSE)
 

Variables

global $version = '1.4.22'
 
global $SQM_INTERNAL_VERSION = array(1,4,22)
 
 $PHP_SELF = php_self()
 

Function Documentation

◆ GenerateRandomString()

GenerateRandomString (   $size,
  $chars,
  $flags = 0 
)

Generates a random string from the caracter set you pass in

Parameters
intsize the size of the string to generate
stringchars a string containing the characters to use
intflags a flag to add a specific set to the characters to use: Flags: 1 = add lowercase a-z to $chars 2 = add uppercase A-Z to $chars 4 = add numbers 0-9 to $chars
Returns
string the random string

Definition at line 614 of file strings.php.

References $j, and sq_mt_randomize().

Referenced by attachSelectedMessages(), getAttachments(), getMessage_RFC822_Attachment(), Deliver\prepareRFC822_Header(), and saveAttachedFiles().

◆ get_location()

get_location ( )

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.

Returns
string the base url for this SquirrelMail installation

Definition at line 340 of file strings.php.

References $config_location_base, $imap_server_type, $is_secure_connection, php_self(), sprintf, SQ_SERVER, SQ_SESSION, sqgetGlobalVar(), and sqsession_register().

◆ makeComposeLink()

makeComposeLink (   $url,
  $text = null,
  $target = '' 
)

Create compose link

Returns a link to the compose-page, taking in consideration the compose_in_new and javascript settings.

Parameters
stringurl the URL to the compose page
stringtext the link text, default "Compose"
Returns
string a link to the compose page

Definition at line 704 of file strings.php.

References $base_uri, $compose_new_win, $javascript_on, $url, _(), makeInternalLink(), SQ_SESSION, and sqgetGlobalVar().

Referenced by displayPageHeader(), formatMenubar(), magicHTML(), parseEmail(), parseUrl(), and plugin_listcommands_menu().

◆ OneTimePadCreate()

OneTimePadCreate (   $length = 100)

Creates encryption key

Creates an encryption key for encrypting the password stored in the cookie. The encryption key itself is stored in the session.

Parameters
intlength optional, length of the string to generate
Returns
string the encryption key

Definition at line 565 of file strings.php.

References sq_mt_randomize().

Referenced by sqauth_save_password().

◆ OneTimePadDecrypt()

OneTimePadDecrypt (   $string,
  $epad 
)

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.

Parameters
stringstring the string to decrypt
stringepad the encryption key from the session
Returns
string the decrypted password

Definition at line 460 of file strings.php.

Referenced by sqauth_read_password(), sqimap_login(), sqspell_getWords(), and sqspell_writeWords().

◆ OneTimePadEncrypt()

OneTimePadEncrypt (   $string,
  $epad 
)

Encrypts password

These functions are used to encrypt the password before it is stored in a cookie. The encryption key is generated by OneTimePadCreate();

Parameters
stringstring the (password)string to encrypt
stringepad the encryption key
Returns
string the base64-encoded encrypted password

Definition at line 430 of file strings.php.

Referenced by sqauth_save_password().

◆ php_self()

php_self ( )

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.

Since
1.2.3
Returns
string The path, filename and any arguments for the current script

Definition at line 266 of file strings.php.

References SQ_SERVER, and sqgetGlobalVar().

Referenced by get_location().

◆ quoteimap()

quoteimap (   $str)

Escapes special characters for use in IMAP commands.

Parameters
stringthe string to escape
Returns
string the escaped string

Definition at line 646 of file strings.php.

Referenced by sqimap_login().

◆ readShortMailboxName()

readShortMailboxName (   $haystack,
  $needle 
)

If $haystack is a full mailbox name and $needle is the mailbox separator character, returns the last part of the mailbox name.

Parameters
stringhaystack full mailbox name to search
stringneedle the mailbox separator character
Returns
string the last part of the mailbox name

Definition at line 240 of file strings.php.

Referenced by displayPageHeader(), sqimap_mailbox_list_all(), and sqimap_mailbox_parse().

◆ RemoveSlashes()

RemoveSlashes ( $array)

Removes slashes from every element in the array

Definition at line 678 of file strings.php.

◆ show_readable_size()

show_readable_size (   $bytes)

Returns a string showing the size of the message/attachment.

Parameters
intbytes the filesize in bytes
Returns
string the filesize in human readable format

Definition at line 582 of file strings.php.

Referenced by formatAttachments(), pf_show_attachments(), printMessageInfo(), and showInputForm().

◆ sm_generate_security_token()

sm_generate_security_token ( )

Generates a security token that is then stored in the user's preferences with a timestamp for later verification/use.

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).

Returns
string A security token
Since
1.4.19 and 1.5.2

Definition at line 1340 of file strings.php.

Referenced by addForm(), delete_move_next_moveNextForm(), delete_move_next_moveRightMainForm(), delete_move_next_read(), formatMailboxName(), formatMenubar(), printSearchMessages(), and showInputForm().

◆ sm_get_user_security_tokens()

sm_get_user_security_tokens (   $purge_old = TRUE)

Gathers the list of secuirty tokens currently stored in the user's preferences and optionally purges old ones from the list.

Parameters
boolean$purge_oldIndicates 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)
Returns
array The list of tokens
Since
1.4.19 and 1.5.2

Definition at line 1296 of file strings.php.

◆ sm_print_r()

sm_print_r ( )

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@.nosp@m.emai.nosp@m.l.add.nosp@m.ress to be displayed. The output is wrapped in <

> and <

> tags.

Returns
void

Definition at line 747 of file strings.php.

◆ sm_truncate_string()

sm_truncate_string (   $string,
  $max_chars,
  $elipses = '',
  $html_entities_as_chars = FALSE 
)

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

Parameters
string$stringThe string to truncate
int$max_charsThe maximum allowable characters
string$elipsesA 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_charsWhether or not to keep HTML entities together (OPTIONAL; default ignore HTML entities)
Returns
string The truncated string
Since
1.4.20 and 1.5.2 (replaced truncateWithEntities())

Definition at line 167 of file strings.php.

References sq_strlen(), sq_strpos(), and sq_substr().

Referenced by printMessageInfo().

◆ sm_validate_security_token()

sm_validate_security_token (   $token,
  $validity_period = 0,
  $show_error = FALSE 
)

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.

Parameters
string$tokenThe token to validate
int$validity_periodThe 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)
boolean$show_errorIndicates 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)
Returns
boolean TRUE if the token validated; FALSE otherwise
Since
1.4.19 and 1.5.2

Definition at line 1405 of file strings.php.

Referenced by delete_move_next_delete(), delete_move_next_move(), and delete_move_next_unread().

◆ sq_fwrite()

sq_fwrite (   $fp,
  $string 
)

version of fwrite which checks for failure

Definition at line 763 of file strings.php.

Referenced by abook_local_file\add(), abook_local_file\overwrite(), savePrefValues(), setSig(), and writecalendardata().

◆ sq_is8bit()

sq_is8bit (   $string,
  $charset = '' 
)

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.

Parameters
string$stringtested string
string$charsetcharset used in a string
Returns
bool true if 8bit symbols are detected
Since
1.5.1 and 1.4.4

Don't use \240 in ranges. Sometimes RH 7.2 doesn't like it. Don't use \200-\237 for iso-8859-x charsets. This ranges stores control symbols in those charsets. Use preg_match instead of ereg in order to avoid problems with mbstring overloading

Definition at line 784 of file strings.php.

Referenced by charset_decode_cp1250(), charset_decode_cp1251(), charset_decode_cp1252(), charset_decode_cp1253(), charset_decode_cp1254(), charset_decode_cp1255(), charset_decode_cp1256(), charset_decode_cp1257(), charset_decode_cp1258(), charset_decode_cp855(), charset_decode_cp866(), charset_decode_iso_8859_1(), charset_decode_iso_8859_10(), charset_decode_iso_8859_11(), charset_decode_iso_8859_13(), charset_decode_iso_8859_14(), charset_decode_iso_8859_15(), charset_decode_iso_8859_16(), charset_decode_iso_8859_2(), charset_decode_iso_8859_3(), charset_decode_iso_8859_4(), charset_decode_iso_8859_5(), charset_decode_iso_8859_6(), charset_decode_iso_8859_7(), charset_decode_iso_8859_8(), charset_decode_iso_8859_9(), charset_decode_iso_ir_111(), charset_decode_koi8_r(), charset_decode_koi8_u(), charset_decode_tis_620(), charset_decode_us_ascii(), charset_decode_utf_8(), encodeHeader(), japanese_charset_xtra(), SendMDN(), and sqimap_login().

◆ sq_lowercase_array_vals()

sq_lowercase_array_vals ( $val,
  $key 
)

Callback function used to lowercase array values.

Parameters
string$valarray value
mixed$keyarray key
Since
1.5.1 and 1.4.6

Definition at line 1263 of file strings.php.

◆ sq_mb_list_encodings()

sq_mb_list_encodings ( )

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.

Returns
array list of encodings supported by php mbstring extension
Since
1.5.1 and 1.4.6

Definition at line 1186 of file strings.php.

Referenced by encodeHeader(), and sqimap_mb_convert_encoding().

◆ sq_mt_randomize()

sq_mt_randomize ( )

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.

Returns
void

Definition at line 522 of file strings.php.

References sq_mt_seed(), SQ_SERVER, and sqgetGlobalVar().

Referenced by GenerateRandomString(), and OneTimePadCreate().

◆ sq_mt_seed()

sq_mt_seed (   $Val)

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.

Parameters
mixedval a value to seed the random number generator
Returns
void

Definition at line 492 of file strings.php.

Referenced by sq_mt_randomize().

◆ sq_strlen()

sq_strlen (   $string,
  $charset = NULL 
)

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.

Parameters
string$strstring
string$charsetcharset
Since
1.5.1 and 1.4.6
Returns
integer number of characters in string

Definition at line 816 of file strings.php.

Referenced by sm_truncate_string(), and sqWordWrap().

◆ sq_strpos()

sq_strpos (   $haystack,
  $needle,
  $offset = 0,
  $charset = 'auto' 
)

This is a replacement for PHP's strpos() that is multibyte-aware.

Parameters
string$haystackThe string to search within
string$needleThe substring to search for
int$offsetThe offset from the beginning of $haystack from which to start searching (OPTIONAL; default none)
string$charsetThe 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).
Returns
mixed The integer offset of the next $needle in $haystack, if found, or FALSE if not found

Definition at line 895 of file strings.php.

Referenced by sm_truncate_string().

◆ sq_substr()

sq_substr (   $string,
  $start,
  $length = NULL,
  $charset = 'auto' 
)

This is a replacement for PHP's substr() that is multibyte-aware.

Parameters
string$stringThe string to operate upon
int$startThe offset at which to begin substring extraction
int$lengthThe 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$charsetThe 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).
Returns
string The desired substring

Of course, you can use more advanced (e.g., negative) values for $start and $length as needed - see the PHP manual for more information: http://www.php.net/manual/function.substr.php

Definition at line 980 of file strings.php.

Referenced by sm_truncate_string().

◆ sq_substr_replace()

sq_substr_replace (   $string,
  $replacement,
  $start,
  $length = NULL,
  $charset = 'auto' 
)

This is a replacement for PHP's substr_replace() that is multibyte-aware.

Parameters
string$stringThe string to operate upon
string$replacementThe string to be inserted
int$startThe offset at which to begin substring replacement
int$lengthThe 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$charsetThe 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).
Returns
string The manipulated string

Of course, you can use more advanced (e.g., negative) values for $start and $length as needed - see the PHP manual for more information: http://www.php.net/manual/function.substr-replace.php

Definition at line 1074 of file strings.php.

◆ sq_trim_value()

sq_trim_value ( $value)

Callback function to trim whitespace from a value, to be used in array_walk

Parameters
string$valuevalue to trim
Since
1.5.2 and 1.4.7

Definition at line 1272 of file strings.php.

◆ sqm_baseuri()

sqm_baseuri ( )

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.

Returns
string the base uri of squirrelmail installation.

If it is in the session, just return it.

Definition at line 315 of file strings.php.

References $base_uri, $PHP_SELF, SQ_SESSION, and sqgetGlobalVar().

Referenced by displayHtmlHeader(), logout_error(), and newmail_plugin().

◆ sqUnWordWrap()

sqUnWordWrap ( $body)

Does the opposite of sqWordWrap()

Parameters
stringbody the text to un-wordwrap
Returns
void

Definition at line 105 of file strings.php.

References $body, $cnt, and $squirrelmail_language.

Referenced by newMail().

◆ sqWordWrap()

if (file_exists(SM_PATH . 'plugins/compatibility/functions.php')) sqWordWrap ( $line,
  $wrap,
  $charset = null 
)

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.Wraps text at $wrap characters

Has a problem with special HTML characters, so call this before you do character translation.

Specifically, &#039 comes up as 5 characters instead of 1. This should not add newlines to the end of lines.

Definition at line 48 of file strings.php.

References $charset, $languages, $squirrelmail_language, and sq_strlen().

Referenced by newMail(), and translateText().

◆ TrimArray()

TrimArray ( $array)

Trims array

Trims every element in the array, ie. remove the first char of each element Obsolete: will probably removed soon

Parameters
arrayarray the array to trim @obsolete

Definition at line 659 of file strings.php.

Variable Documentation

◆ $PHP_SELF

◆ $SQM_INTERNAL_VERSION

$SQM_INTERNAL_VERSION = array(1,4,22)

SquirrelMail internal version number – DO NOT CHANGE $sm_internal_version = array (release, major, minor)

Definition at line 25 of file strings.php.

Referenced by check_sm_version().

◆ $version

$version = '1.4.22'

SquirrelMail version number – DO NOT CHANGE

Definition at line 18 of file strings.php.