diff --git a/public/include/classes/monitoring.class.php b/public/include/classes/monitoring.class.php index 464b7b04..0fc8d8b4 100644 --- a/public/include/classes/monitoring.class.php +++ b/public/include/classes/monitoring.class.php @@ -9,6 +9,11 @@ class Monitoring extends Base { $this->table = 'monitoring'; } + /** + * Store Uptime Robot status information as JSON in settings table + * @param none + * @return bool true on success, false on error + **/ public function storeUptimeRobotStatus() { if ($api_keys = $this->setting->getValue('monitoring_uptimerobot_private_key')) { $aJSONData = array(); @@ -28,11 +33,17 @@ class Monitoring extends Base { } if (!$this->setting->setValue('monitoring_uptimerobot_status', json_encode($aAllMonitorsStatus)) || !$this->setting->setValue('monitoring_uptimerobot_lastcheck', time())) { $this->setErrorMessage('Failed to store uptime status: ' . $setting->getError()); + return false; } } return true; } + /** + * Fetch Uptime Robot Status from settings table + * @param none + * @return array Data on success, false on failure + **/ public function getUptimeRobotStatus() { if ($json = $this->setting->getValue('monitoring_uptimerobot_status')) return json_decode($json, true); diff --git a/public/include/classes/tools.class.php b/public/include/classes/tools.class.php index f6d23b0f..1cf4f875 100644 --- a/public/include/classes/tools.class.php +++ b/public/include/classes/tools.class.php @@ -32,9 +32,15 @@ class Tools extends Base { // run the query $res = curl_exec($ch); - if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch)); + if ($res === false) { + $this->setErrorMessage('Could not get reply: '.curl_error($ch)); + return false; + } $dec = json_decode($res, true); - if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists'); + if (!$dec) { + $this->setErrorMessage('Invalid data received, please make sure connection is working and requested API exists'); + return false; + } return $dec; }