Don't compute spaces when quota is disabled

Also fix code ident
This commit is contained in:
Ludovic Poujol 2019-03-21 17:41:11 +01:00
parent 6b1fa94da9
commit 34c7c5dc22

View file

@ -1,11 +1,11 @@
<?php <?php
/** /**
* Apache VirtualHost Management Page * Apache VirtualHost Management Page
* *
* Copyright (c) 2009 Evolix - Tous droits reserves * Copyright (c) 2009 Evolix - Tous droits reserves
* *
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* *
* @author Gregory Colpart <reg@evolix.fr> * @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr> * @author Thomas Martin <tmartin@evolix.fr>
@ -33,47 +33,58 @@ if (!$conf['cluster']) {
foreach($data_output as $data_line) { foreach($data_output as $data_line) {
$data_split = explode(':', $data_line); $data_split = explode(':', $data_line);
if (strstr($data_split[4],'K')) { if(isset($conf['quota']) && $conf['quota'] === true) {
$taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'M';
$taille_utilise_mo = $taille_utilise;
if ($taille_utilise >= 1024) {
$taille_utilise = number_format(($taille_utilise/1024), 2, '.', '').'G';
}
} else if ($data_split[4] >= 1024) {
$taille_utilise_mo = $data_split[4];
$taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'G';
} else {
$taille_utilise_mo = $data_split[4];
$taille_utilise = $data_split[4];
}
$quota_bas_mo = $data_split[5];
$quota_bas = number_format(($data_split[5]/1024), 2, '.', '').'G';
$quota_haut = number_format(($data_split[6]/1024), 2, '.', '').'G';
$occupation = number_format((($taille_utilise_mo/$quota_bas_mo)*100), 2, '.', '');
if ($occupation >= 90) {
$occupation = '<span style="color:red;font-weight:bold;">'.$occupation.'%</span>';
} else if ($occupation >= 80) {
$occupation = '<span style="color:MediumVioletRed;font-weight:bold;">'.$occupation.'%</span>';
} else if ($occupation >= 70) {
$occupation = '<span style="color:Fuchsia;font-weight:bold;">'.$occupation.'%</span>';
} else {
$occupation = $occupation.'%';
}
array_push($vhost_list, array(
'owner' => $data_split[0],
'configid' => $data_split[1],
'server_name' => $data_split[2],
'server_alias' => $data_split[3],
'size' => $taille_utilise,
'quota_soft' => $quota_bas,
'quota_hard' => $quota_haut,
'occupation' => $occupation,
'php_version' => $data_split[7],
'is_enabled' => $data_split[8])
);
}
if (strstr($data_split[4],'K')) {
$taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'M';
$taille_utilise_mo = $taille_utilise;
if ($taille_utilise >= 1024) {
$taille_utilise = number_format(($taille_utilise/1024), 2, '.', '').'G';
}
} else if ($data_split[4] >= 1024) {
$taille_utilise_mo = $data_split[4];
$taille_utilise = number_format(($data_split[4]/1024), 2, '.', '').'G';
} else {
$taille_utilise_mo = $data_split[4];
$taille_utilise = $data_split[4];
}
$quota_bas_mo = $data_split[5];
$quota_bas = number_format(($data_split[5]/1024), 2, '.', '').'G';
$quota_haut = number_format(($data_split[6]/1024), 2, '.', '').'G';
$occupation = number_format((($taille_utilise_mo/$quota_bas_mo)*100), 2, '.', '');
if ($occupation >= 90) {
$occupation = '<span style="color:red;font-weight:bold;">'.$occupation.'%</span>';
} else if ($occupation >= 80) {
$occupation = '<span style="color:MediumVioletRed;font-weight:bold;">'.$occupation.'%</span>';
} else if ($occupation >= 70) {
$occupation = '<span style="color:Fuchsia;font-weight:bold;">'.$occupation.'%</span>';
} else {
$occupation = $occupation.'%';
}
}
else {
$taille_utilise ="";
$quota_bas = "";
$quota_haut = "";
$occupation = "";
}
array_push($vhost_list, array(
'owner' => $data_split[0],
'configid' => $data_split[1],
'server_name' => $data_split[2],
'server_alias' => $data_split[3],
'size' => $taille_utilise,
'quota_soft' => $quota_bas,
'quota_hard' => $quota_haut,
'occupation' => $occupation,
'php_version' => $data_split[7],
'is_enabled' => $data_split[8])
);
}
} }
else { else {
@ -98,13 +109,12 @@ else {
if (!empty($accounts)) { if (!empty($accounts)) {
foreach($accounts as $account) { foreach($accounts as $account) {
$master = $bdd->get_server_from_roleid($account['id_master']); $master = $bdd->get_server_from_roleid($account['id_master']);
$slave = ''; $slave = '';
if (!empty($account['id_slave'])) if (!empty($account['id_slave']))
$slave = $bdd->get_server_from_roleid($account['id_slave']); $slave = $bdd->get_server_from_roleid($account['id_slave']);
array_push($vhost_list, array( array_push($vhost_list, array(
'owner' => $account['name'], 'owner' => $account['name'],
'server_name'=> $account['domain'], 'server_name'=> $account['domain'],
@ -113,14 +123,11 @@ else {
'replication' => $account['replication'], 'replication' => $account['replication'],
'master' => $master, 'master' => $master,
'slave' => $slave) 'slave' => $slave)
); );
} }
} }
} }
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/webadmin.tpl.php'; include_once EVOADMIN_BASE . '../tpl/webadmin.tpl.php';