From 9b86d576faf6e60e242b7dc00129668fd50943bb Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 18 Jan 2021 20:49:55 +0100 Subject: [PATCH] do not display usages on dashboard in fixed size-units but dynamically adjusted Signed-off-by: Michael Kaufmann --- admin_index.php | 12 ++++++------ customer_index.php | 19 +++++++++---------- .../admin/admin/formfield.admin_add.php | 6 +++--- .../admin/admin/formfield.admin_edit.php | 6 +++--- .../admin/customer/formfield.customer_add.php | 6 +++--- .../customer/formfield.customer_edit.php | 6 +++--- lng/english.lng.php | 17 +++++++++-------- lng/german.lng.php | 16 ++++++++-------- templates/Sparkle/customer/index/index.tpl | 4 ++-- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/admin_index.php b/admin_index.php index efe68cbb..f677e55c 100644 --- a/admin_index.php +++ b/admin_index.php @@ -77,8 +77,8 @@ if ($page == 'overview') { $overview = Database::pexecute_first($overview_stmt, $params); $dec_places = Settings::Get('panel.decimal_places'); - $overview['traffic_used'] = round($overview['traffic_used'] / (1024 * 1024), $dec_places); - $overview['diskspace_used'] = round($overview['diskspace_used'] / 1024, $dec_places); + $overview['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($overview['traffic_used'] * 1024, null, 'bi'); + $overview['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($overview['diskspace_used'] * 1024, null, 'bi'); $number_domains_stmt = Database::prepare(" SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "` @@ -113,10 +113,10 @@ if ($page == 'overview') { } $dec_places = Settings::Get('panel.decimal_places'); - $userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, $dec_places); - $userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, $dec_places); - $userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $dec_places); - $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $dec_places); + $userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1; + $userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace_used'] * 1024, null, 'bi'); + $userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1; + $userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi'); $userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains'); $userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : ''; diff --git a/customer_index.php b/customer_index.php index a164a16e..105a1fa8 100644 --- a/customer_index.php +++ b/customer_index.php @@ -93,21 +93,20 @@ if ($page == 'overview') { 'cid' => $userinfo['customerid'] )); - if ($usages) - { - $userinfo['diskspace_used'] = round($usages['webspace'] / 1024, Settings::Get('panel.decimal_places')); - $userinfo['mailspace_used'] = round($usages['mail'] / 1024, Settings::Get('panel.decimal_places')); - $userinfo['dbspace_used'] = round($usages['mysql'] / 1024, Settings::Get('panel.decimal_places')); - $userinfo['total_used'] = round(($usages['webspace'] + $usages['mail'] + $usages['mysql']) / 1024, Settings::Get('panel.decimal_places')); + if ($usages) { + $userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi'); + $userinfo['mailspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mail'] * 1024, null, 'bi'); + $userinfo['dbspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mysql'] * 1024, null, 'bi'); + $userinfo['total_used'] = \Froxlor\PhpHelper::sizeReadable(($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024, null, 'bi'); } else { $userinfo['diskspace_used'] = 0; $userinfo['mailspace_used'] = 0; $userinfo['dbspace_used'] = 0; $userinfo['total_used'] = 0; } - $userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, Settings::Get('panel.decimal_places')); - $userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), Settings::Get('panel.decimal_places')); - $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), Settings::Get('panel.decimal_places')); + $userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1; + $userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1; + $userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi'); $userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains'); $userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : ''; @@ -123,7 +122,7 @@ if ($page == 'overview') { if ($userinfo['perlenabled'] == '1') $se[] = "Perl/CGI"; if ($userinfo['api_allowed'] == '1') - $se[] = 'API'; + $se[] = 'API'; $services_enabled = implode(", ", $se); eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/index') . "\";"); diff --git a/lib/formfields/admin/admin/formfield.admin_add.php b/lib/formfields/admin/admin/formfield.admin_add.php index 24b41211..710d634f 100644 --- a/lib/formfields/admin/admin/formfield.admin_add.php +++ b/lib/formfields/admin/admin/formfield.admin_add.php @@ -167,7 +167,7 @@ return array( 'value' => array() ), 'diskspace' => array( - 'label' => $lng['customer']['diskspace'], + 'label' => $lng['customer']['diskspace'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 6, @@ -175,7 +175,7 @@ return array( 'ul_field' => $diskspace_ul ), 'traffic' => array( - 'label' => $lng['customer']['traffic'], + 'label' => $lng['customer']['traffic'] . ' (' . $lng['customer']['gib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 4, @@ -215,7 +215,7 @@ return array( 'ul_field' => $email_forwarders_ul ), 'email_quota' => array( - 'label' => $lng['customer']['email_quota'], + 'label' => $lng['customer']['email_quota'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 9, diff --git a/lib/formfields/admin/admin/formfield.admin_edit.php b/lib/formfields/admin/admin/formfield.admin_edit.php index 4827d4ae..5e4eac5d 100644 --- a/lib/formfields/admin/admin/formfield.admin_edit.php +++ b/lib/formfields/admin/admin/formfield.admin_edit.php @@ -196,7 +196,7 @@ return array( ) ), 'diskspace' => array( - 'label' => $lng['customer']['diskspace'], + 'label' => $lng['customer']['diskspace'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => $result['diskspace'], 'maxlength' => 6, @@ -204,7 +204,7 @@ return array( 'ul_field' => $diskspace_ul ), 'traffic' => array( - 'label' => $lng['customer']['traffic'], + 'label' => $lng['customer']['traffic'] . ' (' . $lng['customer']['gib'] . ')', 'type' => 'textul', 'value' => $result['traffic'], 'maxlength' => 4, @@ -244,7 +244,7 @@ return array( 'ul_field' => $email_forwarders_ul ), 'email_quota' => array( - 'label' => $lng['customer']['email_quota'], + 'label' => $lng['customer']['email_quota'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => $result['email_quota'], 'maxlength' => 9, diff --git a/lib/formfields/admin/customer/formfield.customer_add.php b/lib/formfields/admin/customer/formfield.customer_add.php index b9dd6c02..51f4b062 100644 --- a/lib/formfields/admin/customer/formfield.customer_add.php +++ b/lib/formfields/admin/customer/formfield.customer_add.php @@ -190,7 +190,7 @@ return array( 'image' => 'icons/user_add.png', 'fields' => array( 'diskspace' => array( - 'label' => $lng['customer']['diskspace'], + 'label' => $lng['customer']['diskspace'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 16, @@ -198,7 +198,7 @@ return array( 'ul_field' => $diskspace_ul ), 'traffic' => array( - 'label' => $lng['customer']['traffic'], + 'label' => $lng['customer']['traffic'] . ' (' . $lng['customer']['gib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 14, @@ -238,7 +238,7 @@ return array( 'ul_field' => $email_forwarders_ul ), 'email_quota' => array( - 'label' => $lng['customer']['email_quota'], + 'label' => $lng['customer']['email_quota']. ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => 0, 'maxlength' => 9, diff --git a/lib/formfields/admin/customer/formfield.customer_edit.php b/lib/formfields/admin/customer/formfield.customer_edit.php index 47980f3c..82d009bf 100644 --- a/lib/formfields/admin/customer/formfield.customer_edit.php +++ b/lib/formfields/admin/customer/formfield.customer_edit.php @@ -196,7 +196,7 @@ return array( 'image' => 'icons/user_edit.png', 'fields' => array( 'diskspace' => array( - 'label' => $lng['customer']['diskspace'], + 'label' => $lng['customer']['diskspace'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => $result['diskspace'], 'maxlength' => 16, @@ -204,7 +204,7 @@ return array( 'ul_field' => $diskspace_ul ), 'traffic' => array( - 'label' => $lng['customer']['traffic'], + 'label' => $lng['customer']['traffic'] . ' (' . $lng['customer']['gib'] . ')', 'type' => 'textul', 'value' => $result['traffic'], 'maxlength' => 14, @@ -244,7 +244,7 @@ return array( 'ul_field' => $email_forwarders_ul ), 'email_quota' => array( - 'label' => $lng['customer']['email_quota'], + 'label' => $lng['customer']['email_quota'] . ' (' . $lng['customer']['mib'] . ')', 'type' => 'textul', 'value' => $result['email_quota'], 'maxlength' => 9, diff --git a/lng/english.lng.php b/lng/english.lng.php index a9d21b7a..ab4e4fd9 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -60,8 +60,8 @@ $lng['customer']['phone'] = 'Phone'; $lng['customer']['fax'] = 'Fax'; $lng['customer']['email'] = 'Email'; $lng['customer']['customernumber'] = 'Customer ID'; -$lng['customer']['diskspace'] = 'Webspace (MiB)'; -$lng['customer']['traffic'] = 'Traffic (GiB)'; +$lng['customer']['diskspace'] = 'Webspace'; +$lng['customer']['traffic'] = 'Traffic'; $lng['customer']['mysqls'] = 'MySQL-databases'; $lng['customer']['emails'] = 'Email-addresses'; $lng['customer']['accounts'] = 'Email-accounts'; @@ -71,6 +71,7 @@ $lng['customer']['subdomains'] = 'Subdomains'; $lng['customer']['domains'] = 'Domains'; $lng['customer']['unlimited'] = '∞'; $lng['customer']['mib'] = 'MiB'; +$lng['customer']['gib'] = 'GiB'; /** * Customermenue @@ -619,7 +620,7 @@ $lng['traffic']['months'][9] = "September"; $lng['traffic']['months'][10] = "October"; $lng['traffic']['months'][11] = "November"; $lng['traffic']['months'][12] = "December"; -$lng['traffic']['mb'] = "Traffic (MiB)"; +$lng['traffic']['mb'] = "Traffic"; $lng['traffic']['distribution'] = 'FTP | HTTP | Mail'; $lng['traffic']['sumhttp'] = 'Total HTTP-Traffic'; $lng['traffic']['sumftp'] = 'Total FTP-Traffic'; @@ -805,7 +806,7 @@ $lng['serversettings']['mail_quota_enabled']['enforcelink'] = 'Click here to enf $lng['question']['admin_quotas_reallywipe'] = 'Do you really want to wipe all quotas on table mail_users? This cannot be reverted!'; $lng['question']['admin_quotas_reallyenforce'] = 'Do you really want to enforce the default quota to all Users? This cannot be reverted!'; $lng['error']['vmailquotawrong'] = 'The quotasize must be positive number.'; -$lng['customer']['email_quota'] = 'E-mail quota (MiB)'; +$lng['customer']['email_quota'] = 'E-mail quota'; $lng['customer']['email_imap'] = 'E-mail IMAP'; $lng['customer']['email_pop3'] = 'E-mail POP3'; $lng['customer']['mail_quota'] = 'Mailquota'; @@ -1540,9 +1541,9 @@ $lng['mysql']['size'] = 'Size'; $lng['error']['invalidhostname'] = 'Hostname needs to be a valid domain. It can\'t be empty nor can it consist only of whitespaces'; -$lng['traffic']['http'] = 'HTTP (MiB)'; -$lng['traffic']['ftp'] = 'FTP (MiB)'; -$lng['traffic']['mail'] = 'Mail (MiB)'; +$lng['traffic']['http'] = 'HTTP'; +$lng['traffic']['ftp'] = 'FTP'; +$lng['traffic']['mail'] = 'Mail'; // ADDED IN 0.9.27-svn1 $lng['serversettings']['mod_fcgid']['idle_timeout']['title'] = 'Idle Timeout'; @@ -2080,7 +2081,7 @@ $lng['serversettings']['default_sslvhostconf']['title'] = 'Default SSL vHost-set $lng['serversettings']['includedefault_sslvhostconf'] = 'Include non-SSL vHost-settings in SSL-vHost'; $lng['admin']['ownsslvhostsettings'] = 'Own SSL vHost-settings'; $lng['admin']['ipsandports']['ssl_default_vhostconf_domain'] = 'Default SSL vHost-settings for every domain container'; -$lng['customer']['total_diskspace'] = 'Total diskspace (MiB)'; +$lng['customer']['total_diskspace'] = 'Total diskspace'; $lng['admin']['domain_override_tls'] = 'Override system TLS settings'; $lng['domains']['isaliasdomainof'] = 'Is aliasdomain for %s'; $lng['serversettings']['apply_specialsettings_default']['title'] = 'Default value for "' . $lng['admin']['specialsettingsforsubdomains'] . "' setting when editing a domain"; diff --git a/lng/german.lng.php b/lng/german.lng.php index 0bb94b85..1348806a 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -60,8 +60,8 @@ $lng['customer']['phone'] = 'Telefon'; $lng['customer']['fax'] = 'Fax'; $lng['customer']['email'] = 'E-Mail-Adresse'; $lng['customer']['customernumber'] = 'Kundennummer'; -$lng['customer']['diskspace'] = 'Webspace (MiB)'; -$lng['customer']['traffic'] = 'Traffic (GiB)'; +$lng['customer']['diskspace'] = 'Webspace'; +$lng['customer']['traffic'] = 'Traffic'; $lng['customer']['mysqls'] = 'MySQL-Datenbanken'; $lng['customer']['emails'] = 'E-Mail-Adressen'; $lng['customer']['accounts'] = 'E-Mail-Konten'; @@ -612,7 +612,7 @@ $lng['traffic']['months'][9] = "September"; $lng['traffic']['months'][10] = "Oktober"; $lng['traffic']['months'][11] = "November"; $lng['traffic']['months'][12] = "Dezember"; -$lng['traffic']['mb'] = "Traffic (MiB)"; +$lng['traffic']['mb'] = "Traffic"; $lng['traffic']['day'] = "Tag"; $lng['traffic']['distribution'] = 'FTP | HTTP | Mail'; $lng['traffic']['sumhttp'] = 'Gesamt HTTP-Traffic'; @@ -800,7 +800,7 @@ $lng['serversettings']['mail_quota_enabled']['enforcelink'] = 'Hier klicken, um $lng['question']['admin_quotas_reallywipe'] = 'Sind Sie sicher, dass alle E-Mail-Kontingente aus der Tabelle mail_users entfernt werden sollen? Dieser Schritt kann nicht rückgängig gemacht werden!'; $lng['question']['admin_quotas_reallyenforce'] = 'Sind Sie sicher, dass Sie allen Benutzern das Default-Quota zuweisen wollen? Dies kann nicht rückgängig gemacht werden!'; $lng['error']['vmailquotawrong'] = 'Die Kontingent-Größe muss positiv sein.'; -$lng['customer']['email_quota'] = 'E-Mail-Kontingent (MiB)'; +$lng['customer']['email_quota'] = 'E-Mail-Kontingent'; $lng['customer']['email_imap'] = 'IMAP'; $lng['customer']['email_pop3'] = 'POP3'; $lng['customer']['mail_quota'] = 'E-Mail-Kontingent'; @@ -1266,9 +1266,9 @@ $lng['mysql']['size'] = 'Datenbankgröße'; $lng['error']['invalidhostname'] = 'Hostname muss eine gültige Domain sein. Er darf weder leer sein noch nur aus Leerzeichen bestehen'; -$lng['traffic']['http'] = 'HTTP (MiB)'; -$lng['traffic']['ftp'] = 'FTP (MiB)'; -$lng['traffic']['mail'] = 'Mail (MiB)'; +$lng['traffic']['http'] = 'HTTP'; +$lng['traffic']['ftp'] = 'FTP'; +$lng['traffic']['mail'] = 'Mail'; // ADDED IN 0.9.27-svn1 $lng['serversettings']['mod_fcgid']['idle_timeout']['title'] = 'Idle-Timeout'; @@ -1727,7 +1727,7 @@ $lng['serversettings']['default_sslvhostconf']['title'] = 'Standard SSL vHost-Ei $lng['serversettings']['includedefault_sslvhostconf'] = 'Nicht-SSL vHost-Einstellungen in SSL-vHost inkludieren'; $lng['admin']['ownsslvhostsettings'] = 'Eigene SSL vHost-Einstellungen'; $lng['admin']['ipsandports']['ssl_default_vhostconf_domain'] = 'Standard SSL vHost-Einstellungen für jeden Domain-Container'; -$lng['customer']['total_diskspace'] = 'Gesamtspeicherplatz (MiB)'; +$lng['customer']['total_diskspace'] = 'Gesamtspeicherplatz'; $lng['admin']['domain_override_tls'] = 'Überschreibe System TLS Einstellungen'; $lng['domains']['isaliasdomainof'] = 'Ist Aliasdomain für %s'; $lng['serversettings']['apply_specialsettings_default']['title'] = 'Standardwert für "' . $lng['admin']['specialsettingsforsubdomains'] . "' Einstellung beim Bearbeiten einer Domain"; diff --git a/templates/Sparkle/customer/index/index.tpl b/templates/Sparkle/customer/index/index.tpl index 0f128703..21d3b79d 100644 --- a/templates/Sparkle/customer/index/index.tpl +++ b/templates/Sparkle/customer/index/index.tpl @@ -87,7 +87,7 @@ $header {$userinfo['email_accounts']} {$lng['panel']['available']}
- {$userinfo['mailspace_used']} {$lng['customer']['mib']} + {$userinfo['mailspace_used']} @@ -130,7 +130,7 @@ $header {$userinfo['mysqls']} {$lng['panel']['available']}
- {$userinfo['dbspace_used']} {$lng['customer']['mib']} + {$userinfo['dbspace_used']}