Skip to content

Commit

Permalink
run fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 26, 2024
1 parent a48ab8d commit bde43c7
Show file tree
Hide file tree
Showing 279 changed files with 4,693 additions and 4,693 deletions.
2 changes: 1 addition & 1 deletion bin/cleandb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ if (!empty($_SERVER['argv'][1])) {
$days = 7;
}

rcmail_utils::db_clean($days);
\rcmail_utils::db_clean($days);
2 changes: 1 addition & 1 deletion bin/decrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if ($argc < 2) {
exit('Usage: ' . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n");
}

$RCMAIL = rcube::get_instance();
$RCMAIL = \rcube::get_instance();

for ($i = 1; $i < $argc; $i++) {
printf("%s\n", $RCMAIL->decrypt($argv[$i]));
Expand Down
8 changes: 4 additions & 4 deletions bin/deluser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function _die($msg, $usage = false)
exit(1);
}

$rcmail = rcube::get_instance();
$rcmail = \rcube::get_instance();

// get arguments
$args = rcube_utils::get_opt(['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();
Expand All @@ -66,7 +66,7 @@ if (!empty($args['age']) && ($age = intval($args['age']))) {
exit(0);
}

$hostname = rcmail_utils::get_host($args);
$hostname = \rcmail_utils::get_host($args);
$username = isset($args[0]) ? trim($args[0]) : null;

if (empty($username)) {
Expand All @@ -83,7 +83,7 @@ if (!$db->is_connected() || $db->is_error()) {
}

// find user in local database
$user = rcube_user::query($username, $hostname);
$user = \rcube_user::query($username, $hostname);

if (!$user) {
exit("User not found.\n");
Expand Down
2 changes: 1 addition & 1 deletion bin/gc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');

require INSTALL_PATH . 'program/include/clisetup.php';

$rcmail = rcube::get_instance();
$rcmail = \rcube::get_instance();

$session_driver = $rcmail->config->get('session_storage', 'db');
$session_lifetime = $rcmail->config->get('session_lifetime', 0) * 60 * 2;
Expand Down
36 changes: 18 additions & 18 deletions bin/identity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');

require INSTALL_PATH . 'program/include/clisetup.php';

$options = rcube_utils::get_opt([
$options = \rcube_utils::get_opt([
'u' => 'username',
'e' => 'email',
'n' => 'name',
Expand Down Expand Up @@ -80,15 +80,15 @@ function get_identity_attr($options)
$identity = $user->get_identity($identity_id);

if (empty($identity)) {
rcube::raise_error('Invalid identity ID.', false, true);
\rcube::raise_error('Invalid identity ID.', false, true);
}

if (isset($identity[$attribute])) {
$attrValue = $identity[$attribute];

echo "{$attrValue}\n";
} else {
rcube::raise_error('Invalid attribute name. Available attributes: identity_id, user_id, changed, del, standard, name, '
\rcube::raise_error('Invalid attribute name. Available attributes: identity_id, user_id, changed, del, standard, name, '
. 'organization, email, reply-to, bcc, signature, html_signature.', false, true);
}
}
Expand All @@ -114,7 +114,7 @@ function delete_identity($options)
$identities_level = get_identities_level();

if ($identities_level > 1) {
rcube::raise_error("Identities level doesn't allow this action.", false, true);
\rcube::raise_error("Identities level doesn't allow this action.", false, true);
}

if (count($options) === 1) {
Expand All @@ -133,7 +133,7 @@ function delete_identity($options)
$identity = $user->delete_identity($identity_id);

if (!$identity) {
rcube::raise_error('Invalid identity ID.');
\rcube::raise_error('Invalid identity ID.');
exit;
}

Expand All @@ -145,7 +145,7 @@ function add_identity($options)
$identities_level = get_identities_level();

if ($identities_level > 1) {
rcube::raise_error("Identities level doesn't allow this action.", false, true);
\rcube::raise_error("Identities level doesn't allow this action.", false, true);
}

if (count($options) === 1) {
Expand Down Expand Up @@ -207,7 +207,7 @@ function update_identity($options)
$identities_level = get_identities_level();

if ($identities_level > 1) {
rcube::raise_error("Identities level doesn't allow this action.", false, true);
\rcube::raise_error("Identities level doesn't allow this action.", false, true);
}

if (count($options) === 1) {
Expand Down Expand Up @@ -260,7 +260,7 @@ function update_identity($options)

if ($email !== null) {
if ($identities_level > 0) {
rcube::raise_error("Identities level doesn't allow setting email.", false, true);
\rcube::raise_error("Identities level doesn't allow setting email.", false, true);
}

$updated_identity['email'] = $email;
Expand All @@ -279,15 +279,15 @@ function update_identity($options)
}

if (count($updated_identity) === 0) {
rcube::raise_error('No attributes changed. Set some new values.', false, true);
\rcube::raise_error('No attributes changed. Set some new values.', false, true);
}

$user = get_user($options);

$identity = $user->update_identity($identity_id, $updated_identity);

if (!$identity) {
rcube::raise_error('Identity not updated. Either the identity id is incorrect or provided values are invalid.', false, true);
\rcube::raise_error('Identity not updated. Either the identity id is incorrect or provided values are invalid.', false, true);
}

if ($setAsDefault) {
Expand All @@ -314,7 +314,7 @@ function get_option_value($options, $key, $fallback, $isBoolean, $isMandatory, $
}

if ($isMandatory) {
rcube::raise_error($message, false, true);
\rcube::raise_error($message, false, true);
}

return $fallback;
Expand All @@ -323,14 +323,14 @@ function get_option_value($options, $key, $fallback, $isBoolean, $isMandatory, $
function validate_email($email, $fieldName)
{
if (!filter_var($email, \FILTER_VALIDATE_EMAIL)) {
rcube::raise_error("invalid {$fieldName} format", false, true);
\rcube::raise_error("invalid {$fieldName} format", false, true);
}
}

function validate_boolean($value, $fieldName)
{
if (!is_bool($value) && $value !== '0' && $value !== '1') {
rcube::raise_error("{$fieldName} can either be set to 1 (true), 0 (false) or without a value (true)", false, true);
\rcube::raise_error("{$fieldName} can either be set to 1 (true), 0 (false) or without a value (true)", false, true);
}
}

Expand Down Expand Up @@ -363,26 +363,26 @@ function echo_shared_options()

function get_user($options)
{
$rcmail = rcube::get_instance();
$rcmail = \rcube::get_instance();

$db = $rcmail->get_dbh();

$username = get_option_value($options, 'username', '', false, true, 'Enter the username e.g. -u [email protected]');
$host = rcmail_utils::get_host($options);
$host = \rcmail_utils::get_host($options);

// find user in local database
$user = rcube_user::query($username, $host);
$user = \rcube_user::query($username, $host);

if (empty($user)) {
rcube::raise_error("User does not exist: {$username}", false, true);
\rcube::raise_error("User does not exist: {$username}", false, true);
}

return $user;
}

function get_identities_level()
{
$rcmail = rcube::get_instance();
$rcmail = \rcube::get_instance();
$identities_level = intval($rcmail->config->get('identities_level', 0));

return $identities_level;
Expand Down
2 changes: 1 addition & 1 deletion bin/indexcontacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
require_once INSTALL_PATH . 'program/include/clisetup.php';
ini_set('memory_limit', -1);

rcmail_utils::indexcontacts();
\rcmail_utils::indexcontacts();
12 changes: 6 additions & 6 deletions bin/initdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
require_once INSTALL_PATH . 'program/include/clisetup.php';

// get arguments
$opts = rcube_utils::get_opt([
$opts = \rcube_utils::get_opt([
'd' => 'dir',
'u' => 'update',
]);

if (empty($opts['dir'])) {
rcube::raise_error('Database schema directory not specified (--dir).', false, true);
\rcube::raise_error('Database schema directory not specified (--dir).', false, true);
}

// Check if directory exists
if (!file_exists($opts['dir'])) {
rcube::raise_error("Specified database schema directory doesn't exist.", false, true);
\rcube::raise_error("Specified database schema directory doesn't exist.", false, true);
}

$db = rcmail_utils::db();
$db = \rcmail_utils::db();

if (!empty($opts['update']) && in_array($db->table_name('system'), (array) $db->list_tables())) {
echo 'Checking for database schema updates...' . \PHP_EOL;
rcmail_utils::db_update($opts['dir'], 'roundcube', null, ['errors' => true]);
\rcmail_utils::db_update($opts['dir'], 'roundcube', null, ['errors' => true]);
} else {
rcmail_utils::db_init($opts['dir']);
\rcmail_utils::db_init($opts['dir']);
}
22 changes: 11 additions & 11 deletions bin/install-jsdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
require_once INSTALL_PATH . 'program/include/clisetup.php';

if (!function_exists('exec')) {
rcube::raise_error('PHP exec() function is required. Check disable_functions in php.ini.', false, true);
\rcube::raise_error('PHP exec() function is required. Check disable_functions in php.ini.', false, true);
}

$cfgfile = INSTALL_PATH . 'jsdeps.json';
$SOURCES = json_decode(file_get_contents($cfgfile), true);

if (empty($SOURCES['dependencies'])) {
rcube::raise_error("Failed to read dependencies list from {$cfgfile}", false, true);
\rcube::raise_error("Failed to read dependencies list from {$cfgfile}", false, true);
}

$CURL = trim(shell_exec('which curl'));
Expand Down Expand Up @@ -111,7 +111,7 @@ function fetch_from_source($package, $useCache = true, &$filetype = null)

if (!is_readable($cache_file) || !$useCache) {
if (empty($CURL) && empty($WGET)) {
rcube::raise_error("Required 'wget' or 'curl' program not found.", false, true);
\rcube::raise_error("Required 'wget' or 'curl' program not found.", false, true);
}

$url = str_replace('$v', $package['version'], $package['url']);
Expand All @@ -129,7 +129,7 @@ function fetch_from_source($package, $useCache = true, &$filetype = null)
$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}");
\rcube::raise_error("Fetching failed. Using Github API on {$url}");

if ($CURL) {
exec(sprintf('%s -L -H %s -s %s -o %s', $CURL, escapeshellarg($header), escapeshellarg($url), $cache_file), $out, $retval);
Expand All @@ -139,7 +139,7 @@ function fetch_from_source($package, $useCache = true, &$filetype = null)
}

if ($retval !== 0) {
rcube::raise_error("Failed to download source file from {$url}", false, true);
\rcube::raise_error("Failed to download source file from {$url}", false, true);
}
}

Expand Down Expand Up @@ -201,7 +201,7 @@ function compose_destfile($package, $srcfile)
if (file_put_contents(INSTALL_PATH . $package['dest'], $header . file_get_contents($srcfile))) {
echo 'Wrote file ' . INSTALL_PATH . $package['dest'] . "\n";
} else {
rcube::raise_error('Failed to write destination file ' . INSTALL_PATH . $package['dest'], false, true);
\rcube::raise_error('Failed to write destination file ' . INSTALL_PATH . $package['dest'], false, true);
}
}

Expand All @@ -218,7 +218,7 @@ function extract_zipfile($package, $srcfile)
}

if (!is_writable($destdir)) {
rcube::raise_error("Cannot write to destination directory: {$destdir}", false, true);
\rcube::raise_error("Cannot write to destination directory: {$destdir}", false, true);
}

if (!empty($package['map'])) {
Expand All @@ -229,7 +229,7 @@ function extract_zipfile($package, $srcfile)
}

// pick files from the zip archive
rcmail_install::unzip($srcfile, $extract ?? $destdir, $package['pick'] ?? [], !empty($package['flat']));
\rcmail_install::unzip($srcfile, $extract ?? $destdir, $package['pick'] ?? [], !empty($package['flat']));

// map source to dest files/directories
if (!empty($package['map'])) {
Expand Down Expand Up @@ -258,7 +258,7 @@ function extract_zipfile($package, $srcfile)

exec(sprintf('mv -f %s %s', $src_file, $dest_file), $out, $retval);
if ($retval !== 0) {
rcube::raise_error("Failed to move {$src} into {$dest_file}; " . implode('; ', $out));
\rcube::raise_error("Failed to move {$src} into {$dest_file}; " . implode('; ', $out));
}
// Remove sourceMappingURL
elseif (isset($package['sourcemap']) && $package['sourcemap'] === false) {
Expand Down Expand Up @@ -311,7 +311,7 @@ function delete_destfile($package)

// ////////////// Execution

$args = rcube_utils::get_opt([
$args = \rcube_utils::get_opt([
'f' => 'force:bool',
'd' => 'delete:bool',
'g' => 'get:bool',
Expand Down Expand Up @@ -351,7 +351,7 @@ foreach ($SOURCES['dependencies'] as $package) {
}

if (!empty($package['sha1']) && ($sum = sha1_file($srcfile)) !== $package['sha1']) {
rcube::raise_error("Incorrect sha1 sum of {$srcfile}. Expected: {$package['sha1']}, got: {$sum}", false, true);
\rcube::raise_error("Incorrect sha1 sum of {$srcfile}. Expected: {$package['sha1']}, got: {$sum}", false, true);
}

if ($args['extract']) {
Expand Down
14 changes: 7 additions & 7 deletions bin/installto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
require_once INSTALL_PATH . 'program/include/clisetup.php';

if (!function_exists('system')) {
rcube::raise_error('PHP system() function is required. Check disable_functions in php.ini.', false, true);
\rcube::raise_error('PHP system() function is required. Check disable_functions in php.ini.', false, true);
}

$target_dir = unslashify(end($_SERVER['argv']));
$accept = in_array('-y', $_SERVER['argv']) ? 'y' : null;

if (empty($target_dir) || !is_dir(realpath($target_dir))) {
rcube::raise_error("Invalid target: not a directory\nUsage: installto.sh [-y] <TARGET>", false, true);
\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)) {
rcube::raise_error("No valid Roundcube installation found at {$target_dir}", false, true);
\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), '>')) {
rcube::raise_error("Target installation already in version {$oldversion}.", false, true);
\rcube::raise_error("Target installation already in version {$oldversion}.", false, true);
}

if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '==')) {
Expand All @@ -60,7 +60,7 @@ if (strtolower($input) == 'y') {
$adds = [];
$dirs = ['bin', 'SQL', 'plugins', 'skins', 'program', 'public_html'];

if (is_dir(INSTALL_PATH . 'vendor') && (!is_file("{$target_dir}/composer.json") || rcmail_install::vendor_dir_untouched($target_dir))) {
if (is_dir(INSTALL_PATH . 'vendor') && (!is_file("{$target_dir}/composer.json") || \rcmail_install::vendor_dir_untouched($target_dir))) {
$dirs[] = 'vendor';
}
if (file_exists("{$target_dir}/installer")) {
Expand All @@ -73,7 +73,7 @@ if (strtolower($input) == 'y') {
$command = 'rsync -aC --out-format=%n ' . $delete . INSTALL_PATH . "{$dir}/ {$target_dir}/{$dir}/";

if (system($command, $ret) === false || $ret > 0) {
rcube::raise_error("Failed to execute command: {$command}", false, true);
\rcube::raise_error("Failed to execute command: {$command}", false, true);
}
}

Expand All @@ -82,7 +82,7 @@ if (strtolower($input) == 'y') {
$command = 'rsync -a --out-format=%n ' . INSTALL_PATH . "{$source_file} {$target_dir}/{$file}";

if (file_exists(INSTALL_PATH . $file) && (system($command, $ret) === false || $ret > 0)) {
rcube::raise_error("Failed to execute command: {$command}", false, true);
\rcube::raise_error("Failed to execute command: {$command}", false, true);
}
}

Expand Down
Loading

0 comments on commit bde43c7

Please sign in to comment.