pull/300/head
Aleksander Machniak 10 years ago
parent 1484d5fb7f
commit a03233ceba

@ -138,7 +138,7 @@ function in_array_nocase($needle, $haystack)
/**
* Parse a human readable string for a number of bytes.
*
* @param string $str Input string
* @param string $str Input string
*
* @return float Number of bytes
*/
@ -188,7 +188,7 @@ function unslashify($str)
/**
* Returns number of seconds for a specified offset string.
*
* @param string $str String representation of the offset (e.g. 20min, 5h, 2days, 1week)
* @param string $str String representation of the offset (e.g. 20min, 5h, 2days, 1week)
*
* @return int Number of seconds
*/
@ -220,12 +220,12 @@ function get_offset_sec($str)
/**
* Create a unix timestamp with a specified offset from now.
*
* @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days)
* @param int $factor Factor to multiply with the offset
* @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days)
* @param int $factor Factor to multiply with the offset
*
* @return int Unix timestamp
*/
function get_offset_time($offset_str, $factor=1)
function get_offset_time($offset_str, $factor = 1)
{
return time() + get_offset_sec($offset_str) * $factor;
}
@ -241,7 +241,7 @@ function get_offset_time($offset_str, $factor=1)
*
* @return string Abbreviated string
*/
function abbreviate_string($str, $maxlength, $placeholder='...', $ending=false)
function abbreviate_string($str, $maxlength, $placeholder = '...', $ending = false)
{
$length = mb_strlen($str);
@ -254,7 +254,9 @@ function abbreviate_string($str, $maxlength, $placeholder='...', $ending=false)
$first_part_length = floor(($maxlength - $placeholder_length)/2);
$second_starting_location = $length - $maxlength + $first_part_length + $placeholder_length;
$str = mb_substr($str, 0, $first_part_length) . $placeholder . mb_substr($str, $second_starting_location);
$prefix = mb_substr($str, 0, $first_part_length);
$suffix = mb_substr($str, $second_starting_location);
$str = $prefix . $placeholder . $suffix;
}
return $str;
@ -263,7 +265,7 @@ function abbreviate_string($str, $maxlength, $placeholder='...', $ending=false)
/**
* Get all keys from array (recursive).
*
* @param array $array Input array
* @param array $array Input array
*
* @return array List of array keys
*/
@ -309,8 +311,8 @@ function is_ascii($str, $control_chars = true)
/**
* Compose a valid representation of name and e-mail address
*
* @param string $email E-mail address
* @param string $name Person name
* @param string $email E-mail address
* @param string $name Person name
*
* @return string Formatted string
*/
@ -364,7 +366,8 @@ function version_parse($version)
return str_replace(
array('-stable', '-git'),
array('.0', '.99'),
$version);
$version
);
}
/**
@ -378,7 +381,7 @@ if (!function_exists('idn_to_utf8'))
static $idn, $loaded;
if (!$loaded) {
$idn = new Net_IDNA2();
$idn = new Net_IDNA2();
$loaded = true;
}
@ -389,6 +392,7 @@ if (!function_exists('idn_to_utf8'))
catch (Exception $e) {
}
}
return $domain;
}
}
@ -400,7 +404,7 @@ if (!function_exists('idn_to_ascii'))
static $idn, $loaded;
if (!$loaded) {
$idn = new Net_IDNA2();
$idn = new Net_IDNA2();
$loaded = true;
}
@ -411,6 +415,7 @@ if (!function_exists('idn_to_ascii'))
catch (Exception $e) {
}
}
return $domain;
}
}

@ -150,7 +150,7 @@ abstract class rcube_addressbook
/**
* Setter for errors for internal use
*
* @param int Error type (one of this class' error constants)
* @param int Error type (one of this class' error constants)
* @param string Error message (name of a text label)
*/
protected function set_error($type, $message)
@ -167,8 +167,7 @@ abstract class rcube_addressbook
/**
* Set internal list page
*
* @param number Page number to list
* @access public
* @param number Page number to list
*/
function set_page($page)
{
@ -178,8 +177,7 @@ abstract class rcube_addressbook
/**
* Set internal page size
*
* @param number Number of messages to display on one page
* @access public
* @param number Number of messages to display on one page
*/
function set_pagesize($size)
{
@ -206,8 +204,9 @@ abstract class rcube_addressbook
* Check the given data before saving.
* If input isn't valid, the message to display can be fetched using get_error()
*
* @param array Assoziative array with data to save
* @param array Assoziative array with data to save
* @param boolean Attempt to fix/complete record automatically
*
* @return boolean True if input is valid, False if not.
*/
public function validate(&$save_data, $autofix = false)
@ -296,10 +295,10 @@ abstract class rcube_addressbook
/**
* Mark one or more contact records as deleted
*
* @param array Record identifiers
* @param bool Remove records irreversible (see self::undelete)
* @param array Record identifiers
* @param bool Remove records irreversible (see self::undelete)
*/
function delete($ids, $force=true)
function delete($ids, $force = true)
{
/* empty for read-only address books */
}
@ -307,7 +306,7 @@ abstract class rcube_addressbook
/**
* Unmark delete flag on contact record(s)
*
* @param array Record identifiers
* @param array Record identifiers
*/
function undelete($ids)
{

@ -3,7 +3,7 @@
/**
+-----------------------------------------------------------------------+
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2007-2009, The Roundcube Dev Team |
| Copyright (C) 2007-2015, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@ -54,14 +54,16 @@ class rcube_browser
$this->ver = (float) $regs[1];
}
if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs))
if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) {
$this->lang = $regs[1];
else
}
else {
$this->lang = 'en';
}
$this->dom = $this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7);
$this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) ||
($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7) ? true : false;
($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7);
$this->imgdata = !$this->ie;
}
}

@ -90,9 +90,9 @@ class rcube_image
* Resize image to a given size. Use only to shrink an image.
* If an image is smaller than specified size it will be not resized.
*
* @param int $size Max width/height size
* @param string $filename Output filename
* @param boolean $browser_compat Convert to image type displayable by any browser
* @param int $size Max width/height size
* @param string $filename Output filename
* @param boolean $browser_compat Convert to image type displayable by any browser
*
* @return mixed Output type on success, False on failure
*/
@ -285,9 +285,9 @@ class rcube_image
/**
* Convert image to a given type
*
* @param int $type Destination file type (see class constants)
* @param string $filename Output filename (if empty, original file will be used
* and filename extension will be modified)
* @param int $type Destination file type (see class constants)
* @param string $filename Output filename (if empty, original file will be used
* and filename extension will be modified)
*
* @return bool True on success, False on failure
*/

@ -4353,7 +4353,6 @@ class rcube_imap extends rcube_storage
/**
* This is our own debug handler for the IMAP connection
* @access public
*/
public function debug_handler(&$imap, $message)
{

@ -133,8 +133,8 @@ class rcube_mime
/**
* Decode a message header value
*
* @param string $input Header value
* @param string $fallback Fallback charset if none specified
* @param string $input Header value
* @param string $fallback Fallback charset if none specified
*
* @return string Decoded string
*/
@ -290,7 +290,7 @@ class rcube_mime
}
/**
* @access private
* E-mail address list parser
*/
private static function parse_address_list($str, $decode = true, $fallback = null)
{
@ -671,9 +671,9 @@ class rcube_mime
/**
* A method to guess the mime_type of an attachment.
*
* @param string $path Path to the file or file contents
* @param string $name File name (with suffix)
* @param string $failover Mime type supplied for failover
* @param string $path Path to the file or file contents
* @param string $name File name (with suffix)
* @param string $failover Mime type supplied for failover
* @param boolean $is_stream Set to True if $path contains file contents
* @param boolean $skip_suffix Set to True if the config/mimetypes.php mappig should be ignored
*

@ -58,7 +58,8 @@ class rcube_string_replacer
/**
* Add a string to the internal list
*
* @param string String value
* @param string String value
*
* @return int Index of value for retrieval
*/
public function add($str)
@ -140,6 +141,7 @@ class rcube_string_replacer
* Callback function used to build mailto: links around e-mail strings
*
* @param array Matches result from preg_replace_callback
*
* @return int Index of saved string value
*/
public function mailto_callback($matches)

@ -162,12 +162,12 @@ class rcube_utils
/**
* Replacing specials characters to a specific encoding type
*
* @param string Input string
* @param string Encoding type: text|html|xml|js|url
* @param string Replace mode for tags: show|remove|strict
* @param boolean Convert newlines
* @param string Input string
* @param string Encoding type: text|html|xml|js|url
* @param string Replace mode for tags: show|remove|strict
* @param boolean Convert newlines
*
* @return string The quoted string
* @return string The quoted string
*/
public static function rep_specialchars_output($str, $enctype = '', $mode = '', $newlines = true)
{
@ -253,16 +253,16 @@ class rcube_utils
* Read input value and convert it for internal use
* Performs stripslashes() and charset conversion if necessary
*
* @param string Field name to read
* @param int Source to get value from (GPC)
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
* @param string Field name to read
* @param int Source to get value from (GPC)
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
*
* @return string Field value or NULL if not available
* @return string Field value or NULL if not available
*/
public static function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL)
public static function get_input_value($fname, $source, $allow_html = false, $charset = null)
{
$value = NULL;
$value = null;
if ($source == self::INPUT_GET) {
if (isset($_GET[$fname])) {
@ -293,13 +293,13 @@ class rcube_utils
* Parse/validate input value. See self::get_input_value()
* Performs stripslashes() and charset conversion if necessary
*
* @param string Input value
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
* @param string Input value
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
*
* @return string Parsed value
* @return string Parsed value
*/
public static function parse_input_value($value, $allow_html=FALSE, $charset=NULL)
public static function parse_input_value($value, $allow_html = false, $charset = null)
{
global $OUTPUT;
@ -387,9 +387,9 @@ class rcube_utils
*
* @return string Modified CSS source
*/
public static function mod_css_styles($source, $container_id, $allow_remote=false)
public static function mod_css_styles($source, $container_id, $allow_remote = false)
{
$last_pos = 0;
$last_pos = 0;
$replacements = new rcube_string_replacer;
// ignore the whole block if evil styles are detected
@ -457,8 +457,8 @@ class rcube_utils
/**
* Generate CSS classes from mimetype and filename extension
*
* @param string $mimetype Mimetype
* @param string $filename Filename
* @param string $mimetype Mimetype
* @param string $filename Filename
*
* @return string CSS classes separated by space
*/
@ -544,7 +544,8 @@ class rcube_utils
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
&& in_array($_SERVER['REMOTE_ADDR'], rcube::get_instance()->config->get('proxy_whitelist', array()))) {
&& in_array($_SERVER['REMOTE_ADDR'], rcube::get_instance()->config->get('proxy_whitelist', array()))
) {
return true;
}
if ($port && $_SERVER['SERVER_PORT'] == $port) {
@ -581,7 +582,8 @@ class rcube_utils
$h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host;
// %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
$z = preg_replace('/^[^\.]+\./', '', $h);
// %s - domain name after the '@' from e-mail address provided at login screen. Returns FALSE if an invalid email is provided
// %s - domain name after the '@' from e-mail address provided at login screen.
// Returns FALSE if an invalid email is provided
if (strpos($name, '%s') !== false) {
$user_email = self::get_input_value('_user', self::INPUT_POST);
$user_email = self::idn_convert($user_email, true);
@ -607,6 +609,7 @@ class rcube_utils
if (!empty($_SERVER['HTTP_X_REAL_IP'])) {
$remote_ip[] = 'X-Real-IP: ' . $_SERVER['HTTP_X_REAL_IP'];
}
// append the X-Forwarded-For header, if set
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$remote_ip[] = 'X-Forwarded-For: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
@ -654,9 +657,9 @@ class rcube_utils
/**
* Read a specific HTTP request header.
*
* @param string $name Header name
* @param string $name Header name
*
* @return mixed Header value or null if not available
* @return mixed Header value or null if not available
*/
public static function request_header($name)
{
@ -703,14 +706,14 @@ class rcube_utils
/**
* Improved equivalent to strtotime()
*
* @param string $date Date string
* @param object DateTimeZone to use for DateTime object
* @param string $date Date string
* @param DateTimeZone $timezone Timezone to use for DateTime object
*
* @return int Unix timestamp
*/
public static function strtotime($date, $timezone = null)
{
$date = self::clean_datestr($date);
$date = self::clean_datestr($date);
$tzname = $timezone ? ' ' . $timezone->getName() : '';
// unix timestamp
@ -735,14 +738,14 @@ class rcube_utils
/**
* Date parsing function that turns the given value into a DateTime object
*
* @param string $date Date string
* @param object DateTimeZone to use for DateTime object
* @param string $date Date string
* @param DateTimeZone $timezone Timezone to use for DateTime object
*
* @return object DateTime instance or false on failure
* @return DateTime instance or false on failure
*/
public static function anytodatetime($date, $timezone = null)
{
if (is_object($date) && is_a($date, 'DateTime')) {
if ($date instanceof DateTime) {
return $date;
}
@ -887,7 +890,7 @@ class rcube_utils
* @param boolean True to return list of words as array
* @param integer Minimum length of tokens
*
* @return mixed Normalized string or a list of normalized tokens
* @return mixed Normalized string or a list of normalized tokens
*/
public static function normalize_string($str, $as_array = false, $minlen = 2)
{
@ -939,7 +942,8 @@ class rcube_utils
*
* @param string Haystack
* @param string Needle
* @return boolen True if match, False otherwise
*
* @return boolean True if match, False otherwise
*/
public static function words_match($haystack, $needle)
{

Loading…
Cancel
Save