diff --git a/.github/config-test.inc.php b/.github/config-test.inc.php index 674ea5f0e8f..642308f0893 100644 --- a/.github/config-test.inc.php +++ b/.github/config-test.inc.php @@ -24,7 +24,7 @@ 'archive', 'attachment_reminder', 'markasjunk', - 'zipdownload' + 'zipdownload', ]; $config['archive_mbox'] = 'Archive'; diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 098eab4651e..76e630684ef 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,8 +2,10 @@ $finder = PhpCsFixer\Finder::create() ->in([__DIR__]) + ->exclude(['vendor']) + ->ignoreDotFiles(false) ->name('*.php.dist') - ->exclude(['vendor']); + ->name('*.dist.php'); return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) @@ -69,51 +71,35 @@ // TODO 'align_multiline_comment' => false, 'array_indentation' => false, - 'array_syntax' => false, 'backtick_to_shell_exec' => false, - 'binary_operator_spaces' => false, + 'binary_operator_spaces' => ['default' => 'at_least_single_space'], 'blank_line_before_statement' => false, 'class_attributes_separation' => false, 'class_definition' => false, 'class_reference_name_casing' => false, 'class_reference_name_casing' => false, - 'concat_space' => false, 'constant_case' => false, 'control_structure_continuation_position' => false, - 'elseif' => false, 'empty_loop_condition' => false, 'explicit_indirect_variable' => false, 'explicit_string_variable' => false, - 'function_declaration' => false, 'general_phpdoc_annotation_remove' => false, 'heredoc_indentation' => false, 'increment_style' => false, - 'integer_literal_case' => false, - 'list_syntax' => false, 'method_argument_space' => false, - 'method_chaining_indentation' => false, 'modernize_types_casting' => false, 'native_constant_invocation' => false, - 'native_type_declaration_casing' => false, 'new_with_parentheses' => false, - 'no_alias_language_construct_call' => false, 'no_blank_lines_after_phpdoc' => false, 'no_break_comment' => false, 'no_empty_statement' => false, 'no_extra_blank_lines' => false, 'no_null_property_initialization' => false, 'no_unneeded_control_parentheses' => false, - 'no_useless_concat_operator' => false, - 'operator_linebreak' => false, 'php_unit_method_casing' => false, 'phpdoc_annotation_without_dot' => false, - 'phpdoc_no_package' => false, - 'phpdoc_separation' => false, 'phpdoc_summary' => false, 'phpdoc_to_comment' => false, - 'phpdoc_trim' => false, - 'phpdoc_types_order' => false, - 'phpdoc_var_without_name' => false, 'single_line_comment_spacing' => false, 'single_quote' => false, 'single_trait_insert_per_statement' => false, diff --git a/index.php b/index.php index fa37bbde56f..4505551849d 100644 --- a/index.php +++ b/index.php @@ -64,7 +64,7 @@ if (empty($_SESSION['user_id']) && ($force_https = $RCMAIL->config->get('force_https', false))) { // force_https can be true, , :, if (!is_bool($force_https)) { - list($host, $port) = explode(':', $force_https); + [$host, $port] = explode(':', $force_https); if (is_numeric($host) && empty($port)) { $port = $host; @@ -194,14 +194,14 @@ } // end session -else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id'])) { +elseif ($RCMAIL->task == 'logout' && isset($_SESSION['user_id'])) { $RCMAIL->request_security_check(rcube_utils::INPUT_GET | rcube_utils::INPUT_POST); - $userdata = array( + $userdata = [ 'user' => $_SESSION['username'], 'host' => $_SESSION['storage_host'], 'lang' => $RCMAIL->user->language, - ); + ]; $RCMAIL->output->show_message('loggedout'); @@ -211,7 +211,7 @@ } // check session and auth cookie -else if ($RCMAIL->task != 'login' && $_SESSION['user_id']) { +elseif ($RCMAIL->task != 'login' && $_SESSION['user_id']) { if (!$RCMAIL->session->check_auth()) { $RCMAIL->kill_session(); $session_error = 'sessionerror'; @@ -236,7 +236,7 @@ // check if installer is still active if ($RCMAIL->config->get('enable_installer') && is_readable('./installer/index.php')) { $RCMAIL->output->add_footer(html::div(['id' => 'login-addon', 'style' => "background:#ef9398; border:2px solid #dc5757; padding:0.5em; margin:2em auto; width:50em"], - html::tag('h2', array('style' => "margin-top:0.2em"), "Installer script is still accessible") . + html::tag('h2', ['style' => "margin-top:0.2em"], "Installer script is still accessible") . html::p(null, "The install script of your Roundcube installation is still stored in its default location!") . html::p(null, "Please remove the whole installer folder from the Roundcube directory because these files may expose sensitive configuration data like server passwords and encryption keys diff --git a/installer/check.php b/installer/check.php index 2aaa22899b2..ae1bfc958b9 100644 --- a/installer/check.php +++ b/installer/check.php @@ -15,7 +15,7 @@ */ if (!class_exists('rcmail_install', false) || !isset($RCI)) { - die("Not allowed! Please open installer/index.php instead."); + exit("Not allowed! Please open installer/index.php instead."); } $required_php_exts = [ @@ -220,7 +220,7 @@ $RCI->pass($var); } } - else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) { + elseif (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) { $RCI->pass($var); } else { @@ -260,7 +260,7 @@ $RCI->pass($var); } } - else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) { + elseif (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) { $RCI->pass($var); } else { diff --git a/installer/config.php b/installer/config.php index 83fde1428a2..5dd5a6fa9f9 100644 --- a/installer/config.php +++ b/installer/config.php @@ -15,7 +15,7 @@ */ if (!class_exists('rcmail_install', false) || !isset($RCI)) { - die("Not allowed! Please open installer/index.php instead."); + exit("Not allowed! Please open installer/index.php instead."); } // allow the current user to get to the next step @@ -26,7 +26,7 @@ if ($RCI->save_configfile($_SESSION['config'])) { echo '

The config file was saved successfully into' - . ' '.RCMAIL_CONFIG_DIR.' directory of your Roundcube installation.'; + . ' ' . RCMAIL_CONFIG_DIR . ' directory of your Roundcube installation.'; if ($RCI->legacy_config) { echo '

Afterwards, please remove the old configuration files' @@ -47,7 +47,7 @@ } echo '

Copy or download the following configuration and save it'; - echo ' as config.inc.php within the '.RCUBE_CONFIG_DIR.' directory of your Roundcube installation.
'; + echo ' as config.inc.php within the ' . RCUBE_CONFIG_DIR . ' directory of your Roundcube installation.
'; echo ' Make sure that there are no characters before the <?php bracket when saving the file.'; echo ' '; echo $save_button; @@ -131,7 +131,7 @@ '_ip_check', 'id' => 'cfgipcheck']); -echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)); +echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), ['value' => 1]); ?>
@@ -326,7 +326,7 @@ $i = 0; foreach ($default_hosts as $host) { - echo '

' . $text_imaphost->show($host); + echo '
' . $text_imaphost->show($host); if ($i++ > 0) { echo 'remove'; } @@ -626,11 +626,11 @@ list_plugins(); foreach ($plugins as $p) { - $p_check = new html_checkbox(['name' => '_plugins_'.$p['name'], 'id' => 'cfgplugin_'.$p['name'], 'value' => $p['name']]); + $p_check = new html_checkbox(['name' => '_plugins_' . $p['name'], 'id' => 'cfgplugin_' . $p['name'], 'value' => $p['name']]); echo '
'; - echo '
'; + echo '
'; } ?> diff --git a/installer/index.php b/installer/index.php index df68279c261..83c311fca61 100644 --- a/installer/index.php +++ b/installer/index.php @@ -38,7 +38,7 @@ ini_set('display_errors', 1); -define('INSTALL_PATH', realpath(__DIR__ . '/../').'/'); +define('INSTALL_PATH', realpath(__DIR__ . '/../') . '/'); require INSTALL_PATH . 'program/include/iniset.php'; @@ -60,13 +60,13 @@ if (!empty($_SESSION['config'])) { header('Content-type: text/plain'); - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); echo $_SESSION['config']; exit; } http_response_code(404); - die("The requested configuration was not found. Please run the installer from the beginning."); + exit("The requested configuration was not found. Please run the installer from the beginning."); } if ( @@ -77,7 +77,7 @@ $filename = 'config.inc.php'; header('Content-type: text/plain'); - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); $RCI->merge_config(); echo $RCI->create_config(); @@ -151,8 +151,8 @@ foreach (['Check environment', 'Create config', 'Test config'] as $i => $item) { $j = $i + 1; - $link = ($RCI->step >= $j || $RCI->configured) ? '' . rcube::Q($item) . '' : rcube::Q($item); - printf('
  • %s
  • ', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link); + $link = ($RCI->step >= $j || $RCI->configured) ? '' . rcube::Q($item) . '' : rcube::Q($item); + printf('
  • %s
  • ', $j + 1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link); } ?> diff --git a/installer/test.php b/installer/test.php index 5f07e324abd..68fdb016d0c 100644 --- a/installer/test.php +++ b/installer/test.php @@ -14,7 +14,7 @@ */ if (!class_exists('rcmail_install', false) || !isset($RCI)) { - die("Not allowed! Please open installer/index.php instead."); + exit("Not allowed! Please open installer/index.php instead."); } ?> @@ -160,7 +160,7 @@ Make sure that the configured database exists and that the user as write privileges

    '; } } -else if ($db_working && !empty($_POST['updatedb'])) { +elseif ($db_working && !empty($_POST['updatedb'])) { if (!$RCI->update_db($_POST['version'])) { echo '

    Database schema update failed.

    '; } @@ -177,7 +177,7 @@ $db_working = false; } - else if ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { + elseif ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { $RCI->fail('DB Schema', "Database schema differs"); echo '
    • ' . implode("
    • \n
    • ", $err) . "
    "; @@ -208,7 +208,7 @@ // write test $insert_id = md5(uniqid()); $db_write = $DB->query("INSERT INTO " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session') - . " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id); + . " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, " . $DB->now() . ", '127.0.0.1', 'foo')", $insert_id); if ($db_write) { $RCI->pass('DB Write'); diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index fae5e575039..c6298dcb848 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -63,10 +63,10 @@ function acl_actions() if ($action == 'save') { $this->action_save(); } - else if ($action == 'delete') { + elseif ($action == 'delete') { $this->action_delete(); } - else if ($action == 'list') { + elseif ($action == 'list') { $this->action_list(); } @@ -269,7 +269,7 @@ function templ_rights($attrib) $id = "acl$val"; $ul .= html::tag('li', null, $input->show('', ['name' => "acl[$val]", 'value' => $val, 'id' => $id]) - . html::label(['for' => $id, 'title' => $this->gettext('longacl'.$val)], $this->gettext('acl'.$val)) + . html::label(['for' => $id, 'title' => $this->gettext('longacl' . $val)], $this->gettext('acl' . $val)) ); } @@ -282,7 +282,7 @@ function templ_rights($attrib) 'read' => 'lrs', 'write' => 'wi', 'delete' => $deleteright, - 'other' => preg_replace('/[lrswi'.$deleteright.']/', '', implode('', $supported)), + 'other' => preg_replace('/[lrswi' . $deleteright . ']/', '', implode('', $supported)), ]; // give plugins the opportunity to adjust this list @@ -292,8 +292,8 @@ function templ_rights($attrib) foreach ($data['rights'] as $key => $val) { $id = "acl$key"; - $title = !empty($data['titles'][$key]) ? $data['titles'][$key] : $this->gettext('longacl'.$key); - $label = !empty($data['labels'][$key]) ? $data['labels'][$key] : $this->gettext('acl'.$key); + $title = !empty($data['titles'][$key]) ? $data['titles'][$key] : $this->gettext('longacl' . $key); + $label = !empty($data['labels'][$key]) ? $data['labels'][$key] : $this->gettext('acl' . $key); $ul .= html::tag('li', null, $input->show('', ['name' => "acl[$val]", 'value' => $val, 'id' => $id]) . html::label(['for' => $id, 'title' => $title], $label) @@ -415,7 +415,7 @@ private function list_rights($attrib = []) 'read' => 'lrs', 'write' => 'wi', 'delete' => $deleteright, - 'other' => preg_replace('/[lrswi'.$deleteright.']/', '', implode('', $supported)), + 'other' => preg_replace('/[lrswi' . $deleteright . ']/', '', implode('', $supported)), ]; // give plugins the opportunity to adjust this list @@ -510,10 +510,10 @@ private function action_save() if ($prefix && strpos($user, $prefix) === 0) { $username = $user; } - else if (!empty($this->specials) && in_array($user, $this->specials)) { + elseif (!empty($this->specials) && in_array($user, $this->specials)) { $username = $this->gettext($user); } - else if (!empty($user)) { + elseif (!empty($user)) { if (!strpos($user, '@') && ($realm = $this->get_realm())) { $user .= '@' . rcube_utils::idn_to_ascii(preg_replace('/^@/', '', $realm)); } @@ -719,7 +719,7 @@ private function get_realm() $self = $this->rc->get_user_name(); // find realm in username of logged user (?) - list($name, $domain) = rcube_utils::explode('@', $self); + [$name, $domain] = rcube_utils::explode('@', $self); // Use (always existent) ACL entry on the INBOX for the user to determine // whether or not the user ID in ACL entries need to be qualified and how @@ -819,8 +819,8 @@ protected function mod_login($user) $user = mb_strtolower($user); } // lowercase domain name - else if ($login_lc && strpos($user, '@')) { - list($local, $domain) = explode('@', $user); + elseif ($login_lc && strpos($user, '@')) { + [$local, $domain] = explode('@', $user); $user = $local . '@' . mb_strtolower($domain); } diff --git a/plugins/additional_message_headers/additional_message_headers.php b/plugins/additional_message_headers/additional_message_headers.php index b20f9bc0d72..8f79cd37e4d 100644 --- a/plugins/additional_message_headers/additional_message_headers.php +++ b/plugins/additional_message_headers/additional_message_headers.php @@ -10,6 +10,7 @@ * $config['additional_message_headers'] = ['User-Agent' => 'My-Very-Own-Webmail']; * * @author Ziba Scott + * * @website http://roundcube.net */ class additional_message_headers extends rcube_plugin diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php index 3497eebc9d0..6e8e3a3ae1a 100644 --- a/plugins/archive/archive.php +++ b/plugins/archive/archive.php @@ -7,6 +7,7 @@ * to move messages to a (user selectable) archive folder. * * @version 3.2 + * * @license GNU GPLv3+ * @author Andre Rodier, Thomas Bruederli, Aleksander Machniak */ @@ -57,11 +58,11 @@ function init() $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') { + elseif ($rcmail->task == 'mail') { // handler for ajax request $this->register_action('plugin.move2archive', [$this, 'move_messages']); } - else if ($rcmail->task == 'settings') { + elseif ($rcmail->task == 'settings') { $this->add_hook('preferences_list', [$this, 'prefs_table']); $this->add_hook('preferences_save', [$this, 'prefs_save']); @@ -103,7 +104,7 @@ private function _mod_folder_name(&$list, $folder, $new_name) $list[$idx]['name'] = $new_name; return true; } - else if (!empty($item['folders'])) { + elseif (!empty($item['folders'])) { if ($this->_mod_folder_name($list[$idx]['folders'], $folder, $new_name)) { return true; } @@ -162,7 +163,7 @@ function move_messages() $count = count($uids); continue; } - else if (!$archive_type || $archive_type == 'folder') { + elseif (!$archive_type || $archive_type == 'folder') { $folder = $this->archive_folder; if ($archive_type == 'folder') { @@ -373,8 +374,8 @@ private function subfolder_worker($folder) $path = explode($delimiter, $folder); // we'll create all folders in the path - for ($i=0; $ifolders)) { if ($storage->create_folder($_folder, true)) { $this->result['reload'] = true; @@ -449,7 +450,7 @@ function prefs_table($args) ]; } } - else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { + elseif ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { $chbox = new html_checkbox(['name' => '_read_on_archive', 'id' => 'ff_read_on_archive', 'value' => 1]); $args['blocks']['main']['options']['read_on_archive'] = [ 'title' => html::label('ff_read_on_archive', rcube::Q($this->gettext('readonarchive'))), @@ -475,7 +476,7 @@ function prefs_save($args) if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) { $args['prefs']['archive_type'] = rcube_utils::get_input_string('_archive_type', rcube_utils::INPUT_POST); } - else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { + elseif ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { $args['prefs']['read_on_archive'] = (bool) rcube_utils::get_input_value('_read_on_archive', rcube_utils::INPUT_POST); } diff --git a/plugins/archive/tests/Browser/MailTest.php b/plugins/archive/tests/Browser/MailTest.php index 40ffce25365..a93f5a74097 100644 --- a/plugins/archive/tests/Browser/MailTest.php +++ b/plugins/archive/tests/Browser/MailTest.php @@ -69,14 +69,14 @@ public function testMailUI() // Test archive class on folder in folder selector $browser->ctrlClick('#messagelist tbody tr') ->clickToolbarMenuItem('more', null, false) - ->with(new Popupmenu('message-menu'), function ($browser) { - $browser->clickMenuItem('move'); - }) - ->with(new Popupmenu('folder-selector'), function ($browser) { - $browser->assertVisible('li.archive') - ->assertSeeIn('li.archive', 'Archive'); - }) - ->click(); // close menus + ->with(new Popupmenu('message-menu'), function ($browser) { + $browser->clickMenuItem('move'); + }) + ->with(new Popupmenu('folder-selector'), function ($browser) { + $browser->assertVisible('li.archive') + ->assertSeeIn('li.archive', 'Archive'); + }) + ->click(); // close menus }); } } diff --git a/plugins/debug_logger/debug_logger.php b/plugins/debug_logger/debug_logger.php index 308bd79013e..e35b9b74a59 100644 --- a/plugins/debug_logger/debug_logger.php +++ b/plugins/debug_logger/debug_logger.php @@ -16,6 +16,7 @@ * log types and files. * * @author Ziba Scott + * * @website http://roundcube.net * * Example: @@ -99,7 +100,7 @@ function init() function authenticate($args) { - $this->runlog->note('Authenticating '.$args['user'].'@'.$args['host']); + $this->runlog->note('Authenticating ' . $args['user'] . '@' . $args['host']); return $args; } diff --git a/plugins/debug_logger/runlog/runlog.php b/plugins/debug_logger/runlog/runlog.php index 8b7765f7dfc..c7516b0aa0a 100644 --- a/plugins/debug_logger/runlog/runlog.php +++ b/plugins/debug_logger/runlog/runlog.php @@ -39,8 +39,8 @@ public function start($name, $tag = false) $this->parent_stack[] = $name; - $this->print_to_console("start: ".$name, $tag); - $this->print_to_file("start: ".$name, $tag); + $this->print_to_console("start: " . $name, $tag); + $this->print_to_file("start: " . $name, $tag); $this->indent++; } @@ -166,7 +166,7 @@ public function print_to_file($msg, $tag = false) if (strlen($buffer) > $this->max_line_size) { $buffer = substr($buffer,0,$this->max_line_size - 3) . "..."; } - fwrite($this->file_handles['master'], $buffer."\n"); + fwrite($this->file_handles['master'], $buffer . "\n"); } } diff --git a/plugins/emoticons/emoticons.php b/plugins/emoticons/emoticons.php index b949c66398f..72af3b3e0bd 100644 --- a/plugins/emoticons/emoticons.php +++ b/plugins/emoticons/emoticons.php @@ -9,6 +9,7 @@ * @license GNU GPLv3+ * @author Thomas Bruederli * @author Aleksander Machniak + * * @website https://roundcube.net */ class emoticons extends rcube_plugin @@ -89,7 +90,7 @@ function preferences_list($args) 'content' => $checkbox->show(intval($rcube->config->get('emoticons_display', false))), ]; } - else if ($args['section'] == 'compose' && !in_array('emoticons_compose', $dont_override)) { + elseif ($args['section'] == 'compose' && !in_array('emoticons_compose', $dont_override)) { $this->load_config(); $this->add_texts('localization'); @@ -113,7 +114,7 @@ function preferences_save($args) if ($args['section'] == 'mailview') { $args['prefs']['emoticons_display'] = (bool) rcube_utils::get_input_value('_emoticons_display', rcube_utils::INPUT_POST); } - else if ($args['section'] == 'compose') { + elseif ($args['section'] == 'compose') { $args['prefs']['emoticons_compose'] = (bool) rcube_utils::get_input_value('_emoticons_compose', rcube_utils::INPUT_POST); } @@ -133,11 +134,11 @@ protected static function text2icons($text) // E.g. situation when ";)" in "")" shouldn't be replaced by the icon // It's so long because of assertion format restrictions $entity = '(? self::ico_tag('1f603', ':D'), // laugh '/:-?\(/' => self::ico_tag('1f626', ':('), // frown - '/'.$entity.';-?\)/' => self::ico_tag('1f609', ';)'), // wink + '/' . $entity . ';-?\)/' => self::ico_tag('1f609', ';)'), // wink '/8-?\)/' => self::ico_tag('1f60e', '8)'), // cool '/(? self::ico_tag('1f62e', ':O'), // surprised '/(? self::ico_tag('1f61b', ':P'), // tongue out diff --git a/plugins/enigma/enigma.php b/plugins/enigma/enigma.php index 86b1b34649f..bc927e773b3 100644 --- a/plugins/enigma/enigma.php +++ b/plugins/enigma/enigma.php @@ -55,20 +55,20 @@ function init() $this->add_hook('template_object_messagebody', [$this, 'message_output']); } // message composing - else if ($enabled && $this->rc->action == 'compose') { + elseif ($enabled && $this->rc->action == 'compose') { $this->add_hook('message_compose_body', [$this, 'message_compose']); $this->load_ui(); $this->ui->init(); } // message sending (and draft storing) - else if ($enabled && $this->rc->action == 'send') { + elseif ($enabled && $this->rc->action == 'send') { $this->add_hook('message_ready', [$this, 'message_ready']); } $this->password_handler(); } - else if ($this->rc->task == 'settings') { + elseif ($this->rc->task == 'settings') { // add hooks for Enigma settings $this->add_hook('settings_actions', [$this, 'settings_actions']); $this->add_hook('preferences_sections_list', [$this, 'preferences_sections_list']); @@ -88,7 +88,7 @@ function init() $this->password_handler(); } - else if ($this->rc->task == 'cli') { + elseif ($this->rc->task == 'cli') { $this->add_hook('user_delete_commit', [$this, 'user_delete']); } diff --git a/plugins/enigma/lib/enigma_driver_gnupg.php b/plugins/enigma/lib/enigma_driver_gnupg.php index 08d165c1d26..f52bf18269d 100644 --- a/plugins/enigma/lib/enigma_driver_gnupg.php +++ b/plugins/enigma/lib/enigma_driver_gnupg.php @@ -390,7 +390,7 @@ public function delete_key($keyid) $result = $this->delete_privkey($keyid); } // need to delete private key first - else if ($code == enigma_error::DELKEY) { + elseif ($code == enigma_error::DELKEY) { $result = $this->delete_privkey($keyid); if ($result === true) { @@ -475,15 +475,15 @@ protected function get_error_from_exception($e) $error = enigma_error::KEYNOTFOUND; $data['id'] = $e->getKeyId(); } - else if ($e instanceof Crypt_GPG_BadPassphraseException) { + elseif ($e instanceof Crypt_GPG_BadPassphraseException) { $error = enigma_error::BADPASS; $data['bad'] = $e->getBadPassphrases(); $data['missing'] = $e->getMissingPassphrases(); } - else if ($e instanceof Crypt_GPG_NoDataException) { + elseif ($e instanceof Crypt_GPG_NoDataException) { $error = enigma_error::NODATA; } - else if ($e instanceof Crypt_GPG_DeletePrivateKeyException) { + elseif ($e instanceof Crypt_GPG_DeletePrivateKeyException) { $error = enigma_error::DELKEY; } else { @@ -709,7 +709,7 @@ protected function db_save($is_empty = false) $datasize = strlen($data); if (empty($maxsize)) { - $maxsize = min($db->get_variable('max_allowed_packet', 1048500), 4*1024*1024) - 2000; + $maxsize = min($db->get_variable('max_allowed_packet', 1048500), 4 * 1024 * 1024) - 2000; } if ($datasize > $maxsize) { diff --git a/plugins/enigma/lib/enigma_driver_phpssl.php b/plugins/enigma/lib/enigma_driver_phpssl.php index 62fd8b36c3f..c545c18d3e6 100644 --- a/plugins/enigma/lib/enigma_driver_phpssl.php +++ b/plugins/enigma/lib/enigma_driver_phpssl.php @@ -124,7 +124,7 @@ public function import($content, $isfile = false, $passwords = []) {} public function export($key, $with_private = false, $passwords = []) {} - public function list_keys($pattern='') {} + public function list_keys($pattern = '') {} public function get_key($keyid) {} diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php index 3ef5a8ba13b..f720d754297 100644 --- a/plugins/enigma/lib/enigma_engine.php +++ b/plugins/enigma/lib/enigma_engine.php @@ -186,7 +186,7 @@ function sign_message(&$message, $mode = null) // We can't use format=flowed for signed messages if (strpos($text_charset, 'format=flowed')) { - list($charset, $params) = explode(';', $text_charset); + [$charset, $params] = explode(';', $text_charset); $body = rcube_mime::unfold_flowed($body); $body = rcube_mime::wordwrap($body, $line_length, "\r\n", false, $charset); @@ -296,7 +296,7 @@ function encrypt_message(&$message, $mode = null, $is_draft = false) if ($mode & self::ENCRYPT_MODE_BODY) { $encrypt_mode = $mode; } - else if ($mode & self::ENCRYPT_MODE_MIME) { + elseif ($mode & self::ENCRYPT_MODE_MIME) { $encrypt_mode = $mode; } else { @@ -402,15 +402,15 @@ function part_structure($p, $body = null) $this->parse_plain($p, $body); $got_content = true; } - else if ($p['mimetype'] == 'multipart/signed') { + elseif ($p['mimetype'] == 'multipart/signed') { $this->parse_signed($p, $body); $got_content = true; } - else if ($p['mimetype'] == 'multipart/encrypted') { + elseif ($p['mimetype'] == 'multipart/encrypted') { $this->parse_encrypted($p); $got_content = true; } - else if ($p['mimetype'] == 'application/pkcs7-mime') { + elseif ($p['mimetype'] == 'application/pkcs7-mime') { $this->parse_encrypted($p); $got_content = true; } @@ -517,7 +517,7 @@ function parse_plain(&$p, $body = null) if ($mode === 'signed') { $body .= $line; } - else if ($mode === 'encrypted') { + elseif ($mode === 'encrypted') { $body .= $line; } else { @@ -530,7 +530,7 @@ function parse_plain(&$p, $body = null) if ($mode === 'signed') { $this->parse_plain_signed($p, $body, $prefix); } - else if ($mode === 'encrypted') { + elseif ($mode === 'encrypted') { $this->parse_plain_encrypted($p, $body, $prefix); } } @@ -555,7 +555,7 @@ function parse_signed(&$p, $body = null) // including a set of appropriate content headers describing the data. // The second body MUST contain the PGP digital signature. It MUST be // labeled with a content type of "application/pgp-signature". - else if (count($struct->parts) == 2 + elseif (count($struct->parts) == 2 && $struct->parts[1] && $struct->parts[1]->mimetype == 'application/pgp-signature' ) { $this->parse_pgp_signed($p, $body); @@ -581,7 +581,7 @@ function parse_encrypted(&$p) // This body contains the control information. // The second MIME body part MUST contain the actual encrypted data. It // must be labeled with a content type of "application/octet-stream". - else if (count($struct->parts) == 2 + elseif (count($struct->parts) == 2 && $struct->parts[0] && $struct->parts[0]->mimetype == 'application/pgp-encrypted' && $struct->parts[1] && $struct->parts[1]->mimetype == 'application/octet-stream' ) { @@ -629,7 +629,7 @@ private function parse_plain_signed(&$p, $body, $prefix = '') if ($part->body === null) { $part->body = ''; } - else if (preg_match('/^-----BEGIN PGP SIGNATURE-----/', $line)) { + elseif (preg_match('/^-----BEGIN PGP SIGNATURE-----/', $line)) { break; } else { @@ -696,7 +696,7 @@ private function parse_pgp_signed(&$p, $body = null) } // set signed part body - list($msg_body, $sig_body) = $this->explode_signed_body($body, $boundary); + [$msg_body, $sig_body] = $this->explode_signed_body($body, $boundary); // Verify if ($sig_body && $msg_body) { @@ -800,7 +800,7 @@ private function parse_plain_encrypted(&$p, $body, $prefix = '') // decryption failed, but the message may have already // been cached with the modified parts (see above), // let's bring the original state back - else if (!empty($p['object']->mime_parts[$parent])) { + elseif (!empty($p['object']->mime_parts[$parent])) { foreach ((array) $p['object']->mime_parts[$parent]->parts as $p) { if ($p->need_decryption && !preg_match('/^(.*)\.pgp$/i', $p->filename, $m)) { // modify filename @@ -1493,7 +1493,7 @@ protected function sync_keys($recipients) continue; } - list($local, $domain) = explode('@', $recipient); + [$local, $domain] = explode('@', $recipient); // Do this for configured domains only if (is_array($woat) && !in_array_nocase($domain, $woat)) { diff --git a/plugins/enigma/lib/enigma_key.php b/plugins/enigma/lib/enigma_key.php index 96e0150eff0..69a9347bb84 100644 --- a/plugins/enigma/lib/enigma_key.php +++ b/plugins/enigma/lib/enigma_key.php @@ -51,7 +51,7 @@ function get_type() if (!empty($this->subkeys[0]) && $this->subkeys[0]->has_private) { return self::TYPE_KEYPAIR; } - else if (!empty($this->subkeys[0])) { + elseif (!empty($this->subkeys[0])) { return self::TYPE_PUBLIC; } @@ -158,7 +158,7 @@ static function format_fingerprint($fingerprint) } $result = ''; - for ($i=0; $i<40; $i++) { + for ($i = 0; $i < 40; $i++) { if ($i % 4 == 0) { $result .= ' '; } diff --git a/plugins/enigma/lib/enigma_mime_message.php b/plugins/enigma/lib/enigma_mime_message.php index f2eb1d401e2..571122062e3 100644 --- a/plugins/enigma/lib/enigma_mime_message.php +++ b/plugins/enigma/lib/enigma_mime_message.php @@ -211,7 +211,7 @@ public function get($params = null, $filename = null, $skip_head = false) ]); } } - else if ($this->type == self::PGP_ENCRYPTED) { + elseif ($this->type == self::PGP_ENCRYPTED) { $params = [ 'preamble' => "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)", 'content_type' => "multipart/encrypted; protocol=\"application/pgp-encrypted\"", @@ -287,7 +287,7 @@ protected function contentHeaders() if (!empty($this->build_params['boundary'])) { $boundary = $this->build_params['boundary']; } - else if (!empty($this->headers['Content-Type']) + elseif (!empty($this->headers['Content-Type']) && preg_match('/boundary="([^"]+)"/', $this->headers['Content-Type'], $m) ) { $boundary = $m[1]; @@ -300,17 +300,17 @@ protected function contentHeaders() if ($this->type == self::PGP_SIGNED) { $headers['Content-Type'] = "multipart/signed;$eol" - ." protocol=\"application/pgp-signature\";$eol" - ." boundary=\"$boundary\""; + . " protocol=\"application/pgp-signature\";$eol" + . " boundary=\"$boundary\""; if ($this->micalg) { $headers['Content-Type'] .= ";{$eol} micalg=pgp-" . $this->micalg; } } - else if ($this->type == self::PGP_ENCRYPTED) { + elseif ($this->type == self::PGP_ENCRYPTED) { $headers['Content-Type'] = "multipart/encrypted;$eol" - ." protocol=\"application/pgp-encrypted\";$eol" - ." boundary=\"$boundary\""; + . " protocol=\"application/pgp-encrypted\";$eol" + . " boundary=\"$boundary\""; } return $headers; diff --git a/plugins/enigma/lib/enigma_subkey.php b/plugins/enigma/lib/enigma_subkey.php index f02ed8987cd..fdf430f344e 100644 --- a/plugins/enigma/lib/enigma_subkey.php +++ b/plugins/enigma/lib/enigma_subkey.php @@ -95,7 +95,7 @@ function is_expired() * * @param bool $asInt Return the date as an integer * - * @return string|null|int + * @return string|int|null */ function get_creation_date($asInt = false) { diff --git a/plugins/enigma/lib/enigma_ui.php b/plugins/enigma/lib/enigma_ui.php index 2648ebe98ec..0a55db08500 100644 --- a/plugins/enigma/lib/enigma_ui.php +++ b/plugins/enigma/lib/enigma_ui.php @@ -111,7 +111,7 @@ function init() } */ // Message composing UI - else if ($this->rc->action == 'compose') { + elseif ($this->rc->action == 'compose') { $this->compose_ui(); } } @@ -246,7 +246,7 @@ private function key_list() if (!is_array($list)) { $this->rc->output->show_message('enigma.keylisterror', 'error'); } - else if (empty($list)) { + elseif (empty($list)) { $this->rc->output->show_message('enigma.nokeysfound', 'notice'); } else { @@ -272,7 +272,7 @@ private function key_list() $this->rc->output->set_env('rowcount', $size); $this->rc->output->set_env('search_request', $search); - $this->rc->output->set_env('pagecount', ceil($listsize/$pagesize)); + $this->rc->output->set_env('pagecount', ceil($listsize / $pagesize)); $this->rc->output->set_env('current_page', $page); $this->rc->output->command('set_rowcount', $this->get_rowcount_text($listsize, $size, $page)); @@ -384,7 +384,7 @@ function tpl_key_data($attrib) if ($keytype == enigma_key::TYPE_KEYPAIR) { $type = $this->enigma->gettext('typekeypair'); } - else if ($keytype == enigma_key::TYPE_PUBLIC) { + elseif ($keytype == enigma_key::TYPE_PUBLIC) { $type = $this->enigma->gettext('typepublickey'); } @@ -557,7 +557,7 @@ private function key_import() $this->rc->output->send(); } - else if (!empty($_FILES['_file']['tmp_name']) && is_uploaded_file($_FILES['_file']['tmp_name'])) { + elseif (!empty($_FILES['_file']['tmp_name']) && is_uploaded_file($_FILES['_file']['tmp_name'])) { $this->enigma->load_engine(); $result = $this->enigma->engine->import_key($_FILES['_file']['tmp_name'], true); @@ -572,7 +572,7 @@ private function key_import() $this->rc->output->command('parent.enigma_import_success'); } - else if ($result instanceof enigma_error && $result->getCode() == enigma_error::BADPASS) { + elseif ($result instanceof enigma_error && $result->getCode() == enigma_error::BADPASS) { $this->password_prompt($result); } else { @@ -580,7 +580,7 @@ private function key_import() } $this->rc->output->send('iframe'); } - else if (!empty($_FILES['_file']['error'])) { + elseif (!empty($_FILES['_file']['error'])) { rcmail_action::upload_error($_FILES['_file']['error']); $this->rc->output->send('iframe'); } @@ -990,20 +990,20 @@ function status_message($p) $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), $this->enigma->gettext('decryptnokey'))); } - else if ($code == enigma_error::BADPASS) { + elseif ($code == enigma_error::BADPASS) { $missing = $status->getData('missing'); $label = 'decrypt' . (!empty($missing) ? 'no' : 'bad') . 'pass'; $msg = rcube::Q($this->enigma->gettext($label)); $this->password_prompt($status); } - else if ($code == enigma_error::NOMDC) { + elseif ($code == enigma_error::NOMDC) { $msg = rcube::Q($this->enigma->gettext('decryptnomdc')); } else { $msg = rcube::Q($this->enigma->gettext('decrypterror')); } } - else if ($status === enigma_engine::ENCRYPTED_PARTIALLY) { + elseif ($status === enigma_engine::ENCRYPTED_PARTIALLY) { $attrib['class'] = 'boxwarning enigmawarning encrypted'; $msg = rcube::Q($this->enigma->gettext('decryptpartial')); } @@ -1038,7 +1038,7 @@ function status_message($p) $msg = str_replace('$keyid', $sig->id, $msg); $msg = rcube::Q($msg); } - else if ($sig->valid) { + elseif ($sig->valid) { $attrib['class'] = ($sig->partial ? 'boxwarning enigmawarning' : 'boxconfirmation enigmanotice') . ' signed'; $label = 'sigvalid' . ($sig->partial ? 'partial' : ''); $msg = rcube::Q(str_replace('$sender', $sender, $this->enigma->gettext($label))); @@ -1054,7 +1054,7 @@ function status_message($p) } } } - else if ($sig && $sig->getCode() == enigma_error::KEYNOTFOUND) { + elseif ($sig && $sig->getCode() == enigma_error::KEYNOTFOUND) { $attrib['class'] = 'boxwarning enigmawarning signed'; $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')), $this->enigma->gettext('signokey'))); @@ -1137,7 +1137,7 @@ function message_output($p) $p['content'] = html::p(['class' => 'enigmaattachment boxinformation aligned-buttons'], html::span(null, rcube::Q($this->enigma->gettext('keyattfound'))) . html::tag('button', [ - 'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".enigma_import_attachment('".rcube::JQ($part)."')", + 'onclick' => "return " . rcmail_output::JS_OBJECT_NAME . ".enigma_import_attachment('" . rcube::JQ($part) . "')", 'title' => $this->enigma->gettext('keyattimport'), 'class' => 'import btn-sm', ], rcube::Q($this->rc->gettext('import')) @@ -1196,7 +1196,7 @@ function message_ready($p) $status = $engine->encrypt_message($p['message'], $mode, $savedraft); $mode = 'encrypt'; } - else if (!$savedraft && $sign_enable) { + elseif (!$savedraft && $sign_enable) { $engine = $this->enigma->load_engine(); $status = $engine->sign_message($p['message'], enigma_engine::SIGN_MODE_MIME); $mode = 'sign'; @@ -1215,7 +1215,7 @@ function message_ready($p) $msg = 'enigma.' . ($encrypt_enable ? 'encryptnoprivkey' : 'signnokey'); } } - else if ($code == enigma_error::BADPASS) { + elseif ($code == enigma_error::BADPASS) { $this->password_prompt($status); } else { diff --git a/plugins/enigma/tests/EnigmaMimeMessage.php b/plugins/enigma/tests/EnigmaMimeMessage.php index a7da40032fa..644bd0127c2 100644 --- a/plugins/enigma/tests/EnigmaMimeMessage.php +++ b/plugins/enigma/tests/EnigmaMimeMessage.php @@ -89,7 +89,7 @@ function test_get() $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED); $expected = "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)\r\n" - ."\r\n" + . "\r\n" . "--=_%x\r\n" . "Content-Transfer-Encoding: quoted-printable\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" @@ -120,7 +120,7 @@ function test_get() $message->addPGPSignature('signature', 'algorithm'); $signed = "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)\r\n" - ."\r\n" + . "\r\n" . "--=_%x\r\n" . "Content-Transfer-Encoding: quoted-printable\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" @@ -161,7 +161,7 @@ function test_get() $message->setPGPEncryptedBody('encrypted body'); $encrypted = "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\r\n" - ."\r\n" + . "\r\n" . "--=_%x\r\n" . "Content-Type: application/pgp-encrypted\r\n" . "Content-Description: PGP/MIME version identification\r\n" diff --git a/plugins/example_addressbook/example_addressbook_backend.php b/plugins/example_addressbook/example_addressbook_backend.php index b8761137952..41ffc369507 100644 --- a/plugins/example_addressbook/example_addressbook_backend.php +++ b/plugins/example_addressbook/example_addressbook_backend.php @@ -145,7 +145,7 @@ public function count() { // Note: Paging is not implemented - $result = new rcube_result_set(0, ($this->list_page-1) * $this->page_size); + $result = new rcube_result_set(0, ($this->list_page - 1) * $this->page_size); $count = 0; foreach ($this->db_users as $user) { diff --git a/plugins/filesystem_attachments/filesystem_attachments.php b/plugins/filesystem_attachments/filesystem_attachments.php index 1979da80e73..48bc63b8bb2 100644 --- a/plugins/filesystem_attachments/filesystem_attachments.php +++ b/plugins/filesystem_attachments/filesystem_attachments.php @@ -169,7 +169,7 @@ function cleanup($args) protected static function file_id() { $rcube = rcube::get_instance(); - list($usec, $sec) = explode(' ', microtime()); + [$usec, $sec] = explode(' ', microtime()); $id = preg_replace('/[^0-9]/', '', $rcube->user->ID . $sec . $usec); // make sure the ID is really unique (#1489546) diff --git a/plugins/help/help.php b/plugins/help/help.php index 4cfc246d576..64d9e5ed46b 100644 --- a/plugins/help/help.php +++ b/plugins/help/help.php @@ -66,7 +66,7 @@ function action() if ($rcmail->action == 'about') { $rcmail->output->set_pagetitle($this->gettext('about')); } - else if ($rcmail->action == 'license') { + elseif ($rcmail->action == 'license') { $rcmail->output->set_pagetitle($this->gettext('license')); } else { @@ -92,7 +92,7 @@ function help_content($attrib) if ($rcmail->action == 'about') { return file_get_contents($this->home . '/content/about.html'); } - else if ($rcmail->action == 'license') { + elseif ($rcmail->action == 'license') { return file_get_contents($this->home . '/content/license.html'); } } @@ -145,11 +145,11 @@ function help_metadata() // resolve task/action for deep linking $rel = !empty($_REQUEST['_rel']) ? $_REQUEST['_rel'] : ''; - list($task) = explode('/', $rel); + [$task] = explode('/', $rel); if (!empty($index_map[$rel])) { $src .= $index_map[$rel]; } - else if (!empty($index_map[$task])) { + elseif (!empty($index_map[$task])) { $src .= $index_map[$task]; } diff --git a/plugins/hide_blockquote/hide_blockquote.php b/plugins/hide_blockquote/hide_blockquote.php index 2c4770a95bd..6a570a6f28b 100644 --- a/plugins/hide_blockquote/hide_blockquote.php +++ b/plugins/hide_blockquote/hide_blockquote.php @@ -38,7 +38,7 @@ function init() // set env variable for client $rcmail->output->set_env('blockquote_limit', $limit); } - else if ($rcmail->task == 'settings') { + elseif ($rcmail->task == 'settings') { $dont_override = $rcmail->config->get('dont_override', []); if (!in_array('hide_blockquote_limit', $dont_override)) { $this->add_hook('preferences_list', [$this, 'prefs_table']); diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php index c42ece9b08d..39ed72c5820 100644 --- a/plugins/http_authentication/http_authentication.php +++ b/plugins/http_authentication/http_authentication.php @@ -40,7 +40,7 @@ function startup($args) $this->redirect_query = $_SERVER['QUERY_STRING']; } // Set user password in session (see shutdown() method for more info) - else if (!empty($_SESSION['user_id']) && empty($_SESSION['password']) + elseif (!empty($_SESSION['user_id']) && empty($_SESSION['password']) && !empty($_SERVER['PHP_AUTH_PW']) ) { $_SESSION['password'] = $rcmail->encrypt($_SERVER['PHP_AUTH_PW']); diff --git a/plugins/identicon/identicon.php b/plugins/identicon/identicon.php index 180e832e2ac..2eb5de6097a 100644 --- a/plugins/identicon/identicon.php +++ b/plugins/identicon/identicon.php @@ -7,11 +7,14 @@ * for contacts/addresses that do not have a photo image. * * @todo: Make it optional and configurable via user preferences + * * @todo: Make color palettes match the current skin + * * @todo: Implement optional SVG generator * * @license GNU GPLv3+ * @author Aleksander Machniak + * * @website http://roundcube.net */ class identicon extends rcube_plugin diff --git a/plugins/identicon/identicon_engine.php b/plugins/identicon/identicon_engine.php index bc59df8af0b..33dea2796e4 100644 --- a/plugins/identicon/identicon_engine.php +++ b/plugins/identicon/identicon_engine.php @@ -56,7 +56,7 @@ public function __construct($ident, $size = null, $bgcolor = null) } $this->bgcolor = $bgcolor; } - else if ($bgcolor === 'transparent') { + elseif ($bgcolor === 'transparent') { $this->bgcolor = $bgcolor; } } @@ -107,7 +107,7 @@ private function generate() $ident = md5($this->ident, true); // set icon color - $div = intval(255/count($this->palette)); + $div = intval(255 / count($this->palette)); $index = intval(ord($ident[0]) / $div); $this->color = $this->palette[$index] ?? $this->palette[0]; diff --git a/plugins/jqueryui/jqueryui.php b/plugins/jqueryui/jqueryui.php index 762853939c2..d1206ea16db 100644 --- a/plugins/jqueryui/jqueryui.php +++ b/plugins/jqueryui/jqueryui.php @@ -6,6 +6,7 @@ * Provide the jQuery UI library with according themes. * * @version 1.13.2 + * * @author Cor Bosman * @author Thomas Bruederli * @author Aleksander Machniak @@ -68,7 +69,7 @@ public function init() if (self::asset_exists("js/i18n/$package-$lang_l.js", false)) { $this->include_script("js/i18n/$package-$lang_l.js"); } - else if ($lang_s != 'en' && self::asset_exists("js/i18n/$package-$lang_s.js", false)) { + elseif ($lang_s != 'en' && self::asset_exists("js/i18n/$package-$lang_s.js", false)) { $this->include_script("js/i18n/$package-$lang_s.js"); } } diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve.php b/plugins/managesieve/lib/Roundcube/rcube_sieve.php index 42e54f4bf3e..bf158fe88d0 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve.php @@ -422,7 +422,7 @@ private function _parse($txt) } } - if (!empty($script->content[$idx+1]) && $script->content[$idx+1]['type'] != 'if') { + if (!empty($script->content[$idx + 1]) && $script->content[$idx + 1]['type'] != 'if') { $script->content[$idx]['actions'][] = ['type' => 'stop']; } } diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 997ba2b7a0c..1b1d3a63ff7 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -111,7 +111,7 @@ function start($mode = null) if (!empty($_GET['_set']) || !empty($_POST['_set'])) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_GPC, true); } - else if (!empty($_SESSION['managesieve_current'])) { + elseif (!empty($_SESSION['managesieve_current'])) { $script_name = $_SESSION['managesieve_current']; } } @@ -182,7 +182,7 @@ public function connect($username, $password) 'gssapi_cn' => null, ]); - list($host, $scheme, $port) = rcube_utils::parse_host_uri($plugin['host']); + [$host, $scheme, $port] = rcube_utils::parse_host_uri($plugin['host']); // Support explicit STARTTLS by establishing an unencrypted TCP connection, then instructing Net_Sieve to send the `STARTTLS` command. $tls = $scheme === 'tls'; @@ -250,7 +250,7 @@ protected function load_script($script_name = null) if (!empty($this->active)) { $script_name = $this->active[0]; } - else if ($list) { + elseif ($list) { $script_name = $list[0]; } else { @@ -298,7 +298,7 @@ function actions() $this->rc->output->show_message('managesieve.disabledaction', 'error'); } } - else if ($action == 'move' && !$error) { + elseif ($action == 'move' && !$error) { if (isset($this->script[$fid])) { $to = (int) rcube_utils::get_input_value('_to', rcube_utils::INPUT_POST); $rule = $this->script[$fid]; @@ -337,7 +337,7 @@ function actions() } } } - else if ($action == 'act' && !$error) { + elseif ($action == 'act' && !$error) { if (isset($this->script[$fid])) { $rule = $this->script[$fid]; $disabled = !empty($rule['disabled']); @@ -368,7 +368,7 @@ function actions() } } } - else if ($action == 'setact' && !$error) { + elseif ($action == 'setact' && !$error) { if (!in_array('enable_disable_set', $this->disabled_actions)) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_POST, true); $result = $this->activate_script($script_name); @@ -388,7 +388,7 @@ function actions() $this->rc->output->show_message('managesieve.disabledaction', 'error'); } } - else if ($action == 'deact' && !$error) { + elseif ($action == 'deact' && !$error) { if (!in_array('enable_disable_set', $this->disabled_actions)) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_POST, true); $result = $this->deactivate_script($script_name); @@ -407,7 +407,7 @@ function actions() $this->rc->output->show_message('managesieve.disabledaction', 'error'); } } - else if ($action == 'setdel' && !$error) { + elseif ($action == 'setdel' && !$error) { if (!in_array('delete_set', $this->disabled_actions)) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_POST, true); $result = $this->remove_script($script_name); @@ -425,7 +425,7 @@ function actions() $this->rc->output->show_message('managesieve.disabledaction', 'error'); } } - else if ($action == 'setget') { + elseif ($action == 'setget') { if (!in_array('download_set', $this->disabled_actions)) { $this->rc->request_security_check(rcube_utils::INPUT_GET); @@ -440,26 +440,26 @@ function actions() exit; } } - else if ($action == 'list') { + elseif ($action == 'list') { $result = $this->list_rules(); $this->rc->output->command('managesieve_updatelist', 'list', ['list' => $result]); } - else if ($action == 'ruleadd') { + elseif ($action == 'ruleadd') { $rid = rcube_utils::get_input_string('_rid', rcube_utils::INPUT_POST); $id = $this->genid(); $content = $this->rule_div($fid, $id, false, !empty($_SESSION['managesieve-compact-form'])); $this->rc->output->command('managesieve_rulefill', $content, $id, $rid); } - else if ($action == 'actionadd') { + elseif ($action == 'actionadd') { $aid = rcube_utils::get_input_string('_aid', rcube_utils::INPUT_POST); $id = $this->genid(); $content = $this->action_div($fid, $id, false); $this->rc->output->command('managesieve_actionfill', $content, $id, $aid); } - else if ($action == 'addresses') { + elseif ($action == 'addresses') { $aid = rcube_utils::get_input_string('_aid', rcube_utils::INPUT_POST); $this->rc->output->command('managesieve_vacation_addresses_update', $aid, $this->user_emails()); @@ -467,13 +467,13 @@ function actions() $this->rc->output->send(); } - else if ($this->rc->task == 'mail') { + elseif ($this->rc->task == 'mail') { // Initialize the form $rules = rcube_utils::get_input_value('r', rcube_utils::INPUT_GET); if (!empty($rules)) { $tests = []; foreach ($rules as $rule) { - list($header, $value) = explode(':', $rule, 2); + [$header, $value] = explode(':', $rule, 2); $tests[] = [ 'type' => 'contains', 'test' => 'header', @@ -547,7 +547,7 @@ function save() $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); } // check request depth limits - else if ($max_depth && count($_POST['_header']) > $max_depth) { + elseif ($max_depth && count($_POST['_header']) > $max_depth) { rcube::raise_error([ 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, 'message' => "Request size limit exceeded (one of suhosin.request.max_array_depth/suhosin.post.max_array_depth)", @@ -556,7 +556,7 @@ function save() $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); } // filters set add action - else if (!empty($_POST['_newset'])) { + elseif (!empty($_POST['_newset'])) { $name = rcube_utils::get_input_string('_name', rcube_utils::INPUT_POST, true); $copy = rcube_utils::get_input_string('_copy', rcube_utils::INPUT_POST, true); $from = rcube_utils::get_input_string('_from', rcube_utils::INPUT_POST); @@ -568,22 +568,22 @@ function save() if (in_array('new_set', $this->disabled_actions)) { $error = 'managesieve.disabledaction'; } - else if (!$name) { + elseif (!$name) { $this->errors['name'] = $this->plugin->gettext('cannotbeempty'); } - else if (mb_strlen($name) > 128) { + elseif (mb_strlen($name) > 128) { $this->errors['name'] = $this->plugin->gettext('nametoolong'); } - else if (!empty($exceptions) && in_array($name, (array) $exceptions)) { + elseif (!empty($exceptions) && in_array($name, (array) $exceptions)) { $this->errors['name'] = $this->plugin->gettext('namereserved'); } - else if (!empty($kolab) && in_array($name_uc, ['MASTER', 'USER', 'MANAGEMENT'])) { + elseif (!empty($kolab) && in_array($name_uc, ['MASTER', 'USER', 'MANAGEMENT'])) { $this->errors['name'] = $this->plugin->gettext('namereserved'); } - else if (in_array($name, $list)) { + elseif (in_array($name, $list)) { $this->errors['name'] = $this->plugin->gettext('setexist'); } - else if ($from == 'file') { + elseif ($from == 'file') { // from file if (is_uploaded_file($_FILES['_file']['tmp_name'])) { $file = file_get_contents($_FILES['_file']['tmp_name']); @@ -600,7 +600,7 @@ function save() rcmail_action::upload_error($_FILES['_file']['error']); } } - else if (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) { + elseif (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) { $error = 'managesieve.setcreateerror'; } @@ -615,15 +615,15 @@ function save() $this->rc->output->command('parent.managesieve_updatelist', 'setadd', ['name' => $name, 'index' => $index]); } - else if (!empty($msg)) { + elseif (!empty($msg)) { $this->rc->output->command('display_message', $msg, 'error'); } - else if ($error) { + elseif ($error) { $this->rc->output->show_message($error, 'error'); } } // filter add/edit action - else if (isset($_POST['_name'])) { + elseif (isset($_POST['_name'])) { $name = trim(rcube_utils::get_input_string('_name', rcube_utils::INPUT_POST, true)); $fid = trim(rcube_utils::get_input_string('_fid', rcube_utils::INPUT_POST)); $join = trim(rcube_utils::get_input_string('_join', rcube_utils::INPUT_POST)); @@ -731,7 +731,7 @@ function save() if ($sizetarget === '') { $this->errors['tests'][$i]['sizetarget'] = $this->plugin->gettext('cannotbeempty'); } - else if (!preg_match('/^[0-9]+(K|M|G)?$/i', $sizetarget.$sizeitem, $m)) { + elseif (!preg_match('/^[0-9]+(K|M|G)?$/i', $sizetarget . $sizeitem, $m)) { $this->errors['tests'][$i]['sizetarget'] = $this->plugin->gettext('forbiddenchars'); $this->form['tests'][$i]['item'] = $sizeitem; } @@ -739,7 +739,7 @@ function save() $this->form['tests'][$i]['arg'] .= $m[1]; } } - else if ($header == 'spamtest') { + elseif ($header == 'spamtest') { $spamtestop = $this->strip_value($spamtestops[$idx]); $spamtesttarget = $this->strip_value($spamtesttargets[$idx]); $comparator = 'i;ascii-numeric'; @@ -756,11 +756,11 @@ function save() if ($spamtesttarget === '') { $this->errors['tests'][$i]['spamtesttarget'] = $this->plugin->gettext('cannotbeempty'); } - else if (!preg_match('/^([0-9]|10)$/i', $spamtesttarget)) { + elseif (!preg_match('/^([0-9]|10)$/i', $spamtesttarget)) { $this->errors['tests'][$i]['spamtesttarget'] = $this->plugin->gettext('forbiddenchars'); } } - else if ($header == 'currentdate') { + elseif ($header == 'currentdate') { $datepart = $this->strip_value($dateparts[$idx]); $type = preg_replace('/^not/', '', $operator); @@ -778,14 +778,14 @@ function save() if (empty($target)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); } - else if (strpos($type, 'count-') === 0) { + elseif (strpos($type, 'count-') === 0) { foreach ($target as $arg) { if (preg_match('/[^0-9]/', $arg)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); } } } - else if (strpos($type, 'value-') === 0) { + elseif (strpos($type, 'value-') === 0) { // Some date/time formats do not support i;ascii-numeric comparator if ($comparator == 'i;ascii-numeric' && in_array($datepart, ['date', 'time', 'iso8601', 'std11'])) { $comparator = ''; @@ -802,7 +802,7 @@ function save() } } } - else if ($header == 'date') { + elseif ($header == 'date') { $datepart = $this->strip_value($dateparts[$idx]); $dateheader = $this->strip_value($dateheaders[$idx]); $index = $this->strip_value($indexes[$idx]); @@ -823,7 +823,7 @@ function save() if (empty($dateheader)) { $dateheader = 'Date'; } - else if (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $dateheader)) { + elseif (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $dateheader)) { $this->errors['tests'][$i]['dateheader'] = $this->plugin->gettext('forbiddenchars'); } @@ -838,14 +838,14 @@ function save() if (empty($target)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); } - else if (strpos($type, 'count-') === 0) { + elseif (strpos($type, 'count-') === 0) { foreach ($target as $arg) { if (preg_match('/[^0-9]/', $arg)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); } } } - else if (strpos($type, 'value-') === 0) { + elseif (strpos($type, 'value-') === 0) { // Some date/time formats do not support i;ascii-numeric comparator if ($comparator == 'i;ascii-numeric' && in_array($datepart, ['date', 'time', 'iso8601', 'std11'])) { $comparator = ''; @@ -862,7 +862,7 @@ function save() } } } - else if ($header == 'body') { + elseif ($header == 'body') { $trans = $this->strip_value($body_trans[$idx]); $trans_type = $this->strip_value($body_types[$idx], true); $type = preg_replace('/^not/', '', $operator); @@ -884,7 +884,7 @@ function save() if (empty($target) && $type != 'exists') { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); } - else if (preg_match('/^(value|count)-/', $type)) { + elseif (preg_match('/^(value|count)-/', $type)) { foreach ($target as $target_value) { if (preg_match('/[^0-9]/', $target_value)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); @@ -892,7 +892,7 @@ function save() } } } - else if ($header == 'message') { + elseif ($header == 'message') { $test = $this->strip_value($message[$idx]); if (preg_match('/^not/', $test)) { @@ -948,7 +948,7 @@ function save() if (!count($headers)) { $this->errors['tests'][$i]['header'] = $this->plugin->gettext('cannotbeempty'); } - else if ($header == '...') { + elseif ($header == '...') { foreach ($headers as $hr) { // RFC2822: printable ASCII except colon if (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $hr)) { @@ -1001,7 +1001,7 @@ function save() if (empty($target)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); } - else if (preg_match('/^(value|count)-/', $type)) { + elseif (preg_match('/^(value|count)-/', $type)) { foreach ($target as $target_value) { if (preg_match('/[^0-9]/', $target_value)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); @@ -1087,7 +1087,7 @@ function save() if ($target === '') { $this->errors['actions'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); } - else if (!rcube_utils::check_email($target)) { + elseif (!rcube_utils::check_email($target)) { $this->errors['actions'][$i]['target'] = $this->plugin->gettext(!empty($domains) ? 'forbiddenchars' : 'noemailwarning'); } @@ -1118,7 +1118,7 @@ function save() if (empty($this->form['actions'][$i]['name'])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('cannotbeempty'); } - else if (!preg_match('/^[0-9a-z_-]+$/i', $this->form['actions'][$i]['name'])) { + elseif (!preg_match('/^[0-9a-z_-]+$/i', $this->form['actions'][$i]['name'])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('forbiddenchars'); } @@ -1138,7 +1138,7 @@ function save() $this->errors['actions'][$i]['index'] = $this->plugin->gettext('lastindexempty'); } } - else if (!preg_match('/^[0-9]+$/i', $this->form['actions'][$i]['index'])) { + elseif (!preg_match('/^[0-9]+$/i', $this->form['actions'][$i]['index'])) { $this->errors['actions'][$i]['index'] = $this->plugin->gettext('forbiddenchars'); } } @@ -1168,7 +1168,7 @@ function save() if (empty($address)) { unset($this->form['actions'][$i]['addresses'][$aidx]); } - else if (!rcube_utils::check_email($address)) { + elseif (!rcube_utils::check_email($address)) { $this->errors['actions'][$i]['addresses'] = $this->plugin->gettext('noemailwarning'); break; } @@ -1197,7 +1197,7 @@ function save() if (empty($varnames[$idx])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('cannotbeempty'); } - else if (!preg_match('/^[0-9a-z_]+$/i', $varnames[$idx])) { + elseif (!preg_match('/^[0-9a-z_]+$/i', $varnames[$idx])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('forbiddenchars'); } @@ -1287,7 +1287,7 @@ protected function send() if (isset($_GET['_newset']) || isset($_POST['_newset'])) { $this->rc->output->send('managesieve.setedit'); } - else if (isset($_GET['_seteditraw']) || isset($_POST['_seteditraw'])) { + elseif (isset($_GET['_seteditraw']) || isset($_POST['_seteditraw'])) { $this->rc->output->send('managesieve.seteditraw'); } else { @@ -1498,7 +1498,7 @@ function filterset_form($attrib) 'name' => '_from', 'value' => 'set', 'checked' => $selected == 'set', - ]) . rcube::Q($this->plugin->gettext('fromset')) . ' ' . $select->show($copy)) . ''; + ]) . rcube::Q($this->plugin->gettext('fromset')) . ' ' . $select->show($copy)) . ''; } // script upload box @@ -1635,7 +1635,7 @@ function filter_form($attrib) rcube::Q($this->plugin->gettext('scope')), $select->show($join) ); - $out .= '