From 4a4188a96badfd8cbfc19891023a3a47aed12cf6 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sat, 5 Nov 2022 11:07:18 +0100 Subject: [PATCH] prefer combined operators, refs #999 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/Admins.php | 8 ++++---- lib/Froxlor/Api/Commands/Customers.php | 10 +++++----- lib/Froxlor/Cli/ConfigServices.php | 2 +- lib/Froxlor/Config/ConfigService.php | 2 +- lib/Froxlor/Database/Database.php | 2 +- lib/Froxlor/UI/Panel/FroxlorTwig.php | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Froxlor/Api/Commands/Admins.php b/lib/Froxlor/Api/Commands/Admins.php index a2ed4b76..fe64ed53 100644 --- a/lib/Froxlor/Api/Commands/Admins.php +++ b/lib/Froxlor/Api/Commands/Admins.php @@ -262,8 +262,8 @@ class Admins extends ApiCommand implements ResourceEntity $password = Crypt::validatePassword($password, true); } - $diskspace = $diskspace * 1024; - $traffic = $traffic * 1024 * 1024; + $diskspace *= 1024; + $traffic *= 1024 * 1024; // Check if the account already exists // do not check via api as we skip any permission checks for this task @@ -576,8 +576,8 @@ class Admins extends ApiCommand implements ResourceEntity $change_serversettings = $this->getBoolParam('change_serversettings', true, $result['change_serversettings']); $ipaddress = $this->getParam('ipaddress', true, ($result['ip'] != -1 ? json_decode($result['ip'], true) : -1)); - $diskspace = $diskspace * 1024; - $traffic = $traffic * 1024 * 1024; + $diskspace *= 1024; + $traffic *= 1024 * 1024; } // validation diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index 7a2c82f8..dde6c865 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -409,8 +409,8 @@ class Customers extends ApiCommand implements ResourceEntity } $allowed_mysqlserver = array_map('intval', $allowed_mysqlserver); - $diskspace = $diskspace * 1024; - $traffic = $traffic * 1024 * 1024; + $diskspace *= 1024; + $traffic *= 1024 * 1024; if (((($this->getUserDetail('diskspace_used') + $diskspace) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) { Response::standardError('youcantallocatemorethanyouhave', '', true); @@ -1107,8 +1107,8 @@ class Customers extends ApiCommand implements ResourceEntity } if ($this->isAdmin()) { - $diskspace = $diskspace * 1024; - $traffic = $traffic * 1024 * 1024; + $diskspace *= 1024; + $traffic *= 1024 * 1024; if (((($this->getUserDetail('diskspace_used') + $diskspace - $result['diskspace']) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls - $result['mysqls']) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails - $result['emails']) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts - $result['email_accounts']) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders - $result['email_forwarders']) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota - $result['email_quota']) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps - $result['ftps']) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains - $result['subdomains']) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) { Response::standardError('youcantallocatemorethanyouhave', '', true); @@ -1351,7 +1351,7 @@ class Customers extends ApiCommand implements ResourceEntity 'api_allowed' => $api_allowed, 'allowed_mysqlserver' => empty($allowed_mysqlserver) ? "" : json_encode($allowed_mysqlserver) ]; - $upd_data = $upd_data + $admin_upd_data; + $upd_data += $admin_upd_data; } $upd_query = "UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET diff --git a/lib/Froxlor/Cli/ConfigServices.php b/lib/Froxlor/Cli/ConfigServices.php index 93c31819..c4b43b5b 100644 --- a/lib/Froxlor/Cli/ConfigServices.php +++ b/lib/Froxlor/Cli/ConfigServices.php @@ -235,7 +235,7 @@ final class ConfigServices extends CliCommand $title = $dd->title; if ($dd->default) { $default_daemon = $di; - $title = $title . " (default)"; + $title .= " (default)"; } $table_rows[] = [$di, $title]; $valid_options[] = $di; diff --git a/lib/Froxlor/Config/ConfigService.php b/lib/Froxlor/Config/ConfigService.php index 799630f7..c3b1dda0 100644 --- a/lib/Froxlor/Config/ConfigService.php +++ b/lib/Froxlor/Config/ConfigService.php @@ -143,7 +143,7 @@ class ConfigService $name = str_replace('.', '', $value); $versiontag = "[@version='" . $value . "']"; } elseif ($key == 'version' && $name != '') { - $name = $name . str_replace('.', '', $value); + $name .= str_replace('.', '', $value); $versiontag = "[@version='" . $value . "']"; } } diff --git a/lib/Froxlor/Database/Database.php b/lib/Froxlor/Database/Database.php index f9e4da12..8aa9b79d 100644 --- a/lib/Froxlor/Database/Database.php +++ b/lib/Froxlor/Database/Database.php @@ -248,7 +248,7 @@ class Database $replacements = []; foreach ($substitutions as $search => $replace) { - $replacements = $replacements + self::createShiftedSubstitutions($search, $replace, $minLength); + $replacements += self::createShiftedSubstitutions($search, $replace, $minLength); } $content = str_replace(array_keys($replacements), array_values($replacements), $content); diff --git a/lib/Froxlor/UI/Panel/FroxlorTwig.php b/lib/Froxlor/UI/Panel/FroxlorTwig.php index e98e4568..8b40a6ff 100644 --- a/lib/Froxlor/UI/Panel/FroxlorTwig.php +++ b/lib/Froxlor/UI/Panel/FroxlorTwig.php @@ -89,7 +89,7 @@ class FroxlorTwig extends AbstractExtension public function formatBytesFilter($size, $suffix = "B", $factor = 1) { - $size = $size * $factor; + $size *= $factor; $units = [ '', 'K',