parent
b59afd9d33
commit
c645444db9
|
@ -5,6 +5,7 @@ Changelog
|
|||
Not yet released
|
||||
----------------
|
||||
|
||||
* #642: Added post field as addition to #631.
|
||||
* #644: Fixed urlencoding in Nexmo message
|
||||
* #639: Added combined notifications.
|
||||
* #626: Added redirect check.
|
||||
|
|
|
@ -349,10 +349,11 @@ function psm_parse_msg($status, $type, $vars, $combi = false) {
|
|||
* @param boolean $add_agent add user agent?
|
||||
* @param string|bool $website_username Username website
|
||||
* @param string|bool $website_password Password website
|
||||
* @param string|bool $request_method Request method like GET, POST etc.
|
||||
* @param string|null $request_method Request method like GET, POST etc.
|
||||
* @param string|null $post_field POST data
|
||||
* @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) {
|
||||
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);
|
||||
|
||||
$ch = curl_init();
|
||||
|
@ -370,6 +371,10 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = null, $ad
|
|||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_method);
|
||||
}
|
||||
|
||||
if (!empty($post_field)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_field);
|
||||
}
|
||||
|
||||
if ($website_username !== false && $website_password !== false && !empty($website_username) && !empty($website_password)) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $website_username.":".$website_password);
|
||||
}
|
||||
|
|
|
@ -166,6 +166,8 @@ $sm_lang = array(
|
|||
'request_method' => 'Request method',
|
||||
'custom_request_method' => 'Custom request method',
|
||||
'popular_request_methods' => 'Popular request methods',
|
||||
'post_field' => 'Post field',
|
||||
'post_field_description' => 'The data that will be send using the request method above. Example: param1=val1&param2=val2&...',
|
||||
'please_select' => 'Please select',
|
||||
'type' => 'Type',
|
||||
'type_website' => 'Website',
|
||||
|
|
|
@ -62,6 +62,7 @@ abstract class AbstractServerController extends AbstractController {
|
|||
`s`.`ip`,
|
||||
`s`.`port`,
|
||||
`s`.`request_method`,
|
||||
`s`.`post_field`,
|
||||
`s`.`type`,
|
||||
`s`.`label`,
|
||||
`s`.`pattern`,
|
||||
|
|
|
@ -197,6 +197,7 @@ class ServerController extends AbstractServerController {
|
|||
'edit_value_ip' => $edit_server['ip'],
|
||||
'edit_value_port' => $edit_server['port'],
|
||||
'edit_value_request_method' => $edit_server['request_method'],
|
||||
'edit_value_post_field' => $edit_server['post_field'],
|
||||
'edit_value_timeout' => $edit_server['timeout'],
|
||||
'default_value_timeout' => PSM_CURL_TIMEOUT,
|
||||
'edit_value_pattern' => $edit_server['pattern'],
|
||||
|
@ -268,6 +269,7 @@ class ServerController extends AbstractServerController {
|
|||
'website_password' => $encrypted_password,
|
||||
'port' => intval(psm_POST('port', 0)),
|
||||
'request_method' => empty(psm_POST('request_method')) ? null : psm_POST('request_method'),
|
||||
'post_field' => empty(psm_POST('post_field')) ? null : psm_POST('post_field'),
|
||||
'type' => psm_POST('type', ''),
|
||||
'pattern' => psm_POST('pattern', ''),
|
||||
'pattern_online' => in_array($_POST['pattern_online'], array('yes', 'no')) ? $_POST['pattern_online'] : 'yes',
|
||||
|
@ -288,6 +290,10 @@ class ServerController extends AbstractServerController {
|
|||
$clean['ip'] = 'http://'.$clean['ip'];
|
||||
}
|
||||
|
||||
if($clean['request_method'] == null) {
|
||||
$clean['post_field'] = null;
|
||||
}
|
||||
|
||||
// validate the lot
|
||||
$server_validator = new \psm\Util\Server\ServerValidator($this->db);
|
||||
|
||||
|
@ -473,6 +479,8 @@ class ServerController extends AbstractServerController {
|
|||
'label_request_method' => psm_get_lang('servers', 'request_method'),
|
||||
'label_custom_request_method' => psm_get_lang('servers', 'custom_request_method'),
|
||||
'label_popular_request_methods' => psm_get_lang('servers', 'popular_request_methods'),
|
||||
'label_post_field' => psm_get_lang('servers', 'post_field'),
|
||||
'label_post_field_description' => psm_get_lang('servers', 'post_field_description'),
|
||||
'label_none' => psm_get_lang('system', 'none'),
|
||||
'label_please_select' => psm_get_lang('servers', 'please_select'),
|
||||
'label_type' => psm_get_lang('servers', 'type'),
|
||||
|
|
|
@ -196,7 +196,7 @@ class Installer {
|
|||
`email` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`user_id`),
|
||||
UNIQUE KEY `unique_username` (`user_name`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
PSM_DB_PREFIX.'users_preferences' => "CREATE TABLE IF NOT EXISTS `".PSM_DB_PREFIX."users_preferences` (
|
||||
`user_id` int(11) unsigned NOT NULL,
|
||||
`key` varchar(255) NOT NULL,
|
||||
|
@ -207,7 +207,7 @@ class Installer {
|
|||
`user_id` INT( 11 ) UNSIGNED NOT NULL ,
|
||||
`server_id` INT( 11 ) UNSIGNED NOT NULL ,
|
||||
PRIMARY KEY ( `user_id` , `server_id` )
|
||||
) ENGINE = MYISAM ;",
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;",
|
||||
PSM_DB_PREFIX.'log' => "CREATE TABLE `".PSM_DB_PREFIX."log` (
|
||||
`log_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`server_id` int(11) unsigned NOT NULL,
|
||||
|
@ -215,7 +215,7 @@ class Installer {
|
|||
`message` varchar(255) NOT NULL,
|
||||
`datetime` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`log_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
PSM_DB_PREFIX.'log_users' => "CREATE TABLE `".PSM_DB_PREFIX."log_users` (
|
||||
`log_id` int(11) UNSIGNED NOT NULL ,
|
||||
`user_id` int(11) UNSIGNED NOT NULL ,
|
||||
|
@ -224,12 +224,13 @@ class Installer {
|
|||
PSM_DB_PREFIX.'servers' => "CREATE TABLE `".PSM_DB_PREFIX."servers` (
|
||||
`server_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`ip` varchar(500) NOT NULL,
|
||||
`port` int(5) unsigned NOT NULL,
|
||||
`request_method` varchar(50) unsigned NULL,
|
||||
`port` int(5) NOT NULL,
|
||||
`request_method` varchar(50) NULL,
|
||||
`label` varchar(255) NOT NULL,
|
||||
`type` enum('ping','service','website') NOT NULL default 'service',
|
||||
`pattern` varchar(255) NOT NULL default '',
|
||||
`pattern_online` enum('yes','no') NOT NULL default 'yes',
|
||||
`post_field` varchar(255) NOT NULL default '',
|
||||
`redirect_check` enum('ok','bad') NOT NULL default 'bad',
|
||||
`allow_http_status` varchar(255) NOT NULL default '',
|
||||
`header_name` varchar(255) NOT NULL default '',
|
||||
|
@ -255,7 +256,7 @@ class Installer {
|
|||
`last_error_output` varchar(255) DEFAULT NULL,
|
||||
`last_output` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`server_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
PSM_DB_PREFIX.'servers_uptime' => "CREATE TABLE IF NOT EXISTS `".PSM_DB_PREFIX."servers_uptime` (
|
||||
`servers_uptime_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`server_id` int(11) unsigned NOT NULL,
|
||||
|
@ -264,7 +265,7 @@ class Installer {
|
|||
`latency` float(9,7) DEFAULT NULL,
|
||||
PRIMARY KEY (`servers_uptime_id`),
|
||||
KEY `server_id` (`server_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||
PSM_DB_PREFIX.'servers_history' => "CREATE TABLE IF NOT EXISTS `".PSM_DB_PREFIX."servers_history` (
|
||||
`servers_history_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`server_id` int(11) unsigned NOT NULL,
|
||||
|
@ -560,15 +561,16 @@ class Installer {
|
|||
* If you have a lot of server that are redirecting,
|
||||
* this will make sure you're servers stay online.
|
||||
*/
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `allow_http_status` VARCHAR(255) NOT NULL DEFAULT '' AFTER `pattern_online`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `allow_http_status` VARCHAR(255) NOT NULL DEFAULT '' AFTER `pattern_online`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD `redirect_check` ENUM( 'ok','bad' ) NOT NULL DEFAULT 'ok' AFTER `allow_http_status`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` CHANGE `redirect_check` `redirect_check` ENUM('ok','bad') NOT NULL DEFAULT 'bad';";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `last_error` VARCHAR(255) NULL AFTER `website_password`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `last_error_output` TEXT NULL AFTER `last_error`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `last_output` TEXT NULL AFTER `last_error_output`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `request_method` varchar(50) NULL AFTER `port`;";
|
||||
$queries[] = "ALTER TABLE `".PSM_DB_PREFIX."servers` ADD COLUMN `post_field` varchar(255) NOT NULL DEFAULT '' AFTER `pattern_online`;";
|
||||
$queries[] = "INSERT INTO `".PSM_DB_PREFIX."config` (`key`, `value`) VALUES ('combine_notifications', '1');";
|
||||
$this->execSQL($queries);
|
||||
$this->log('Combined notifications enabled. Check out the config page for more info.');
|
||||
$this->execSQL($queries);
|
||||
$this->log('Combined notifications enabled. Check out the config page for more info.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ class StatusUpdater {
|
|||
* Please note: if the server is down but has not met the warning threshold, this will return true
|
||||
* to avoid any "we are down" events.
|
||||
*
|
||||
* @todo Get last_output when there is a HPPT 50x error.
|
||||
*
|
||||
* @todo Get last_output when there is a HTTP 50x error.
|
||||
*
|
||||
* @param int $server_id
|
||||
* @param int $max_runs how many times should the script recheck the server if unavailable. default is 2
|
||||
* @return boolean TRUE if server is up, FALSE otherwise
|
||||
|
@ -88,7 +88,8 @@ class StatusUpdater {
|
|||
$this->server = $this->db->selectRow(PSM_DB_PREFIX.'servers', array(
|
||||
'server_id' => $server_id,
|
||||
), array(
|
||||
'server_id', 'ip', 'port', 'request_method', 'label', 'type', 'pattern', 'pattern_online', 'allow_http_status', 'redirect_check', 'header_name', 'header_value', 'status', 'active', 'warning_threshold',
|
||||
'server_id', 'ip', 'port', 'request_method', 'label', 'type', 'pattern', 'pattern_online', 'post_field',
|
||||
'allow_http_status', 'redirect_check', 'header_name', 'header_value', 'status', 'active', 'warning_threshold',
|
||||
'warning_threshold_counter', 'timeout', 'website_username', 'website_password', 'last_offline'
|
||||
));
|
||||
if (empty($this->server)) {
|
||||
|
@ -242,7 +243,8 @@ class StatusUpdater {
|
|||
true,
|
||||
$this->server['website_username'],
|
||||
psm_password_decrypt($this->server['server_id'].psm_get_conf('password_encrypt_key'), $this->server['website_password']),
|
||||
$this->server['request_method']
|
||||
$this->server['request_method'],
|
||||
$this->server['post_field']
|
||||
);
|
||||
$this->header = $curl_result;
|
||||
|
||||
|
|
|
@ -85,6 +85,12 @@
|
|||
<input class="input" type="text" id="requestMethod" name="request_method" value="{{ edit_value_request_method }}" maxlength="50" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group postGroup types typeWebsite">
|
||||
<label class="control-label" for="postField">{{ label_post_field }}</label>
|
||||
<div class="controls">
|
||||
<input class="input" type="text" id="postField" name="post_field" value="{{ edit_value_post_field }}" maxlength="255" data-toggle="tooltip" title="{{ label_post_field_description}}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group types typeWebsite">
|
||||
<label class="control-label" for="pattern">{{ label_pattern }}</label>
|
||||
<div class="controls">
|
||||
|
|
|
@ -86,6 +86,7 @@ $().ready(function() {
|
|||
$('#popularRequestMethods').change(function () {
|
||||
changePopular($(this).val(), $('#type').val());
|
||||
});
|
||||
|
||||
// server type
|
||||
$('.types').hide();
|
||||
changeTypeSwitch($('#type').val());
|
||||
|
@ -138,24 +139,34 @@ function changeTypeSwitch(typeInput) {
|
|||
}
|
||||
|
||||
function changePopular(inputValue, typeInput, changedType = false) {
|
||||
if (typeInput == 'website') {
|
||||
htmlClass = '.requestMethodGroup';
|
||||
htmlID = '#requestMethod';
|
||||
} else if (typeInput == 'service') {
|
||||
htmlClass = '.portGroup';
|
||||
htmlID = '#port';
|
||||
}
|
||||
|
||||
if (inputValue == 'custom') {
|
||||
$(htmlClass).slideDown();
|
||||
} else {
|
||||
changedType ? $(htmlClass).hide() : $(htmlClass).slideUp();
|
||||
$(htmlID).val(inputValue);
|
||||
if (typeInput === 'website') {
|
||||
htmlClass = '.requestMethodGroup';
|
||||
htmlID = '#requestMethod';
|
||||
postClass = '.postGroup';
|
||||
} else if (typeInput === 'service') {
|
||||
htmlClass = '.portGroup';
|
||||
htmlID = '#port';
|
||||
}
|
||||
|
||||
if (typeInput === 'website' && inputValue === '') {
|
||||
changedType ? $(postClass).hide() : $(postClass).slideUp();
|
||||
} else {
|
||||
$(postClass).slideDown();
|
||||
}
|
||||
|
||||
if (inputValue === 'custom') {
|
||||
$(htmlClass).slideDown();
|
||||
return;
|
||||
}
|
||||
|
||||
changedType ? $(htmlClass).hide() : $(htmlClass).slideUp();
|
||||
$(htmlID).val(inputValue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function psm_xhr(mod, params, method, on_complete, options) {
|
||||
method = (typeof method == 'undefined') ? 'GET' : method;
|
||||
method = (typeof method === 'undefined') ? 'GET' : method;
|
||||
|
||||
var xhr_options = {
|
||||
data: params,
|
||||
|
@ -213,8 +224,8 @@ function rtrim(str) {
|
|||
|
||||
function psm_flash_message(message) {
|
||||
var flashmessage = $('#flashmessage');
|
||||
if (flashmessage.length) {
|
||||
if (typeof message != 'undefined') {
|
||||
if(flashmessage.length){
|
||||
if(typeof message !== 'undefined') {
|
||||
flashmessage.html(message);
|
||||
}
|
||||
var t = flashmessage.html();
|
||||
|
|
Loading…
Reference in New Issue