+
+ * Custom time-out per server
+
Translators
+++++++++++
diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php
index 6178e1e3..75600c40 100644
--- a/src/includes/functions.inc.php
+++ b/src/includes/functions.inc.php
@@ -263,11 +263,13 @@ function psm_parse_msg($status, $type, $vars) {
* @param string $href
* @param boolean $header return headers?
* @param boolean $body return body?
- * @param int $timeout connection timeout in seconds
+ * @param int $timeout connection timeout in seconds. defaults to PSM_CURL_TIMEOUT (10 secs).
* @param boolean $add_agent add user agent?
* @return string cURL result
*/
-function psm_curl_get($href, $header = false, $body = true, $timeout = 10, $add_agent = true) {
+function psm_curl_get($href, $header = false, $body = true, $timeout = null, $add_agent = true) {
+ $timeout = $timeout == null ? PSM_CURL_TIMEOUT : intval($timeout);
+
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_NOBODY, (!$body));
diff --git a/src/includes/psmconfig.inc.php b/src/includes/psmconfig.inc.php
index 2a3d43a5..588cf21f 100644
--- a/src/includes/psmconfig.inc.php
+++ b/src/includes/psmconfig.inc.php
@@ -29,7 +29,7 @@
/**
* Current PSM version
*/
-define('PSM_VERSION', '3.1.1-dev');
+define('PSM_VERSION', '3.1.0-dev');
/**
* URL to check for updates. Will not be checked if turned off on config page.
@@ -96,3 +96,8 @@ define('PSM_LOGIN_RESET_RUNTIME', 3600);
* Number of seconds the cron is supposedly dead and we will run another cron anyway.
*/
define('PSM_CRON_TIMEOUT', 600);
+
+/**
+ * Default timeout in seconds for curl requests (can be overwritten per-server).
+ */
+define('PSM_CURL_TIMEOUT', 10);
diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php
index d2594220..ed4bd7fa 100644
--- a/src/lang/bg_BG.lang.php
+++ b/src/lang/bg_BG.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Статус',
'label' => 'Име',
'domain' => 'Хост',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Порт',
'type' => 'Тип',
'type_website' => 'Сайт',
diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php
index d556a284..78897094 100644
--- a/src/lang/da_DK.lang.php
+++ b/src/lang/da_DK.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Label',
'domain' => 'Domæne/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Port',
'type' => 'Type',
'type_website' => 'Hjemmeside',
diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php
index adf5f496..d68edb95 100644
--- a/src/lang/de_DE.lang.php
+++ b/src/lang/de_DE.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Beschriftung',
'domain' => 'Domain/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Port',
'type' => 'Type',
'type_website' => 'Website',
diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php
index 3bd86815..4e0f40f3 100644
--- a/src/lang/en_US.lang.php
+++ b/src/lang/en_US.lang.php
@@ -112,6 +112,7 @@ $sm_lang = array(
'label' => 'Label',
'domain' => 'Domain/IP',
'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Port',
'type' => 'Type',
'type_website' => 'Website',
diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php
index b3c19d5b..ab40d797 100644
--- a/src/lang/es_ES.lang.php
+++ b/src/lang/es_ES.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Titulo',
'domain' => 'Domain/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Port',
'type' => 'Tipo',
'type_website' => 'Website',
diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php
index c1f1048c..5f85c3be 100644
--- a/src/lang/fr_FR.lang.php
+++ b/src/lang/fr_FR.lang.php
@@ -112,6 +112,7 @@ $sm_lang = array(
'label' => 'Nom',
'domain' => 'Domaine/IP',
'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Port',
'type' => 'Type',
'type_website' => 'Site Web',
diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php
index d11ca077..91e5f247 100644
--- a/src/lang/it_IT.lang.php
+++ b/src/lang/it_IT.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Nome',
'domain' => 'Dominio/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Porta',
'type' => 'Tipo',
'type_website' => 'Website',
diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php
index 3fbcb2ca..0050349c 100644
--- a/src/lang/ko_KR.lang.php
+++ b/src/lang/ko_KR.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Label',
'domain' => 'Domain/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Port',
'type' => 'Type',
'type_website' => 'Website',
diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php
index 7bd1d21c..9488bad4 100644
--- a/src/lang/nl_NL.lang.php
+++ b/src/lang/nl_NL.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Label',
'domain' => 'Domein/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Aantal seconden te wachten op een reactie van de server.',
'port' => 'Poort',
'type' => 'Type',
'type_website' => 'Website',
diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php
index fc436eea..7cd76c3b 100644
--- a/src/lang/pt_BR.lang.php
+++ b/src/lang/pt_BR.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Status',
'label' => 'Etiqueta',
'domain' => 'Domínio/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Porta',
'type' => 'Tipo',
'type_website' => 'Website',
diff --git a/src/lang/ru_RU.lang.php b/src/lang/ru_RU.lang.php
index eefd430d..4dd0d6f8 100644
--- a/src/lang/ru_RU.lang.php
+++ b/src/lang/ru_RU.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => 'Статус',
'label' => 'Лейбл',
'domain' => 'Домен/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => 'Порт',
'type' => 'Тип',
'type_website' => 'Веб-сайт',
diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php
index 7da4897a..6649dd35 100644
--- a/src/lang/zh_CN.lang.php
+++ b/src/lang/zh_CN.lang.php
@@ -111,6 +111,8 @@ $sm_lang = array(
'status' => '状态',
'label' => '标签',
'domain' => '域名/IP',
+ 'timeout' => 'Timeout',
+ 'timeout_description' => 'Number of seconds to wait for the server to respond.',
'port' => '端口',
'type' => '类型',
'type_website' => '网站',
diff --git a/src/psm/Module/Server/Controller/AbstractServerController.class.php b/src/psm/Module/Server/Controller/AbstractServerController.class.php
index a89d71a6..c2ac5955 100644
--- a/src/psm/Module/Server/Controller/AbstractServerController.class.php
+++ b/src/psm/Module/Server/Controller/AbstractServerController.class.php
@@ -113,6 +113,7 @@ abstract class AbstractServerController extends AbstractController {
$server['error'] = htmlentities($server['error']);
$server['type'] = psm_get_lang('servers', 'type_' . $server['type']);
+ $server['timeout'] = ($server['timeout'] > 0) ? $server['timeout'] : PSM_CURL_TIMEOUT;
return $server;
}
diff --git a/src/psm/Module/Server/Controller/ServerController.class.php b/src/psm/Module/Server/Controller/ServerController.class.php
index e677c522..128b7ba0 100644
--- a/src/psm/Module/Server/Controller/ServerController.class.php
+++ b/src/psm/Module/Server/Controller/ServerController.class.php
@@ -191,6 +191,7 @@ class ServerController extends AbstractServerController {
'edit_value_ip' => $edit_server['ip'],
'edit_value_port' => $edit_server['port'],
'edit_value_timeout' => $edit_server['timeout'],
+ 'default_value_timeout' => PSM_CURL_TIMEOUT,
'edit_value_pattern' => $edit_server['pattern'],
'edit_value_warning_threshold' => $edit_server['warning_threshold'],
'edit_type_selected_' . $edit_server['type'] => 'selected="selected"',
@@ -217,7 +218,7 @@ class ServerController extends AbstractServerController {
$clean = array(
'label' => trim(strip_tags(psm_POST('label', ''))),
'ip' => trim(strip_tags(psm_POST('ip', ''))),
- 'timeout' => intval(psm_POST('timeout', 0)),
+ 'timeout' => (isset($_POST['timeout']) && intval($_POST['timeout']) > 0) ? intval($_POST['timeout']) : null,
'port' => intval(psm_POST('port', 0)),
'type' => psm_POST('type', ''),
'pattern' => psm_POST('pattern', ''),
@@ -365,6 +366,7 @@ class ServerController extends AbstractServerController {
'label_status' => psm_get_lang('servers', 'status'),
'label_domain' => psm_get_lang('servers', 'domain'),
'label_timeout' => psm_get_lang('servers', 'timeout'),
+ 'label_timeout_description' => psm_get_lang('servers', 'timeout_description'),
'label_port' => psm_get_lang('servers', 'port'),
'label_type' => psm_get_lang('servers', 'type'),
'label_website' => psm_get_lang('servers', 'type_website'),
diff --git a/src/psm/Util/Install/Installer.class.php b/src/psm/Util/Install/Installer.class.php
index 7ddb82a6..3634aca6 100644
--- a/src/psm/Util/Install/Installer.class.php
+++ b/src/psm/Util/Install/Installer.class.php
@@ -78,7 +78,7 @@ class Installer {
// different DB version, check if the version requires any changes
// @todo this is currently a manual check for each version, similar to upgrade().. not a clean way
- if(version_compare($version_db, '3.1.1', '<')) {
+ if(version_compare($version_db, '3.1.0', '<')) {
return true;
} else {
// change database version to current version so this check won't be required next time
@@ -218,7 +218,7 @@ class Installer {
`sms` enum('yes','no') NOT NULL default 'no',
`warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1',
`warning_threshold_counter` mediumint(1) unsigned NOT NULL DEFAULT '0',
- `timeout` int(1) NOT NULL DEFAULT '10',
+ `timeout` smallint(1) unsigned NULL DEFAULT NULL,
PRIMARY KEY (`server_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
PSM_DB_PREFIX . 'servers_uptime' => "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "servers_uptime` (
@@ -275,10 +275,6 @@ class Installer {
// upgrade to 3.1.0
$this->upgrade310();
}
- if(version_compare($version_from, '3.1.1', '<')) {
- // upgrade to 3.1.1
- $this->upgrade311();
- }
psm_update_conf('version', $version_to);
}
@@ -402,12 +398,7 @@ class Installer {
`value` varchar(255) NOT NULL,
PRIMARY KEY (`user_id`, `key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
- $this->execSQL($queries);
- }
-
- protected function upgrade311() {
- $queries = array();
- $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` INT( 1 ) NOT NULL DEFAULT '10';";
+ $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` smallint(1) unsigned NULL DEFAULT NULL;";
$this->execSQL($queries);
}
}
diff --git a/src/templates/server/server.tpl.html b/src/templates/server/server.tpl.html
old mode 100755
new mode 100644
index bcd0346e..693dceb1
--- a/src/templates/server/server.tpl.html
+++ b/src/templates/server/server.tpl.html
@@ -92,12 +92,6 @@
-
-
-
-
-
-
+
+
+
+ s
+
+