rcube_utils

Utility class providing common functions

package

Framework

subpackage

Utils

Methods

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

anytodatetime(string $date, \DateTimeZone $timezone = null) : \DateTime
static

Arguments

$date

string

Date string

$timezone

\DateTimeZone

Timezone to use for DateTime object

Response

\DateTime

instance or false on failure

Convert binary data into readable form (containing a-zA-Z0-9 characters)

bin2ascii(string $input) : string
static
deprecated

since 1.3.1

Arguments

$input

string

Binary input

Response

string

Readable output (Base62)

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) : boolean
static

Arguments

$ip

string

IP address in v4 or v6 format

Response

boolean

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

Clean up date string for strtotime() input

clean_datestr(string $date) : string
static

Arguments

$date

string

Date string

Response

string

Date string

Format current date according to specified format.

date_format(string $format = null) : string
static

This method supports microseconds (u).

Arguments

$format

string

Date format (default: 'd-M-Y H:i:s O')

Response

string

Formatted date

Explode quoted string

explode_quoted_string( $delimiter,  $string) : array
static

Arguments

$delimiter

$string

Response

array

String items

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

Turns the given date-only string in defined format into YYYY-MM-DD format.

format_datestr(string $date, string $format) : \strin
static

Supported formats: 'Y/m/d', 'Y.m.d', 'd-m-Y', 'd/m/Y', 'd.m.Y', 'j.n.Y'

Arguments

$date

string

Date string

$format

string

Input date format

Response

\strin

Date string in YYYY-MM-DD format, or the original string if format is not supported

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

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 commandline arguments into a hash array

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

Arguments

$aliases

array

Argument alias names

Response

array

Argument values hash

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

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

idn_convert

idn_convert( $input,  $is_utf = false) 
static

Arguments

$input

$is_utf

idn_to_ascii

idn_to_ascii( $str) 
static

Arguments

$str

idn_to_utf8

idn_to_utf8( $str) 
static

Arguments

$str

OS-dependent absolute path detection

is_absolute_path( $path) 
static

Arguments

$path

Get maximum upload size

max_upload_size() : integer
static

Response

integer

Maximum size in bytes

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

Replace all css definitions with #container [def] and remove css-inlined scripting, make position style safe

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

Arguments

$source

$container_id

$allow_remote

Response

string

Modified CSS source

Normalize the given string for fulltext search.

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

Currently only optimized for ISO-8859-1 and ISO-8859-2 characters; to be extended

Arguments

$str

$as_array

$minlen

Response

mixed

Normalized string or a list of normalized tokens

Replaces hostname variables.

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

Arguments

$name

string

Hostname

$host

string

Optional IMAP hostname

Response

string

Hostname

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

Parses socket options and returns options for specified hostname.

parse_socket_options( &$options, string $host = null) 
static

Arguments

$options

$host

string

Hostname

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

Generate a random string

random_bytes(integer $length, boolean $raw = false) : string
static

Arguments

$length

integer

String length

$raw

boolean

Return RAW data instead of ascii

Response

string

The generated random string

Returns the real remote IP address

remote_addr() : string
static

Response

string

Remote IP address

Returns remote IP address and forwarded addresses if found

remote_ip() : string
static

Response

string

Remote IP address(es)

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

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

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

Arguments

$mode

integer

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

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

Resolve relative URL

resolve_url(string $url) : string
static

Arguments

$url

string

Relative URL

Response

string

Absolute URL

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

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

Arguments

$name

$value

$exp

Improved equivalent to strtotime()

strtotime(string $date, \DateTimeZone $timezone = null) : integer
static

Arguments

$date

string

Date string

$timezone

\DateTimeZone

Timezone to use for DateTime object

Response

integer

Unix timestamp

Split the given string into word tokens

tokenize_string( $str,  $minlen = 2) : array
static

Arguments

$str

$minlen

Response

array

List of tokens

Compare two strings for matching words (order not relevant)

words_match( $haystack,  $needle) : boolean
static

Arguments

$haystack

$needle

Response

boolean

True if match, False otherwise

Decode escaped entities used by known XSS exploits.

xss_entity_decode( $content) : string
static

Arguments

$content

Response

string

Decoded string

Constants

INPUT_GET

INPUT_GET

INPUT_POST

INPUT_POST

INPUT_GP

INPUT_GP

INPUT_GPC

INPUT_GPC