diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index ed948d2e..43bb55ee 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -354,7 +354,7 @@ function psm_parse_msg($status, $type, $vars, $combi = false) { * @return string cURL result */ function psm_curl_get($href, $header = false, $body = true, $timeout = null, $add_agent = true, $website_username = false, $website_password = false, $request_method = null, $post_field = null) { - $timeout = $timeout == null ? PSM_CURL_TIMEOUT : intval($timeout); + ($timeout === null || $timeout > 0) ? PSM_CURL_TIMEOUT : intval($timeout); $ch = curl_init(); if(defined('PSM_DEBUG') && PSM_DEBUG === true && psm_is_cli()) { diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index b1a2f5dc..12475174 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -252,7 +252,7 @@ class ServerController extends AbstractServerController { $clean = array( 'label' => trim(strip_tags(psm_POST('label', ''))), 'ip' => trim(strip_tags(psm_POST('ip', ''))), - 'timeout' => (isset($_POST['timeout']) && intval($_POST['timeout']) > 0) ? intval($_POST['timeout']) : null, + 'timeout' => (isset($_POST['timeout']) && intval($_POST['timeout']) > 0) ? intval($_POST['timeout']) : 10, 'website_username' => psm_POST('website_username'), 'website_password' => $encrypted_password, 'port' => intval(psm_POST('port', 0)), diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 9588d4aa..2b1f26b8 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -202,11 +202,12 @@ class StatusUpdater { * @return boolean */ protected function updateService($max_runs, $run = 1) { + $timeout = ($this->server['timeout'] === null || $this->server['timeout'] > 0) ? PSM_CURL_TIMEOUT : intval($this->server['timeout']); $errno = 0; // save response time $starttime = microtime(true); - $fp = @fsockopen($this->server['ip'], $this->server['port'], $errno, $this->error, $this->server['timeout']); + $fp = @fsockopen($this->server['ip'], $this->server['port'], $errno, $this->error, $timeout); $status = ($fp === false) ? false : true; $this->rtime = (microtime(true) - $starttime); diff --git a/src/templates/default/module/server/server/update.tpl.html b/src/templates/default/module/server/server/update.tpl.html index e137f4a3..7f0f3788 100644 --- a/src/templates/default/module/server/server/update.tpl.html +++ b/src/templates/default/module/server/server/update.tpl.html @@ -115,7 +115,7 @@ {{ macro.input_field("number", "warning_threshold", null, "warning_threshold", label_warning_threshold, edit_value_warning_threshold, "0", "5", 'warning_threshold_help', label_warning_threshold_description) }} - {{ macro.input_field("number", "timeout", null, "timeout", label_timeout, edit_value_timeout, null, "10", 'timeout_help', label_timeout_description) }} + {{ macro.input_field("number", "timeout", null, "timeout", label_timeout, edit_value_timeout, default_value_timeout, "10", 'timeout_help', label_timeout_description) }}