Source Code Documentation


Field Summary | Method Summary | Field Detail | Method Detail

Package s2Member\Utilities

s2member\includes\classes\utils-strings.inc.php at line #28

Class c_ws_plugin__s2member_utils_strings

c_ws_plugin__s2member_utils_strings

public class c_ws_plugin__s2member_utils_strings

String utilities.

Since:

3.5


( 2 Fields )
Field Summary
public static array

$ampersand_entities

Array of all ampersand entities.

public static array

$quote_entities_w_variations

Array of all quote entities (and entities for quote variations).

( 24 Methods )
Method Summary
public static str

_rsa_sha1_key_fix_wrappers(str $key)

Fixes incomplete private key wrappers for RSA-SHA1 signing.

public static str|bool

_rsa_sha1_shell_sign(str $string, str $key, str $openssl)

Generates an RSA-SHA1 signature from the command line.

public static str

base64_url_safe_decode(str $base64_url_safe, array $url_unsafe_chars, array $url_safe_chars, str $trim_padding_chars)

Base64 URL-safe decoding.

public static str

base64_url_safe_encode(str $string, array $url_unsafe_chars, array $url_safe_chars, str $trim_padding_chars)

Base64 URL-safe encoding.

public static str

esc_dq(str $string, int $times, str $escape_char)

Escapes double quotes.

public static str

esc_ds(str $string, int $times)

Escapes dollars signs (for regex patterns).

public static str

esc_js_sq(str $string, int $times)

Escapes JavaScript and single quotes.

public static str

esc_refs(str $string, int $times)

Escapes backreferences (for regex patterns).

public static str

esc_sq(str $string, int $times)

Escapes single quotes.

public static str

highlight_php(bool $string, str $str)

Highlights PHP, and also Shortcodes.

public static str

hmac_sha1_sign(str $string, str $key)

Generates an HMAC-SHA1 signature.

public static array

parse_emails(str|array $value)

Parses email addresses from a string or array.

public static str|array

preg_quote_deep(str|array $value, str $delimiter)

Escapes meta characters with preg_quote() deeply.

public static str

random_str_gen(int $length, bool $special_chars, bool $extra_special_chars)

Generates a random string with letters/numbers/symbols.

public static str|bool

rsa_sha1_sign(str $string, str $key)

Generates an RSA-SHA1 signature.

public static str

strip_2_kb_chars(str $string)

Sanitizes a string; by stripping characters NOT on a standard U.S.

public static str|array

trim(str|array $value, str|bool $chars, str|bool $extra_chars)

Trims deeply; alias of trim_deep.

public static str|array

trim_deep(str|array $value, str|bool $chars, str|bool $extra_chars)

Trims deeply; or use s2Member\Utilitiesc_ws_plugin__s2member_utils_strings::trim().

public static str|array

trim_dq_deep(str|array $value)

Trims double quotes deeply.

public static str|array

trim_dsq_deep(str|array $value)

Trims double and single quotes deeply.

public static str|array

trim_qts_deep(str|array $value)

Trims all single/double quote entity variations deeply.

public static str|array

trim_sq_deep(str|array $value)

Trims single quotes deeply.

public static str|array

urldecode_ur_chars_deep(str|array $value)

Decodes unreserved chars encoded by PHP's urlencode(), deeply.

public static str|array

wrap_deep(str|array $value, str $beg, str $end, bool $wrap_e)

Wraps a string with the characters provided.

( 2 Fields )
Field Detail

s2member\includes\classes\utils-strings.inc.php at line #40

ampersand_entities

public static array $ampersand_entities = array(...)

Array of all ampersand entities.

Array keys are actually regex patterns (very useful).

Since:

111106

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #51

quote_entities_w_variations

public static array $quote_entities_w_variations = array(...)

Array of all quote entities (and entities for quote variations).

Array keys are actually regex patterns (very useful).

Since:

111106

[ back to top ]

( 24 Methods )
Method Detail

s2member\includes\classes\utils-strings.inc.php at line #490

_rsa_sha1_key_fix_wrappers()

public static str _rsa_sha1_key_fix_wrappers(str $key)

Fixes incomplete private key wrappers for RSA-SHA1 signing.

Used by s2Member\Utilitiesc_ws_plugin__s2member_utils_strings::rsa_sha1_sign().

Since:

111017

Parameters:

str $key - The secret key to be used in an RSA-SHA1 signature.

Returns:

str - Key with incomplete wrappers corrected, when/if possible.

See Also:

http://www.faqs.org/qa/qa-14736.html

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #463

_rsa_sha1_shell_sign()

public static str|bool _rsa_sha1_shell_sign(str $string, str $key, str $openssl)

Generates an RSA-SHA1 signature from the command line.

Used by s2Member\Utilitiesc_ws_plugin__s2member_utils_strings::rsa_sha1_sign().

Since:

111017

Parameters:

str $string - Input string/data, to be signed by this routine.

str $key - The secret key that will be used in this signature.

str $openssl - Optional. Defaults to openssl. Path to OpenSSL executable.

Returns:

str|bool - An RSA-SHA1 signature string, or false on failure.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #407

base64_url_safe_decode()

public static str base64_url_safe_decode(str $base64_url_safe, array $url_unsafe_chars, array $url_safe_chars, str $trim_padding_chars)

Base64 URL-safe decoding.

Note, this function is backward compatible with routines supplied by s2Member in the past; where padding characters were replaced with ~ or ., instead of being stripped completely.

Since:

110913

Parameters:

str $base64_url_safe - Input string to be base64 decoded.

array $url_unsafe_chars - Optional. An array of un-safe character replacements. Defaults to: array("+", "/").

array $url_safe_chars - Optional. An array of safe characters. Defaults to: array("-", "_").

str $trim_padding_chars - Optional. A string of padding chars to rtrim. Defaults to: =~..

Returns:

str - The decoded string.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #382

base64_url_safe_encode()

public static str base64_url_safe_encode(str $string, array $url_unsafe_chars, array $url_safe_chars, str $trim_padding_chars)

Base64 URL-safe encoding.

Since:

110913

Parameters:

str $string - Input string to be base64 encoded.

array $url_unsafe_chars - Optional. An array of un-safe characters. Defaults to: array("+", "/").

array $url_safe_chars - Optional. An array of safe character replacements. Defaults to: array("-", "_").

str $trim_padding_chars - Optional. A string of padding chars to rtrim. Defaults to: =~..

Returns:

str - The base64 URL-safe encoded string.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #63

esc_dq()

public static str esc_dq(str $string, int $times, str $escape_char)

Escapes double quotes.

Since:

3.5

Parameters:

str $string - Input string.

int $times - Number of escapes. Defaults to 1.

str $escape_char - The character to be used in escapes.

Returns:

str - Output string after double quotes are escaped.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #114

esc_ds()

public static str esc_ds(str $string, int $times)

Escapes dollars signs (for regex patterns).

Since:

3.5

Parameters:

str $string - Input string.

int $times - Number of escapes. Defaults to 1.

Returns:

str - Output string after dollar signs are escaped.

Deprecated:

Starting with s2Member v120103, please use: c_ws_plugin__s2member_utils_strings::esc_refs().

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #95

esc_js_sq()

public static str esc_js_sq(str $string, int $times)

Escapes JavaScript and single quotes.

Since:

110901

Parameters:

str $string - Input string.

int $times - Number of escapes. Defaults to 1.

Returns:

str - Output string after JavaScript and single quotes are escaped.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #130

esc_refs()

public static str esc_refs(str $string, int $times)

Escapes backreferences (for regex patterns).

Since:

120103

Parameters:

str $string - Input string.

int $times - Number of escapes. Defaults to 1.

Returns:

str - Output string after backreferences are escaped.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #79

esc_sq()

public static str esc_sq(str $string, int $times)

Escapes single quotes.

Since:

3.5

Parameters:

str $string - Input string.

int $times - Number of escapes. Defaults to 1.

Returns:

str - Output string after single quotes are escaped.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #333

highlight_php()

public static str highlight_php(bool $string, str $str)

Highlights PHP, and also Shortcodes.

Since:

3.5

Parameters:

str $str - Input string to be highlighted.

Returns:

str - The highlighted string.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #515

hmac_sha1_sign()

public static str hmac_sha1_sign(str $string, str $key)

Generates an HMAC-SHA1 signature.

Since:

111017

Parameters:

str $string - Input string/data, to be signed by this routine.

str $key - The secret key that will be used in this signature.

Returns:

str - An HMAC-SHA1 signature string.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #348

parse_emails()

public static array parse_emails(str|array $value)

Parses email addresses from a string or array.

Since:

111009

Parameters:

str|array $value - Input string or an array is also fine.

Returns:

array - Array of parsed email addresses.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #288

preg_quote_deep()

public static str|array preg_quote_deep(str|array $value, str $delimiter)

Escapes meta characters with preg_quote() deeply.

Since:

110926

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

str $delimiter - Optional. If a delimiting character is specified, it will also be escaped via preg_quote().

Returns:

str|array - Either the input string, or the input array; after all data is escaped with preg_quote().

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #311

random_str_gen()

public static str random_str_gen(int $length, bool $special_chars, bool $extra_special_chars)

Generates a random string with letters/numbers/symbols.

Since:

3.5

Parameters:

int $length - Optional. Defaults to 12. Length of the random string.

bool $special_chars - Defaults to true. If false, special chars are NOT included.

bool $extra_special_chars - Defaults to false. If true, extra special chars are included.

Returns:

str - A randomly generated string, based on parameter configuration.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #428

rsa_sha1_sign()

public static str|bool rsa_sha1_sign(str $string, str $key)

Generates an RSA-SHA1 signature.

Since:

111017

Parameters:

str $string - Input string/data, to be signed by this routine.

str $key - The secret key that will be used in this signature.

Returns:

str|bool - An RSA-SHA1 signature string, or false on failure.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #145

strip_2_kb_chars()

public static str strip_2_kb_chars(str $string)

Sanitizes a string; by stripping characters NOT on a standard U.S. keyboard.

Since:

111106

Parameters:

str $string - Input string.

Returns:

str - Output string, after characters NOT on a standard U.S. keyboard have been stripped.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #163

trim()

public static str|array trim(str|array $value, str|bool $chars, str|bool $extra_chars)

Trims deeply; alias of trim_deep.

Since:

111106

See Also:

s2Member\Utilitiesc_ws_plugin__s2member_utils_strings::trim_deep()

http://php.net/manual/en/function.trim.php

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

str|bool $chars - Optional. Defaults to false, indicating the default trim chars \t\n\r\0\x0B. Or, set to a specific string of chars.

str|bool $extra_chars - Optional. This is NOT possible with PHP alone, but here you can specify extra chars; in addition to $chars.

Returns:

str|array - Either the input string, or the input array; after all data is trimmed up according to arguments passed in.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #181

trim_deep()

public static str|array trim_deep(str|array $value, str|bool $chars, str|bool $extra_chars)

Trims deeply; or use s2Member\Utilitiesc_ws_plugin__s2member_utils_strings::trim().

Since:

3.5

See Also:

s2Member\Utilitiesc_ws_plugin__s2member_utils_strings::trim()

http://php.net/manual/en/function.trim.php

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

str|bool $chars - Optional. Defaults to false, indicating the default trim chars \t\n\r\0\x0B. Or, set to a specific string of chars.

str|bool $extra_chars - Optional. This is NOT possible with PHP alone, but here you can specify extra chars; in addition to $chars.

Returns:

str|array - Either the input string, or the input array; after all data is trimmed up according to arguments passed in.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #205

trim_dq_deep()

public static str|array trim_dq_deep(str|array $value)

Trims double quotes deeply.

Since:

3.5

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

Returns:

str|array - Either the input string, or the input array; after all data is trimmed up.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #231

trim_dsq_deep()

public static str|array trim_dsq_deep(str|array $value)

Trims double and single quotes deeply.

Since:

111106

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

Returns:

str|array - Either the input string, or the input array; after all data is trimmed up.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #246

trim_qts_deep()

public static str|array trim_qts_deep(str|array $value)

Trims all single/double quote entity variations deeply.

This is useful on Shortcode attributes mangled by a Visual Editor.

Since:

111011

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

Returns:

str|array - Either the input string, or the input array; after all data is trimmed up.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #218

trim_sq_deep()

public static str|array trim_sq_deep(str|array $value)

Trims single quotes deeply.

Since:

111106

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

Returns:

str|array - Either the input string, or the input array; after all data is trimmed up.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #534

urldecode_ur_chars_deep()

public static str|array urldecode_ur_chars_deep(str|array $value)

Decodes unreserved chars encoded by PHP's urlencode(), deeply.

For further details regarding unreserved chars, see: http://www.faqs.org/rfcs/rfc3986.html.

Since:

111017

See Also:

http://www.faqs.org/rfcs/rfc3986.html

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

Returns:

str|array - Either the input string, or the input array; after all unreserved chars are decoded properly.

[ back to top ]

s2member\includes\classes\utils-strings.inc.php at line #266

wrap_deep()

public static str|array wrap_deep(str|array $value, str $beg, str $end, bool $wrap_e)

Wraps a string with the characters provided.

This is useful when preparing an input array for c_ws_plugin__s2member_utils_arrays::in_regex_array().

Since:

3.5

Parameters:

str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.

str $beg - Optional. A string value to wrap at the beginning of each value.

str $end - Optional. A string value to wrap at the ending of each value.

bool $wrap_e - Optional. Defaults to false. Should empty strings be wrapped too?

Returns:

str|array - Either the input string, or the input array; after all data is wrapped up.

[ back to top ]

Source Code Documentation


Field Summary | Method Summary | Field Detail | Method Detail