| | |
| | | <?php |
| | | |
| | | /* |
| | | /** |
| | | +-----------------------------------------------------------------------+ |
| | | | This file is part of the Roundcube PHP suite | |
| | | | Copyright (C) 2005-2013, The Roundcube Dev Team | |
| | | | Copyright (C) 2005-2015, The Roundcube Dev Team | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | |
| | | | Author: Aleksander Machniak <alec@alec.pl> | |
| | | +-----------------------------------------------------------------------+ |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * Roundcube Framework Initialization |
| | |
| | | } |
| | | |
| | | // framework constants |
| | | define('RCUBE_VERSION', '1.0-git'); |
| | | define('RCUBE_VERSION', '1.2-git'); |
| | | define('RCUBE_CHARSET', 'UTF-8'); |
| | | |
| | | if (!defined('RCUBE_LIB_DIR')) { |
| | | define('RCUBE_LIB_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR); |
| | | define('RCUBE_LIB_DIR', __DIR__ . '/'); |
| | | } |
| | | |
| | | if (!defined('RCUBE_INSTALL_PATH')) { |
| | |
| | | } |
| | | |
| | | // set internal encoding for mbstring extension |
| | | if (extension_loaded('mbstring')) { |
| | | if (function_exists('mb_internal_encoding')) { |
| | | mb_internal_encoding(RCUBE_CHARSET); |
| | | @mb_regex_encoding(RCUBE_CHARSET); |
| | | } |
| | | if (function_exists('mb_regex_encoding')) { |
| | | mb_regex_encoding(RCUBE_CHARSET); |
| | | } |
| | | |
| | | // make sure the Roundcube lib directory is in the include_path |
| | |
| | | spl_autoload_register('rcube_autoload'); |
| | | |
| | | // set PEAR error handling (will also load the PEAR main class) |
| | | PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); |
| | | |
| | | if (class_exists('PEAR')) { |
| | | @PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Parse a human readable string for a number of bytes. |
| | |
| | | return floatval($bytes); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Make sure the string ends with a slash |
| | | */ |
| | |
| | | return unslashify($str).'/'; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Remove slashes at the end of the string |
| | | */ |
| | |
| | | { |
| | | return preg_replace('/\/+$/', '', $str); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns number of seconds for a specified offset string. |
| | |
| | | return $amount; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create a unix timestamp with a specified offset from now. |
| | | * |
| | |
| | | { |
| | | return time() + get_offset_sec($offset_str) * $factor; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Truncate string if it is longer than the allowed length. |
| | |
| | | return $str; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Get all keys from array (recursive). |
| | | * |
| | |
| | | return $keys; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Remove all non-ascii and non-word chars except ., -, _ |
| | | */ |
| | |
| | | $allowed = 'a-z0-9\_\-' . (!$css_id ? '\.' : ''); |
| | | return preg_replace("/[^$allowed]/i", $replace_with, $str); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Check if a string contains only ascii characters |
| | |
| | | $regexp = $control_chars ? '/[^\x00-\x7F]/' : '/[^\x20-\x7E]/'; |
| | | return preg_match($regexp, $str) ? false : true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Compose a valid representation of name and e-mail address |
| | |
| | | return $email; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Format e-mail address |
| | | * |
| | |
| | | return $email; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Fix version number so it can be used correctly in version_compare() |
| | | * |
| | |
| | | $version); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * mbstring replacement functions |
| | | */ |
| | | if (!extension_loaded('mbstring')) |
| | | { |
| | | function mb_strlen($str) |
| | | { |
| | | return strlen($str); |
| | | } |
| | | |
| | | function mb_strtolower($str) |
| | | { |
| | | return strtolower($str); |
| | | } |
| | | |
| | | function mb_strtoupper($str) |
| | | { |
| | | return strtoupper($str); |
| | | } |
| | | |
| | | function mb_substr($str, $start, $len=null) |
| | | { |
| | | return substr($str, $start, $len); |
| | | } |
| | | |
| | | function mb_strpos($haystack, $needle, $offset=0) |
| | | { |
| | | return strpos($haystack, $needle, $offset); |
| | | } |
| | | |
| | | function mb_strrpos($haystack, $needle, $offset=0) |
| | | { |
| | | return strrpos($haystack, $needle, $offset); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * intl replacement functions |
| | | */ |
| | | |
| | | if (!function_exists('idn_to_utf8')) |
| | | { |
| | | function idn_to_utf8($domain, $flags=null) |
| | | function idn_to_utf8($domain) |
| | | { |
| | | static $idn, $loaded; |
| | | |
| | |
| | | |
| | | if (!function_exists('idn_to_ascii')) |
| | | { |
| | | function idn_to_ascii($domain, $flags=null) |
| | | function idn_to_ascii($domain) |
| | | { |
| | | static $idn, $loaded; |
| | | |
| | |
| | | '/Net_(.+)/', |
| | | '/Auth_(.+)/', |
| | | '/^html_.+/', |
| | | '/^rcube(.*)/', |
| | | '/^utf8$/', |
| | | '/^rcube(.*)/' |
| | | ), |
| | | array( |
| | | 'Mail/\\1', |
| | | 'Net/\\1', |
| | | 'Auth/\\1', |
| | | 'Roundcube/html', |
| | | 'Roundcube/rcube\\1', |
| | | 'utf8.class', |
| | | 'Roundcube/rcube\\1' |
| | | ), |
| | | $classname |
| | | ); |
| | |
| | | */ |
| | | function rcube_pear_error($err) |
| | | { |
| | | error_log(sprintf("%s (%s): %s", |
| | | $err->getMessage(), |
| | | $err->getCode(), |
| | | $err->getUserinfo()), 0); |
| | | $msg = sprintf("ERROR: %s (%s)", $err->getMessage(), $err->getCode()); |
| | | |
| | | if ($info = $err->getUserinfo()) { |
| | | $msg .= ': ' . $info; |
| | | } |
| | | |
| | | error_log($msg, 0); |
| | | } |