c_ws_plugin__s2member_utils_strings
public class c_ws_plugin__s2member_utils_strings
3.5
( 2 Fields ) Field Summary | |
---|---|
public static array | Array of all ampersand entities. |
public static array | 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 |
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 |
public static str|array | trim_deep(str|array $value, str|bool $chars, str|bool $extra_chars) Trims deeply; or use s2Member\Utilities → c_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 |
public static str|array | wrap_deep(str|array $value, str $beg, str $end, bool $wrap_e) Wraps a string with the characters provided. |
public static array $ampersand_entities = array(...)
Array of all ampersand entities.
Array keys are actually regex patterns (very useful).
111106
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).
111106
public static str _rsa_sha1_key_fix_wrappers(str $key)
Fixes incomplete private key wrappers for RSA-SHA1 signing.
Used by s2Member\Utilities → c_ws_plugin__s2member_utils_strings::rsa_sha1_sign().
111017
str $key - The secret key to be used in an RSA-SHA1 signature.
str - Key with incomplete wrappers corrected, when/if possible.
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\Utilities → c_ws_plugin__s2member_utils_strings::rsa_sha1_sign().
111017
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.
str|bool - An RSA-SHA1 signature string, or false on failure.
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.
110913
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: =~.
.
str - The decoded string.
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.
110913
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: =~.
.
str - The base64 URL-safe encoded string.
public static str esc_dq(str $string, int $times, str $escape_char)
Escapes double quotes.
3.5
str $string - Input string.
int $times - Number of escapes. Defaults to 1.
str $escape_char - The character to be used in escapes.
str - Output string after double quotes are escaped.
public static str esc_ds(str $string, int $times)
Escapes dollars signs (for regex patterns).
3.5
str $string - Input string.
int $times - Number of escapes. Defaults to 1.
str - Output string after dollar signs are escaped.
Starting with s2Member v120103, please use: c_ws_plugin__s2member_utils_strings::esc_refs()
.
public static str esc_js_sq(str $string, int $times)
Escapes JavaScript and single quotes.
110901
str $string - Input string.
int $times - Number of escapes. Defaults to 1.
str - Output string after JavaScript and single quotes are escaped.
public static str esc_refs(str $string, int $times)
Escapes backreferences (for regex patterns).
120103
str $string - Input string.
int $times - Number of escapes. Defaults to 1.
str - Output string after backreferences are escaped.
public static str esc_sq(str $string, int $times)
Escapes single quotes.
3.5
str $string - Input string.
int $times - Number of escapes. Defaults to 1.
str - Output string after single quotes are escaped.
public static str highlight_php(bool $string, str $str)
Highlights PHP, and also Shortcodes.
3.5
str $str - Input string to be highlighted.
str - The highlighted string.
public static str hmac_sha1_sign(str $string, str $key)
Generates an HMAC-SHA1 signature.
111017
str $string - Input string/data, to be signed by this routine.
str $key - The secret key that will be used in this signature.
str - An HMAC-SHA1 signature string.
public static array parse_emails(str|array $value)
Parses email addresses from a string or array.
111009
str|array $value - Input string or an array is also fine.
array - Array of parsed email addresses.
public static str|array preg_quote_deep(str|array $value, str $delimiter)
Escapes meta characters with preg_quote()
deeply.
110926
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()
.
str|array - Either the input string, or the input array; after all data is escaped with preg_quote()
.
public static str random_str_gen(int $length, bool $special_chars, bool $extra_special_chars)
Generates a random string with letters/numbers/symbols.
3.5
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.
str - A randomly generated string, based on parameter configuration.
public static str|bool rsa_sha1_sign(str $string, str $key)
Generates an RSA-SHA1 signature.
111017
str $string - Input string/data, to be signed by this routine.
str $key - The secret key that will be used in this signature.
str|bool - An RSA-SHA1 signature string, or false on failure.
public static str strip_2_kb_chars(str $string)
Sanitizes a string; by stripping characters NOT on a standard U.S. keyboard.
111106
str $string - Input string.
str - Output string, after characters NOT on a standard U.S. keyboard have been stripped.
public static str|array trim(str|array $value, str|bool $chars, str|bool $extra_chars)
Trims deeply; alias of trim_deep
.
111106
s2Member\Utilities → c_ws_plugin__s2member_utils_strings::trim_deep()
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
.
str|array - Either the input string, or the input array; after all data is trimmed up according to arguments passed in.
public static str|array trim_deep(str|array $value, str|bool $chars, str|bool $extra_chars)
Trims deeply; or use s2Member\Utilities → c_ws_plugin__s2member_utils_strings::trim().
3.5
s2Member\Utilities → c_ws_plugin__s2member_utils_strings::trim()
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
.
str|array - Either the input string, or the input array; after all data is trimmed up according to arguments passed in.
public static str|array trim_dq_deep(str|array $value)
Trims double quotes deeply.
3.5
str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.
str|array - Either the input string, or the input array; after all data is trimmed up.
public static str|array trim_dsq_deep(str|array $value)
Trims double and single quotes deeply.
111106
str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.
str|array - Either the input string, or the input array; after all data is trimmed up.
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.
111011
str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.
str|array - Either the input string, or the input array; after all data is trimmed up.
public static str|array trim_sq_deep(str|array $value)
Trims single quotes deeply.
111106
str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.
str|array - Either the input string, or the input array; after all data is trimmed up.
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.
111017
str|array $value - Either a string, an array, or a multi-dimensional array, filled with integer and/or string values.
str|array - Either the input string, or the input array; after all unreserved chars are decoded properly.
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()
.
3.5
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?
str|array - Either the input string, or the input array; after all data is wrapped up.
String utilities.