aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/collectd.inc.php
diff options
context:
space:
mode:
authorPeter Wu2014-07-20 15:59:51 +0200
committerPeter Wu2014-07-20 23:23:24 +0200
commitb7be6ba7ed302e18a313af4cbb2827b1fb62193a (patch)
treec262da09f5fe403ed5657e9ee84d5a22abb0acfb /inc/collectd.inc.php
parentDefensive programming: more urlencode/htmlentities (diff)
downloadapt-panopticon_cgp-b7be6ba7ed302e18a313af4cbb2827b1fb62193a.zip
apt-panopticon_cgp-b7be6ba7ed302e18a313af4cbb2827b1fb62193a.tar.gz
apt-panopticon_cgp-b7be6ba7ed302e18a313af4cbb2827b1fb62193a.tar.bz2
apt-panopticon_cgp-b7be6ba7ed302e18a313af4cbb2827b1fb62193a.tar.xz
Fix type confusion
index.php expects that collectd_hosts() always return an array for array_diff. Since an empty array evaluates to FALSE anyway, do not change the type and just return the empty array. In base.php, if no files are returned, the loop is never called and three variables are not initialized. Do it now.
Diffstat (limited to 'inc/collectd.inc.php')
-rw-r--r--inc/collectd.inc.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php
index fda685d..761f7c4 100644
--- a/inc/collectd.inc.php
+++ b/inc/collectd.inc.php
@@ -9,7 +9,7 @@ function collectd_hosts() {
9 global $CONFIG; 9 global $CONFIG;
10 10
11 if (!is_dir($CONFIG['datadir'])) 11 if (!is_dir($CONFIG['datadir']))
12 return false; 12 return array();
13 13
14 $dir = array_diff(scandir($CONFIG['datadir']), array('.', '..')); 14 $dir = array_diff(scandir($CONFIG['datadir']), array('.', '..'));
15 foreach($dir as $k => $v) { 15 foreach($dir as $k => $v) {
@@ -17,7 +17,7 @@ function collectd_hosts() {
17 unset($dir[$k]); 17 unset($dir[$k]);
18 } 18 }
19 19
20 return $dir ? $dir : false; 20 return $dir;
21} 21}
22 22
23 23
@@ -36,7 +36,7 @@ function get_host_rrd_files($dir) {
36 $files[] = str_replace($dir.'/', '', $object->getPathname()); 36 $files[] = str_replace($dir.'/', '', $object->getPathname());
37 } 37 }
38 38
39 return $files ? $files : false; 39 return $files;
40} 40}
41 41
42 42