From 27ca8d86742199683e85e77bccba68671782b13a Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Tue, 21 Feb 2017 12:33:05 -0600 Subject: [PATCH 1/2] use === operator in getDiskPercent function --- web/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index 970a5a822..8e3f910cb 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1434,12 +1434,12 @@ function getLoad() { function getDiskPercent($path = ZM_DIR_EVENTS) { $total = disk_total_space($path); - if ( ! $total ) { + if ( $total === false ) { Error("disk_total_space returned false for " . $path ); return 0; } $free = disk_free_space($path); - if ( ! $free ) { + if ( $free === false ) { Error("disk_free_space returned false for " . $path ); } $space = round(($total - $free) / $total * 100); From 8759e2bdb43a66ee8595e5ffa3367860e7190043 Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Tue, 21 Feb 2017 13:10:41 -0600 Subject: [PATCH 2/2] prevent divide by zero, make error messages more descriptive --- web/includes/functions.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index 8e3f910cb..82676b27d 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1435,14 +1435,17 @@ function getLoad() { function getDiskPercent($path = ZM_DIR_EVENTS) { $total = disk_total_space($path); if ( $total === false ) { - Error("disk_total_space returned false for " . $path ); + Error("disk_total_space returned false. Verify the web account user has access to " . $path ); return 0; + } elseif ( $total == 0 ) { + Error("disk_total_space indicates the following path has a filesystem size of zero bytes" . $path ); + return 100; } $free = disk_free_space($path); if ( $free === false ) { - Error("disk_free_space returned false for " . $path ); + Error("disk_free_space returned false. Verify the web account user has access to " . $path ); } - $space = round(($total - $free) / $total * 100); + $space = round((($total - $free) / $total) * 100); return( $space ); }