Browse Source

PHP8 fixes, short array syntax

pull/7779/head
Aleksander Machniak 5 years ago
parent
commit
61a5ade872
  1. 6
      bin/cleandb.sh
  2. 6
      bin/deluser.sh
  3. 4
      bin/initdb.sh
  4. 43
      bin/install-jsdeps.sh
  5. 19
      bin/installto.sh
  6. 12
      bin/moduserprefs.sh
  7. 28
      bin/msgexport.sh
  8. 31
      bin/msgimport.sh
  9. 106
      bin/package2composer.sh
  10. 51
      bin/update.sh
  11. 14
      bin/updatecss.sh
  12. 12
      bin/updatedb.sh
  13. 2
      program/lib/Roundcube/rcube.php
  14. 9
      program/lib/Roundcube/rcube_imap.php
  15. 5
      program/lib/Roundcube/rcube_utils.php

6
bin/cleandb.sh

@ -21,9 +21,11 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require INSTALL_PATH.'program/include/clisetup.php';
if (!empty($_SERVER['argv'][1]))
if (!empty($_SERVER['argv'][1])) {
$days = intval($_SERVER['argv'][1]);
else
}
else {
$days = 7;
}
rcmail_utils::db_clean($days);

6
bin/deluser.sh

@ -41,7 +41,7 @@ function _die($msg, $usage=false)
$rcmail = rcube::get_instance();
// get arguments
$args = rcube_utils::get_opt(array('h' => 'host', 'a' => 'age', 'd' => 'dry-run:bool'));
$args = rcube_utils::get_opt(['h' => 'host', 'a' => 'age', 'd' => 'dry-run:bool']);
if (!empty($args['age']) && ($age = intval($args['age']))) {
$db = $rcmail->get_dbh();
@ -103,7 +103,7 @@ if (!$user) {
}
// inform plugins about approaching user deletion
$plugin = $rcmail->plugins->exec_hook('user_delete_prepare', array('user' => $user, 'username' => $username, 'host' => $args['host']));
$plugin = $rcmail->plugins->exec_hook('user_delete_prepare', ['user' => $user, 'username' => $username, 'host' => $args['host']]);
// let plugins cleanup their own user-related data
if (!$plugin['abort']) {
@ -120,7 +120,7 @@ if ($plugin['abort']) {
// deleting the user record should be sufficient due to ON DELETE CASCADE foreign key references
// but not all database backends actually support this so let's do it by hand
foreach (array('identities','contacts','contactgroups','dictionary','cache','cache_index','cache_messages','cache_thread','searches','users') as $table) {
foreach (['identities','contacts','contactgroups','dictionary','cache','cache_index','cache_messages','cache_thread','searches','users'] as $table) {
$db->query('DELETE FROM ' . $db->table_name($table, true) . ' WHERE `user_id` = ?', $user->ID);
}

4
bin/initdb.sh

@ -23,9 +23,9 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array(
$opts = rcube_utils::get_opt([
'd' => 'dir',
));
]);
if (empty($opts['dir'])) {
rcube::raise_error("Database schema directory not specified (--dir).", false, true);

43
bin/install-jsdeps.sh

@ -33,9 +33,9 @@ if (empty($SOURCES['dependencies'])) {
rcube::raise_error("Failed to read dependencies list from $cfgfile", false, true);
}
$CURL = trim(`which curl`);
$WGET = trim(`which wget`);
$UNZIP = trim(`which unzip`);
$CURL = trim(`which curl`);
$WGET = trim(`which wget`);
$UNZIP = trim(`which unzip`);
if (($CACHEDIR = getenv("CACHEDIR")) && is_writeable($CACHEDIR)) {
// use $CACHEDIR
@ -50,7 +50,7 @@ else {
//////////////// License definitions
$LICENSES = array();
$LICENSES = [];
$LICENSES['MIT'] = <<<EOM
* Licensed under the MIT licenses
*
@ -122,22 +122,26 @@ function fetch_from_source($package, $useCache = true, &$filetype = null)
echo "Fetching $url\n";
if ($CURL)
if ($CURL) {
exec(sprintf('%s -L -s %s -o %s', $CURL, escapeshellarg($url), $cache_file), $out, $retval);
else
}
else {
exec(sprintf('%s -q %s -O %s', $WGET, escapeshellarg($url), $cache_file), $out, $retval);
}
// Try Github API as a fallback (#6248)
if ($retval !== 0 && $package['api_url']) {
if ($retval !== 0 && !empty($package['api_url'])) {
$url = str_replace('$v', $package['version'], $package['api_url']);
$header = 'Accept:application/vnd.github.v3.raw';
rcube::raise_error("Fetching failed. Using Github API on $url");
if ($CURL)
if ($CURL) {
exec(sprintf('%s -L -H %s -s %s -o %s', $CURL, escapeshellarg($header), escapeshellarg($url), $cache_file), $out, $retval);
else
}
else {
exec(sprintf('%s --header %s -q %s -O %s', $WGET, escapeshellarg($header), escapeshellarg($url), $cache_file), $out, $retval);
}
}
if ($retval !== 0) {
@ -245,7 +249,7 @@ function extract_zipfile($package, $srcfile)
mkdir($extract, 0774, true);
}
$zip_command = '%s -' . ($package['flat'] ? 'j' : 'o') . ' %s -d %s';
$zip_command = '%s -' . (!empty($package['flat']) ? 'j' : 'o') . ' %s -d %s';
exec(sprintf($zip_command, $UNZIP, escapeshellarg($srcfile), $extract), $out, $retval);
// get the root folder of the extracted package
@ -256,7 +260,7 @@ function extract_zipfile($package, $srcfile)
echo "Installing $sourcedir/$src into $destdir/$dest\n";
$dest_file = $destdir . '/' . $dest;
$src_file = $sourcedir . '/' . $src;
$src_file = $sourcedir . '/' . $src;
// make sure the destination's parent directory exists
if (strpos($dest, '/') !== false) {
@ -336,9 +340,20 @@ function delete_destfile($package)
//////////////// Execution
$args = rcube_utils::get_opt(array('f' => 'force:bool', 'd' => 'delete:bool', 'g' => 'get:bool', 'e' => 'extract:bool'))
+ array('force' => false, 'delete' => false, 'get' => false, 'extract' => false);
$WHAT = $args[0];
$args = rcube_utils::get_opt([
'f' => 'force:bool',
'd' => 'delete:bool',
'g' => 'get:bool',
'e' => 'extract:bool'
])
+ [
'force' => false,
'delete' => false,
'get' => false,
'extract' => false
];
$WHAT = isset($args[0]) ? $args[0] : null;
$useCache = !$args['force'] && !$args['get'];
if (!$args['get'] && !$args['extract'] && !$args['delete']) {

19
bin/installto.sh

@ -29,18 +29,21 @@ if (!function_exists('system')) {
$target_dir = unslashify(end($_SERVER['argv']));
$accept = in_array('-y', $_SERVER['argv']) ? 'y' : null;
if (empty($target_dir) || !is_dir(realpath($target_dir)))
if (empty($target_dir) || !is_dir(realpath($target_dir))) {
rcube::raise_error("Invalid target: not a directory\nUsage: installto.sh [-y] <TARGET>", false, true);
}
// read version from iniset.php
$iniset = @file_get_contents($target_dir . '/program/include/iniset.php');
if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z0-9-]*)/', $iniset, $m))
if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z0-9-]*)/', $iniset, $m)) {
rcube::raise_error("No valid Roundcube installation found at $target_dir", false, true);
}
$oldversion = $m[1];
if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>'))
if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>')) {
rcube::raise_error("Target installation already in version $oldversion.", false, true);
}
if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '==')) {
echo "Target installation already in version $oldversion. Do you want to update again? (y/N)\n";
@ -54,8 +57,8 @@ $input = $accept ?: trim(fgets(STDIN));
if (strtolower($input) == 'y') {
echo "Copying files to target location...";
$adds = array();
$dirs = array('bin','SQL','plugins','skins','program');
$adds = [];
$dirs = ['bin','SQL','plugins','skins','program'];
if (is_dir(INSTALL_PATH . 'vendor') && !is_file("$target_dir/composer.json")) {
$dirs[] = 'vendor';
@ -66,7 +69,7 @@ if (strtolower($input) == 'y') {
foreach ($dirs as $dir) {
// @FIXME: should we use --delete for all directories?
$delete = in_array($dir, array('program', 'vendor', 'installer')) ? '--delete ' : '';
$delete = in_array($dir, ['program', 'vendor', 'installer']) ? '--delete ' : '';
$command = "rsync -aC --out-format=%n " . $delete . INSTALL_PATH . "$dir/ $target_dir/$dir/";
if (system($command, $ret) === false || $ret > 0) {
@ -74,7 +77,7 @@ if (strtolower($input) == 'y') {
}
}
foreach (array('index.php','config/defaults.inc.php','composer.json-dist','jsdeps.json','CHANGELOG','README.md','UPGRADING','LICENSE','INSTALL') as $file) {
foreach (['index.php','config/defaults.inc.php','composer.json-dist','jsdeps.json','CHANGELOG','README.md','UPGRADING','LICENSE','INSTALL'] as $file) {
$command = "rsync -a --out-format=%n " . INSTALL_PATH . "$file $target_dir/$file";
if (file_exists(INSTALL_PATH . $file) && (system($command, $ret) === false || $ret > 0)) {
@ -83,7 +86,7 @@ if (strtolower($input) == 'y') {
}
// Copy .htaccess or .user.ini if needed
foreach (array('.htaccess','.user.ini') as $file) {
foreach (['.htaccess','.user.ini'] as $file) {
if (file_exists(INSTALL_PATH . $file)) {
if (!file_exists("$target_dir/$file") || file_get_contents(INSTALL_PATH . $file) != file_get_contents("$target_dir/$file")) {
if (copy(INSTALL_PATH . $file, "$target_dir/$file.new")) {

12
bin/moduserprefs.sh

@ -33,14 +33,14 @@ function print_usage()
// get arguments
$args = rcube_utils::get_opt(array(
$args = rcube_utils::get_opt([
'u' => 'user',
'd' => 'delete:bool',
't' => 'type',
'c' => 'config',
));
]);
if ($_SERVER['argv'][1] == 'help') {
if (empty($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') {
print_usage();
exit;
}
@ -51,15 +51,15 @@ else if (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) {
}
$pref_name = trim($args[0]);
$pref_value = $args['delete'] ? null : trim($args[1]);
$pref_value = !empty($args['delete']) ? null : trim($args[1]);
if ($pref_value === null) {
$args['type'] = null;
}
if ($args['config']) {
if (!empty($args['config'])) {
$rcube = rcube::get_instance();
$rcube->config->load_from_file($args['config']);
}
rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], $args['type']);
rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], isset($args['type']) ? $args['type'] : null);

28
bin/msgexport.sh

@ -30,7 +30,7 @@ function print_usage()
function vputs($str)
{
$out = $GLOBALS['args']['file'] ? STDOUT : STDERR;
$out = !empty($GLOBALS['args']['file']) ? STDOUT : STDERR;
fwrite($out, $str);
}
@ -46,11 +46,12 @@ function export_mailbox($mbox, $filename)
$IMAP->set_folder($mbox);
vputs("Getting message list of {$mbox}...");
$index = $IMAP->index($mbox, null, 'ASC');
$count = $index->count();
$index = $index->get();
vputs("Getting message list of {$mbox}...");
vputs("$count messages\n");
if ($filename) {
@ -82,10 +83,10 @@ function export_mailbox($mbox, $filename)
}
// get arguments
$opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file');
$args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX');
$opts = ['h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file'];
$args = rcube_utils::get_opt($opts) + ['host' => 'localhost', 'mbox' => 'INBOX'];
if ($_SERVER['argv'][1] == 'help') {
if (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') {
print_usage();
exit;
}
@ -107,14 +108,15 @@ $args['pass'] = rcube_utils::prompt_silent("Password: ");
// parse $host URL
$a_host = parse_url($args['host']);
if ($a_host['host']) {
if (!empty($a_host['host'])) {
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? TRUE : FALSE;
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl','imaps','tls'])) ? TRUE : FALSE;
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
}
else {
$host = $args['host'];
$host = $args['host'];
$imap_port = 143;
$imap_ssl = false;
}
// instantiate IMAP class
@ -125,15 +127,17 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
vputs("IMAP login successful.\n");
$filename = null;
$mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : array($args['mbox']);
$mailboxes = $args['mbox'] == '*' ? $IMAP->list_folders(null) : [$args['mbox']];
foreach ($mailboxes as $mbox) {
if ($args['file'])
if (!empty($args['file'])) {
$filename = preg_replace('/\.[a-z0-9]{3,4}$/i', '', $args['file']) . asciiwords($mbox) . '.mbox';
else if ($args['mbox'] == '*')
}
else if ($args['mbox'] == '*') {
$filename = asciiwords($mbox) . '.mbox';
}
if ($args['mbox'] == '*' && in_array(strtolower($mbox), array('junk','spam','trash'))) {
if ($args['mbox'] == '*' && in_array(strtolower($mbox), ['junk','spam','trash'])) {
continue;
}

31
bin/msgimport.sh

@ -28,16 +28,15 @@ function print_usage()
print "--file Message file to upload\n";
}
// get arguments
$opts = array('h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file');
$args = rcube_utils::get_opt($opts) + array('host' => 'localhost', 'mbox' => 'INBOX');
$opts = ['h' => 'host', 'u' => 'user', 'p' => 'pass', 'm' => 'mbox', 'f' => 'file'];
$args = rcube_utils::get_opt($opts) + ['host' => 'localhost', 'mbox' => 'INBOX'];
if ($_SERVER['argv'][1] == 'help') {
if (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') {
print_usage();
exit;
}
else if (!($args['host'] && $args['file'])) {
else if (empty($args['host']) || empty($args['file'])) {
print "Missing required parameters.\n";
print_usage();
exit;
@ -60,14 +59,15 @@ if (empty($args['pass'])) {
// parse $host URL
$a_host = parse_url($args['host']);
if ($a_host['host']) {
if (!empty($a_host['host'])) {
$host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? TRUE : FALSE;
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl','imaps','tls'])) ? TRUE : FALSE;
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
}
else {
$host = $args['host'];
$host = $args['host'];
$imap_port = 143;
$imap_ssl = false;
}
// instantiate IMAP class
@ -85,10 +85,12 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
while (($line = fgets($fp)) !== false) {
if (preg_match('/^From\s+-/', $line) && $lastline == '') {
if (!empty($message)) {
if ($IMAP->save_message($args['mbox'], rtrim($message)))
if ($IMAP->save_message($args['mbox'], rtrim($message))) {
$count++;
else
}
else {
rcube::raise_error("Failed to save message to {$args['mbox']}", false, true);
}
$message = '';
}
continue;
@ -98,14 +100,17 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl))
$lastline = rtrim($line);
}
if (!empty($message) && $IMAP->save_message($args['mbox'], rtrim($message)))
if (!empty($message) && $IMAP->save_message($args['mbox'], rtrim($message))) {
$count++;
}
// upload message from file
if ($count)
if ($count) {
print "$count messages successfully added to {$args['mbox']}.\n";
else
}
else {
print "Adding messages failed!\n";
}
}
else {
rcube::raise_error("IMAP login failed.", false, true);

106
bin/package2composer.sh

@ -1,106 +0,0 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| This file is part of the Roundcube Webmail client |
| |
| Copyright (C) The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Convert a plugin's package.xml file into a composer.json description |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <thomas@roundcube.net> |
+-----------------------------------------------------------------------+
*/
ini_set('error_reporting', E_ALL & ~E_NOTICE);
list(, $filename, $vendor) = $_SERVER['argv'];
if (!$filename || !is_readable($filename)) {
die("Invalid input file name!\nUsage: " . $_SERVER['argv'][0] . " XMLFILE VENDOR\n");
}
if (!$vendor) {
$vendor = 'anonymous';
}
$package = new SimpleXMLElement(file_get_contents($filename));
$data = array(
'name' => $vendor . '/' . strval($package->name),
'type' => 'roundcube-plugin',
'description' => trim(strval($package->description), '- ') ? trim(strval($package->description)) : trim(strval($package->summary)),
'homepage' => strval($package->uri),
'license' => 'GPLv3+',
'version' => strval($package->version->release),
'authors' => array(),
'repositories' => array(
array('type' => 'composer', 'url' => 'https://plugins.roundcube.net'),
),
'require' => array(
'php' => '>=5.3.0',
'roundcube/plugin-installer' => '>=0.1.3',
),
);
if ($package->license) {
$data['license'] = strval($package->license);
}
if ($package->lead) {
foreach ($package->lead as $lead) {
if (strval($lead->active) == 'no') {
continue;
}
$data['authors'][] = array(
'name' => strval($lead->name),
'email' => strval($lead->email),
'role' => 'Lead',
);
}
}
if ($devs = $package->developer) {
foreach ($package->developer as $dev) {
$data['authors'][] = array(
'name' => strval($dev->name),
'email' => strval($dev->email),
'role' => 'Developer',
);
}
}
if ($package->dependencies->required->extension) {
foreach ($package->dependencies->required->extension as $ext) {
$data['require']['ext-' . strval($ext->name)] = '*';
}
}
// remove empty values
$data = array_filter($data);
// use the JSON encoder from the Composer package
if (is_file('composer.phar')) {
include 'phar://composer.phar/src/Composer/Json/JsonFile.php';
echo \Composer\Json\JsonFile::encode($data);
}
// PHP 5.4's json_encode() does the job, too
else if (defined('JSON_PRETTY_PRINT')) {
$flags = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT & JSON_UNESCAPED_SLASHES : 0;
echo json_encode($data, $flags);
}
else {
fwrite(STDERR,
"FAILED! composer.phar not found in current directory.
Please download it from http://getcomposer.org/download/ or with
curl -s http://getcomposer.org/installer | php
");
}
echo "\n";

51
bin/update.sh

@ -23,10 +23,10 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept:bool'));
$opts = rcube_utils::get_opt(['v' => 'version', 'y' => 'accept:bool']);
// ask user if no version is specified
if (!$opts['version']) {
if (empty($opts['version'])) {
echo "What version are you upgrading from? Type '?' if you don't know.\n";
if (($input = trim(fgets(STDIN))) && preg_match('/^[0-9.]+[a-z0-9-]*$/', $input)) {
@ -48,7 +48,7 @@ if ($RCI->configured) {
$err = 0;
// list old/replaced config options
if (is_array($messages['replaced'])) {
if (!empty($messages['replaced'])) {
echo "WARNING: Replaced config options:\n";
echo "(These config options have been replaced or renamed)\n";
@ -59,7 +59,7 @@ if ($RCI->configured) {
}
// list obsolete config options (just a notice)
if (is_array($messages['obsolete'])) {
if (!empty($messages['obsolete'])) {
echo "NOTICE: Obsolete config options:\n";
echo "(You still have some obsolete or inexistent properties set."
. " This isn't a problem but should be noticed)\n";
@ -79,18 +79,18 @@ if ($RCI->configured) {
// ask user to update config files
if ($err) {
if (!$opts['accept']) {
if (empty($opts['accept'])) {
echo "Do you want me to fix your local configuration? (y/N)\n";
$input = trim(fgets(STDIN));
}
// positive: merge the local config with the defaults
if ($opts['accept'] || strtolower($input) == 'y') {
if (!empty($opts['accept']) || strtolower($input) == 'y') {
$error = $written = false;
echo ". backing up the current config file(s)...\n";
foreach (array('config', 'main', 'db') as $file) {
foreach (['config', 'main', 'db'] as $file) {
if (file_exists(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php')) {
if (!copy(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php', RCMAIL_CONFIG_DIR . '/' . $file . '.old.php')) {
$error = true;
@ -109,7 +109,7 @@ if ($RCI->configured) {
echo "Done.\n";
echo "Your configuration files are now up-to-date!\n";
if ($messages['missing']) {
if (!empty($messages['missing'])) {
echo "But you still need to add the following missing options:\n";
foreach ($messages['missing'] as $msg) {
echo "- '" . $msg['prop'] . ($msg['name'] ? "': " . $msg['name'] : "'") . "\n";
@ -117,7 +117,7 @@ if ($RCI->configured) {
}
if ($RCI->legacy_config) {
foreach (array('main', 'db') as $file) {
foreach (['main', 'db'] as $file) {
@unlink(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php');
}
}
@ -143,7 +143,7 @@ if ($RCI->configured) {
}
// check dependencies based on the current configuration
if (is_array($messages['dependencies'])) {
if (!empty($messages['dependencies'])) {
echo "WARNING: Dependency check failed!\n";
echo "(Some of your configuration settings require other options to be configured "
. "or additional PHP modules to be installed)\n";
@ -168,10 +168,9 @@ if ($RCI->configured) {
}
// check database schema
if ($RCI->config['db_dsnw']) {
if (!empty($RCI->config['db_dsnw'])) {
echo "Executing database schema update.\n";
$success = rcmail_utils::db_update(INSTALL_PATH . 'SQL', 'roundcube', $opts['version'],
array('errors' => true));
$success = rcmail_utils::db_update(INSTALL_PATH . 'SQL', 'roundcube', $opts['version'], ['errors' => true]);
}
// update composer dependencies
@ -181,11 +180,11 @@ if ($RCI->configured) {
$comsposer_json = null;
// update the require section with the new dependencies
if (is_array($composer_data['require']) && is_array($composer_template['require'])) {
if (!empty($composer_data['require']) && !empty($composer_template['require'])) {
$composer_data['require'] = array_merge($composer_data['require'], $composer_template['require']);
// remove obsolete packages
$old_packages = array(
$old_packages = [
'pear-pear.php.net/net_socket',
'pear-pear.php.net/auth_sasl',
'pear-pear.php.net/net_idna2',
@ -196,7 +195,7 @@ if ($RCI->configured) {
'pear/mail_mime-decode',
'roundcube/net_sieve',
'endroid/qrcode',
);
];
foreach ($old_packages as $pkg) {
if (array_key_exists($pkg, $composer_data['require'])) {
@ -206,9 +205,9 @@ if ($RCI->configured) {
}
// update the repositories section with the new dependencies
if (is_array($composer_template['repositories'])) {
if (!is_array($composer_data['repositories'])) {
$composer_data['repositories'] = array();
if (!empty($composer_template['repositories'])) {
if (empty($composer_data['repositories'])) {
$composer_data['repositories'] = [];
}
foreach ($composer_template['repositories'] as $repo) {
@ -242,19 +241,7 @@ if ($RCI->configured) {
$composer_data['repositories'] = array_values($composer_data['repositories']);
}
// use the JSON encoder from the Composer package
if (is_file('composer.phar')) {
include 'phar://composer.phar/src/Composer/Json/JsonFile.php';
$comsposer_json = \Composer\Json\JsonFile::encode($composer_data);
}
// PHP 5.4's json_encode() does the job, too
else if (defined('JSON_PRETTY_PRINT')) {
$comsposer_json = json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
else {
$success = false;
$comsposer_json = null;
}
$comsposer_json = json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
// write updated composer.json back to disk
if ($comsposer_json && is_writeable(INSTALL_PATH . 'composer.json')) {

14
bin/updatecss.sh

@ -22,9 +22,7 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array(
'd' => 'dir',
));
$opts = rcube_utils::get_opt(['d' => 'dir']);
if (empty($opts['dir'])) {
print "Skin directory not specified (--dir). Using skins/ and plugins/*/skins/.\n";
@ -41,7 +39,7 @@ else if (!file_exists($opts['dir'])) {
rcube::raise_error("Specified directory doesn't exist.", false, true);
}
else {
$dirs = array($opts['dir']);
$dirs = [$opts['dir']];
}
foreach ($dirs as $dir) {
@ -52,8 +50,8 @@ foreach ($dirs as $dir) {
$files = get_files($dir);
$images = get_images($img_dir);
$find = array();
$replace = array();
$find = [];
$replace = [];
// build regexps array
foreach ($images as $path => $sum) {
@ -76,7 +74,7 @@ foreach ($dirs as $dir) {
function get_images($dir)
{
$images = array();
$images = [];
$dh = opendir($dir);
while ($file = readdir($dh)) {
@ -99,7 +97,7 @@ function get_images($dir)
function get_files($dir)
{
$files = array();
$files = [];
$dh = opendir($dir);
while ($file = readdir($dh)) {

12
bin/updatedb.sh

@ -23,11 +23,11 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array(
'v' => 'version',
'd' => 'dir',
'p' => 'package',
));
$opts = rcube_utils::get_opt([
'v' => 'version',
'd' => 'dir',
'p' => 'package',
]);
if (empty($opts['dir'])) {
rcube::raise_error("Database schema directory not specified (--dir).", false, true);
@ -36,4 +36,4 @@ if (empty($opts['package'])) {
rcube::raise_error("Database schema package name not specified (--package).", false, true);
}
rcmail_utils::db_update($opts['dir'], $opts['package'], $opts['version'], array('errors' => true));
rcmail_utils::db_update($opts['dir'], $opts['package'], $opts['version'], ['errors' => true]);

2
program/lib/Roundcube/rcube.php

@ -815,7 +815,7 @@ class rcube
static $rcube_languages, $rcube_language_aliases;
// user HTTP_ACCEPT_LANGUAGE if no language is specified
if (empty($lang) || $lang == 'auto') {
if ((empty($lang) || $lang == 'auto') && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lang = $accept_langs[0];

9
program/lib/Roundcube/rcube_imap.php

@ -147,7 +147,14 @@ class rcube_imap extends rcube_storage
$attempt = 0;
do {
$data = ['host' => $host, 'user' => $user, 'attempt' => ++$attempt, 'socket_options' => []];
$data = [
'host' => $host,
'user' => $user,
'attempt' => ++$attempt,
'socket_options' => [],
'retry' => false
];
$data = $this->plugins->exec_hook('storage_connect', array_merge($this->options, $data));
if (!empty($data['pass'])) {

5
program/lib/Roundcube/rcube_utils.php

@ -704,7 +704,7 @@ class rcube_utils
*/
public static function remote_ip()
{
$address = $_SERVER['REMOTE_ADDR'];
$address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
// append the NGINX X-Real-IP header, if set
if (!empty($_SERVER['HTTP_X_REAL_IP']) && $_SERVER['HTTP_X_REAL_IP'] != $address) {
@ -1197,7 +1197,8 @@ class rcube_utils
$args[] = $arg;
}
if ($alias = $aliases[$key]) {
if (!empty($aliases[$key])) {
$alias = $aliases[$key];
$args[$alias] = $args[$key];
}
}

Loading…
Cancel
Save