summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/Roundcube/bootstrap.php12
-rw-r--r--program/lib/Roundcube/rcube.php17
-rw-r--r--program/lib/Roundcube/rcube_base_replacer.php4
-rw-r--r--program/lib/Roundcube/rcube_config.php24
-rw-r--r--program/lib/Roundcube/rcube_image.php89
-rw-r--r--program/lib/Roundcube/rcube_imap.php21
-rw-r--r--program/lib/Roundcube/rcube_imap_generic.php49
-rw-r--r--program/lib/Roundcube/rcube_ldap.php13
-rw-r--r--program/lib/Roundcube/rcube_storage.php2
-rw-r--r--program/lib/Roundcube/rcube_string_replacer.php2
-rw-r--r--program/lib/Roundcube/rcube_utils.php17
11 files changed, 163 insertions, 87 deletions
diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php
index 182ea1232..5d5a22387 100644
--- a/program/lib/Roundcube/bootstrap.php
+++ b/program/lib/Roundcube/bootstrap.php
@@ -58,7 +58,7 @@ define('RCUBE_VERSION', '1.0-git');
define('RCUBE_CHARSET', 'UTF-8');
if (!defined('RCUBE_LIB_DIR')) {
- define('RCUBE_LIB_DIR', dirname(__FILE__).'/');
+ define('RCUBE_LIB_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR);
}
if (!defined('RCUBE_INSTALL_PATH')) {
@@ -83,6 +83,16 @@ if (extension_loaded('mbstring')) {
@mb_regex_encoding(RCUBE_CHARSET);
}
+// make sure the Roundcube lib directory is in the include_path
+$rcube_path = realpath(RCUBE_LIB_DIR . '..');
+$sep = PATH_SEPARATOR;
+$regexp = "!(^|$sep)" . preg_quote($rcube_path, '!') . "($sep|\$)!";
+$path = ini_get('include_path');
+
+if (!preg_match($regexp, $path)) {
+ set_include_path($path . PATH_SEPARATOR . $rcube_path);
+}
+
// Register autoloader
spl_autoload_register('rcube_autoload');
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index e0f889a87..d9c3dd8b9 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -467,6 +467,10 @@ class rcube
$this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME']));
$this->session->set_ip_check($this->config->get('ip_check'));
+ if ($this->config->get('session_auth_name')) {
+ $this->session->set_cookiename($this->config->get('session_auth_name'));
+ }
+
// start PHP session (if not in CLI mode)
if ($_SERVER['REMOTE_ADDR']) {
$this->session->start();
@@ -494,7 +498,14 @@ class rcube
public function gc_temp()
{
$tmp = unslashify($this->config->get('temp_dir'));
- $expire = time() - 172800; // expire in 48 hours
+
+ // expire in 48 hours by default
+ $temp_dir_ttl = $this->config->get('temp_dir_ttl', '48h');
+ $temp_dir_ttl = get_offset_sec($temp_dir_ttl);
+ if ($temp_dir_ttl < 6*3600)
+ $temp_dir_ttl = 6*3600; // 6 hours sensible lower bound.
+
+ $expire = time() - $temp_dir_ttl;
if ($tmp && ($dir = opendir($tmp))) {
while (($fname = readdir($dir)) !== false) {
@@ -1393,6 +1404,10 @@ class rcube
'options' => $options,
));
+ if ($plugin['abort']) {
+ return isset($plugin['result']) ? $plugin['result'] : false;
+ }
+
$from = $plugin['from'];
$mailto = $plugin['mailto'];
$options = $plugin['options'];
diff --git a/program/lib/Roundcube/rcube_base_replacer.php b/program/lib/Roundcube/rcube_base_replacer.php
index e41ccb1d9..a59bba926 100644
--- a/program/lib/Roundcube/rcube_base_replacer.php
+++ b/program/lib/Roundcube/rcube_base_replacer.php
@@ -44,8 +44,8 @@ class rcube_base_replacer
public function replace($body)
{
return preg_replace_callback(array(
- '/(src|background|href)=(["\']?)([^"\'\s]+)(\2|\s|>)/Ui',
- '/(url\s*\()(["\']?)([^"\'\)\s]+)(\2)\)/Ui',
+ '/(src|background|href)=(["\']?)([^"\'\s>]+)(\2|\s|>)/i',
+ '/(url\s*\()(["\']?)([^"\'\)\s]+)(\2)\)/i',
),
array($this, 'callback'), $body);
}
diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php
index 62567a0e0..90e1394cf 100644
--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -282,8 +282,8 @@ class rcube_config
*/
public function merge($prefs)
{
+ $prefs = $this->fix_legacy_props($prefs);
$this->prop = array_merge($this->prop, $prefs, $this->userprefs);
- $this->fix_legacy_props();
}
@@ -295,6 +295,8 @@ class rcube_config
*/
public function set_user_prefs($prefs)
{
+ $prefs = $this->fix_legacy_props($prefs);
+
// Honor the dont_override setting for any existing user preferences
$dont_override = $this->get('dont_override');
if (is_array($dont_override) && !empty($dont_override)) {
@@ -316,8 +318,6 @@ class rcube_config
$this->userprefs = $prefs;
$this->prop = array_merge($this->prop, $prefs);
- $this->fix_legacy_props();
-
// override timezone settings with client values
if ($this->prop['timezone'] == 'auto') {
$this->prop['_timezone_value'] = isset($_SESSION['timezone']) ? $this->client_timezone() : $this->prop['_timezone_value'];
@@ -330,7 +330,7 @@ class rcube_config
/**
* Getter for all config options
*
- * @return array Hash array containg all config properties
+ * @return array Hash array containing all config properties
*/
public function all()
{
@@ -482,16 +482,22 @@ class rcube_config
/**
* Convert legacy options into new ones
+ *
+ * @param array $props Hash array with config props
+ *
+ * @return array Converted config props
*/
- private function fix_legacy_props()
+ private function fix_legacy_props($props)
{
foreach ($this->legacy_props as $new => $old) {
- if (isset($this->prop[$old])) {
- if (!isset($this->prop[$new])) {
- $this->prop[$new] = $this->prop[$old];
+ if (isset($props[$old])) {
+ if (!isset($props[$new])) {
+ $props[$new] = $props[$old];
}
- unset($this->prop[$old]);
+ unset($props[$old]);
}
}
+
+ return $props;
}
}
diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php
index c9a555300..4e4caae93 100644
--- a/program/lib/Roundcube/rcube_image.php
+++ b/program/lib/Roundcube/rcube_image.php
@@ -105,7 +105,6 @@ class rcube_image
if ($convert) {
$p['out'] = $filename;
$p['in'] = $this->image_file;
- $p['size'] = $size.'x'.$size;
$type = $props['type'];
if (!$type && ($data = $this->identify())) {
@@ -120,11 +119,37 @@ class rcube_image
$type = 'jpg';
}
- $p += array('type' => $type, 'types' => "bmp,eps,gif,jp2,jpg,png,svg,tif", 'quality' => 75);
- $p['-opts'] = array('-resize' => $p['size'].'>');
+ // If only one dimension is greater than the limit convert doesn't
+ // work as expected, we need to calculate new dimensions
+ $scale = $size / max($props['width'], $props['height']);
- if (in_array($type, explode(',', $p['types']))) { // Valid type?
- $result = rcube::exec($convert . ' 2>&1 -flatten -auto-orient -colorspace sRGB -strip -quality {quality} {-opts} {intype}:{in} {type}:{out}', $p);
+ // if file is smaller than the limit, we do nothing
+ // but copy original file to destination file
+ if ($scale >= 1 && $p['intype'] == $type) {
+ $result = ($this->image_file == $filename || copy($this->image_file, $filename)) ? '' : false;
+ }
+ else {
+ if ($scale >= 1) {
+ $width = $props['width'];
+ $height = $props['height'];
+ }
+ else {
+ $width = intval($props['width'] * $scale);
+ $height = intval($props['height'] * $scale);
+ }
+
+ $valid_types = "bmp,eps,gif,jp2,jpg,png,svg,tif";
+
+ $p += array(
+ 'type' => $type,
+ 'quality' => 75,
+ 'size' => $width . 'x' . $height,
+ );
+
+ if (in_array($type, explode(',', $valid_types))) { // Valid type?
+ $result = rcube::exec($convert . ' 2>&1 -flatten -auto-orient -colorspace sRGB -strip'
+ . ' -quality {quality} -resize {size} {intype}:{in} {type}:{out}', $p);
+ }
}
if ($result === '') {
@@ -161,34 +186,34 @@ class rcube_image
// Imagemagick resize is implemented in shrinking mode (see -resize argument above)
// we do the same here, if an image is smaller than specified size
// we do nothing but copy original file to destination file
- if ($scale > 1) {
- return $this->image_file == $filename || copy($this->image_file, $filename) ? $type : false;
- }
-
- $width = $props['width'] * $scale;
- $height = $props['height'] * $scale;
-
- $new_image = imagecreatetruecolor($width, $height);
-
- // Fix transparency of gif/png image
- if ($props['gd_type'] != IMAGETYPE_JPEG) {
- imagealphablending($new_image, false);
- imagesavealpha($new_image, true);
- $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
- imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
+ if ($scale >= 1) {
+ $result = $this->image_file == $filename || copy($this->image_file, $filename);
}
-
- imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $props['width'], $props['height']);
- $image = $new_image;
-
- if ($props['gd_type'] == IMAGETYPE_JPEG) {
- $result = imagejpeg($image, $filename, 75);
- }
- elseif($props['gd_type'] == IMAGETYPE_GIF) {
- $result = imagegif($image, $filename);
- }
- elseif($props['gd_type'] == IMAGETYPE_PNG) {
- $result = imagepng($image, $filename, 6, PNG_ALL_FILTERS);
+ else {
+ $width = intval($props['width'] * $scale);
+ $height = intval($props['height'] * $scale);
+ $new_image = imagecreatetruecolor($width, $height);
+
+ // Fix transparency of gif/png image
+ if ($props['gd_type'] != IMAGETYPE_JPEG) {
+ imagealphablending($new_image, false);
+ imagesavealpha($new_image, true);
+ $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
+ imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
+ }
+
+ imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $props['width'], $props['height']);
+ $image = $new_image;
+
+ if ($props['gd_type'] == IMAGETYPE_JPEG) {
+ $result = imagejpeg($image, $filename, 75);
+ }
+ elseif($props['gd_type'] == IMAGETYPE_GIF) {
+ $result = imagegif($image, $filename);
+ }
+ elseif($props['gd_type'] == IMAGETYPE_PNG) {
+ $result = imagepng($image, $filename, 6, PNG_ALL_FILTERS);
+ }
}
if ($result) {
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index c5346c8aa..689a6266d 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -70,7 +70,7 @@ class rcube_imap extends rcube_storage
protected $search_sort_field = '';
protected $search_threads = false;
protected $search_sorted = false;
- protected $options = array('auth_method' => 'check');
+ protected $options = array('auth_type' => 'check');
protected $caching = false;
protected $messages_caching = false;
protected $threading = false;
@@ -391,10 +391,10 @@ class rcube_imap extends rcube_storage
public function check_permflag($flag)
{
$flag = strtoupper($flag);
- $imap_flag = $this->conn->flags[$flag];
$perm_flags = $this->get_permflags($this->folder);
+ $imap_flag = $this->conn->flags[$flag];
- return in_array_nocase($imap_flag, $perm_flags);
+ return $imap_flag && !empty($perm_flags) && in_array_nocase($imap_flag, $perm_flags);
}
@@ -410,17 +410,7 @@ class rcube_imap extends rcube_storage
if (!strlen($folder)) {
return array();
}
-/*
- Checking PERMANENTFLAGS is rather rare, so we disable caching of it
- Re-think when we'll use it for more than only MDNSENT flag
- $cache_key = 'mailboxes.permanentflags.' . $folder;
- $permflags = $this->get_cache($cache_key);
-
- if ($permflags !== null) {
- return explode(' ', $permflags);
- }
-*/
if (!$this->check_connection()) {
return array();
}
@@ -435,10 +425,7 @@ class rcube_imap extends rcube_storage
if (!is_array($permflags)) {
$permflags = array();
}
-/*
- // Store permflags as string to limit cached object size
- $this->update_cache($cache_key, implode(' ', $permflags));
-*/
+
return $permflags;
}
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index e1193749b..bce4cd4e2 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -704,22 +704,11 @@ class rcube_imap_generic
*/
function connect($host, $user, $password, $options=null)
{
- // set options
- if (is_array($options)) {
- $this->prefs = $options;
- }
- // set auth method
- if (!empty($this->prefs['auth_type'])) {
- $auth_method = strtoupper($this->prefs['auth_type']);
- } else {
- $auth_method = 'CHECK';
- }
+ // configure
+ $this->set_prefs($options);
- if (!empty($this->prefs['disabled_caps'])) {
- $this->prefs['disabled_caps'] = array_map('strtoupper', (array)$this->prefs['disabled_caps']);
- }
-
- $result = false;
+ $auth_method = $this->prefs['auth_type'];
+ $result = false;
// initialize connection
$this->error = '';
@@ -896,6 +885,36 @@ class rcube_imap_generic
}
/**
+ * Initializes environment
+ */
+ protected function set_prefs($prefs)
+ {
+ // set preferences
+ if (is_array($prefs)) {
+ $this->prefs = $prefs;
+ }
+
+ // set auth method
+ if (!empty($this->prefs['auth_type'])) {
+ $this->prefs['auth_type'] = strtoupper($this->prefs['auth_type']);
+ }
+ else {
+ $this->prefs['auth_type'] = 'CHECK';
+ }
+
+ // disabled capabilities
+ if (!empty($this->prefs['disabled_caps'])) {
+ $this->prefs['disabled_caps'] = array_map('strtoupper', (array)$this->prefs['disabled_caps']);
+ }
+
+ // additional message flags
+ if (!empty($this->prefs['message_flags'])) {
+ $this->flags = array_merge($this->flags, $this->prefs['message_flags']);
+ unset($this->prefs['message_flags']);
+ }
+ }
+
+ /**
* Checks connection status
*
* @return bool True if connection is active and user is logged in, False otherwise.
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index 555a56471..cb7fa8466 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -514,7 +514,8 @@ class rcube_ldap extends rcube_addressbook
$this->result = new rcube_result_set($entries['count'], ($this->list_page-1) * $this->page_size);
}
else {
- $prop = $this->group_id ? $this->group_data : $this->prop;
+ $prop = $this->group_id ? $this->group_data : $this->prop;
+ $base_dn = $this->group_id ? $this->group_base_dn : $this->base_dn;
// use global search filter
if (!empty($this->filter))
@@ -522,7 +523,7 @@ class rcube_ldap extends rcube_addressbook
// exec LDAP search if no result resource is stored
if ($this->ready && !$this->ldap_result)
- $this->ldap_result = $this->ldap->search($prop['base_dn'], $prop['filter'], $prop['scope'], $this->prop['attributes'], $prop);
+ $this->ldap_result = $this->ldap->search($base_dn, $prop['filter'], $prop['scope'], $this->prop['attributes'], $prop);
// count contacts for this user
$this->result = $this->count();
@@ -841,12 +842,13 @@ class rcube_ldap extends rcube_addressbook
}
// We have a connection but no result set, attempt to get one.
else if ($this->ready) {
- $prop = $this->group_id ? $this->group_data : $this->prop;
+ $prop = $this->group_id ? $this->group_data : $this->prop;
+ $base_dn = $this->group_id ? $this->group_base_dn : $this->base_dn;
if (!empty($this->filter)) { // Use global search filter
$prop['filter'] = $this->filter;
}
- $count = $this->ldap->search($prop['base_dn'], $prop['filter'], $prop['scope'], array('dn'), $prop, true);
+ $count = $this->ldap->search($base_dn, $prop['filter'], $prop['scope'], array('dn'), $prop, true);
}
return new rcube_result_set($count, ($this->list_page-1) * $this->page_size);
@@ -1584,6 +1586,7 @@ class rcube_ldap extends rcube_addressbook
$base_dn = $this->groups_base_dn;
$filter = $this->prop['groups']['filter'];
+ $scope = $this->prop['groups']['scope'];
$name_attr = $this->prop['groups']['name_attr'];
$email_attr = $this->prop['groups']['email_attr'] ? $this->prop['groups']['email_attr'] : 'mail';
$sort_attrs = $this->prop['groups']['sort'] ? (array)$this->prop['groups']['sort'] : array($name_attr);
@@ -1604,7 +1607,7 @@ class rcube_ldap extends rcube_addressbook
}
$attrs = array_unique(array('dn', 'objectClass', $name_attr, $email_attr, $sort_attr));
- $ldap_data = $ldap->search($base_dn, $filter, $this->prop['groups']['scope'], $attrs, $this->prop['groups']);
+ $ldap_data = $ldap->search($base_dn, $filter, $scope, $attrs, $this->prop['groups']);
if ($ldap_data === false) {
return array();
diff --git a/program/lib/Roundcube/rcube_storage.php b/program/lib/Roundcube/rcube_storage.php
index de8334551..e697b2c73 100644
--- a/program/lib/Roundcube/rcube_storage.php
+++ b/program/lib/Roundcube/rcube_storage.php
@@ -39,7 +39,7 @@ abstract class rcube_storage
protected $default_charset = 'ISO-8859-1';
protected $default_folders = array('INBOX');
protected $search_set;
- protected $options = array('auth_method' => 'check');
+ protected $options = array('auth_type' => 'check');
protected $page_size = 10;
protected $threading = false;
diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php
index d1f1f4dbc..354b4596d 100644
--- a/program/lib/Roundcube/rcube_string_replacer.php
+++ b/program/lib/Roundcube/rcube_string_replacer.php
@@ -37,7 +37,7 @@ class rcube_string_replacer
// Support unicode/punycode in top-level domain part
$utf_domain = '[^?&@"\'\\/()<>\s\r\t\n]+\\.?([^\\x00-\\x2f\\x3b-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-zA-Z0-9]{2,})';
$url1 = '.:;,';
- $url2 = 'a-zA-Z0-9%=#$@+?!&\\/_~\\[\\]\\(\\){}\*-';
+ $url2 = 'a-zA-Z0-9%=#$@+?|!&\\/_~\\[\\]\\(\\){}\*-';
$this->link_pattern = "/([\w]+:\/\/|\W[Ww][Ww][Ww]\.|^[Ww][Ww][Ww]\.)($utf_domain([$url1]*[$url2]+)*)/";
$this->mailto_pattern = "/("
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index cf87dedb7..2540f779d 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -739,11 +739,22 @@ class rcube_utils
*/
public static function strtotime($date)
{
+ $date = trim($date);
+
// check for MS Outlook vCard date format YYYYMMDD
- if (preg_match('/^([12][90]\d\d)([01]\d)(\d\d)$/', trim($date), $matches)) {
- return mktime(0,0,0, intval($matches[2]), intval($matches[3]), intval($matches[1]));
+ if (preg_match('/^([12][90]\d\d)([01]\d)([0123]\d)$/', $date, $m)) {
+ return mktime(0,0,0, intval($m[2]), intval($m[3]), intval($m[1]));
}
- else if (is_numeric($date)) {
+
+ // common little-endian formats, e.g. dd/mm/yyyy (not all are supported by strtotime)
+ if (preg_match('/^(\d{1,2})[.\/-](\d{1,2})[.\/-](\d{4})$/', $date, $m)
+ && $m[1] > 0 && $m[1] <= 31 && $m[2] > 0 && $m[2] <= 12 && $m[3] >= 1970
+ ) {
+ return mktime(0,0,0, intval($m[2]), intval($m[1]), intval($m[3]));
+ }
+
+ // unix timestamp
+ if (is_numeric($date)) {
return (int) $date;
}