CS fixes, Avoid usused variables, fixed minor bugs

pull/6957/head
Aleksander Machniak 5 years ago
parent 20e25582e7
commit 66fab8cdb2

@ -14,7 +14,13 @@ class archive extends rcube_plugin
{ {
public $task = 'settings|mail|login'; public $task = 'settings|mail|login';
private $archive_folder;
private $folders;
/**
* Plugin initialization.
*/
function init() function init()
{ {
$rcmail = rcmail::get_instance(); $rcmail = rcmail::get_instance();
@ -22,9 +28,9 @@ class archive extends rcube_plugin
// register special folder type // register special folder type
rcube_storage::$folder_types[] = 'archive'; rcube_storage::$folder_types[] = 'archive';
$archive_folder = $rcmail->config->get('archive_mbox'); $this->archive_folder = $rcmail->config->get('archive_mbox');
if ($rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show') && $archive_folder) { if ($rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show') && $this->archive_folder) {
$this->include_stylesheet($this->local_skin_path() . '/archive.css'); $this->include_stylesheet($this->local_skin_path() . '/archive.css');
$this->include_script('archive.js'); $this->include_script('archive.js');
$this->add_texts('localization', true); $this->add_texts('localization', true);
@ -47,7 +53,7 @@ class archive extends rcube_plugin
$this->add_hook('render_mailboxlist', array($this, 'render_mailboxlist')); $this->add_hook('render_mailboxlist', array($this, 'render_mailboxlist'));
// set env variables for client // set env variables for client
$rcmail->output->set_env('archive_folder', $archive_folder); $rcmail->output->set_env('archive_folder', $this->archive_folder);
$rcmail->output->set_env('archive_type', $rcmail->config->get('archive_type','')); $rcmail->output->set_env('archive_type', $rcmail->config->get('archive_type',''));
} }
else if ($rcmail->task == 'mail') { else if ($rcmail->task == 'mail') {
@ -58,11 +64,11 @@ class archive extends rcube_plugin
$this->add_hook('preferences_list', array($this, 'prefs_table')); $this->add_hook('preferences_list', array($this, 'prefs_table'));
$this->add_hook('preferences_save', array($this, 'save_prefs')); $this->add_hook('preferences_save', array($this, 'save_prefs'));
if ($rcmail->action == 'folders' && $archive_folder) { if ($rcmail->action == 'folders' && $this->archive_folder) {
$this->include_stylesheet($this->local_skin_path() . '/archive.css'); $this->include_stylesheet($this->local_skin_path() . '/archive.css');
$this->include_script('archive.js'); $this->include_script('archive.js');
// set env variables for client // set env variables for client
$rcmail->output->set_env('archive_folder', $archive_folder); $rcmail->output->set_env('archive_folder', $this->archive_folder);
} }
} }
} }
@ -72,18 +78,14 @@ class archive extends rcube_plugin
*/ */
function render_mailboxlist($p) function render_mailboxlist($p)
{ {
$rcmail = rcmail::get_instance();
$archive_folder = $rcmail->config->get('archive_mbox');
$show_real_name = $rcmail->config->get('show_real_foldernames');
// set localized name for the configured archive folder // set localized name for the configured archive folder
if ($archive_folder && !$show_real_name) { if ($this->archive_folder && !rcmail::get_instance()->config->get('show_real_foldernames')) {
if (isset($p['list'][$archive_folder])) { if (isset($p['list'][$this->archive_folder])) {
$p['list'][$archive_folder]['name'] = $this->gettext('archivefolder'); $p['list'][$this->archive_folder]['name'] = $this->gettext('archivefolder');
} }
else { else {
// search in subfolders // search in subfolders
$this->_mod_folder_name($p['list'], $archive_folder, $this->gettext('archivefolder')); $this->_mod_folder_name($p['list'], $this->archive_folder, $this->gettext('archivefolder'));
} }
} }
@ -129,15 +131,13 @@ class archive extends rcube_plugin
$delimiter = $storage->get_hierarchy_delimiter(); $delimiter = $storage->get_hierarchy_delimiter();
$read_on_move = (bool) $rcmail->config->get('read_on_archive'); $read_on_move = (bool) $rcmail->config->get('read_on_archive');
$archive_type = $rcmail->config->get('archive_type', ''); $archive_type = $rcmail->config->get('archive_type', '');
$archive_folder = $rcmail->config->get('archive_mbox'); $archive_prefix = $this->archive_folder . $delimiter;
$archive_prefix = $archive_folder . $delimiter;
$search_request = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC); $search_request = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC);
// count messages before changing anything // count messages before changing anything
if ($_POST['_from'] != 'show') { if ($_POST['_from'] != 'show') {
$threading = (bool) $storage->get_threading(); $threading = (bool) $storage->get_threading();
$old_count = $storage->count(null, $threading ? 'THREADS' : 'ALL'); $old_count = $storage->count(null, $threading ? 'THREADS' : 'ALL');
$old_pages = ceil($old_count / $storage->get_pagesize());
} }
$count = 0; $count = 0;
@ -152,12 +152,12 @@ class archive extends rcube_plugin
); );
foreach (rcmail::get_uids(null, null, $multifolder, rcube_utils::INPUT_POST) as $mbox => $uids) { foreach (rcmail::get_uids(null, null, $multifolder, rcube_utils::INPUT_POST) as $mbox => $uids) {
if (!$archive_folder || $mbox === $archive_folder || strpos($mbox, $archive_prefix) === 0) { if (!$this->archive_folder || $mbox === $this->archive_folder || strpos($mbox, $archive_prefix) === 0) {
$count = count($uids); $count = count($uids);
continue; continue;
} }
else if (!$archive_type || $archive_type == 'folder') { else if (!$archive_type || $archive_type == 'folder') {
$folder = $archive_folder; $folder = $this->archive_folder;
if ($archive_type == 'folder') { if ($archive_type == 'folder') {
// compose full folder path // compose full folder path
@ -202,7 +202,7 @@ class archive extends rcube_plugin
} }
// compose full folder path // compose full folder path
$folder = $archive_folder . ($subfolder ? $delimiter . $subfolder : ''); $folder = $this->archive_folder . ($subfolder ? $delimiter . $subfolder : '');
$execute[$folder][] = $message->uid; $execute[$folder][] = $message->uid;
} }
@ -348,7 +348,7 @@ class archive extends rcube_plugin
$delimiter = $storage->get_hierarchy_delimiter(); $delimiter = $storage->get_hierarchy_delimiter();
if ($this->folders === null) { if ($this->folders === null) {
$this->folders = $storage->list_folders('', $archive_folder . '*', 'mail', null, true); $this->folders = $storage->list_folders('', $this->archive_folder . '*', 'mail', null, true);
} }
if (!in_array($folder, $this->folders)) { if (!in_array($folder, $this->folders)) {

@ -38,8 +38,8 @@ class runlog {
$this->parent_stack[] = $name; $this->parent_stack[] = $name;
$this->print_to_console("start: ".$name, $tag, 'start'); $this->print_to_console("start: ".$name, $tag);
$this->print_to_file("start: ".$name, $tag, 'start'); $this->print_to_file("start: ".$name, $tag);
$this->indent++; $this->indent++;
} }
@ -72,8 +72,8 @@ class runlog {
$tag_report .= "$tag: $count, "; $tag_report .= "$tag: $count, ";
} }
$end_txt = sprintf("end: $name - %0.4f seconds $tag_report", $this->run_log[$lastk]['duration']); $end_txt = sprintf("end: $name - %0.4f seconds $tag_report", $this->run_log[$lastk]['duration']);
$this->print_to_console($end_txt, $this->run_log[$lastk]['tag'], 'end'); $this->print_to_console($end_txt, $this->run_log[$lastk]['tag']);
$this->print_to_file($end_txt, $this->run_log[$lastk]['tag'], 'end'); $this->print_to_file($end_txt, $this->run_log[$lastk]['tag']);
} }
} }
@ -137,7 +137,7 @@ class runlog {
$this->print_to_console($msg, $tag); $this->print_to_console($msg, $tag);
} }
public function print_to_file($msg, $tag = false, $type = false) public function print_to_file($msg, $tag = false)
{ {
if (!$tag) { if (!$tag) {
$file_handle_tag = 'master'; $file_handle_tag = 'master';

@ -574,8 +574,8 @@ class enigma_driver_gnupg extends enigma_driver
$data_result = $db->query("SELECT `data`, `mtime` FROM $table" $data_result = $db->query("SELECT `data`, `mtime` FROM $table"
. " WHERE `file_id` = ?", $record['file_id']); . " WHERE `file_id` = ?", $record['file_id']);
$data = $db->fetch_assoc($data_result); $record = $db->fetch_assoc($data_result);
$data = $data ? base64_decode($data['data']) : null; $data = $record ? base64_decode($record['data']) : null;
if ($data === null || $data === false) { if ($data === null || $data === false) {
rcube::raise_error(array( rcube::raise_error(array(
@ -590,7 +590,7 @@ class enigma_driver_gnupg extends enigma_driver
if (file_put_contents($tmpfile, $data, LOCK_EX) === strlen($data)) { if (file_put_contents($tmpfile, $data, LOCK_EX) === strlen($data)) {
rename($tmpfile, $file); rename($tmpfile, $file);
touch($file, $data_record['mtime']); touch($file, $record['mtime']);
if ($this->debug) { if ($this->debug) {
$this->debug("SYNC: Fetched file: $file"); $this->debug("SYNC: Fetched file: $file");

@ -46,10 +46,12 @@ class enigma_key
*/ */
function get_type() function get_type()
{ {
if ($this->subkeys[0]->has_private) if ($this->subkeys[0]->has_private) {
return enigma_key::TYPE_KEYPAIR; return enigma_key::TYPE_KEYPAIR;
else if (!empty($this->subkeys[0])) }
else if (!empty($this->subkeys[0])) {
return enigma_key::TYPE_PUBLIC; return enigma_key::TYPE_PUBLIC;
}
return enigma_key::TYPE_UNKNOWN; return enigma_key::TYPE_UNKNOWN;
} }
@ -59,9 +61,11 @@ class enigma_key
*/ */
function is_revoked() function is_revoked()
{ {
foreach ($this->subkeys as $subkey) foreach ($this->subkeys as $subkey) {
if (!$subkey->revoked) if (!$subkey->revoked) {
return false; return false;
}
}
return true; return true;
} }
@ -71,9 +75,11 @@ class enigma_key
*/ */
function is_valid() function is_valid()
{ {
foreach ($this->users as $user) foreach ($this->users as $user) {
if ($user->valid) if ($user->valid) {
return true; return true;
}
}
return false; return false;
} }
@ -85,9 +91,11 @@ class enigma_key
{ {
$now = time(); $now = time();
foreach ($this->subkeys as $subkey) foreach ($this->subkeys as $subkey) {
if (!$subkey->expires || $subkey->expires > $now) if (!$subkey->expires || $subkey->expires > $now) {
return true; return true;
}
}
return false; return false;
} }
@ -97,11 +105,11 @@ class enigma_key
*/ */
function is_private() function is_private()
{ {
$now = time(); foreach ($this->subkeys as $subkey) {
if ($subkey->has_private) {
foreach ($this->subkeys as $subkey)
if ($subkey->has_private)
return true; return true;
}
}
return false; return false;
} }

@ -1253,7 +1253,6 @@ class enigma_ui
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST); $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST); $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST); $mime_id = rcube_utils::get_input_value('_part', rcube_utils::INPUT_POST);
$storage = $this->rc->get_storage();
$engine = $this->enigma->load_engine(); $engine = $this->enigma->load_engine();
if ($uid && $mime_id) { if ($uid && $mime_id) {

@ -72,7 +72,6 @@ class filesystem_attachments extends rcube_plugin
{ {
$args['status'] = false; $args['status'] = false;
$group = $args['group']; $group = $args['group'];
$rcmail = rcube::get_instance();
// use common temp dir for file uploads // use common temp dir for file uploads
$tmpfname = rcube_utils::temp_filename('attmnt'); $tmpfname = rcube_utils::temp_filename('attmnt');
@ -199,7 +198,7 @@ class filesystem_attachments extends rcube_plugin
private function find_file_by_id($id) private function find_file_by_id($id)
{ {
foreach ((array) $_SESSION['plugins']['filesystem_attachments'] as $group => $files) { foreach ((array) $_SESSION['plugins']['filesystem_attachments'] as $files) {
if (isset($files[$id])) { if (isset($files[$id])) {
return true; return true;
} }

@ -143,7 +143,7 @@ class help extends rcube_plugin
// resolve task/action for deep linking // resolve task/action for deep linking
$rel = $_REQUEST['_rel']; $rel = $_REQUEST['_rel'];
list($task, $action) = explode('/', $rel); list($task, ) = explode('/', $rel);
if ($add = $index_map[$rel]) { if ($add = $index_map[$rel]) {
$src .= $add; $src .= $add;
} }

@ -1564,7 +1564,7 @@ class rcube_sieve_engine
} }
if ($compact) { if ($compact) {
$select = new html_select(array('name' => '_join', 'id' => '_join' . $id, $select = new html_select(array('name' => '_join', 'id' => '_join',
'onchange' => 'rule_join_radio(this.value)')); 'onchange' => 'rule_join_radio(this.value)'));
foreach (array('allof', 'anyof', 'any') as $val) { foreach (array('allof', 'anyof', 'any') as $val) {

@ -200,17 +200,11 @@ class rcube_sieve_forward extends rcube_sieve_engine
return; return;
} }
$date_extension = in_array('date', $this->exts);
$regex_extension = in_array('regex', $this->exts);
$status = rcube_utils::get_input_value('forward_status', rcube_utils::INPUT_POST); $status = rcube_utils::get_input_value('forward_status', rcube_utils::INPUT_POST);
$action = rcube_utils::get_input_value('forward_action', rcube_utils::INPUT_POST); $action = rcube_utils::get_input_value('forward_action', rcube_utils::INPUT_POST);
$target = rcube_utils::get_input_value('action_target', rcube_utils::INPUT_POST, true); $target = rcube_utils::get_input_value('action_target', rcube_utils::INPUT_POST, true);
$forward_action['type'] = 'forward'; $date_extension = in_array('date', $this->exts);
$forward_action['reason'] = $this->strip_value(str_replace("\r\n", "\n", $reason));
$forward_action['subject'] = trim($subject);
$forward_action['from'] = trim($from);
$forward_tests = (array) $this->forward['tests']; $forward_tests = (array) $this->forward['tests'];
if ($action == 'redirect' || $action == 'copy') { if ($action == 'redirect' || $action == 'copy') {
@ -230,7 +224,7 @@ class rcube_sieve_forward extends rcube_sieve_engine
$rule['disabled'] = $status == 'off'; $rule['disabled'] = $status == 'off';
$rule['tests'] = $forward_tests; $rule['tests'] = $forward_tests;
$rule['join'] = $date_extension ? count($forward_tests) > 1 : false; $rule['join'] = $date_extension ? count($forward_tests) > 1 : false;
$rule['actions'] = array($forward_action); $rule['actions'] = array();
$rule['after'] = $after; $rule['after'] = $after;
if ($action && $action != 'keep') { if ($action && $action != 'keep') {
@ -455,7 +449,7 @@ class rcube_sieve_forward extends rcube_sieve_engine
$this->init_script(); $this->init_script();
$this->forward_rule(); $this->forward_rule();
$forward['type'] = 'forward'; $date_extension = in_array('date', $this->exts);
if ($data['action'] == 'redirect' || $data['action'] == 'copy') { if ($data['action'] == 'redirect' || $data['action'] == 'copy') {
if (empty($data['target']) || !rcube_utils::check_email($data['target'])) { if (empty($data['target']) || !rcube_utils::check_email($data['target'])) {
@ -478,7 +472,7 @@ class rcube_sieve_forward extends rcube_sieve_engine
$rule['disabled'] = isset($data['enabled']) && !$data['enabled']; $rule['disabled'] = isset($data['enabled']) && !$data['enabled'];
$rule['tests'] = $forward_tests; $rule['tests'] = $forward_tests;
$rule['join'] = $date_extension ? count($forward_tests) > 1 : false; $rule['join'] = $date_extension ? count($forward_tests) > 1 : false;
$rule['actions'] = array($forward); $rule['actions'] = array();
if ($data['action'] && $data['action'] != 'keep') { if ($data['action'] && $data['action'] != 'keep') {
$rule['actions'][] = array( $rule['actions'][] = array(

@ -591,6 +591,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine
public static function vacation_interval(&$vacation) public static function vacation_interval(&$vacation)
{ {
$rcube = rcube::get_instance(); $rcube = rcube::get_instance();
$seconds_extension = in_array('vacation-seconds', $this->exts);
if (isset($vacation['seconds'])) { if (isset($vacation['seconds'])) {
$interval = $vacation['seconds']; $interval = $vacation['seconds'];
@ -722,7 +723,6 @@ class rcube_sieve_vacation extends rcube_sieve_engine
// check supported extensions // check supported extensions
$date_extension = in_array('date', $this->exts); $date_extension = in_array('date', $this->exts);
$regex_extension = in_array('regex', $this->exts); $regex_extension = in_array('regex', $this->exts);
$seconds_extension = in_array('vacation-seconds', $this->exts);
// set user's timezone // set user's timezone
try { try {
@ -754,8 +754,8 @@ class rcube_sieve_vacation extends rcube_sieve_engine
else if ($regex_extension) { else if ($regex_extension) {
// Sieve 'date' extension not available, read start/end from RegEx based rules instead // Sieve 'date' extension not available, read start/end from RegEx based rules instead
if ($date_tests = self::parse_regexp_tests($this->vacation['tests'])) { if ($date_tests = self::parse_regexp_tests($this->vacation['tests'])) {
$from = new DateTime($date_tests['from'] . ' ' . '00:00:00', $timezone); $start = new DateTime($date_tests['from'] . ' ' . '00:00:00', $timezone);
$to = new DateTime($date_tests['to'] . ' ' . '23:59:59', $timezone); $end = new DateTime($date_tests['to'] . ' ' . '23:59:59', $timezone);
} }
} }
@ -801,7 +801,6 @@ class rcube_sieve_vacation extends rcube_sieve_engine
// check supported extensions // check supported extensions
$date_extension = in_array('date', $this->exts); $date_extension = in_array('date', $this->exts);
$regex_extension = in_array('regex', $this->exts); $regex_extension = in_array('regex', $this->exts);
$seconds_extension = in_array('vacation-seconds', $this->exts);
$vacation['type'] = 'vacation'; $vacation['type'] = 'vacation';
$vacation['reason'] = $this->strip_value(str_replace("\r\n", "\n", $data['message'])); $vacation['reason'] = $this->strip_value(str_replace("\r\n", "\n", $data['message']));

@ -84,31 +84,12 @@ class rcube_directadmin_password
* @author Phi1 'l0rdphi1' Stier <l0rdphi1@liquenox.net> * @author Phi1 'l0rdphi1' Stier <l0rdphi1@liquenox.net>
* @package HTTPSocket * @package HTTPSocket
* @version 3.0.2 * @version 3.0.2
* 3.0.2
* added longer curl timeouts
* 3.0.1
* support for tcp:// conversion to http://
* 3.0.0
* swapped to use curl to address ssl certificate issues with php 5.6
* 2.7.2
* added x-use-https header check
* added max number of location redirects
* added custom settable message if x-use-https is found, so users can be told where to set their scripts
* if a redirect host is https, add ssl:// to remote_host
* 2.7.1
* added isset to headers['location'], line 306
*/ */
class HTTPSocket { class HTTPSocket
{
var $version = '3.0.2'; var $version = '3.0.2';
/* all vars are private except $error, $query_cache, and $doFollowLocationHeader */ // all vars are private except $error, $query_cache, and $doFollowLocationHeader
var $method = 'GET'; var $method = 'GET';
@ -123,28 +104,23 @@ class HTTPSocket {
var $result_status_code; var $result_status_code;
var $lastTransferSpeed; var $lastTransferSpeed;
var $bind_host; var $bind_host;
var $error = array(); var $error = array();
var $warn = array(); var $warn = array();
var $query_cache = array(); var $query_cache = array();
var $doFollowLocationHeader = true;
var $doFollowLocationHeader = TRUE;
var $redirectURL; var $redirectURL;
var $max_redirects = 5; var $max_redirects = 5;
var $ssl_setting_message = 'DirectAdmin appears to be using SSL. Change your script to connect to ssl://'; var $ssl_setting_message = 'DirectAdmin appears to be using SSL. Change your script to connect to ssl://';
var $extra_headers = array(); var $extra_headers = array();
/** /**
* Create server "connection". * Create server "connection".
* *
*/ */
function connect($host, $port = '' ) function connect($host, $port = '')
{
if (!is_numeric($port))
{ {
if (!is_numeric($port)) {
$port = 2222; $port = 2222;
} }
@ -152,10 +128,9 @@ class HTTPSocket {
$this->remote_port = $port; $this->remote_port = $port;
} }
function bind( $ip = '' ) function bind($ip = '')
{
if ( $ip == '' )
{ {
if ($ip == '') {
$ip = $_SERVER['SERVER_ADDR']; $ip = $_SERVER['SERVER_ADDR'];
} }
@ -167,7 +142,7 @@ class HTTPSocket {
* *
* @param string|null request method. supports GET, POST, and HEAD. default is GET * @param string|null request method. supports GET, POST, and HEAD. default is GET
*/ */
function set_method( $method = 'GET' ) function set_method($method = 'GET')
{ {
$this->method = strtoupper($method); $this->method = strtoupper($method);
} }
@ -178,15 +153,13 @@ class HTTPSocket {
* @param string|null username. default is null * @param string|null username. default is null
* @param string|null password. default is null * @param string|null password. default is null
*/ */
function set_login( $uname = '', $passwd = '' ) function set_login($uname = '', $passwd = '')
{
if ( strlen($uname) > 0 )
{ {
if (strlen($uname) > 0) {
$this->remote_uname = $uname; $this->remote_uname = $uname;
} }
if ( strlen($passwd) > 0 ) if (strlen($passwd) > 0) {
{
$this->remote_passwd = $passwd; $this->remote_passwd = $passwd;
} }
@ -197,66 +170,62 @@ class HTTPSocket {
* *
* @param string containing properly formatted server API. See DA API docs and examples. Http:// URLs O.K. too. * @param string containing properly formatted server API. See DA API docs and examples. Http:// URLs O.K. too.
* @param string|array query to pass to url * @param string|array query to pass to url
* @param int if connection KB/s drops below value here, will drop connection
*/ */
function query( $request, $content = '', $doSpeedCheck = 0 ) function query($request, $content = '')
{ {
$this->error = $this->warn = array(); $this->error = $this->warn = array();
$this->result_status_code = NULL; $this->result_status_code = null;
$is_ssl = FALSE; $is_ssl = false;
// is our request a http:// ... ? // is our request a http:// ... ?
if (preg_match('!^http://!i',$request) || preg_match('!^https://!i',$request)) if (preg_match('!^http://!i',$request) || preg_match('!^https://!i',$request)) {
{
$location = parse_url($request); $location = parse_url($request);
if (preg_match('!^https://!i',$request)) if (preg_match('!^https://!i',$request)) {
{
$this->connect('https://'.$location['host'],$location['port']); $this->connect('https://'.$location['host'],$location['port']);
} }
else else {
$this->connect('http://'.$location['host'],$location['port']); $this->connect('http://'.$location['host'],$location['port']);
}
$this->set_login($location['user'],$location['pass']); $this->set_login($location['user'],$location['pass']);
$request = $location['path']; $request = $location['path'];
$content = $location['query']; $content = $location['query'];
if ( strlen($request) < 1 ) if (strlen($request) < 1) {
{
$request = '/'; $request = '/';
} }
} }
if (preg_match('!^ssl://!i', $this->remote_host)) if (preg_match('!^ssl://!i', $this->remote_host)) {
$this->remote_host = 'https://'.substr($this->remote_host, 6); $this->remote_host = 'https://'.substr($this->remote_host, 6);
}
if (preg_match('!^tcp://!i', $this->remote_host)) if (preg_match('!^tcp://!i', $this->remote_host)) {
$this->remote_host = 'http://'.substr($this->remote_host, 6); $this->remote_host = 'http://'.substr($this->remote_host, 6);
}
if (preg_match('!^https://!i', $this->remote_host)) if (preg_match('!^https://!i', $this->remote_host)) {
$is_ssl = TRUE; $is_ssl = true;
}
$array_headers = array( $array_headers = array(
'Host' => ( $this->remote_port == 80 ? $this->remote_host : "$this->remote_host:$this->remote_port" ), 'Host' => $this->remote_port == 80 ? $this->remote_host : "$this->remote_host:$this->remote_port",
'Accept' => '*/*', 'Accept' => '*/*',
'Connection' => 'Close' ); 'Connection' => 'Close' );
foreach ( $this->extra_headers as $key => $value ) foreach ($this->extra_headers as $key => $value) {
{
$array_headers[$key] = $value; $array_headers[$key] = $value;
} }
$this->result = $this->result_header = $this->result_body = ''; $this->result = $this->result_header = $this->result_body = '';
// was content sent as an array? if so, turn it into a string // was content sent as an array? if so, turn it into a string
if (is_array($content)) if (is_array($content)) {
{
$pairs = array(); $pairs = array();
foreach ( $content as $key => $value ) foreach ($content as $key => $value) {
{
$pairs[] = "$key=".urlencode($value); $pairs[] = "$key=".urlencode($value);
} }
@ -264,15 +233,15 @@ class HTTPSocket {
unset($pairs); unset($pairs);
} }
$OK = TRUE; $OK = true;
if ($this->method == 'GET') if ($this->method == 'GET') {
$request .= '?'.$content; $request .= '?'.$content;
}
$ch = curl_init($this->remote_host.':'.$this->remote_port.$request); $ch = curl_init($this->remote_host.':'.$this->remote_port.$request);
if ($is_ssl) if ($is_ssl) {
{
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //1 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //1
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //2 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //2
//curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); //curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
@ -289,33 +258,23 @@ class HTTPSocket {
curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 512); curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 512);
curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 120); curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 120);
//if ($this->doFollowLocationHeader)
//{
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
// curl_setopt($ch, CURLOPT_MAXREDIRS, $this->max_redirects);
//}
// instance connection // instance connection
if ($this->bind_host) if ($this->bind_host) {
{
curl_setopt($ch, CURLOPT_INTERFACE, $this->bind_host); curl_setopt($ch, CURLOPT_INTERFACE, $this->bind_host);
} }
// if we have a username and password, add the header // if we have a username and password, add the header
if ( isset($this->remote_uname) && isset($this->remote_passwd) ) if (isset($this->remote_uname) && isset($this->remote_passwd)) {
{
curl_setopt($ch, CURLOPT_USERPWD, $this->remote_uname.':'.$this->remote_passwd); curl_setopt($ch, CURLOPT_USERPWD, $this->remote_uname.':'.$this->remote_passwd);
} }
// for DA skins: if $this->remote_passwd is NULL, try to use the login key system // for DA skins: if $this->remote_passwd is NULL, try to use the login key system
if ( isset($this->remote_uname) && $this->remote_passwd == NULL ) if (isset($this->remote_uname) && $this->remote_passwd == NULL) {
{
$array_headers['Cookie'] = "session={$_SERVER['SESSION_ID']}; key={$_SERVER['SESSION_KEY']}"; $array_headers['Cookie'] = "session={$_SERVER['SESSION_ID']}; key={$_SERVER['SESSION_KEY']}";
} }
// if method is POST, add content length & type headers // if method is POST, add content length & type headers
if ( $this->method == 'POST' ) if ($this->method == 'POST') {
{
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
@ -325,18 +284,15 @@ class HTTPSocket {
curl_setopt($ch, CURLOPT_HTTPHEADER, $array_headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $array_headers);
if(!($this->result = curl_exec($ch))) {
if( !($this->result = curl_exec($ch)) )
{
$this->error[] .= curl_error($ch); $this->error[] .= curl_error($ch);
$OK = FALSE; $OK = false;
} }
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$this->result_header = substr($this->result, 0, $header_size); $this->result_header = substr($this->result, 0, $header_size);
$this->result_body = substr($this->result, $header_size); $this->result_body = substr($this->result, $header_size);
$this->result_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->result_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$this->lastTransferSpeed = curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD) / 1024; $this->lastTransferSpeed = curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD) / 1024;
curl_close($ch); curl_close($ch);
@ -346,29 +302,27 @@ class HTTPSocket {
$headers = $this->fetch_header(); $headers = $this->fetch_header();
// did we get the full file? // did we get the full file?
if ( !empty($headers['content-length']) && $headers['content-length'] != strlen($this->result_body) ) if (!empty($headers['content-length']) && $headers['content-length'] != strlen($this->result_body)) {
{
$this->result_status_code = 206; $this->result_status_code = 206;
} }
// now, if we're being passed a location header, should we follow it? // now, if we're being passed a location header, should we follow it?
if ($this->doFollowLocationHeader) if ($this->doFollowLocationHeader) {
{
//dont bother if we didn't even setup the script correctly //dont bother if we didn't even setup the script correctly
if (isset($headers['x-use-https']) && $headers['x-use-https']=='yes') if (isset($headers['x-use-https']) && $headers['x-use-https'] == 'yes') {
die($this->ssl_setting_message); die($this->ssl_setting_message);
}
if (isset($headers['location'])) if (isset($headers['location'])) {
{ if ($this->max_redirects <= 0) {
if ($this->max_redirects <= 0)
die("Too many redirects on: ".$headers['location']); die("Too many redirects on: ".$headers['location']);
}
$this->max_redirects--; $this->max_redirects--;
$this->redirectURL = $headers['location']; $this->redirectURL = $headers['location'];
$this->query($headers['location']); $this->query($headers['location']);
} }
} }
} }
function getTransferSpeed() function getTransferSpeed()
@ -383,21 +337,19 @@ class HTTPSocket {
* @param boolean return as array? (like PHP's file() command) * @param boolean return as array? (like PHP's file() command)
* @return string result body * @return string result body
*/ */
function get($location, $asArray = FALSE ) function get($location, $asArray = false)
{ {
$this->query($location); $this->query($location);
if ( $this->get_status_code() == 200 ) if ($this->get_status_code() == 200) {
{ if ($asArray) {
if ($asArray)
{
return preg_split("/\n/",$this->fetch_body()); return preg_split("/\n/",$this->fetch_body());
} }
return $this->fetch_body(); return $this->fetch_body();
} }
return FALSE; return false;
} }
/** /**
@ -449,22 +401,20 @@ class HTTPSocket {
* @param string (optional) header to return * @param string (optional) header to return
* @return array result header * @return array result header
*/ */
function fetch_header( $header = '' ) function fetch_header($header = '')
{ {
$array_headers = preg_split("/\r\n/",$this->result_header); $array_headers = preg_split("/\r\n/",$this->result_header);
$array_return = array( 0 => $array_headers[0] ); $array_return = array(0 => $array_headers[0]);
unset($array_headers[0]); unset($array_headers[0]);
foreach ( $array_headers as $pair ) foreach ($array_headers as $pair) {
{
if ($pair == '' || $pair == "\r\n") continue; if ($pair == '' || $pair == "\r\n") continue;
list($key,$value) = preg_split("/: /",$pair,2); list($key,$value) = preg_split("/: /",$pair,2);
$array_return[strtolower($key)] = $value; $array_return[strtolower($key)] = $value;
} }
if ( $header != '' ) if ($header != '') {
{
return $array_return[strtolower($header)]; return $array_return[strtolower($header)];
} }

@ -30,8 +30,6 @@ class rcube_domainfactory_password
{ {
function save($curpass, $passwd, $username) function save($curpass, $passwd, $username)
{ {
$rcmail = rcmail::get_instance();
if ($ch = curl_init()) { if ($ch = curl_init()) {
// initial login // initial login
curl_setopt_array($ch, array( curl_setopt_array($ch, array(

@ -51,7 +51,7 @@ class rcube_gearman_password
'code' => 600, 'code' => 600,
'type' => 'php', 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Password plugin: Gearman authentication failed for user $username: $error" 'message' => "Password plugin: Gearman authentication failed for user $username"
), true, false); ), true, false);
} }
} }

@ -85,7 +85,7 @@ class rcube_ldap_simple_password
$entry[$smblchattr] = time(); $entry[$smblchattr] = time();
} }
$this->_debug("C: Modify $user_dn: " . print_r($entry, true)); $this->_debug("C: Modify {$this->user}: " . print_r($entry, true));
if (!ldap_modify($this->conn, $this->user, $entry)) { if (!ldap_modify($this->conn, $this->user, $entry)) {
$this->_debug("S: ".ldap_error($this->conn)); $this->_debug("S: ".ldap_error($this->conn));

@ -33,7 +33,6 @@ class rcube_virtualmin_password
{ {
function save($currpass, $newpass, $username) function save($currpass, $newpass, $username)
{ {
$rcmail = rcmail::get_instance();
$curdir = RCUBE_PLUGINS_DIR . 'password/helpers'; $curdir = RCUBE_PLUGINS_DIR . 'password/helpers';
$username = escapeshellarg($username); $username = escapeshellarg($username);

@ -55,7 +55,6 @@ class rcube_zxcvbn_password
return; return;
} }
$rcmail = rcmail::get_instance();
$zxcvbn = new ZxcvbnPhp\Zxcvbn(); $zxcvbn = new ZxcvbnPhp\Zxcvbn();
$strength = $zxcvbn->passwordStrength($passwd); $strength = $zxcvbn->passwordStrength($passwd);

@ -132,7 +132,6 @@ class password extends rcube_plugin
$this->rc->output->set_pagetitle($this->gettext('changepasswd')); $this->rc->output->set_pagetitle($this->gettext('changepasswd'));
$form_disabled = $this->rc->config->get('password_disabled');
$confirm = $this->rc->config->get('password_confirm_current'); $confirm = $this->rc->config->get('password_confirm_current');
$required_length = intval($this->rc->config->get('password_minimum_length')); $required_length = intval($this->rc->config->get('password_minimum_length'));
$force_save = $this->rc->config->get('password_force_save'); $force_save = $this->rc->config->get('password_force_save');

@ -133,7 +133,6 @@ class zipdownload extends rcube_plugin
// require CSRF protected request // require CSRF protected request
$rcmail->request_security_check(rcube_utils::INPUT_GET); $rcmail->request_security_check(rcube_utils::INPUT_GET);
$imap = $rcmail->get_storage();
$tmpfname = rcube_utils::temp_filename('zipdownload'); $tmpfname = rcube_utils::temp_filename('zipdownload');
$tempfiles = array($tmpfname); $tempfiles = array($tmpfname);
$message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET)); $message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));

@ -475,7 +475,6 @@ class rcmail_install
private function db_read_schema($schemafile) private function db_read_schema($schemafile)
{ {
$lines = file($schemafile); $lines = file($schemafile);
$table_block = false;
$schema = array(); $schema = array();
$keywords = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN'); $keywords = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN');

@ -653,7 +653,7 @@ EOF;
$this->page_headers(); $this->page_headers();
// call super method // call super method
$this->_write($template, $this->config->get('skin_path')); $this->_write($template);
} }
/** /**
@ -864,7 +864,7 @@ EOF;
public function abs_url($str, $search_path = false) public function abs_url($str, $search_path = false)
{ {
if ($str[0] == '/') { if ($str[0] == '/') {
if ($search_path && ($file_url = $this->get_skin_file($str, $skin_path))) { if ($search_path && ($file_url = $this->get_skin_file($str))) {
return $file_url; return $file_url;
} }
@ -967,7 +967,7 @@ EOF;
} }
// add file modification timestamp // add file modification timestamp
if (preg_match('/\.(js|css|less|ico|png|svg|jpeg)$/', $file, $m)) { if (preg_match('/\.(js|css|less|ico|png|svg|jpeg)$/', $file)) {
$file = $this->file_mod($file); $file = $this->file_mod($file);
} }
@ -1578,7 +1578,7 @@ EOF;
// try to find out the button type // try to find out the button type
if ($attrib['type']) { if ($attrib['type']) {
$attrib['type'] = strtolower($attrib['type']); $attrib['type'] = strtolower($attrib['type']);
if ($pos = strpos($attrib['type'], '-menuitem')) { if (strpos($attrib['type'], '-menuitem')) {
$attrib['type'] = substr($attrib['type'], 0, -9); $attrib['type'] = substr($attrib['type'], 0, -9);
$menuitem = true; $menuitem = true;
} }
@ -1832,9 +1832,8 @@ EOF;
* Process template and write to stdOut * Process template and write to stdOut
* *
* @param string $output HTML output * @param string $output HTML output
* @param string $base_path Base for absolute paths
*/ */
protected function _write($output = '', $base_path = '') protected function _write($output = '')
{ {
$output = trim($output); $output = trim($output);

@ -248,7 +248,7 @@ class rcmail_sendmail
else if (preg_match('/[^\x00-\x7F]/', $message->getTXTBody())) { else if (preg_match('/[^\x00-\x7F]/', $message->getTXTBody())) {
$transfer_encoding = $this->rcmail->config->get('force_7bit') ? 'quoted-printable' : '8bit'; $transfer_encoding = $this->rcmail->config->get('force_7bit') ? 'quoted-printable' : '8bit';
} }
else if ($message_charset == 'UTF-8') { else if ($this->options['charset'] == 'UTF-8') {
$text_charset = 'US-ASCII'; $text_charset = 'US-ASCII';
} }
@ -287,9 +287,9 @@ class rcmail_sendmail
// Check if we have enough memory to handle the message in it // Check if we have enough memory to handle the message in it
// It's faster than using files, so we'll do this if we only can // It's faster than using files, so we'll do this if we only can
if (is_array($attachments) && ($mem_limit = parse_bytes(ini_get('memory_limit')))) { if (is_array($attachments)) {
$memory = 0; $memory = 0;
foreach ($attachments as $id => $attachment) { foreach ($attachments as $attachment) {
$memory += $attachment['size']; $memory += $attachment['size'];
} }

@ -260,7 +260,7 @@ abstract class rcube_addressbook
* *
* @return mixed The created record ID on success, False on error * @return mixed The created record ID on success, False on error
*/ */
function insert($save_data, $check=false) function insert($save_data, $check = false)
{ {
/* empty for read-only address books */ /* empty for read-only address books */
} }
@ -273,7 +273,7 @@ abstract class rcube_addressbook
* *
* @return array List of created record IDs * @return array List of created record IDs
*/ */
function insertMultiple($recset, $check=false) function insertMultiple($recset, $check = false)
{ {
$ids = array(); $ids = array();
if (is_object($recset) && is_a($recset, rcube_result_set)) { if (is_object($recset) && is_a($recset, rcube_result_set)) {
@ -282,6 +282,7 @@ abstract class rcube_addressbook
$ids[] = $insert; $ids[] = $insert;
} }
} }
return $ids; return $ids;
} }

@ -294,10 +294,8 @@ class rcube_contacts extends rcube_addressbook
$required = array($required); $required = array($required);
} }
$where = $and_where = $post_search = array(); $where = $post_search = array();
$mode = intval($mode); $mode = intval($mode);
$WS = ' ';
$AS = self::SEPARATOR;
// direct ID search // direct ID search
if ($fields == 'ID' || $fields == $this->primary_key) { if ($fields == 'ID' || $fields == $this->primary_key) {
@ -390,7 +388,7 @@ class rcube_contacts extends rcube_addressbook
if (!empty($required)) { if (!empty($required)) {
foreach ($required as $req) { foreach ($required as $req) {
$hit = false; $hit = false;
foreach ($row as $c => $values) { foreach (array_keys($row) as $c) {
if ($c === $req || strpos($c, $req.':') === 0) { if ($c === $req || strpos($c, $req.':') === 0) {
if ((is_string($row[$c]) && strlen($row[$c])) || !empty($row[$c])) { if ((is_string($row[$c]) && strlen($row[$c])) || !empty($row[$c])) {
$hit = true; $hit = true;

@ -666,7 +666,8 @@ class rcube_html2text
* Callback function for preg_replace_callback use. * Callback function for preg_replace_callback use.
* *
* @param array $matches PREG matches * @param array $matches PREG matches
* @return string *
* @return string Element content
*/ */
public function tags_preg_callback($matches) public function tags_preg_callback($matches)
{ {
@ -686,7 +687,8 @@ class rcube_html2text
* Callback function for preg_replace_callback use in PRE content handler. * Callback function for preg_replace_callback use in PRE content handler.
* *
* @param array $matches PREG matches * @param array $matches PREG matches
* @return string *
* @return string PRE content
*/ */
public function pre_preg_callback($matches) public function pre_preg_callback($matches)
{ {
@ -697,6 +699,7 @@ class rcube_html2text
* Strtoupper function with HTML tags and entities handling. * Strtoupper function with HTML tags and entities handling.
* *
* @param string $str Text to convert * @param string $str Text to convert
*
* @return string Converted text * @return string Converted text
*/ */
private function _toupper($str) private function _toupper($str)
@ -718,6 +721,7 @@ class rcube_html2text
* Strtoupper multibyte wrapper function with HTML entities handling. * Strtoupper multibyte wrapper function with HTML entities handling.
* *
* @param string $str Text to convert * @param string $str Text to convert
*
* @return string Converted text * @return string Converted text
*/ */
private function _strtoupper($str) private function _strtoupper($str)

@ -2706,13 +2706,13 @@ class rcube_imap extends rcube_storage
* *
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function copy_message($uids, $to_mbox, $from_mbox='') public function copy_message($uids, $to_mbox, $from_mbox = '')
{ {
if (!strlen($from_mbox)) { if (!strlen($from_mbox)) {
$from_mbox = $this->folder; $from_mbox = $this->folder;
} }
list($uids, $all_mode) = $this->parse_uids($uids); list($uids, ) = $this->parse_uids($uids);
// exit if no message uids are specified // exit if no message uids are specified
if (empty($uids)) { if (empty($uids)) {
@ -2741,7 +2741,7 @@ class rcube_imap extends rcube_storage
* *
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function delete_message($uids, $folder='') public function delete_message($uids, $folder = '')
{ {
if (!strlen($folder)) { if (!strlen($folder)) {
$folder = $this->folder; $folder = $this->folder;

@ -2653,22 +2653,18 @@ class rcube_imap_generic
*/ */
public static function sortHeaders($messages, $field, $flag) public static function sortHeaders($messages, $field, $flag)
{ {
// Strategy: First, we'll create an "index" array.
// Then, we'll use sort() on that array, and use that to sort the main array.
$field = empty($field) ? 'uid' : strtolower($field); $field = empty($field) ? 'uid' : strtolower($field);
$flag = empty($flag) ? 'ASC' : strtoupper($flag); $order = empty($flag) ? 'ASC' : strtoupper($flag);
$index = array(); $index = array();
$result = array();
reset($messages); reset($messages);
// Create an index
foreach ($messages as $key => $headers) { foreach ($messages as $key => $headers) {
$value = null;
switch ($field) { switch ($field) {
case 'arrival': case 'arrival':
$field = 'internaldate'; $field = 'internaldate';
// no-break
case 'date': case 'date':
case 'internaldate': case 'internaldate':
case 'timestamp': case 'timestamp':
@ -2684,33 +2680,26 @@ class rcube_imap_generic
$value = $headers->$field; $value = $headers->$field;
if (is_string($value)) { if (is_string($value)) {
$value = str_replace('"', '', $value); $value = str_replace('"', '', $value);
if ($field == 'subject') { if ($field == 'subject') {
$value = preg_replace('/^(Re:\s*|Fwd:\s*|Fw:\s*)+/i', '', $value); $value = preg_replace('/^(Re:\s*|Fwd:\s*|Fw:\s*)+/i', '', $value);
} }
$data = strtoupper($value);
} }
} }
$index[$key] = $value; $index[$key] = $value;
} }
if (!empty($index)) { $sort_order = $flag == 'ASC' ? SORT_ASC : SORT_DESC;
// sort index $sort_flags = SORT_STRING | SORT_FLAG_CASE;
if ($flag == 'ASC') {
asort($index);
}
else {
arsort($index);
}
// form new array based on index if (in_array($field, array('arrival', 'date', 'internaldate', 'timestamp'))) {
foreach ($index as $key => $val) { $sort_flags = SORT_NUMERIC;
$result[$key] = $messages[$key];
}
} }
return $result; array_multisort($index, $sort_order, $sort_flags, $messages);
return $messages;
} }
/** /**

@ -655,10 +655,11 @@ class rcube_ldap extends rcube_addressbook
/** /**
* Fetch members of the given group entry from server * Fetch members of the given group entry from server
* *
* @param string Group DN * @param string $dn Group DN
* @param array Group entry * @param array $entry Group entry
* @param string Member attribute to use * @param string $attr Member attribute to use
* @param boolean Count only * @param bool $count Count only
*
* @return array Accumulated group members * @return array Accumulated group members
*/ */
private function _list_group_members($dn, $entry, $attr, $count) private function _list_group_members($dn, $entry, $attr, $count)
@ -699,16 +700,17 @@ class rcube_ldap extends rcube_addressbook
/** /**
* List members of group class groupOfUrls * List members of group class groupOfUrls
* *
* @param string Group DN * @param string $dn Group DN
* @param array Group entry * @param array $entry Group entry
* @param boolean True if only used for counting * @param boo $count True if only used for counting
*
* @return array Accumulated group members * @return array Accumulated group members
*/ */
private function _list_group_memberurl($dn, $entry, $count) private function _list_group_memberurl($dn, $entry, $count)
{ {
$group_members = array(); $group_members = array();
for ($i=0; $i < $entry['memberurl']['count']; $i++) { for ($i = 0; $i < $entry['memberurl']['count']; $i++) {
// extract components from url // extract components from url
if (!preg_match('!ldap://[^/]*/([^\?]+)\?\?(\w+)\?(.*)$!', $entry['memberurl'][$i], $m)) { if (!preg_match('!ldap://[^/]*/([^\?]+)\?\?(\w+)\?(.*)$!', $entry['memberurl'][$i], $m)) {
continue; continue;
@ -717,16 +719,19 @@ class rcube_ldap extends rcube_addressbook
// add search filter if any // add search filter if any
$filter = $this->filter ? '(&(' . $m[3] . ')(' . $this->filter . '))' : $m[3]; $filter = $this->filter ? '(&(' . $m[3] . ')(' . $this->filter . '))' : $m[3];
$attrs = $count ? array('dn','objectClass') : $this->prop['list_attributes']; $attrs = $count ? array('dn','objectClass') : $this->prop['list_attributes'];
if ($result = $this->ldap->search($m[1], $filter, $m[2], $attrs, $this->group_data)) { if ($result = $this->ldap->search($m[1], $filter, $m[2], $attrs, $this->group_data)) {
$entries = $result->entries(); $entries = $result->entries();
for ($j = 0; $j < $entries['count']; $j++) { for ($j = 0; $j < $entries['count']; $j++) {
if ($this->is_group_entry($entries[$j]) && ($nested_group_members = $this->list_group_members($entries[$j]['dn'], $count))) if ($this->is_group_entry($entries[$j]) && ($nested_group_members = $this->list_group_members($entries[$j]['dn'], $count))) {
$group_members = array_merge($group_members, $nested_group_members); $group_members = array_merge($group_members, $nested_group_members);
else }
else {
$group_members[] = $entries[$j]; $group_members[] = $entries[$j];
} }
} }
} }
}
return $group_members; return $group_members;
} }
@ -751,7 +756,7 @@ class rcube_ldap extends rcube_addressbook
* *
* @return rcube_result_set List of contact records * @return rcube_result_set List of contact records
*/ */
function search($fields, $value, $mode=0, $select=true, $nocount=false, $required=array()) function search($fields, $value, $mode = 0, $select = true, $nocount = false, $required = array())
{ {
$mode = intval($mode); $mode = intval($mode);
@ -925,7 +930,6 @@ class rcube_ldap extends rcube_addressbook
$prop = $this->group_id ? $this->group_data : $this->prop; $prop = $this->group_id ? $this->group_data : $this->prop;
$base_dn = $this->group_id ? $prop['base_dn'] : $this->base_dn; $base_dn = $this->group_id ? $prop['base_dn'] : $this->base_dn;
$attrs = $count ? array('dn') : $this->prop['attributes']; $attrs = $count ? array('dn') : $this->prop['attributes'];
$entries = array();
// Use global search filter // Use global search filter
if ($filter = $this->filter) { if ($filter = $this->filter) {

@ -210,7 +210,7 @@ class rcube_message
* Get content of a specific part of this message * Get content of a specific part of this message
* *
* @param string $mime_id Part ID * @param string $mime_id Part ID
* @param boolean $formatted Enables formatting of text/* parts bodies * @param bool $formatted Enables formatting of text/* parts bodies
* @param int $max_bytes Only return/read this number of bytes * @param int $max_bytes Only return/read this number of bytes
* @param mixed $mode NULL to return a string, -1 to print body * @param mixed $mode NULL to return a string, -1 to print body
* or file pointer to save the body into * or file pointer to save the body into
@ -1099,7 +1099,7 @@ class rcube_message
// check parents' charset // check parents' charset
$items = explode('.', $part->mime_id); $items = explode('.', $part->mime_id);
for ($i = count($items)-1; $i > 0; $i--) { for ($i = count($items)-1; $i > 0; $i--) {
$last = array_pop($items); array_pop($items);
$parent = $this->mime_parts[implode('.', $items)]; $parent = $this->mime_parts[implode('.', $items)];
if ($parent && $parent->charset) { if ($parent && $parent->charset) {

@ -375,8 +375,6 @@ class rcube_mime_decode
$struct->charset = $part->ctype_parameters['charset']; $struct->charset = $part->ctype_parameters['charset'];
} }
$part_charset = $struct->charset ?: $this->params['default_charset'];
// determine filename // determine filename
if (($filename = $part->d_parameters['filename']) || ($filename = $part->ctype_parameters['name'])) { if (($filename = $part->d_parameters['filename']) || ($filename = $part->ctype_parameters['name'])) {
if (!$this->params['decode_headers']) { if (!$this->params['decode_headers']) {

@ -290,6 +290,7 @@ class rcube_result_index
return $idx; return $idx;
} }
return true; return true;
} }

@ -166,7 +166,13 @@ class rcube_result_multifolder
$msgid .= '-' . $this->folder; $msgid .= '-' . $this->folder;
} }
return array_search($msgid, $this->index); $idx = array_search($msgid, $this->index);
if ($get_index) {
return $idx;
}
return $idx !== false;
} }
/** /**

@ -503,7 +503,9 @@ class rcube_user
*/ */
function failed_login() function failed_login()
{ {
if ($this->ID && ($rate = (int) $this->rc->config->get('login_rate_limit', 3))) { if ($this->ID && $this->rc->config->get('login_rate_limit', 3)) {
$counter = 0;
if (empty($this->data['failed_login'])) { if (empty($this->data['failed_login'])) {
$failed_login = new DateTime('now'); $failed_login = new DateTime('now');
$counter = 1; $counter = 1;

@ -81,8 +81,6 @@ function rcmail_contact_details($attrib)
return false; return false;
} }
$i_size = $attrib['size'] ?: 40;
$form = array( $form = array(
'contact' => array( 'contact' => array(
'name' => $RCMAIL->gettext('properties'), 'name' => $RCMAIL->gettext('properties'),

@ -184,7 +184,6 @@ function rcmail_contact_record_groups($contact_id)
'noclose' => true, 'noclose' => true,
); );
$list = array();
$members = $CONTACTS->get_record_groups($contact_id); $members = $CONTACTS->get_record_groups($contact_id);
$table = new html_table(array('tagname' => 'ul', 'cols' => 1, 'class' => 'proplist simplelist')); $table = new html_table(array('tagname' => 'ul', 'cols' => 1, 'class' => 'proplist simplelist'));
$checkbox = new html_checkbox(array('name' => '_gid[]', $checkbox = new html_checkbox(array('name' => '_gid[]',

@ -1205,7 +1205,6 @@ function rcmail_washtml_link_callback($tag, $attribs, $content, $washtml)
'c' => $washtml->get_config('container_id'), 'c' => $washtml->get_config('container_id'),
'p' => $washtml->get_config('css_prefix'), 'p' => $washtml->get_config('css_prefix'),
)); ));
$end = ' />';
$content = null; $content = null;
} }
else if (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) { else if (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) {

@ -125,7 +125,6 @@ function rcmail_zip_extract($path)
return; return;
} }
$rcmail = rcmail::get_instance();
$zip = new ZipArchive; $zip = new ZipArchive;
$files = array(); $files = array();
@ -136,7 +135,7 @@ function rcmail_zip_extract($path)
if (copy("zip://$path#$entry", $tmpfname)) { if (copy("zip://$path#$entry", $tmpfname)) {
$ctype = rcube_mime::file_content_type($tmpfname, $entry); $ctype = rcube_mime::file_content_type($tmpfname, $entry);
list($mtype_primary, $mtype_secondary) = explode('/', $ctype); list($mtype_primary, ) = explode('/', $ctype);
if (in_array($mtype_primary, array('text', 'message'))) { if (in_array($mtype_primary, array('text', 'message'))) {
$files[] = $tmpfname; $files[] = $tmpfname;

@ -29,7 +29,6 @@ $sources = array();
if ($_POST['_from'] != 'show') { if ($_POST['_from'] != 'show') {
$old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL'); $old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
$old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
} }
// move messages // move messages

Loading…
Cancel
Save