rcube_utils

Utility class providing common functions

package

Framework

subpackage

Utils

Methods

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

setcookie($name, $value, $exp) 
static

Arguments

$name

$value

$exp

E-mail address validation.

check_email(string $email, boolean $dns_check = true) : boolean
static

Arguments

$email

string

Email address

$dns_check

boolean

True to check dns

Response

boolean

True on success, False if address is invalid

Validates IPv4 or IPv6 address

check_ip(string $ip) : bool
static

Arguments

$ip

string

IP address in v4 or v6 format

Response

bool

True if the address is valid

Check whether the HTTP referer matches the current request

check_referer() : boolean
static

Response

boolean

True if referer is the same host+path, false if not

Replacing specials characters to a specific encoding type

rep_specialchars_output($str, $enctype = '', $mode = '', $newlines = true) : string
static

Arguments

$str

$enctype

$mode

$newlines

Response

string

The quoted string

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

get_input_value($fname, $source, $allow_html = FALSE, $charset = NULL) : string
static

Arguments

$fname

$source

$allow_html

$charset

Response

string

Field value or NULL if not available

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

parse_input_value($value, $allow_html = FALSE, $charset = NULL) : string
static

Arguments

$value

$allow_html

$charset

Response

string

Parsed value

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

request2param(int $mode = null, string $ignore = 'task|action', boolean $allow_html = false) : array
static

Arguments

$mode

int

Source to get value from (GPC)

$ignore

string

PCRE expression to skip parameters by name

$allow_html

boolean

Allow HTML tags in field value

Response

array

Hash array with all request parameters

Convert the given string into a valid HTML identifier Same functionality as done in app.js with rcube_webmail.html_identifier()

html_identifier($str, $encode = false) 
static

Arguments

$str

$encode

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

mod_css_styles($source, $container_id, $allow_remote = false) : string
static

Arguments

$source

$container_id

$allow_remote

Response

string

Modified CSS source

Generate CSS classes from mimetype and filename extension

file2class(string $mimetype, string $filename) : string
static

Arguments

$mimetype

string

Mimetype

$filename

string

Filename

Response

string

CSS classes separated by space

Decode escaped entities used by known XSS exploits.

xss_entity_decode($content) : string
static

Arguments

$content

Response

string

Decoded string

preg_replace_callback callback for xss_entity_decode

xss_entity_decode_callback(array $matches) : string
static

Arguments

$matches

array

Result from preg_replace_callback

Response

string

Decoded entity

Check if we can process not exceeding memory_limit

mem_check($need) : boolean
static

Arguments

$need

Response

boolean

True if memory won't be exceeded, False otherwise

Check if working in SSL mode

https_check(integer $port = null, boolean $use_https = true) : boolean
static

Arguments

$port

integer

HTTPS port number

$use_https

boolean

Enables 'use_https' option checking

Response

boolean

Replaces hostname variables.

parse_host(string $name, string $host = '') : string
static

Arguments

$name

string

Hostname

$host

string

Optional IMAP hostname

Response

string

Hostname

Returns remote IP address and forwarded addresses if found

remote_ip() : string
static

Response

string

Remote IP address(es)

Returns the real remote IP address

remote_addr() : string
static

Response

string

Remote IP address

Read a specific HTTP request header.

request_header(string $name) : mixed
static

Arguments

$name

string

Header name

Response

mixed

Header value or null if not available

Explode quoted string

explode_quoted_string($delimiter, $string) : array
static

Arguments

$delimiter

$string

Response

array

String items

Improved equivalent to strtotime()

strtotime(string $date) : int
static

Arguments

$date

string

Date string

Response

int

Unix timestamp

Date parsing function that turns the given value into a DateTime object

anytodatetime(string $date) : object
static

Arguments

$date

string

Date string

Response

object

DateTime instance or false on failure

Clean up date string for strtotime() input

clean_datestr(string $date) : string
static

Arguments

$date

string

Date string

Response

string

Date string

idn_to_ascii

idn_to_ascii($str) 
static

Arguments

$str

idn_to_utf8

idn_to_utf8($str) 
static

Arguments

$str

idn_convert

idn_convert($input, $is_utf = false) 
static

Arguments

$input

$is_utf

Split the given string into word tokens

tokenize_string($str) : array
static

Arguments

$str

Response

array

List of tokens

Normalize the given string for fulltext search.

normalize_string($str, $as_array = false) : mixed
static

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

Arguments

$str

$as_array

Response

mixed

Normalized string or a list of normalized tokens

Parse commandline arguments into a hash array

get_opt(array $aliases = array()) : array
static

Arguments

$aliases

array

Argument alias names

Response

array

Argument values hash

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

prompt_silent($prompt = "Password:") : string
static

Arguments

$prompt

Response

string

Password

Find out if the string content means true or false

get_boolean(string $str) : boolean
static

Arguments

$str

string

Input value

Response

boolean

Boolean value

Constants

INPUT_GET

INPUT_GET

INPUT_POST

INPUT_POST

INPUT_GPC

INPUT_GPC