GenerateRandomString (line
746)
Generates a random string from the character set you pass in
string
GenerateRandomString
(int $size, string $chars, [int $flags = 0])
-
int
$size: the length of the string to generate
-
string
$chars: a string containing the characters to use
-
int
$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
794)
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], [string $target = ''])
-
string
$url: the URL to the compose page
-
string
$text: the link text, default "Compose"
-
string
$target: (since 1.4.3) url target
OneTimePadCreate (line
695)
Creates encryption key
Creates an encryption key for encrypting the password stored in the cookie. The encryption key itself is stored in the session.
Pad must be longer or equal to encoded string length in 1.4.4/1.5.0 and older.
string
OneTimePadCreate
([int $length = 100])
-
int
$length: optional, length of the string to generate
OneTimePadDecrypt (line
586)
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: the string to decrypt
-
string
$epad: the encryption key from the session
OneTimePadEncrypt (line
555)
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: the (password)string to encrypt
-
string
$epad: the encryption key
Escapes special characters for use in IMAP commands.
string
quoteimap
(string $str)
-
string
$str: the string to escape
readShortMailboxName (line
443)
If $haystack is a full mailbox name and $needle is the mailbox separator character, returns the last part of the mailbox name.
string
readShortMailboxName
(mixed $haystack, mixed $needle)
show_readable_size (line
713)
Returns a string showing the size of the message/attachment.
string
show_readable_size
(int $bytes)
-
int
$bytes: the filesize in bytes
Checks for spaces in strings - only used if PHP doesn't have native ctype support
You might be able to rewrite the function by adding short evaluation form.
possible problems:
- iso-2022-xx charsets - hex 20 might be part of other symbol. I might
be wrong. 0x20 is not used in iso-2022-jp. I haven't checked iso-2022-kr and iso-2022-cn mappings.
- no-break space ( ) - it is 8bit symbol, that depends on charset.
there are at least three different charset groups that have nbsp in different places.
I don't see any charset/nbsp options in php ctype either.
bool
sm_ctype_space
(string $string)
-
string
$string: tested string
Wraps text at $wrap characters. While sqWordWrap takes a single line of text and wraps it, this function works on the entire corpus at once, this allows it to be a little bit smarter and when and how to wrap.
string
&sqBodyWrap
( &$body, int $wrap, string $body)
-
string
$body: the entire body of text
-
int
$wrap: the maximum line length
-
&$body
Appends citation markers to the string.
Also appends a trailing space.
null
sqMakeCite
( &$str, int $citeLevel, string $str)
-
string
$str: The string to append to
-
int
$citeLevel: the number of markers to append
-
&$str
Create a newline in the string, adding citation markers to the newline as necessary.
null
sqMakeNewLine
( &$str, int $citeLevel, &$column, string $str, int $column)
-
string
$str: the string to make a newline in
-
int
$citeLevel: the citation level the newline is at
-
int
$column: starting column of the newline
-
&$str
-
&$column
Does the opposite of sqWordWrap()
void
sqUnWordWrap
( &$body, string $body)
-
string
$body: the text to un-wordwrap
-
&$body
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, int $wrap, [string $charset = ''], string $line)
-
string
$line: the line of text to wrap, by ref
-
int
$wrap: the maximum line lenth
-
string
$charset: name of charset used in $line string. Available since v.1.5.1.
-
&$line
Counts 8bit bytes in string
integer
sq_count8bit
(string $string)
-
string
$string: tested string
version of fwrite which checks for failure
number
sq_fwrite
(resource $fp, string $string)
-
resource
$fp
-
string
$string
sq_get_html_translation_table (line
859)
sq_get_html_translation_table
Returns the translation table used by sq_htmlentities()
array
sq_get_html_translation_table
(integer $table, [integer $quote_style = ENT_COMPAT], [string $charset = 'us-ascii'])
-
integer
$table: html translation table. Possible values (without quotes):
- HTML_ENTITIES - full html entities table defined by charset
- HTML_SPECIALCHARS - html special characters table
-
integer
$quote_style: quote encoding style. Possible values (without quotes):
- ENT_COMPAT - (default) encode double quotes
- ENT_NOQUOTES - don't encode double or single quotes
- ENT_QUOTES - encode double and single quotes
-
string
$charset: charset used for encoding. default to us-ascii, 'auto' uses $default_charset global value.
sq_htmlentities (line
923)
sq_htmlentities
Convert all applicable characters to HTML entities. Minimal php requirement - v.4.0.5.
Function is designed for people that want to use full power of htmlentities() in i18n environment.
string
sq_htmlentities
(string $string, [integer $quote_style = ENT_COMPAT], [string $charset = 'us-ascii'])
-
string
$string: string that has to be sanitized
-
integer
$quote_style: quote encoding style. Possible values (without quotes):
- ENT_COMPAT - (default) encode double quotes
- ENT_NOQUOTES - don't encode double or single quotes
- ENT_QUOTES - encode double and single quotes
-
string
$charset: charset used for encoding. defaults to 'us-ascii', 'auto' uses $default_charset global value.
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
1046)
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
976)
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 you want to test all mbstring encodings - fill $list_of_encodings array.
array
sq_mb_list_encodings
()
sq_mt_randomize (line
650)
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
( $Val, mixed $val)
-
mixed
$val: a value to seed the random number generator. mixed = integer or string.
-
$Val
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 $str, [string $charset = null])
-
string
$str: string
-
string
$charset: charset
Wrapper that is used to switch between vanilla and multibyte strpos functions.
string
sq_strpos
(string $haystack, mixed $needle, integer $offset, [string $charset = 'auto'])
-
string
$haystack
-
mixed
$needle
-
integer
$offset
-
string
$charset
sq_strtoupper (line
1230)
Wrapper that is used to switch between vanilla and multibyte strtoupper functions.
string
sq_strtoupper
(string $string, [string $charset = 'auto'])
-
string
$string
-
string
$charset
string padding with multibyte support
string
sq_str_pad
(string $string, integer $width, string $pad, integer $padtype, [string $charset = ''])
-
string
$string: original string
-
integer
$width: padded string width
-
string
$pad: padding symbols
-
integer
$padtype: padding type (internal php defines, see str_pad() description)
-
string
$charset: charset used in original string
Wrapper that is used to switch between vanilla and multibyte substr functions.
string
sq_substr
(string $string, integer $start, integer $length, [string $charset = 'auto'])
-
string
$string
-
integer
$start
-
integer
$length
-
string
$charset
sq_trim_value (line
1285)
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