Skip to content

Commit 3156fe8

Browse files
committed
Fix divison by zero error when total swap amount is zero
Reported bug under Ubuntu with zero swap
1 parent 6e3ce8d commit 3156fe8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

backend/sys_infos.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,16 @@
9494
$swaptotal = $swap[1];
9595
$swapused = $swap[2];
9696
$swapfree = $swap[3];
97-
$swapperc = round(($swapused/$swaptotal)*100);
97+
if($swaptotal == 0){
98+
$swapperc = 0;
99+
}else{
100+
$swapperc = round(($swapused/$swaptotal)*100);
101+
}
102+
98103
}
99104
//
100105
if(isset($_GET["statemail"])){
101-
106+
102107
$name_tag = array();
103108
$name_tag[0] = "Sunday";
104109
$name_tag[1] = "Monday";
@@ -130,7 +135,7 @@
130135
//echo $command;
131136
$output=shell_exec($command);
132137
echo "<pre>$output</pre><br>";
133-
138+
134139
$a1 = "\n<div class=\"testbox\" style=\"border: 1px dotted green; position: absolute; margin:0px; padding:10px; z-index:5; background-color:#ffffcc; color:#000000;\"> \n";
135140
$a2 = " \n </div> \n";
136141
$ausgabe = $a1 . "Status mail was sent!<br><button onclick='location.replace(\"../index.php\");'>Zurück</button>" . $a2;

0 commit comments

Comments
 (0)