From cae9a1550d77e4b2f6d4637ee47efc57183f40ee Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 22 Nov 2021 23:14:32 +0200 Subject: [PATCH] Added disk and bandwidth percentage values to the session response. --- web/api/v1/add/ip/index.php | 2 ++ web/api/v1/edit/server/index.php | 5 ++--- web/api/v1/list/db/index.php | 2 ++ web/api/v1/list/mail/index.php | 6 ++++++ web/api/v1/list/stats/index.php | 3 +++ web/api/v1/list/user/index.php | 3 +++ web/api/v1/list/web/index.php | 3 +++ 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/web/api/v1/add/ip/index.php b/web/api/v1/add/ip/index.php index 39a2959af..0f3cf412e 100644 --- a/web/api/v1/add/ip/index.php +++ b/web/api/v1/add/ip/index.php @@ -7,6 +7,8 @@ $TAB = 'IP'; header('Content-Type: application/json'); include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +// var_dump($_SESSION['user']); + // Check user if ($_SESSION['user'] != 'admin') { exit; diff --git a/web/api/v1/edit/server/index.php b/web/api/v1/edit/server/index.php index 76a005283..58ba4789b 100644 --- a/web/api/v1/edit/server/index.php +++ b/web/api/v1/edit/server/index.php @@ -636,10 +636,9 @@ $result = array( 'mail_system' => $_SESSION['MAIL_SYSTEM'], 'antivirus_system' => $_SESSION['ANTIVIRUS_SYSTEM'], 'antispam_system' => $_SESSION['ANTISPAM_SYSTEM'], - 'mail_url' => $_SESSION['MAIL_URL'], + 'mail_url' => $_SESSION['DB_PMA_URL'], 'pgsql_url' => $_SESSION['DB_PGA_URL'], 'mail_certificate' => $_SESSION['MAIL_CERTIFICATE'], - 'db_pma_url' => $_SESSION['DB_PMA_URL'], 'dns_system' => $_SESSION['DNS_SYSTEM'], 'web_system' => $_SESSION['WEB_SYSTEM'], 'softaculous' => $_SESSION['SOFTACULOUS'], @@ -667,7 +666,7 @@ $result = array( 'v_dns_cluster' => $v_dns_cluster, 'db_hosts' => $db_hosts, 'mysql_hosts' => $v_mysql_hosts, - 'mysql' => $mysql, + 'mysql' => $v_mysql, 'pgsql_hosts' => $v_pgsql_hosts, 'pgsql' => $v_pgsql, 'protocols' => [ __('ftp'), __('sftp') ], diff --git a/web/api/v1/list/db/index.php b/web/api/v1/list/db/index.php index 42c872958..2ad5c4b50 100644 --- a/web/api/v1/list/db/index.php +++ b/web/api/v1/list/db/index.php @@ -25,6 +25,8 @@ list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":"); foreach ($data as $key => $value) { ++$i; + $data[$key]['U_DISK_PERCENT'] = get_percentage($data[$key]['U_DISK'],$panel[$user]['DISK_QUOTA']); + if ( $i == 1) { $total_amount = __('1 database'); } else { diff --git a/web/api/v1/list/mail/index.php b/web/api/v1/list/mail/index.php index 8d6c59126..abc6f47df 100644 --- a/web/api/v1/list/mail/index.php +++ b/web/api/v1/list/mail/index.php @@ -35,6 +35,12 @@ top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB foreach ($data as $key => $value) { ++$i; + if (empty($_GET['domain'])){ + $data[$key]['U_DISK_PERCENT'] = get_percentage($data[$key]['U_DISK'], $data[$key]['QUOTA']); + } else { + $data[$key]['U_DISK_PERCENT'] = get_percentage($data[$key]['U_DISK'], $panel[$user]['DISK_QUOTA']); + } + list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":"); $webmail = "/webmail/"; if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL']; diff --git a/web/api/v1/list/stats/index.php b/web/api/v1/list/stats/index.php index 9053d9227..480757720 100644 --- a/web/api/v1/list/stats/index.php +++ b/web/api/v1/list/stats/index.php @@ -35,6 +35,9 @@ if ($user == 'admin') { foreach ($data as $key => $value) { ++$i; + $data[$key]['U_BANDWIDTH_PERCENT'] = get_percentage($data[$key]['U_BANDWIDTH'],$data[$key]['BANDWIDTH']); + $data[$key]['U_DISK_PERCENT'] = get_percentage($data[$key]['U_DISK'],$data[$key]['DISK_QUOTA']); + if ( $i == 1) { $total_amount = __('1 month'); } else { diff --git a/web/api/v1/list/user/index.php b/web/api/v1/list/user/index.php index acacb3a21..66681de45 100644 --- a/web/api/v1/list/user/index.php +++ b/web/api/v1/list/user/index.php @@ -28,6 +28,9 @@ foreach ($data as $key => $value) { $total_amount = __('%s accounts', $i); } + $data[$key]['U_BANDWIDTH_PERCENT'] = get_percentage($data[$key]['U_BANDWIDTH'],$data[$key]['BANDWIDTH']); + $data[$key]['U_DISK_PERCENT'] = get_percentage($data[$key]['U_DISK'],$data[$key]['DISK_QUOTA']); + $data[$key]['U_BANDWIDTH'] = humanize_usage_size($data[$key]['U_BANDWIDTH']); $data[$key]['U_BANDWIDTH_MEASURE'] = humanize_usage_measure($data[$key]['U_BANDWIDTH_MEASURE']); diff --git a/web/api/v1/list/web/index.php b/web/api/v1/list/web/index.php index 252de541a..c49e8a5c4 100644 --- a/web/api/v1/list/web/index.php +++ b/web/api/v1/list/web/index.php @@ -23,6 +23,9 @@ $_SESSION['back'] = $_SERVER['REQUEST_URI']; foreach ($data as $key => $value) { ++$i; + $data[$key]['U_BANDWIDTH_PERCENT'] = get_percentage($data[$key]['U_BANDWIDTH'],$panel[$user]['BANDWIDTH']); + $data[$key]['U_DISK_PERCENT'] = get_percentage($data[$key]['U_DISK'],$data[$key]['DISK_QUOTA']); + if ($data[$key]['SUSPENDED'] == 'yes') { $data[$key]['status'] = 'suspended'; $data[$key]['spnd_action'] = 'unsuspend' ;