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';
private $archive_folder;
private $folders;
/**
* Plugin initialization.
*/
function init()
{
$rcmail = rcmail::get_instance();
@ -22,9 +28,9 @@ class archive extends rcube_plugin
// register special folder type
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_script('archive.js');
$this->add_texts('localization', true);
@ -47,7 +53,7 @@ class archive extends rcube_plugin
$this->add_hook('render_mailboxlist', array($this, 'render_mailboxlist'));
// 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',''));
}
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_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_script('archive.js');
// 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)
{
$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
if ($archive_folder && !$show_real_name) {
if (isset($p['list'][$archive_folder])) {
$p['list'][$archive_folder]['name'] = $this->gettext('archivefolder');
if ($this->archive_folder && !rcmail::get_instance()->config->get('show_real_foldernames')) {
if (isset($p['list'][$this->archive_folder])) {
$p['list'][$this->archive_folder]['name'] = $this->gettext('archivefolder');
}
else {
// 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();
$read_on_move = (bool) $rcmail->config->get('read_on_archive');
$archive_type = $rcmail->config->get('archive_type', '');
$archive_folder = $rcmail->config->get('archive_mbox');
$archive_prefix = $archive_folder . $delimiter;
$archive_prefix = $this->archive_folder . $delimiter;
$search_request = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC);
// count messages before changing anything
if ($_POST['_from'] != 'show') {
$threading = (bool) $storage->get_threading();
$old_count = $storage->count(null, $threading ? 'THREADS' : 'ALL');
$old_pages = ceil($old_count / $storage->get_pagesize());
}
$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) {
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);
continue;
}
else if (!$archive_type || $archive_type == 'folder') {
$folder = $archive_folder;
$folder = $this->archive_folder;
if ($archive_type == 'folder') {
// compose full folder path
@ -202,7 +202,7 @@ class archive extends rcube_plugin
}
// compose full folder path
$folder = $archive_folder . ($subfolder ? $delimiter . $subfolder : '');
$folder = $this->archive_folder . ($subfolder ? $delimiter . $subfolder : '');
$execute[$folder][] = $message->uid;
}
@ -348,7 +348,7 @@ class archive extends rcube_plugin
$delimiter = $storage->get_hierarchy_delimiter();
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)) {

@ -38,8 +38,8 @@ class runlog {
$this->parent_stack[] = $name;
$this->print_to_console("start: ".$name, $tag, 'start');
$this->print_to_file("start: ".$name, $tag, 'start');
$this->print_to_console("start: ".$name, $tag);
$this->print_to_file("start: ".$name, $tag);
$this->indent++;
}
@ -72,8 +72,8 @@ class runlog {
$tag_report .= "$tag: $count, ";
}
$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_file($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']);
}
}
@ -137,7 +137,7 @@ class runlog {
$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) {
$file_handle_tag = 'master';

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

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

@ -1253,7 +1253,6 @@ class enigma_ui
$uid = rcube_utils::get_input_value('_uid', 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);
$storage = $this->rc->get_storage();
$engine = $this->enigma->load_engine();
if ($uid && $mime_id) {

@ -72,7 +72,6 @@ class filesystem_attachments extends rcube_plugin
{
$args['status'] = false;
$group = $args['group'];
$rcmail = rcube::get_instance();
// use common temp dir for file uploads
$tmpfname = rcube_utils::temp_filename('attmnt');
@ -199,7 +198,7 @@ class filesystem_attachments extends rcube_plugin
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])) {
return true;
}

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

@ -1564,7 +1564,7 @@ class rcube_sieve_engine
}
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)'));
foreach (array('allof', 'anyof', 'any') as $val) {

@ -200,17 +200,11 @@ class rcube_sieve_forward extends rcube_sieve_engine
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);
$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);
$forward_action['type'] = 'forward';
$forward_action['reason'] = $this->strip_value(str_replace("\r\n", "\n", $reason));
$forward_action['subject'] = trim($subject);
$forward_action['from'] = trim($from);
$date_extension = in_array('date', $this->exts);
$forward_tests = (array) $this->forward['tests'];
if ($action == 'redirect' || $action == 'copy') {
@ -230,7 +224,7 @@ class rcube_sieve_forward extends rcube_sieve_engine
$rule['disabled'] = $status == 'off';
$rule['tests'] = $forward_tests;
$rule['join'] = $date_extension ? count($forward_tests) > 1 : false;
$rule['actions'] = array($forward_action);
$rule['actions'] = array();
$rule['after'] = $after;
if ($action && $action != 'keep') {
@ -455,7 +449,7 @@ class rcube_sieve_forward extends rcube_sieve_engine
$this->init_script();
$this->forward_rule();
$forward['type'] = 'forward';
$date_extension = in_array('date', $this->exts);
if ($data['action'] == 'redirect' || $data['action'] == 'copy') {
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['tests'] = $forward_tests;
$rule['join'] = $date_extension ? count($forward_tests) > 1 : false;
$rule['actions'] = array($forward);
$rule['actions'] = array();
if ($data['action'] && $data['action'] != 'keep') {
$rule['actions'][] = array(

@ -591,6 +591,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine
public static function vacation_interval(&$vacation)
{
$rcube = rcube::get_instance();
$seconds_extension = in_array('vacation-seconds', $this->exts);
if (isset($vacation['seconds'])) {
$interval = $vacation['seconds'];
@ -722,7 +723,6 @@ class rcube_sieve_vacation extends rcube_sieve_engine
// check supported extensions
$date_extension = in_array('date', $this->exts);
$regex_extension = in_array('regex', $this->exts);
$seconds_extension = in_array('vacation-seconds', $this->exts);
// set user's timezone
try {
@ -754,8 +754,8 @@ class rcube_sieve_vacation extends rcube_sieve_engine
else if ($regex_extension) {
// Sieve 'date' extension not available, read start/end from RegEx based rules instead
if ($date_tests = self::parse_regexp_tests($this->vacation['tests'])) {
$from = new DateTime($date_tests['from'] . ' ' . '00:00:00', $timezone);
$to = new DateTime($date_tests['to'] . ' ' . '23:59:59', $timezone);
$start = new DateTime($date_tests['from'] . ' ' . '00:00:00', $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
$date_extension = in_array('date', $this->exts);
$regex_extension = in_array('regex', $this->exts);
$seconds_extension = in_array('vacation-seconds', $this->exts);
$vacation['type'] = 'vacation';
$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>
* @package HTTPSocket
* @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';
/* all vars are private except $error, $query_cache, and $doFollowLocationHeader */
// all vars are private except $error, $query_cache, and $doFollowLocationHeader
var $method = 'GET';
@ -123,18 +104,14 @@ class HTTPSocket {
var $result_status_code;
var $lastTransferSpeed;
var $bind_host;
var $error = array();
var $warn = array();
var $query_cache = array();
var $doFollowLocationHeader = TRUE;
var $doFollowLocationHeader = true;
var $redirectURL;
var $max_redirects = 5;
var $ssl_setting_message = 'DirectAdmin appears to be using SSL. Change your script to connect to ssl://';
var $extra_headers = array();
/**
@ -143,8 +120,7 @@ class HTTPSocket {
*/
function connect($host, $port = '')
{
if (!is_numeric($port))
{
if (!is_numeric($port)) {
$port = 2222;
}
@ -154,8 +130,7 @@ class HTTPSocket {
function bind($ip = '')
{
if ( $ip == '' )
{
if ($ip == '') {
$ip = $_SERVER['SERVER_ADDR'];
}
@ -180,13 +155,11 @@ class HTTPSocket {
*/
function set_login($uname = '', $passwd = '')
{
if ( strlen($uname) > 0 )
{
if (strlen($uname) > 0) {
$this->remote_uname = $uname;
}
if ( strlen($passwd) > 0 )
{
if (strlen($passwd) > 0) {
$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|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->result_status_code = NULL;
$this->result_status_code = null;
$is_ssl = FALSE;
$is_ssl = false;
// 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);
if (preg_match('!^https://!i',$request))
{
if (preg_match('!^https://!i',$request)) {
$this->connect('https://'.$location['host'],$location['port']);
}
else
else {
$this->connect('http://'.$location['host'],$location['port']);
}
$this->set_login($location['user'],$location['pass']);
$request = $location['path'];
$content = $location['query'];
if ( strlen($request) < 1 )
{
if (strlen($request) < 1) {
$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);
}
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);
}
if (preg_match('!^https://!i', $this->remote_host))
$is_ssl = TRUE;
if (preg_match('!^https://!i', $this->remote_host)) {
$is_ssl = true;
}
$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' => '*/*',
'Connection' => 'Close' );
foreach ( $this->extra_headers as $key => $value )
{
foreach ($this->extra_headers as $key => $value) {
$array_headers[$key] = $value;
}
$this->result = $this->result_header = $this->result_body = '';
// was content sent as an array? if so, turn it into a string
if (is_array($content))
{
if (is_array($content)) {
$pairs = array();
foreach ( $content as $key => $value )
{
foreach ($content as $key => $value) {
$pairs[] = "$key=".urlencode($value);
}
@ -264,15 +233,15 @@ class HTTPSocket {
unset($pairs);
}
$OK = TRUE;
$OK = true;
if ($this->method == 'GET')
if ($this->method == 'GET') {
$request .= '?'.$content;
}
$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_VERIFYHOST, false); //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_TIME, 120);
//if ($this->doFollowLocationHeader)
//{
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
// curl_setopt($ch, CURLOPT_MAXREDIRS, $this->max_redirects);
//}
// instance connection
if ($this->bind_host)
{
if ($this->bind_host) {
curl_setopt($ch, CURLOPT_INTERFACE, $this->bind_host);
}
// 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);
}
// 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']}";
}
// 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_POSTFIELDS, $content);
@ -325,18 +284,15 @@ class HTTPSocket {
curl_setopt($ch, CURLOPT_HTTPHEADER, $array_headers);
if( !($this->result = curl_exec($ch)) )
{
if(!($this->result = curl_exec($ch))) {
$this->error[] .= curl_error($ch);
$OK = FALSE;
$OK = false;
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$this->result_header = substr($this->result, 0, $header_size);
$this->result_body = substr($this->result, $header_size);
$this->result_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$this->lastTransferSpeed = curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD) / 1024;
curl_close($ch);
@ -346,29 +302,27 @@ class HTTPSocket {
$headers = $this->fetch_header();
// 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;
}
// 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
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);
}
if (isset($headers['location']))
{
if ($this->max_redirects <= 0)
if (isset($headers['location'])) {
if ($this->max_redirects <= 0) {
die("Too many redirects on: ".$headers['location']);
}
$this->max_redirects--;
$this->redirectURL = $headers['location'];
$this->query($headers['location']);
}
}
}
function getTransferSpeed()
@ -383,21 +337,19 @@ class HTTPSocket {
* @param boolean return as array? (like PHP's file() command)
* @return string result body
*/
function get($location, $asArray = FALSE )
function get($location, $asArray = false)
{
$this->query($location);
if ( $this->get_status_code() == 200 )
{
if ($asArray)
{
if ($this->get_status_code() == 200) {
if ($asArray) {
return preg_split("/\n/",$this->fetch_body());
}
return $this->fetch_body();
}
return FALSE;
return false;
}
/**
@ -456,15 +408,13 @@ class HTTPSocket {
$array_return = array(0 => $array_headers[0]);
unset($array_headers[0]);
foreach ( $array_headers as $pair )
{
foreach ($array_headers as $pair) {
if ($pair == '' || $pair == "\r\n") continue;
list($key,$value) = preg_split("/: /",$pair,2);
$array_return[strtolower($key)] = $value;
}
if ( $header != '' )
{
if ($header != '') {
return $array_return[strtolower($header)];
}

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

@ -51,7 +51,7 @@ class rcube_gearman_password
'code' => 600,
'type' => 'php',
'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);
}
}

@ -85,7 +85,7 @@ class rcube_ldap_simple_password
$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)) {
$this->_debug("S: ".ldap_error($this->conn));

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

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

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

@ -133,7 +133,6 @@ class zipdownload extends rcube_plugin
// require CSRF protected request
$rcmail->request_security_check(rcube_utils::INPUT_GET);
$imap = $rcmail->get_storage();
$tmpfname = rcube_utils::temp_filename('zipdownload');
$tempfiles = array($tmpfname);
$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)
{
$lines = file($schemafile);
$table_block = false;
$schema = array();
$keywords = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN');

@ -653,7 +653,7 @@ EOF;
$this->page_headers();
// 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)
{
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;
}
@ -967,7 +967,7 @@ EOF;
}
// 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);
}
@ -1578,7 +1578,7 @@ EOF;
// try to find out the button type
if ($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);
$menuitem = true;
}
@ -1832,9 +1832,8 @@ EOF;
* Process template and write to stdOut
*
* @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);

@ -248,7 +248,7 @@ class rcmail_sendmail
else if (preg_match('/[^\x00-\x7F]/', $message->getTXTBody())) {
$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';
}
@ -287,9 +287,9 @@ class rcmail_sendmail
// 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
if (is_array($attachments) && ($mem_limit = parse_bytes(ini_get('memory_limit')))) {
if (is_array($attachments)) {
$memory = 0;
foreach ($attachments as $id => $attachment) {
foreach ($attachments as $attachment) {
$memory += $attachment['size'];
}

@ -282,6 +282,7 @@ abstract class rcube_addressbook
$ids[] = $insert;
}
}
return $ids;
}

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

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

@ -2712,7 +2712,7 @@ class rcube_imap extends rcube_storage
$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
if (empty($uids)) {

@ -2653,22 +2653,18 @@ class rcube_imap_generic
*/
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);
$flag = empty($flag) ? 'ASC' : strtoupper($flag);
$order = empty($flag) ? 'ASC' : strtoupper($flag);
$index = array();
$result = array();
reset($messages);
// Create an index
foreach ($messages as $key => $headers) {
$value = null;
switch ($field) {
case 'arrival':
$field = 'internaldate';
// no-break
case 'date':
case 'internaldate':
case 'timestamp':
@ -2684,33 +2680,26 @@ class rcube_imap_generic
$value = $headers->$field;
if (is_string($value)) {
$value = str_replace('"', '', $value);
if ($field == 'subject') {
$value = preg_replace('/^(Re:\s*|Fwd:\s*|Fw:\s*)+/i', '', $value);
}
$data = strtoupper($value);
}
}
$index[$key] = $value;
}
if (!empty($index)) {
// sort index
if ($flag == 'ASC') {
asort($index);
}
else {
arsort($index);
}
$sort_order = $flag == 'ASC' ? SORT_ASC : SORT_DESC;
$sort_flags = SORT_STRING | SORT_FLAG_CASE;
// form new array based on index
foreach ($index as $key => $val) {
$result[$key] = $messages[$key];
}
if (in_array($field, array('arrival', 'date', 'internaldate', 'timestamp'))) {
$sort_flags = SORT_NUMERIC;
}
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
*
* @param string Group DN
* @param array Group entry
* @param string Member attribute to use
* @param boolean Count only
* @param string $dn Group DN
* @param array $entry Group entry
* @param string $attr Member attribute to use
* @param bool $count Count only
*
* @return array Accumulated group members
*/
private function _list_group_members($dn, $entry, $attr, $count)
@ -699,9 +700,10 @@ class rcube_ldap extends rcube_addressbook
/**
* List members of group class groupOfUrls
*
* @param string Group DN
* @param array Group entry
* @param boolean True if only used for counting
* @param string $dn Group DN
* @param array $entry Group entry
* @param boo $count True if only used for counting
*
* @return array Accumulated group members
*/
private function _list_group_memberurl($dn, $entry, $count)
@ -717,16 +719,19 @@ class rcube_ldap extends rcube_addressbook
// add search filter if any
$filter = $this->filter ? '(&(' . $m[3] . ')(' . $this->filter . '))' : $m[3];
$attrs = $count ? array('dn','objectClass') : $this->prop['list_attributes'];
if ($result = $this->ldap->search($m[1], $filter, $m[2], $attrs, $this->group_data)) {
$entries = $result->entries();
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);
else
}
else {
$group_members[] = $entries[$j];
}
}
}
}
return $group_members;
}
@ -925,7 +930,6 @@ class rcube_ldap extends rcube_addressbook
$prop = $this->group_id ? $this->group_data : $this->prop;
$base_dn = $this->group_id ? $prop['base_dn'] : $this->base_dn;
$attrs = $count ? array('dn') : $this->prop['attributes'];
$entries = array();
// Use global search filter
if ($filter = $this->filter) {

@ -210,7 +210,7 @@ class rcube_message
* Get content of a specific part of this message
*
* @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 mixed $mode NULL to return a string, -1 to print body
* or file pointer to save the body into
@ -1099,7 +1099,7 @@ class rcube_message
// check parents' charset
$items = explode('.', $part->mime_id);
for ($i = count($items)-1; $i > 0; $i--) {
$last = array_pop($items);
array_pop($items);
$parent = $this->mime_parts[implode('.', $items)];
if ($parent && $parent->charset) {

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

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

@ -166,7 +166,13 @@ class rcube_result_multifolder
$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()
{
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'])) {
$failed_login = new DateTime('now');
$counter = 1;

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

@ -184,7 +184,6 @@ function rcmail_contact_record_groups($contact_id)
'noclose' => true,
);
$list = array();
$members = $CONTACTS->get_record_groups($contact_id);
$table = new html_table(array('tagname' => 'ul', 'cols' => 1, 'class' => 'proplist simplelist'));
$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'),
'p' => $washtml->get_config('css_prefix'),
));
$end = ' />';
$content = null;
}
else if (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) {

@ -125,7 +125,6 @@ function rcmail_zip_extract($path)
return;
}
$rcmail = rcmail::get_instance();
$zip = new ZipArchive;
$files = array();
@ -136,7 +135,7 @@ function rcmail_zip_extract($path)
if (copy("zip://$path#$entry", $tmpfname)) {
$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'))) {
$files[] = $tmpfname;

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

Loading…
Cancel
Save