diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cb25dba52..46953446a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, fileinfo, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, ldap + extensions: dom, curl, fileinfo, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, ldap, intl tools: composer:v2 coverage: none diff --git a/CHANGELOG b/CHANGELOG index 0d56d6f56..30c3b977d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,9 @@ CHANGELOG Roundcube Webmail =========================== - Require PHP >= 5.5 +- Require php-intl +- Remove use of ext-iconv +- Remove use of Net_IDNA2 package - Automatically collected recipients and trusted senders (#6904) - Added configurable Collected Recipients addressbook source (#4971) - Added configurable Trusted Senders addressbook source (#5046) @@ -14,7 +17,6 @@ CHANGELOG Roundcube Webmail - Upgrade to TinyMCE 5.5.1 - Upgrade to jQuery 3.5.1 (#7464) - Allow array in smtp_host config (#7296) -- Remove use of ext-iconv - Support proxy for server-side HTTP requests (#7658) - Add posibility to (re-)define field mapping on contacts import from a CSV file (#7045, #6668) - Move "On request for return receipt" from "Mailbox View" to "Displaying Messages" (#7614) diff --git a/INSTALL b/INSTALL index ec774f17d..c45f385e0 100644 --- a/INSTALL +++ b/INSTALL @@ -12,9 +12,9 @@ REQUIREMENTS * An IMAP, HTTP and SMTP server * .htaccess support allowing overrides for DirectoryIndex * PHP Version 5.5 or greater including: - - PCRE, DOM, JSON, Session, Sockets, OpenSSL, Mbstring, Filter, Ctype (required) + - PCRE, DOM, JSON, Session, Sockets, OpenSSL, Mbstring, Filter, Ctype, Intl (required) - PHP PDO with driver for either MySQL, PostgreSQL, SQL Server, Oracle or SQLite (required) - - Zip, Fileinfo, Intl, Exif (recommended) + - Zip, Fileinfo, Exif (recommended) - LDAP for LDAP addressbook support (optional) - GD, Imagick (optional thumbnails generation, QR-code) * PEAR and PEAR packages distributed with Roundcube or external. diff --git a/composer.json-dist b/composer.json-dist index cb7ddd8ae..89d1fa8d2 100644 --- a/composer.json-dist +++ b/composer.json-dist @@ -12,7 +12,6 @@ "php": ">=5.5.0", "pear/pear-core-minimal": "~1.10.1", "pear/auth_sasl": "~1.1.0", - "pear/net_idna2": "~0.2.0", "pear/mail_mime": "~1.10.0", "pear/net_smtp": "~1.9.0", "pear/crypt_gpg": "~1.6.3", diff --git a/installer/check.php b/installer/check.php index 8f7d5093e..d4d701197 100644 --- a/installer/check.php +++ b/installer/check.php @@ -18,59 +18,54 @@ if (!class_exists('rcmail_install', false) || !isset($RCI)) { die("Not allowed! Please open installer/index.php instead."); } -?> -
- 'pcre', 'DOM' => 'dom', 'Session' => 'session', 'XML' => 'xml', + 'Intl' => 'intl', 'JSON' => 'json', 'PDO' => 'PDO', 'Multibyte' => 'mbstring', 'OpenSSL' => 'openssl', 'Filter' => 'filter', 'Ctype' => 'ctype', -); +]; -$optional_php_exts = array( +$optional_php_exts = [ 'cURL' => 'curl', 'FileInfo' => 'fileinfo', - 'Intl' => 'intl', 'Exif' => 'exif', 'LDAP' => 'ldap', 'GD' => 'gd', 'Imagick' => 'imagick', 'Zip' => 'zip', -); +]; -$required_libs = array( +$required_libs = [ 'PEAR' => 'pear.php.net', 'Auth_SASL' => 'pear.php.net', 'Net_SMTP' => 'pear.php.net', - 'Net_IDNA2' => 'pear.php.net', 'Mail_mime' => 'pear.php.net', 'GuzzleHttp\Client' => 'github.com/guzzle/guzzle', -); +]; -$optional_libs = array( +$optional_libs = [ 'Net_LDAP3' => 'git.kolab.org', -); +]; -$ini_checks = array( - 'file_uploads' => 1, - 'session.auto_start' => 0, - 'mbstring.func_overload' => 0, - 'suhosin.session.encrypt' => 0, -); +$ini_checks = [ + 'file_uploads' => 1, + 'session.auto_start' => 0, + 'mbstring.func_overload' => 0, + 'suhosin.session.encrypt' => 0, +]; -$optional_checks = array( - 'date.timezone' => '-VALID-', -); +$optional_checks = [ + 'date.timezone' => '-VALID-', +]; -$source_urls = array( +$source_urls = [ 'cURL' => 'https://www.php.net/manual/en/book.curl.php', 'Sockets' => 'https://www.php.net/manual/en/book.sockets.php', 'Session' => 'https://www.php.net/manual/en/book.session.php', @@ -99,10 +94,13 @@ $source_urls = array( 'PEAR' => 'https://pear.php.net', 'Net_SMTP' => 'https://pear.php.net/package/Net_SMTP', 'Mail_mime' => 'https://pear.php.net/package/Mail_mime', - 'Net_IDNA2' => 'https://pear.php.net/package/Net_IDNA2', 'Net_LDAP3' => 'https://git.kolab.org/diffusion/PNL', -); +]; +?> + + +configured ? 3 : 2) . '" />'; ?> @@ -112,7 +110,8 @@ echo 'Check which of the supported extensions are installed. At least one of them is required.

supported_dbs as $database => $ext) { if (extension_loaded($ext)) { $RCI->pass($database); @@ -180,7 +179,6 @@ if (empty($found_db_driver)) { ?> -

Check for required 3rd party libs

This also checks if the include path is set correctly.

@@ -242,7 +240,8 @@ foreach ($optional_checks as $var => $val) { if ($val === '-NOTEMPTY-') { if (empty($status)) { $RCI->optfail($var, "Could be set"); - } else { + } + else { $RCI->pass($var); } echo '
'; @@ -275,7 +274,7 @@ foreach ($optional_checks as $var => $val) { failures) { - echo '

Sorry but your webserver does not meet the requirements for Roundcube!
+ echo '

Sorry but your webserver does not meet the requirements for Roundcube!
Please install the missing modules or fix the php.ini settings according to the above check results.
Hint: only checks showing NOT OK need to be fixed.

'; } diff --git a/installer/config.php b/installer/config.php index 69aac3941..ede2047f7 100644 --- a/installer/config.php +++ b/installer/config.php @@ -19,13 +19,13 @@ if (!class_exists('rcmail_install', false) || !isset($RCI)) { } // register these boolean fields -$RCI->bool_config_props = array( - 'ip_check' => 1, +$RCI->bool_config_props = [ + 'ip_check' => 1, 'enable_spellcheck' => 1, - 'auto_create_user' => 1, - 'smtp_log' => 1, - 'prefer_html' => 1, -); + 'auto_create_user' => 1, + 'smtp_log' => 1, + 'prefer_html' => 1, +]; // allow the current user to get to the next step $_SESSION['allowinstaller'] = true; @@ -34,10 +34,12 @@ if (!empty($_POST['submit'])) { $_SESSION['config'] = $RCI->create_config(); if ($RCI->save_configfile($_SESSION['config'])) { - echo '

The config file was saved successfully into '.RCMAIL_CONFIG_DIR.' directory of your Roundcube installation.'; + echo '

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

Afterwards, please remove the old configuration files main.inc.php and db.inc.php from the config directory.'; + echo '

Afterwards, please remove the old configuration files' + . ' main.inc.php and db.inc.php from the config directory.'; } echo '

'; @@ -60,12 +62,13 @@ if (!empty($_POST['submit'])) { echo $save_button; if ($RCI->legacy_config) { - echo '

Afterwards, please remove the old configuration files main.inc.php and db.inc.php from the config directory.'; + echo '

Afterwards, please remove the old configuration files' + . ' main.inc.php and db.inc.php from the config directory.'; } echo '

'; - $textbox = new html_textarea(array('rows' => 16, 'cols' => 60, 'class' => "configfile")); + $textbox = new html_textarea(['rows' => 16, 'cols' => 60, 'class' => 'configfile']); echo $textbox->show(($_SESSION['config'])); } @@ -90,7 +93,7 @@ if (!empty($_POST['submit'])) {
'_product_name', 'size' => 30, 'id' => "cfgprodname")); +$input_prodname = new html_inputfield(['name' => '_product_name', 'size' => 30, 'id' => 'cfgprodname']); echo $input_prodname->show($RCI->getprop('product_name')); ?> @@ -101,7 +104,7 @@ echo $input_prodname->show($RCI->getprop('product_name'));
'_support_url', 'size' => 50, 'id' => "cfgsupporturl")); +$input_support = new html_inputfield(['name' => '_support_url', 'size' => 50, 'id' => 'cfgsupporturl']); echo $input_support->show($RCI->getprop('support_url')); ?> @@ -109,23 +112,11 @@ echo $input_support->show($RCI->getprop('support_url'));

Enter an absolute URL (including http://) to a support page/form or a mailto: link.

-
skin_logo
-
- '_skin_logo', 'size' => 50, 'id' => "cfgskinlogo")); -echo $input_skin->show($RCI->getprop('skin_logo')); - -?> -
Custom image to display instead of the Roundcube logo.
-

Enter a URL relative to the document root of this Roundcube installation.

-
-
temp_dir
'_temp_dir', 'size' => 30, 'id' => "cfgtempdir")); +$input_tempdir = new html_inputfield(['name' => '_temp_dir', 'size' => 30, 'id' => 'cfgtempdir']); echo $input_tempdir->show($RCI->getprop('temp_dir')); ?> @@ -136,7 +127,7 @@ echo $input_tempdir->show($RCI->getprop('temp_dir'));
'_des_key', 'size' => 30, 'id' => "cfgdeskey")); +$input_deskey = new html_inputfield(['name' => '_des_key', 'size' => 30, 'id' => 'cfgdeskey']); echo $input_deskey->show($RCI->getprop('des_key')); ?> @@ -148,7 +139,7 @@ echo $input_deskey->show($RCI->getprop('des_key'));
'_ip_check', 'id' => "cfgipcheck")); +$check_ipcheck = new html_checkbox(['name' => '_ip_check', 'id' => 'cfgipcheck']); echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)); ?> @@ -157,30 +148,33 @@ echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)

This increases security but can cause sudden logouts when someone uses a proxy with changing IPs.

-
enable_spellcheck
'_enable_spellcheck', 'id' => "cfgspellcheck")); -echo $check_spell->show(intval($RCI->getprop('enable_spellcheck')), array('value' => 1)); +$check_spell = new html_checkbox(['name' => '_enable_spellcheck', 'id' => 'cfgspellcheck']); +echo $check_spell->show(intval($RCI->getprop('enable_spellcheck')), ['value' => 1]); ?> +
spellcheck_engine
+ '_spellcheck_engine', 'id' => "cfgspellcheckengine")); -if (extension_loaded('pspell')) - $select_spell->add('Pspell', 'pspell'); -if (extension_loaded('enchant')) - $select_spell->add('Enchant', 'enchant'); +$select_spell = new html_select(['name' => '_spellcheck_engine', 'id' => 'cfgspellcheckengine']); +if (extension_loaded('pspell')) { + $select_spell->add('Pspell', 'pspell'); +} +if (extension_loaded('enchant')) { + $select_spell->add('Enchant', 'enchant'); +} $select_spell->add('Googie', 'googie'); $select_spell->add('ATD', 'atd'); echo $select_spell->show($RCI->is_post ? $_POST['_spellcheck_engine'] : 'pspell'); - ?> +

Googie implies that the message content will be sent to external server to check the spelling.

@@ -188,9 +182,10 @@ echo $select_spell->show($RCI->is_post ? $_POST['_spellcheck_engine'] : 'pspell'
identities_level
+ '_identities_level', 'id' => "cfgidentitieslevel")); +$input_ilevel = new html_select(['name' => '_identities_level', 'id' => 'cfgidentitieslevel']); $input_ilevel->add('many identities with possibility to edit all params', 0); $input_ilevel->add('many identities with possibility to edit all params but not email address', 1); $input_ilevel->add('one identity with possibility to edit all params', 2); @@ -199,6 +194,7 @@ $input_ilevel->add('one identity with possibility to edit only signature', 4); echo $input_ilevel->show($RCI->getprop('identities_level'), 0); ?> +
Level of identities access

Defines what users can do with their identities.

@@ -212,13 +208,13 @@ echo $input_ilevel->show($RCI->getprop('identities_level'), 0);
log_driver
+ '_log_driver', 'id' => "cfglogdriver")); -$select_log_driver->add(array('file', 'syslog', 'stdout'), array('file', 'syslog', 'stdout')); +$select_log_driver = new html_select(['name' => '_log_driver', 'id' => 'cfglogdriver']); +$select_log_driver->add(['file', 'syslog', 'stdout'], ['file', 'syslog', 'stdout']); echo $select_log_driver->show($RCI->getprop('log_driver', 'file')); - ?> +
How to do logging? 'file' - write to files in the log directory, 'syslog' - use the syslog facility, 'stdout' writes to the process' STDOUT file descriptor.
@@ -226,7 +222,7 @@ echo $select_log_driver->show($RCI->getprop('log_driver', 'file'));
'_log_dir', 'size' => 30, 'id' => "cfglogdir")); +$input_logdir = new html_inputfield(['name' => '_log_dir', 'size' => 30, 'id' => 'cfglogdir']); echo $input_logdir->show($RCI->getprop('log_dir')); ?> @@ -237,7 +233,7 @@ echo $input_logdir->show($RCI->getprop('log_dir'));
'_syslog_id', 'size' => 30, 'id' => "cfgsyslogid")); +$input_syslogid = new html_inputfield(['name' => '_syslog_id', 'size' => 30, 'id' => 'cfgsyslogid']); echo $input_syslogid->show($RCI->getprop('syslog_id', 'roundcube')); ?> @@ -248,7 +244,7 @@ echo $input_syslogid->show($RCI->getprop('syslog_id', 'roundcube'));
'_syslog_facility', 'id' => "cfgsyslogfacility")); +$input_syslogfacility = new html_select(['name' => '_syslog_facility', 'id' => 'cfgsyslogfacility']); $input_syslogfacility->add('user-level messages', LOG_USER); $input_syslogfacility->add('mail subsystem', LOG_MAIL); $input_syslogfacility->add('local level 0', LOG_LOCAL0); @@ -265,13 +261,9 @@ echo $input_syslogfacility->show($RCI->getprop('syslog_facility'), LOG_USER);
What ID to use when logging with syslog. Note that this only applies if you are using the 'syslog' log_driver.
- - - -
Database setup
@@ -280,17 +272,17 @@ echo $input_syslogfacility->show($RCI->getprop('syslog_facility'), LOG_USER);

Database settings for read/write operations:

'_dbtype', 'id' => "cfgdbtype")); +$select_dbtype = new html_select(['name' => '_dbtype', 'id' => 'cfgdbtype']); foreach ($RCI->supported_dbs as $database => $ext) { if (extension_loaded($ext)) { $select_dbtype->add($database, substr($ext, 4)); } } -$input_dbhost = new html_inputfield(array('name' => '_dbhost', 'size' => 20, 'id' => "cfgdbhost")); -$input_dbname = new html_inputfield(array('name' => '_dbname', 'size' => 20, 'id' => "cfgdbname")); -$input_dbuser = new html_inputfield(array('name' => '_dbuser', 'size' => 20, 'id' => "cfgdbuser")); -$input_dbpass = new html_inputfield(array('name' => '_dbpass', 'size' => 20, 'id' => "cfgdbpass")); +$input_dbhost = new html_inputfield(['name' => '_dbhost', 'size' => 20, 'id' => 'cfgdbhos']); +$input_dbname = new html_inputfield(['name' => '_dbname', 'size' => 20, 'id' => 'cfgdbname']); +$input_dbuser = new html_inputfield(['name' => '_dbuser', 'size' => 20, 'id' => 'cfgdbuser']); +$input_dbpass = new html_inputfield(['name' => '_dbpass', 'size' => 20, 'id' => 'cfgdbpass']); $dsnw = rcube_db::parse_dsn($RCI->getprop('db_dsnw')); @@ -312,7 +304,7 @@ echo '
';
'_db_prefix', 'size' => 20, 'id' => "cfgdbprefix")); +$input_prefix = new html_inputfield(['name' => '_db_prefix', 'size' => 20, 'id' => 'cfgdbprefix']); echo $input_prefix->show($RCI->getprop('db_prefix')); ?> @@ -332,18 +324,20 @@ echo $input_prefix->show($RCI->getprop('db_prefix'));
'_default_host[]', 'size' => 30)); +$text_imaphost = new html_inputfield(['name' => '_default_host[]', 'size' => 30]); $default_hosts = $RCI->get_hostlist(); -if (empty($default_hosts)) - $default_hosts = array(''); +if (empty($default_hosts)) { + $default_hosts = ['']; +} $i = 0; foreach ($default_hosts as $host) { - echo '
' . $text_imaphost->show($host); - if ($i++ > 0) - echo 'remove'; - echo '
'; + echo '
' . $text_imaphost->show($host); + if ($i++ > 0) { + echo 'remove'; + } + echo '
'; } ?> @@ -357,7 +351,7 @@ foreach ($default_hosts as $host) {
'_default_port', 'size' => 6, 'id' => "cfgimapport")); +$text_imapport = new html_inputfield(['name' => '_default_port', 'size' => 6, 'id' => 'cfgimapport']); echo $text_imapport->show($RCI->getprop('default_port')); ?> @@ -368,7 +362,7 @@ echo $text_imapport->show($RCI->getprop('default_port'));
'_username_domain', 'size' => 30, 'id' => "cfguserdomain")); +$text_userdomain = new html_inputfield(['name' => '_username_domain', 'size' => 30, 'id' => 'cfguserdomain']); echo $text_userdomain->show($RCI->getprop('username_domain')); ?> @@ -381,8 +375,8 @@ echo $text_userdomain->show($RCI->getprop('username_domain'));
'_auto_create_user', 'id' => "cfgautocreate")); -echo $check_autocreate->show(intval($RCI->getprop('auto_create_user')), array('value' => 1)); +$check_autocreate = new html_checkbox(['name' => '_auto_create_user', 'id' => 'cfgautocreate']); +echo $check_autocreate->show(intval($RCI->getprop('auto_create_user')), ['value' => 1]); ?>
@@ -398,7 +392,7 @@ what means that you have to create those records manually or disable this option
'_sent_mbox', 'size' => 20, 'id' => "cfgsentmbox")); +$text_sentmbox = new html_inputfield(['name' => '_sent_mbox', 'size' => 20, 'id' => 'cfgsentmbox']); echo $text_sentmbox->show($RCI->getprop('sent_mbox')); ?> @@ -411,7 +405,7 @@ echo $text_sentmbox->show($RCI->getprop('sent_mbox'));
'_trash_mbox', 'size' => 20, 'id' => "cfgtrashmbox")); +$text_trashmbox = new html_inputfield(['name' => '_trash_mbox', 'size' => 20, 'id' => 'cfgtrashmbox']); echo $text_trashmbox->show($RCI->getprop('trash_mbox')); ?> @@ -424,7 +418,7 @@ echo $text_trashmbox->show($RCI->getprop('trash_mbox'));
'_drafts_mbox', 'size' => 20, 'id' => "cfgdraftsmbox")); +$text_draftsmbox = new html_inputfield(['name' => '_drafts_mbox', 'size' => 20, 'id' => 'cfgdraftsmbox']); echo $text_draftsmbox->show($RCI->getprop('drafts_mbox')); ?> @@ -437,7 +431,7 @@ echo $text_draftsmbox->show($RCI->getprop('drafts_mbox'));
'_junk_mbox', 'size' => 20, 'id' => "cfgjunkmbox")); +$text_junkmbox = new html_inputfield(['name' => '_junk_mbox', 'size' => 20, 'id' => 'cfgjunkmbox']); echo $text_junkmbox->show($RCI->getprop('junk_mbox')); ?> @@ -450,7 +444,6 @@ echo $text_junkmbox->show($RCI->getprop('junk_mbox'));
-
SMTP Settings
@@ -458,7 +451,7 @@ echo $text_junkmbox->show($RCI->getprop('junk_mbox'));
'_smtp_server', 'size' => 30, 'id' => "cfgsmtphost")); +$text_smtphost = new html_inputfield(['name' => '_smtp_server', 'size' => 30, 'id' => 'cfgsmtphost']); echo $text_smtphost->show($RCI->getprop('smtp_server', 'localhost')); ?> @@ -471,7 +464,7 @@ echo $text_smtphost->show($RCI->getprop('smtp_server', 'localhost'));
'_smtp_port', 'size' => 6, 'id' => "cfgsmtpport")); +$text_smtpport = new html_inputfield(['name' => '_smtp_port', 'size' => 6, 'id' => 'cfgsmtpport']); echo $text_smtpport->show($RCI->getprop('smtp_port')); ?> @@ -482,8 +475,8 @@ echo $text_smtpport->show($RCI->getprop('smtp_port'));
'_smtp_user', 'size' => 20, 'id' => "cfgsmtpuser")); -$text_smtppass = new html_inputfield(array('name' => '_smtp_pass', 'size' => 20, 'id' => "cfgsmtppass")); +$text_smtpuser = new html_inputfield(['name' => '_smtp_user', 'size' => 20, 'id' => 'cfgsmtpuser']); +$text_smtppass = new html_inputfield(['name' => '_smtp_pass', 'size' => 20, 'id' => 'cfgsmtppass']); echo $text_smtpuser->show($RCI->getprop('smtp_user')); echo $text_smtppass->show($RCI->getprop('smtp_pass')); @@ -492,32 +485,20 @@ echo $text_smtppass->show($RCI->getprop('smtp_pass'));

'_smtp_user_u', 'id' => "cfgsmtpuseru")); -echo $check_smtpuser->show($RCI->getprop('smtp_user') == '%u' || $_POST['_smtp_user_u'] ? 1 : 0, array('value' => 1)); +$check_smtpuser = new html_checkbox(['name' => '_smtp_user_u', 'id' => 'cfgsmtpuseru']); +echo $check_smtpuser->show($RCI->getprop('smtp_user') == '%u' || !empty($_POST['_smtp_user_u']) ? 1 : 0, ['value' => 1]); ?>

- +
smtp_log
'_smtp_log', 'id' => "cfgsmtplog")); -echo $check_smtplog->show(intval($RCI->getprop('smtp_log')), array('value' => 1)); +$check_smtplog = new html_checkbox(['name' => '_smtp_log', 'id' => 'cfgsmtplog']); +echo $check_smtplog->show(intval($RCI->getprop('smtp_log')), ['value' => 1]); ?>
@@ -535,7 +516,7 @@ echo $check_smtplog->show(intval($RCI->getprop('smtp_log')), array('value' => 1)
'_language', 'size' => 6, 'id' => "cfglocale")); +$input_locale = new html_inputfield(['name' => '_language', 'size' => 6, 'id' => 'cfglocale']); echo $input_locale->show($RCI->getprop('language')); ?> @@ -547,7 +528,7 @@ echo $input_locale->show($RCI->getprop('language'));
'_skin', 'id' => "cfgskin")); +$input_skin = new html_select(['name' => '_skin', 'id' => 'cfgskin']); $input_skin->add($RCI->list_skins()); echo $input_skin->show($RCI->getprop('skin')); @@ -563,7 +544,7 @@ $pagesize = $RCI->getprop('mail_pagesize'); if (!$pagesize) { $pagesize = $RCI->getprop('pagesize'); } -$input_pagesize = new html_inputfield(array('name' => '_mail_pagesize', 'size' => 6, 'id' => "cfgmailpagesize")); +$input_pagesize = new html_inputfield(['name' => '_mail_pagesize', 'size' => 6, 'id' => 'cfgmailpagesize']); echo $input_pagesize->show($pagesize); ?> @@ -578,7 +559,7 @@ $pagesize = $RCI->getprop('addressbook_pagesize'); if (!$pagesize) { $pagesize = $RCI->getprop('pagesize'); } -$input_pagesize = new html_inputfield(array('name' => '_addressbook_pagesize', 'size' => 6, 'id' => "cfgabookpagesize")); +$input_pagesize = new html_inputfield(['name' => '_addressbook_pagesize', 'size' => 6, 'id' => 'cfgabookpagesize']); echo $input_pagesize->show($pagesize); ?> @@ -589,7 +570,7 @@ echo $input_pagesize->show($pagesize);
'_prefer_html', 'id' => "cfghtmlview", 'value' => 1)); +$check_htmlview = new html_checkbox(['name' => '_prefer_html', 'id' => 'cfghtmlview', 'value' => 1]); echo $check_htmlview->show(intval($RCI->getprop('prefer_html'))); ?> @@ -601,7 +582,7 @@ echo $check_htmlview->show(intval($RCI->getprop('prefer_html'))); '_htmleditor', 'id' => "cfghtmlcompose")); +$select_htmlcomp = new html_select(['name' => '_htmleditor', 'id' => 'cfghtmlcompose']); $select_htmlcomp->add('never', 0); $select_htmlcomp->add('always', 1); $select_htmlcomp->add('on reply to HTML message only', 2); @@ -615,10 +596,11 @@ echo $select_htmlcomp->show(intval($RCI->getprop('htmleditor'))); '_draft_autosave', 'id' => 'cfgautosave')); +$select_autosave = new html_select(['name' => '_draft_autosave', 'id' => 'cfgautosave']); $select_autosave->add('never', 0); -foreach (array(1, 3, 5, 10) as $i => $min) - $select_autosave->add("$min min", $min*60); +foreach ([1, 3, 5, 10] as $i => $min) { + $select_autosave->add("$min min", $min * 60); +} echo $select_autosave->show(intval($RCI->getprop('draft_autosave'))); @@ -629,15 +611,15 @@ echo $select_autosave->show(intval($RCI->getprop('draft_autosave')));
'ask the user', 1 => 'send automatically', 3 => 'send receipt to user contacts, otherwise ask the user', 4 => 'send receipt to user contacts, otherwise ignore', 2 => 'ignore', -); +]; -$select_mdnreq = new html_select(array('name' => '_mdn_requests', 'id' => "cfgmdnreq")); +$select_mdnreq = new html_select(['name' => '_mdn_requests', 'id' => 'cfgmdnreq']); $select_mdnreq->add(array_values($mdn_opts), array_keys($mdn_opts)); echo $select_mdnreq->show(intval($RCI->getprop('mdn_requests'))); @@ -649,7 +631,7 @@ echo $select_mdnreq->show(intval($RCI->getprop('mdn_requests')));
'_mime_param_folding', 'id' => "cfgmimeparamfolding")); +$select_param_folding = new html_select(['name' => '_mime_param_folding', 'id' => 'cfgmimeparamfolding']); $select_param_folding->add('Full RFC 2231 (Roundcube, Thunderbird)', '0'); $select_param_folding->add('RFC 2047/2231 (MS Outlook, OE)', '1'); $select_param_folding->add('Full RFC 2047 (deprecated)', '2'); @@ -665,7 +647,6 @@ echo $select_param_folding->show(strval($RCI->getprop('mime_param_folding')));

*  These settings are defaults for the user preferences

-
Plugins
@@ -673,7 +654,7 @@ echo $select_param_folding->show(strval($RCI->getprop('mime_param_folding'))); list_plugins(); foreach ($plugins as $p) { - $p_check = new html_checkbox(array('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 '
'; diff --git a/installer/index.php b/installer/index.php index e17aa8dee..3fe302672 100644 --- a/installer/index.php +++ b/installer/index.php @@ -42,53 +42,56 @@ define('INSTALL_PATH', realpath(__DIR__ . '/../').'/'); require INSTALL_PATH . 'program/include/iniset.php'; -if (function_exists('session_start')) - session_start(); +if (function_exists('session_start')) { + session_start(); +} $RCI = rcmail_install::get_instance(); $RCI->load_config(); if (isset($_GET['_getconfig'])) { - $filename = 'config.inc.php'; - if (!empty($_SESSION['config']) && $_GET['_getconfig'] == 2) { - $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename; - @unlink($path); - file_put_contents($path, $_SESSION['config']); - exit; - } - else if (!empty($_SESSION['config'])) { - header('Content-type: text/plain'); - header('Content-Disposition: attachment; filename="'.$filename.'"'); - echo $_SESSION['config']; - exit; - } - else { + $filename = 'config.inc.php'; + if (!empty($_SESSION['config']) && $_GET['_getconfig'] == 2) { + $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename; + @unlink($path); + file_put_contents($path, $_SESSION['config']); + exit; + } + + if (!empty($_SESSION['config'])) { + header('Content-type: text/plain'); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + echo $_SESSION['config']; + exit; + } + header('HTTP/1.0 404 Not found'); die("The requested configuration was not found. Please run the installer from the beginning."); - } } -if ($RCI->configured && ($RCI->getprop('enable_installer') || $_SESSION['allowinstaller']) && - !empty($_GET['_mergeconfig'])) { - $filename = 'config.inc.php'; +if ( + $RCI->configured + && ($RCI->getprop('enable_installer') || $_SESSION['allowinstaller']) && + !empty($_GET['_mergeconfig']) +) { + $filename = 'config.inc.php'; - header('Content-type: text/plain'); - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-type: text/plain'); + header('Content-Disposition: attachment; filename="'.$filename.'"'); - $RCI->merge_config(); - echo $RCI->create_config(); - exit; + $RCI->merge_config(); + echo $RCI->create_config(); + exit; } // go to 'check env' step if we have a local configuration if ($RCI->configured && empty($_REQUEST['_step'])) { - header("Location: ./?_step=1"); - exit; + header("Location: ./?_step=1"); + exit; } ?> - + Roundcube Webmail Installer @@ -113,22 +116,23 @@ if ($RCI->configured && empty($_REQUEST['_step'])) { configured && !$RCI->getprop('enable_installer') && !$_SESSION['allowinstaller']) { +// exit if installation is complete +if ($RCI->configured && !$RCI->getprop('enable_installer') && empty($_SESSION['allowinstaller'])) { // header("HTTP/1.0 404 Not Found"); if ($RCI->configured && $RCI->legacy_config) { - echo '

Your configuration needs to be migrated!

'; - echo '

We changed the configuration files structure and your installation needs to be updated accordingly.

'; - echo '

Please run the bin/update.sh script from the command line or set

  $rcube_config[\'enable_installer\'] = true;

'; - echo ' in your RCUBE_CONFIG_DIR/main.inc.php to let the installer help you migrating it.

'; + echo '

Your configuration needs to be migrated!

'; + echo '

We changed the configuration files structure and your installation needs to be updated accordingly.

'; + echo '

Please run the bin/update.sh script from the command line or set

  $rcube_config[\'enable_installer\'] = true;

'; + echo ' in your RCUBE_CONFIG_DIR/main.inc.php to let the installer help you migrating it.

'; } else { - echo '

The installer is disabled!

'; - echo '

To enable it again, set $config[\'enable_installer\'] = true; in RCUBE_CONFIG_DIR/config.inc.php

'; + echo '

The installer is disabled!

'; + echo '

To enable it again, set $config[\'enable_installer\'] = true; in RCUBE_CONFIG_DIR/config.inc.php

'; } + echo ''; exit; - } +} ?> @@ -136,21 +140,21 @@ if ($RCI->configured && empty($_REQUEST['_step'])) {
    './check.php', 2 => './config.php', 3 => './test.php', - ); +]; - if (!in_array($RCI->step, array_keys($include_steps))) { +if (!in_array($RCI->step, array_keys($include_steps))) { $RCI->step = 1; - } +} - foreach (array('Check environment', 'Create config', 'Test config') as $i => $item) { +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('
  1. %s
  2. ', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link); - } +} ?>
@@ -162,7 +166,7 @@ include $include_steps[$RCI->step]; diff --git a/installer/test.php b/installer/test.php index 0566fa7a6..6594d978c 100644 --- a/installer/test.php +++ b/installer/test.php @@ -24,73 +24,74 @@ if (!class_exists('rcmail_install', false) || !isset($RCI)) { load_config_file(RCUBE_CONFIG_DIR . 'defaults.inc.php'); - if (!empty($config)) { - $RCI->pass('defaults.inc.php'); - } - else { - $RCI->fail('defaults.inc.php', 'Syntax error'); - } + $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'defaults.inc.php'); + if (!empty($config)) { + $RCI->pass('defaults.inc.php'); + } + else { + $RCI->fail('defaults.inc.php', 'Syntax error'); + } } else { - $RCI->fail('defaults.inc.php', 'Unable to read default config file?'); + $RCI->fail('defaults.inc.php', 'Unable to read default config file?'); } + echo '
'; if ($read_config = is_readable(RCUBE_CONFIG_DIR . 'config.inc.php')) { - $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'config.inc.php'); - if (!empty($config)) { - $RCI->pass('config.inc.php'); - } - else { - $RCI->fail('config.inc.php', 'Syntax error'); - } + $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'config.inc.php'); + if (!empty($config)) { + $RCI->pass('config.inc.php'); + } + else { + $RCI->fail('config.inc.php', 'Syntax error'); + } } else { - $RCI->fail('config.inc.php', 'Unable to read file. Did you create the config file?'); + $RCI->fail('config.inc.php', 'Unable to read file. Did you create the config file?'); } + echo '
'; - if ($RCI->configured && ($messages = $RCI->check_config())) { - if (is_array($messages['replaced'])) { - echo '

Replaced config options

'; - echo '

The following config options have been replaced or renamed. '; - echo 'Please update them accordingly in your config files.

'; + if (is_array($messages['replaced'])) { + echo '

Replaced config options

'; + echo '

The following config options have been replaced or renamed. '; + echo 'Please update them accordingly in your config files.

'; - echo '
    '; - foreach ($messages['replaced'] as $msg) { - echo html::tag('li', null, html::span('propname', $msg['prop']) . - ' was replaced by ' . html::span('propname', $msg['replacement'])); + echo '
      '; + foreach ($messages['replaced'] as $msg) { + echo html::tag('li', null, html::span('propname', $msg['prop']) . + ' was replaced by ' . html::span('propname', $msg['replacement'])); + } + echo '
    '; } - echo '
'; - } - if (is_array($messages['obsolete'])) { - echo '

Obsolete config options

'; - echo '

You still have some obsolete or inexistent properties set. This isn\'t a problem but should be noticed.

'; + if (is_array($messages['obsolete'])) { + echo '

Obsolete config options

'; + echo '

You still have some obsolete or inexistent properties set. This isn\'t a problem but should be noticed.

'; - echo '
    '; - foreach ($messages['obsolete'] as $msg) { - echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ': ' . $msg['name'] : '')); + echo '
      '; + foreach ($messages['obsolete'] as $msg) { + echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ': ' . $msg['name'] : '')); + } + echo '
    '; } - echo '
'; - } - echo '

OK, lazy people can download the updated config file here: '; - echo html::a(array('href' => './?_mergeconfig=1'), 'config.inc.php') . '  '; - echo "

"; + echo '

OK, lazy people can download the updated config file here: '; + echo html::a(['href' => './?_mergeconfig=1'], 'config.inc.php') . '  '; + echo "

"; - if (is_array($messages['dependencies'])) { - echo '

Dependency check failed

'; - echo '

Some of your configuration settings require other options to be configured or additional PHP modules to be installed

'; + if (is_array($messages['dependencies'])) { + echo '

Dependency check failed

'; + echo '

Some of your configuration settings require other options to be configured or additional PHP modules to be installed

'; - echo '
    '; - foreach ($messages['dependencies'] as $msg) { - echo html::tag('li', null, html::span('propname', $msg['prop']) . ': ' . $msg['explain']); + echo '
      '; + foreach ($messages['dependencies'] as $msg) { + echo html::tag('li', null, html::span('propname', $msg['prop']) . ': ' . $msg['explain']); + } + echo '
    '; } - echo '
'; - } } ?> @@ -99,9 +100,10 @@ if ($RCI->configured && ($messages = $RCI->check_config())) {

Roundcube may need to write/save files into these directories

config['temp_dir'] ? $RCI->config['temp_dir'] : 'temp'; -if ($RCI->config['log_driver'] != 'syslog') +$dirs[] = !empty($RCI->config['temp_dir']) ? $RCI->config['temp_dir'] : 'temp'; +if ($RCI->config['log_driver'] != 'syslog') { $dirs[] = $RCI->config['log_dir'] ? $RCI->config['log_dir'] : 'logs'; +} foreach ($dirs as $dir) { $dirpath = rcube_utils::is_absolute_path($dir) ? $dir : INSTALL_PATH . $dir; @@ -151,14 +153,14 @@ else { } // initialize db with schema found in /SQL/* -if ($db_working && $_POST['initdb']) { +if ($db_working && !empty($_POST['initdb'])) { if (!$RCI->init_db($DB)) { $db_working = false; echo '

Please try to inizialize the database manually as described in the INSTALL guide. Make sure that the configured database extists and that the user as write privileges

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

Database schema update failed.

'; } @@ -175,7 +177,7 @@ if ($db_working) { else if ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { $RCI->fail('DB Schema', "Database schema differs"); echo '
  • ' . join("
  • \n
  • ", $err) . "
"; - $select = $RCI->versions_select(array('name' => 'version')); + $select = $RCI->versions_select(['name' => 'version']); $select->add('0.9 or newer', ''); echo '

You should run the update queries to get the schema fixed.

Version to update from: ' . $select->show('') . ' 

'; $db_working = false; @@ -199,12 +201,12 @@ if ($db_working) { . " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id); if ($db_write) { - $RCI->pass('DB Write'); - $DB->query("DELETE FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session') - . " WHERE `sess_id` = ?", $insert_id); + $RCI->pass('DB Write'); + $DB->query("DELETE FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session') + . " WHERE `sess_id` = ?", $insert_id); } else { - $RCI->fail('DB Write', $RCI->get_error()); + $RCI->fail('DB Write', $RCI->get_error()); } echo '
'; @@ -237,52 +239,52 @@ if ($db_working) { check_mime_detection()) { - $RCI->fail('Fileinfo/mime_content_type configuration'); - if (!empty($RCI->config['mime_magic'])) { - echo '

Try setting the mime_magic config option to null.

'; - } - else { - echo '

Check the Fileinfo functions of your PHP installation.
'; - echo 'The path to the magic.mime file can be set using the mime_magic config option in Roundcube.

'; - } + $RCI->fail('Fileinfo/mime_content_type configuration'); + if (!empty($RCI->config['mime_magic'])) { + echo '

Try setting the mime_magic config option to null.

'; + } + else { + echo '

Check the Fileinfo functions of your PHP installation.
'; + echo 'The path to the magic.mime file can be set using the mime_magic config option in Roundcube.

'; + } } else { - $RCI->pass('Fileinfo/mime_content_type configuration'); - echo "
"; + $RCI->pass('Fileinfo/mime_content_type configuration'); + echo "
"; } if ($errors = $RCI->check_mime_extensions()) { - $RCI->fail('Mimetype to file extension mapping'); - echo '

Please set a valid path to your webserver\'s mime.types file to the mime_types config option.
'; - echo 'If you can\'t find such a file, download it from svn.apache.org.

'; + $RCI->fail('Mimetype to file extension mapping'); + echo '

Please set a valid path to your webserver\'s mime.types file to the mime_types config option.
'; + echo 'If you can\'t find such a file, download it from svn.apache.org.

'; } else { - $RCI->pass('Mimetype to file extension mapping'); - echo "
"; + $RCI->pass('Mimetype to file extension mapping'); + echo "
"; } $smtp_hosts = $RCI->get_hostlist('smtp_server'); if (!empty($smtp_hosts)) { - $smtp_host_field = new html_select(array('name' => '_smtp_host', 'id' => 'smtp_server')); - $smtp_host_field->add($smtp_hosts); + $smtp_host_field = new html_select(['name' => '_smtp_host', 'id' => 'smtp_server']); + $smtp_host_field->add($smtp_hosts); } else { - $smtp_host_field = new html_inputfield(array('name' => '_smtp_host', 'id' => 'smtp_server')); + $smtp_host_field = new html_inputfield(['name' => '_smtp_host', 'id' => 'smtp_server']); } $user = $RCI->getprop('smtp_user', '(none)'); $pass = $RCI->getprop('smtp_pass', '(none)'); if ($user == '%u') { - $user_field = new html_inputfield(array('name' => '_smtp_user', 'id' => 'smtp_user')); - $user = $user_field->show($_POST['_smtp_user']); + $user_field = new html_inputfield(['name' => '_smtp_user', 'id' => 'smtp_user']); + $user = $user_field->show(isset($_POST['_smtp_user']) ? $_POST['_smtp_user'] : ''); } else { $user = html::quote($user); } if ($pass == '%p') { - $pass_field = new html_passwordfield(array('name' => '_smtp_pass', 'id' => 'smtp_pass')); + $pass_field = new html_passwordfield(['name' => '_smtp_pass', 'id' => 'smtp_pass']); $pass = $pass_field->show(); } else { @@ -298,7 +300,7 @@ else { - show($_POST['_smtp_host']); ?> + show(isset($_POST['_smtp_host']) ? $_POST['_smtp_host'] : ''); ?> @@ -318,62 +320,63 @@ else { '_from', 'id' => 'sendmailfrom')); -$to_field = new html_inputfield(array('name' => '_to', 'id' => 'sendmailto')); +$from_field = new html_inputfield(['name' => '_from', 'id' => 'sendmailfrom']); +$to_field = new html_inputfield(['name' => '_to', 'id' => 'sendmailto']); if (isset($_POST['sendmail'])) { - echo '

Trying to send email...
'; + echo '

Trying to send email...
'; - $smtp_host = trim($_POST['_smtp_host']); - $smtp_port = $RCI->getprop('smtp_port'); + $smtp_host = trim($_POST['_smtp_host']); + $smtp_port = $RCI->getprop('smtp_port'); - $from = rcube_utils::idn_to_ascii(trim($_POST['_from'])); - $to = rcube_utils::idn_to_ascii(trim($_POST['_to'])); + $from = rcube_utils::idn_to_ascii(trim($_POST['_from'])); + $to = rcube_utils::idn_to_ascii(trim($_POST['_to'])); - if (preg_match('/^' . $RCI->email_pattern . '$/i', $from) && - preg_match('/^' . $RCI->email_pattern . '$/i', $to) - ) { - $headers = array( - 'From' => $from, - 'To' => $to, - 'Subject' => 'Test message from Roundcube', - ); + if ( + preg_match('/^' . $RCI->email_pattern . '$/i', $from) + && preg_match('/^' . $RCI->email_pattern . '$/i', $to) + ) { + $headers = [ + 'From' => $from, + 'To' => $to, + 'Subject' => 'Test message from Roundcube', + ]; - $body = 'This is a test to confirm that Roundcube can send email.'; + $body = 'This is a test to confirm that Roundcube can send email.'; - // send mail using configured SMTP server - $CONFIG = $RCI->config; + // send mail using configured SMTP server + $CONFIG = $RCI->config; - if (!empty($_POST['_smtp_user'])) { - $CONFIG['smtp_user'] = $_POST['_smtp_user']; - } - if (!empty($_POST['_smtp_pass'])) { - $CONFIG['smtp_pass'] = $_POST['_smtp_pass']; - } + if (!empty($_POST['_smtp_user'])) { + $CONFIG['smtp_user'] = $_POST['_smtp_user']; + } + if (!empty($_POST['_smtp_pass'])) { + $CONFIG['smtp_pass'] = $_POST['_smtp_pass']; + } - $mail_object = new Mail_mime(); - $send_headers = $mail_object->headers($headers); - $head = $mail_object->txtHeaders($send_headers); + $mail_object = new Mail_mime(); + $send_headers = $mail_object->headers($headers); + $head = $mail_object->txtHeaders($send_headers); - $SMTP = new rcube_smtp(); - $SMTP->connect($smtp_host, $smtp_port, $CONFIG['smtp_user'], $CONFIG['smtp_pass']); + $SMTP = new rcube_smtp(); + $SMTP->connect($smtp_host, $smtp_port, $CONFIG['smtp_user'], $CONFIG['smtp_pass']); - $status = $SMTP->send_mail($headers['From'], $headers['To'], $head, $body); - $smtp_response = $SMTP->get_response(); + $status = $SMTP->send_mail($headers['From'], $headers['To'], $head, $body); + $smtp_response = $SMTP->get_response(); - if ($status) { - $RCI->pass('SMTP send'); + if ($status) { + $RCI->pass('SMTP send'); + } + else { + $RCI->fail('SMTP send', join('; ', $smtp_response)); + } } else { - $RCI->fail('SMTP send', join('; ', $smtp_response)); + $RCI->fail('SMTP send', 'Invalid sender or recipient'); } - } - else { - $RCI->fail('SMTP send', 'Invalid sender or recipient'); - } - echo '

'; + echo '

'; } ?> @@ -382,11 +385,11 @@ if (isset($_POST['sendmail'])) { - show($_POST['_from']); ?> + show(isset($_POST['_from']) ? $_POST['_from'] : ''); ?> - show($_POST['_to']); ?> + show(isset($_POST['_to']) ? $_POST['_to'] : ''); ?> @@ -400,15 +403,15 @@ if (isset($_POST['sendmail'])) { $default_hosts = $RCI->get_hostlist(); if (!empty($default_hosts)) { - $host_field = new html_select(array('name' => '_host', 'id' => 'imaphost')); - $host_field->add($default_hosts); + $host_field = new html_select(['name' => '_host', 'id' => 'imaphost']); + $host_field->add($default_hosts); } else { - $host_field = new html_inputfield(array('name' => '_host', 'id' => 'imaphost')); + $host_field = new html_inputfield(['name' => '_host', 'id' => 'imaphost']); } -$user_field = new html_inputfield(array('name' => '_user', 'id' => 'imapuser')); -$pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass')); +$user_field = new html_inputfield(['name' => '_user', 'id' => 'imapuser']); +$pass_field = new html_passwordfield(['name' => '_pass', 'id' => 'imappass']); ?> @@ -416,7 +419,7 @@ $pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass' - show($_POST['_host']); ?> + show(isset($_POST['_host']) ? $_POST['_host'] : ''); ?> Port @@ -424,7 +427,7 @@ $pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass' - show($_POST['_user']); ?> + show(isset($_POST['_user']) ? $_POST['_user'] : ''); ?> @@ -437,39 +440,41 @@ $pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass' if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) { - echo '

Connecting to ' . rcube::Q($_POST['_host']) . '...
'; + echo '

Connecting to ' . rcube::Q($_POST['_host']) . '...
'; - $imap_host = trim($_POST['_host']); - $imap_port = $RCI->getprop('default_port'); - $imap_ssl = false; - $a_host = parse_url($imap_host); + $imap_host = trim($_POST['_host']); + $imap_port = $RCI->getprop('default_port'); + $imap_ssl = false; + $a_host = parse_url($imap_host); - if ($a_host['host']) { - $imap_host = $a_host['host']; - $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; - if (isset($a_host['port'])) - $imap_port = $a_host['port']; - else if ($imap_ssl && $imap_ssl != 'tls' && (!$imap_port || $imap_port == 143)) - $imap_port = 993; - } + if ($a_host['host']) { + $imap_host = $a_host['host']; + $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl','imaps','tls'])) ? $a_host['scheme'] : null; + if (isset($a_host['port'])) { + $imap_port = $a_host['port']; + } + else if ($imap_ssl && $imap_ssl != 'tls' && (!$imap_port || $imap_port == 143)) { + $imap_port = 993; + } + } - $imap_host = rcube_utils::idn_to_ascii($imap_host); - $imap_user = rcube_utils::idn_to_ascii($_POST['_user']); + $imap_host = rcube_utils::idn_to_ascii($imap_host); + $imap_user = rcube_utils::idn_to_ascii($_POST['_user']); - $imap = new rcube_imap; - $imap->set_options(array( - 'auth_type' => $RCI->getprop('imap_auth_type'), - 'debug' => $RCI->getprop('imap_debug'), - 'socket_options' => $RCI->getprop('imap_conn_options'), - )); + $imap = new rcube_imap; + $imap->set_options([ + 'auth_type' => $RCI->getprop('imap_auth_type'), + 'debug' => $RCI->getprop('imap_debug'), + 'socket_options' => $RCI->getprop('imap_conn_options'), + ]); - if ($imap->connect($imap_host, $imap_user, $_POST['_pass'], $imap_port, $imap_ssl)) { - $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no')); - $imap->close(); - } - else { - $RCI->fail('IMAP connect', $RCI->get_error()); - } + if ($imap->connect($imap_host, $imap_user, $_POST['_pass'], $imap_port, $imap_ssl)) { + $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no')); + $imap->close(); + } + else { + $RCI->fail('IMAP connect', $RCI->get_error()); + } } ?> diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php index e0d9c260a..7514fbbfd 100644 --- a/plugins/new_user_identity/new_user_identity.php +++ b/plugins/new_user_identity/new_user_identity.php @@ -72,6 +72,10 @@ class new_user_identity extends rcube_plugin 'host' => $this->rc->user->data['mail_host'], ]); + if (empty($ldap_entry['email_list'])) { + return $args; + } + foreach ((array) $ldap_entry['email_list'] as $email) { foreach ($identities as $identity) { if ($identity['email'] == $email) { @@ -93,6 +97,7 @@ class new_user_identity extends rcube_plugin $this->rc->user->insert_identity($plugin['record']); } } + return $args; } diff --git a/program/actions/settings/identity_edit.php b/program/actions/settings/identity_edit.php index 4252bfeb6..b7760696d 100644 --- a/program/actions/settings/identity_edit.php +++ b/program/actions/settings/identity_edit.php @@ -206,7 +206,7 @@ class rcmail_action_settings_identity_edit extends rcmail_action $value = $colprop['value']; } else { - $val = isset(self::$record[$col]) ? self::$record[$col] : ''; + $val = isset(self::$record[$col]) ? self::$record[$col] : ''; $value = rcube_output::get_edit_field($col, $val, $colprop, $colprop['type']); } diff --git a/program/actions/settings/identity_save.php b/program/actions/settings/identity_save.php index 19e100b66..95a1722ee 100644 --- a/program/actions/settings/identity_save.php +++ b/program/actions/settings/identity_save.php @@ -34,7 +34,7 @@ class rcmail_action_settings_identity_save extends rcmail_action $a_save_cols = ['name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature']; $a_boolean_cols = ['standard', 'html_signature']; - $updated = $default_id = false; + $updated = false; // check input if (empty($_POST['_email']) && ($IDENTITIES_LEVEL == 0 || $IDENTITIES_LEVEL == 2)) { diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php index 185f063d3..9cfd150d7 100644 --- a/program/include/rcmail_install.php +++ b/program/include/rcmail_install.php @@ -158,7 +158,7 @@ class rcmail_install } } else if ($in_config && $token[0] == T_COMMENT) { - $buffer .= strtr($token[1], ['\n' => "\n"]); + $buffer .= strtr($token[1], ['\n' => "\n"]) . "\n"; } } } @@ -172,7 +172,7 @@ class rcmail_install * @param string $name Property name * @param string $default Default value * - * @return string The property value + * @return mixed The property value */ public function getprop($name, $default = '') { diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index d3f948645..4a71bf722 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -384,70 +384,6 @@ function version_parse($version) ); } -// intl replacement functions - -if (!function_exists('idn_to_utf8')) -{ - /** - * Convert domain name from IDNA ASCII to Unicode - * - * @param string $domain Domain to convert in an IDNA ASCII-compatible format. - * - * @return string|false Unicode domain, False on failure - */ - function idn_to_utf8($domain) - { - static $idn, $loaded; - - if (!$loaded) { - $idn = new Net_IDNA2(['version' => '2008']); - $loaded = true; - } - - if ($idn && $domain && preg_match('/(^|\.)xn--/i', $domain)) { - try { - $domain = $idn->decode($domain); - } - catch (Exception $e) { - return false; - } - } - - return $domain; - } -} - -if (!function_exists('idn_to_ascii')) -{ - /** - * Convert domain name to IDNA ASCII-compatible form Unicode - * - * @param string $domain The domain to convert, which must be UTF-8 encoded - * - * @return string|false The domain name encoded in ASCII-compatible form, False on failure - */ - function idn_to_ascii($domain) - { - static $idn, $loaded; - - if (!$loaded) { - $idn = new Net_IDNA2(['version' => '2008']); - $loaded = true; - } - - if ($idn && $domain && preg_match('/[^\x20-\x7E]/', $domain)) { - try { - $domain = $idn->encode($domain); - } - catch (Exception $e) { - return false; - } - } - - return $domain; - } -} - /** * Use PHP5 autoload for dynamic class loading * diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php index aa85dae29..b6724b4f4 100644 --- a/program/lib/Roundcube/html.php +++ b/program/lib/Roundcube/html.php @@ -332,7 +332,7 @@ class html // attributes with no value if (in_array($key, self::$bool_attrib)) { - if ($value) { + if (!empty($value)) { $value = $key; if (self::$doctype == 'xhtml') { $value .= '="' . $value . '"'; @@ -342,7 +342,7 @@ class html } } else { - $attrib_arr[] = $key . '="' . self::quote($value) . '"'; + $attrib_arr[] = $key . '="' . self::quote((string) $value) . '"'; } } @@ -385,6 +385,11 @@ class html */ public static function quote($str) { + // PHP8 does not like e.g. an array as htmlspecialchars() argument + if (!is_string($str)) { + return (string) $str; + } + return @htmlspecialchars($str, ENT_COMPAT | ENT_SUBSTITUTE, RCUBE_CHARSET); } } @@ -692,7 +697,10 @@ class html_select extends html { if (is_array($names)) { foreach ($names as $i => $text) { - $this->options[] = ['text' => $text, 'value' => $values[$i]] + $attrib; + $this->options[] = [ + 'text' => $text, + 'value' => isset($values[$i]) ? $values[$i] : '' + ] + $attrib; } } else { diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 8e0a184ab..d7c41da54 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1291,13 +1291,14 @@ class rcube // trigger logging hook if (is_object(self::$instance) && is_object(self::$instance->plugins)) { $log = self::$instance->plugins->exec_hook('write_log', - ['name' => $name, 'date' => $date, 'line' => $line]); + ['name' => $name, 'date' => $date, 'line' => $line] + ); $name = $log['name']; $line = $log['line']; $date = $log['date']; - if ($log['abort']) { + if (!empty($log['abort'])) { return true; } } diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 1bc600f99..5d66bd067 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -1024,7 +1024,6 @@ class rcube_utils // Because php-intl extension lowercases domains and return false // on invalid input (#6224), we skip conversion when not needed - // for compatibility with our Net_IDNA2 wrappers in bootstrap.php if ($is_utf) { if (preg_match('/[^\x20-\x7E]/', $domain)) {