Class rcube_utils

Description

Utility class providing common functions

Located in /lib/Roundcube/rcube_utils.php (line 27)


	
			
Class Constant Summary
 INPUT_GET = 0x0101
 INPUT_GPC = 0x0103
 INPUT_POST = 0x0102
Method Summary
 static boolean check_email (string $email, [boolean $dns_check = true])
 static bool check_ip (string $ip)
 static boolean check_referer ()
 static array explode_quoted_string (string $delimiter, string $string)
 static string file2class (string $mimetype, string $filename)
 static boolean get_boolean (string $str)
 static string get_input_value (string $fname, int $source, [boolean $allow_html = FALSE], [string $charset = NULL])
 static array get_opt ([array $aliases = array()])
 static void html_identifier ( $str, [ $encode = false])
 static boolean https_check ([integer $port = null], [boolean $use_https = true])
 static void idn_convert ( $input, [ $is_utf = false])
 static void idn_to_ascii ( $str)
 static void idn_to_utf8 ( $str)
 static boolean mem_check (integer $need)
 static string mod_css_styles (string $source, string $container_id, [ $allow_remote = false])
 static mixed normalize_string (string $str, [boolean $as_array = false])
 static string parse_host (string $name, [string $host = ''])
 static string parse_input_value (string $value, [boolean $allow_html = FALSE], [string $charset = NULL])
 static string prompt_silent ([ $prompt = "Password:"])
 static string remote_ip ()
 static string rep_specialchars_output (string $str, [string $enctype = ''], [string $mode = ''], [boolean $newlines = true])
 static array request2param ([int $mode = null], [string $ignore = 'task|action'])
 static mixed request_header (string $name)
 static void setcookie (string $name, string $value, [string $exp = 0])
 static int strtotime (string $date)
 static array tokenize_string (string $str)
 static string xss_entity_decode (string $content)
 static string xss_entity_decode_callback (array $matches)
Methods
static check_email (line 61)

E-mail address validation.

  • return: True on success, False if address is invalid
  • access: public
boolean check_email (string $email, [boolean $dns_check = true])
  • string $email: Email address
  • boolean $dns_check: True to check dns
static check_ip (line 155)

Validates IPv4 or IPv6 address

  • return: True if the address is valid
  • access: public
bool check_ip (string $ip)
  • string $ip: IP address in v4 or v6 format
static check_referer (line 198)

Check whether the HTTP referer matches the current request

  • return: True if referer is the same host+path, false if not
  • access: public
boolean check_referer ()
static explode_quoted_string (line 694)

Explode quoted string

  • return: String items
  • access: public
array explode_quoted_string (string $delimiter, string $string)
  • string $delimiter: Delimiter expression string for preg_match()
  • string $string: Input string
static file2class (line 511)

Generate CSS classes from mimetype and filename extension

  • return: CSS classes separated by space
  • access: public
string file2class (string $mimetype, string $filename)
  • string $mimetype: Mimetype
  • string $filename: Filename
static get_boolean (line 926)

Find out if the string content means true or false

  • return: Boolean value
  • access: public
boolean get_boolean (string $str)
  • string $str: Input value
static get_input_value (line 308)

Read input value and convert it for internal use Performs stripslashes() and charset conversion if necessary

  • return: Field value or NULL if not available
  • access: public
string get_input_value (string $fname, int $source, [boolean $allow_html = FALSE], [string $charset = NULL])
  • string $fname: Field name to read
  • int $source: Source to get value from (GPC)
  • boolean $allow_html: Allow HTML tags in field value
  • string $charset: Charset to convert into
static get_opt (line 849)

Parse commandline arguments into a hash array

  • return: Argument values hash
  • access: public
array get_opt ([array $aliases = array()])
  • array $aliases: Argument alias names
static html_identifier (line 422)

Convert the given string into a valid HTML identifier

Same functionality as done in app.js with rcube_webmail.html_identifier()

  • access: public
void html_identifier ( $str, [ $encode = false])
  • $str
  • $encode
static https_check (line 583)

Check if working in SSL mode

  • access: public
boolean https_check ([integer $port = null], [boolean $use_https = true])
  • integer $port: HTTPS port number
  • boolean $use_https: Enables 'use_https' option checking
static idn_convert (line 782)
  • access: public
void idn_convert ( $input, [ $is_utf = false])
  • $input
  • $is_utf
static idn_to_ascii (line 766)
  • access: public
void idn_to_ascii ( $str)
  • $str
static idn_to_utf8 (line 776)
  • access: public
void idn_to_utf8 ( $str)
  • $str
static mem_check (line 566)

Check if we can process not exceeding memory_limit

  • return: True if memory won't be exceeded, False otherwise
  • access: public
boolean mem_check (integer $need)
  • integer $need: Required amount of memory
static mod_css_styles (line 442)

Replace all css definitions with #container [def] and remove css-inlined scripting

  • return: Modified CSS source
  • access: public
string mod_css_styles (string $source, string $container_id, [ $allow_remote = false])
  • string $source: CSS source code
  • string $container_id: Container ID to use as prefix
  • $allow_remote
static normalize_string (line 823)

Normalize the given string for fulltext search.

Currently only optimized for Latin-1 characters; to be extended

  • return: Normalized string or a list of normalized tokens
  • access: public
mixed normalize_string (string $str, [boolean $as_array = false])
  • string $str: Input string (UTF-8)
  • boolean $as_array: True to return list of words as array
static parse_host (line 612)

Replaces hostname variables.

  • return: Hostname
  • access: public
string parse_host (string $name, [string $host = ''])
  • string $name: Hostname
  • string $host: Optional IMAP hostname
static parse_input_value (line 348)

Parse/validate input value. See self::get_input_value() Performs stripslashes() and charset conversion if necessary

  • return: Parsed value
  • access: public
string parse_input_value (string $value, [boolean $allow_html = FALSE], [string $charset = NULL])
  • string $value: Input value
  • boolean $allow_html: Allow HTML tags in field value
  • string $charset: Charset to convert into
static prompt_silent (line 889)

Safe password prompt for command line from http://blogs.sitepoint.com/2009/05/01/interactive-cli-password-prompt-in-php/

  • return: Password
  • access: public
string prompt_silent ([ $prompt = "Password:"])
  • $prompt
static remote_ip (line 644)

Returns remote IP address and forwarded addresses if found

  • return: Remote IP address(es)
  • access: public
string remote_ip ()
static rep_specialchars_output (line 216)

Replacing specials characters to a specific encoding type

  • return: The quoted string
  • access: public
string rep_specialchars_output (string $str, [string $enctype = ''], [string $mode = ''], [boolean $newlines = true])
  • string $str: Input string
  • string $enctype: Encoding type: text|html|xml|js|url
  • string $mode: Replace mode for tags: show|replace|remove
  • boolean $newlines: Convert newlines
static request2param (line 402)

Convert array of request parameters (prefixed with _) to a regular array with non-prefixed keys.

  • return: Hash array with all request parameters
  • access: public
array request2param ([int $mode = null], [string $ignore = 'task|action'])
  • int $mode: Source to get value from (GPC)
  • string $ignore: PCRE expression to skip parameters by name
static request_header (line 672)

Read a specific HTTP request header.

  • return: Header value or null if not available
  • access: public
mixed request_header (string $name)
  • string $name: Header name
static setcookie (line 41)

Helper method to set a cookie with the current path and host settings

  • access: public
void setcookie (string $name, string $value, [string $exp = 0])
  • string $name: Cookie name
  • string $value: Cookie value
  • string $exp: Expiration time
static strtotime (line 722)

Improved equivalent to strtotime()

  • return: Unix timestamp
  • access: public
int strtotime (string $date)
  • string $date: Date string
static tokenize_string (line 807)

Split the given string into word tokens

  • return: List of tokens
  • access: public
array tokenize_string (string $str)
  • string $str: Input to tokenize
static xss_entity_decode (line 535)

Decode escaped entities used by known XSS exploits.

See http://downloads.securityfocus.com/vulnerabilities/exploits/26800.eml for examples

  • return: Decoded string
  • access: public
string xss_entity_decode (string $content)
  • string $content: CSS content to decode
static xss_entity_decode_callback (line 553)

preg_replace_callback callback for xss_entity_decode

  • return: Decoded entity
  • access: public
string xss_entity_decode_callback (array $matches)
  • array $matches: Result from preg_replace_callback
Class Constants
INPUT_GET = 0x0101 (line 30)
INPUT_GPC = 0x0103 (line 32)
INPUT_POST = 0x0102 (line 31)

Documentation generated on Fri, 03 May 2013 12:45:06 +0200 by phpDocumentor 1.4.4