feat(functions): getDifference(), getPercentageUsed()

clean up variable definition a little bit
main
steven 2020-12-02 12:21:43 -05:00
parent 3bad21bf42
commit 9b1d12835b
1 changed files with 25 additions and 15 deletions

View File

@ -10,31 +10,41 @@
<meta name="msapplication-TileColor" content="#00aba9">
<meta name="theme-color" content="#ffffff">
<?php
function getPercentageUsed($total, $used) {
return ($total && $used ?
sprintf('%.4f', (100 * $used / $total))
: false);
}
function getDifference($minuend, $subtrahend) {
return ($minuend && $subtrahend ?
$minuend - $subtrahend
: false);
}
$hinamizawa_total = disk_total_space(/data/);
$hinamizawa_free = disk_free_space(/data/);
$hinamizawa_percent_used = $hinamizawa_total ?
(($hinamizawa_total - $hinamizawa_free) / $hinamizawa_total)
: false;
$hinamizawa_used = getDifference($hinamizawa_total, $hinamizawa_free);
$hinamizawa_percent =
getPercentageUsed($hinamizawa_total, $hinamizawa_used);
$maebara_total = disk_total_space(/data/maebara/);
$maebara_free = disk_free_space(/data/maebara/);
$maebara_percent_used = $maebara_total ?
(($maebara_total - $maebara_free) / $maebara_total)
: false;
$maebara_used = getDifference($maebara_total, $maebara_free);
$maebara_percent =
getPercentageUsed($maebara_total, $maebara_used);
$houjou_total = disk_total_space(/data/houjou/);
$houjou_free = disk_free_space(/data/houjou/);
$houjou_percent_used = $houjou_total ?
(($houjou_total - $houjou_free) / $houjou_total)
: false;
$houjou_used = getDifference($houjou_total, $houjou_free);
$houjou_percent =
getPercentageUsed($houjou_total, $houjou_used);
$ryuuguu_total = disk_total_space(/data/ryuuguu/);
$ryuuguu_free = disk_free_space(/data/ryuuguu/);
$ryuuguu_percent_used = $ryuuguu_total ?
(($ryuuguu_total - $ryuuguu_free) / $ryuuguu_total)
: false;
$ryuuguu_used = getDifference($ryuuguu_total, $ryuuguu_free);
$ryuuguu_percent =
getPercentageUsed($ryuuguu_total, $ryuuguu_used);
$sonozaki_total = disk_total_space(/data/sonozaki/);
$sonozaki_free = disk_free_space(/data/sonozaki/);
$sonozaki_percent_used = $sonozaki_total
(($sonozaki_total - $sonozaki_free) / $sonozaki_total)
: false;
$sonozaki_used = getDifference($sonozaki_total, $sonozaki_free);
$sonozaki_percent =
getPercentageUsed($sonozaki_total, $sonozaki_used);
?>
<style type="text/css">
.pie {