From 12bed9b6ac9deb8062487475bc84f29d84acd4ca Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 3 Oct 2018 11:11:33 -0400 Subject: [PATCH] Use alternate, working test for relative ZM_DIR_EVENTS. Don't use human output from du when specifying mid to be consistent. --- web/api/app/Controller/HostController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php index be787cafc..f0df3797e 100644 --- a/web/api/app/Controller/HostController.php +++ b/web/api/app/Controller/HostController.php @@ -101,8 +101,8 @@ class HostController extends AppController { $this->loadModel('Monitor'); // If $mid is passed, see if it is valid - if ($mid) { - if (!$this->Monitor->exists($mid)) { + if ( $mid ) { + if ( !$this->Monitor->exists($mid) ) { throw new NotFoundException(__('Invalid monitor')); } } @@ -110,14 +110,16 @@ class HostController extends AppController { $zm_dir_events = ZM_DIR_EVENTS; // Test to see if $zm_dir_events is relative or absolute - if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) { + #if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) { + if ( substr($zm_dir_events, 0, 1) != '/' ) { // relative - so add the full path $zm_dir_events = ZM_PATH_WEB . '/' . $zm_dir_events; } if ( $mid ) { // Get disk usage for $mid - $usage = shell_exec("du -sh0 $zm_dir_events/$mid | awk '{print $1}'"); + Logger::Debug("Executing du -s0 $zm_dir_events/$mid | awk '{print $1}'"); + $usage = shell_exec("du -s0 $zm_dir_events/$mid | awk '{print $1}'"); } else { $monitors = $this->Monitor->find('all', array( 'fields' => array('Id', 'Name', 'WebColour')