Merge branch 'develop' into develop

This commit is contained in:
Tim 2020-08-12 19:44:38 +02:00 committed by GitHub
commit 6b272d29d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 830 additions and 297 deletions

View File

@ -6,6 +6,18 @@ Not yet released
----------------
\-
v3.5.2 (released August 12, 2020)
-----------------------------
* Fixed missing version numbers.
* See https://github.com/phpservermon/phpservermon/compare/v3.5.1...v3.5.2
v3.5.1 (released August 12, 2020)
-----------------------------
* Security update regaring jQuery, see #972.
* See https://github.com/phpservermon/phpservermon/compare/v3.5.0...v3.5.1
v3.5.0 (released May 1, 2020)
-----------------------------

View File

@ -5,7 +5,7 @@ PHP Server Monitor
:alt: Join the chat at https://gitter.im/erickrf/nlpnet
:target: https://gitter.im/phpservermon/phpservermon
Version 3.5.1
Version 3.5.2
PHP Server Monitor is a script that checks whether your websites and servers are up and running.
It comes with a web based user interface where you can manage your services and websites,
@ -61,6 +61,7 @@ The following SMS gateways are currently available:
* Plivo - <https://www.plivo.com/>
* Callr - <https://www.callr.com/>
* SMSAPI - <https://www.smsapi.com/en>
* OVH SMS PRO - <https://www.ovhtelecom.fr/sms/>

View File

@ -51,9 +51,9 @@ copyright = u'2008-2017, Pepijn Over'
# built documents.
#
# The short X.Y version.
version = '3.5.0'
version = '3.5'
# The full version, including alpha/beta/rc tags.
release = '3.5.0'
release = '3.5.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@ -34,21 +34,21 @@ namespace {
#
###############################################
/**
* Retrieve language settings from the selected language file
* Return false if arg is not found
*
* @return string|bool
* @see psm_load_lang()
*/
/**
* Retrieve language settings from the selected language file
* Return false if arg is not found
*
* @return string|bool
* @see psm_load_lang()
*/
function psm_get_lang()
{
$args = func_get_args();
if (empty($args)) {
return isset($GLOBALS['sm_lang']) ? $GLOBALS['sm_lang'] : $GLOBALS['sm_lang_default'];
}
if (isset($GLOBALS['sm_lang'])) {
$lang = $GLOBALS['sm_lang'];
$not_found = false;
@ -72,13 +72,13 @@ namespace {
return $lang;
}
/**
* Load default language from the English (en_US) language file to the $GLOBALS['sm_lang_default'] variable
* Load language from the language file to the $GLOBALS['sm_lang'] variable if language is different from default
*
* @param string $lang language
* @see psm_get_lang()
*/
/**
* Load default language from the English (en_US) language file to the $GLOBALS['sm_lang_default'] variable
* Load language from the language file to the $GLOBALS['sm_lang'] variable if language is different from default
*
* @param string $lang language
* @see psm_get_lang()
*/
function psm_load_lang($lang)
{
// load default language - English (en_US)
@ -86,29 +86,29 @@ namespace {
$default_lang_file = PSM_PATH_LANG . 'en_US.lang.php';
file_exists($default_lang_file) ? require $default_lang_file :
trigger_error("English translation needs to be installed at all time!", E_USER_ERROR);
trigger_error("English translation needs to be installed at all time!", E_USER_ERROR);
isset($sm_lang) ? $GLOBALS['sm_lang_default'] = $sm_lang :
trigger_error("\$sm_lang not found in English translation!", E_USER_ERROR);
trigger_error("\$sm_lang not found in English translation!", E_USER_ERROR);
unset($sm_lang);
// load translation is the selected language is not English (en_US)
if ($lang != "en_US") {
$lang_file = PSM_PATH_LANG . $lang . '.lang.php';
file_exists($lang_file) ? require $lang_file :
trigger_error("Translation file could not be found! Default language will be used.", E_USER_WARNING);
trigger_error("Translation file could not be found! Default language will be used.", E_USER_WARNING);
isset($sm_lang) ? $GLOBALS['sm_lang'] = $sm_lang :
trigger_error("\$sm_lang not found in translation file! Default language will be used.", E_USER_WARNING);
trigger_error("\$sm_lang not found in translation file! Default language will be used.", E_USER_WARNING);
isset($sm_lang['locale']) ? setlocale(LC_TIME, $sm_lang['locale']) :
trigger_error("locale could not ben found in translation file.", E_USER_WARNING);
trigger_error("locale could not ben found in translation file.", E_USER_WARNING);
}
}
/**
* Retrieve a list with keys of the available languages
*
* @return array
* @see psm_load_lang()
*/
/**
* Retrieve a list with keys of the available languages
*
* @return array
* @see psm_load_lang()
*/
function psm_get_langs()
{
$fn_ext = '.lang.php';
@ -133,11 +133,11 @@ namespace {
return $langs;
}
/**
* Retrieve a list with available sms gateways
*
* @return array
*/
/**
* Retrieve a list with available sms gateways
*
* @return array
*/
function psm_get_sms_gateways()
{
$sms_gateway_files = glob(PSM_PATH_SMS_GATEWAY . '*.php');
@ -155,14 +155,14 @@ namespace {
return $sms_gateways;
}
/**
* Get a setting from the config.
*
* @param string $key
* @param mixed $alt if not set, return this alternative
* @return string
* @see psm_load_conf()
*/
/**
* Get a setting from the config.
*
* @param string $key
* @param mixed $alt if not set, return this alternative
* @return string
* @see psm_load_conf()
*/
function psm_get_conf($key, $alt = null)
{
if (!isset($GLOBALS['sm_config'])) {
@ -173,13 +173,13 @@ namespace {
return $result;
}
/**
* Load config from the database to the $GLOBALS['sm_config'] variable
*
* @global object $db
* @return boolean
* @see psm_get_conf()
*/
/**
* Load config from the database to the $GLOBALS['sm_config'] variable
*
* @return boolean
* @global object $db
* @see psm_get_conf()
*/
function psm_load_conf()
{
global $db;
@ -204,14 +204,14 @@ namespace {
}
}
/**
* Update a config setting.
*
* If the key does not exist yet it will be created.
* @global \psm\Service\Database $db
* @param string $key
* @param string $value
*/
/**
* Update a config setting.
*
* If the key does not exist yet it will be created.
* @param string $key
* @param string $value
* @global \psm\Service\Database $db
*/
function psm_update_conf($key, $value)
{
global $db;
@ -223,8 +223,8 @@ namespace {
$db->save(
PSM_DB_PREFIX . 'config',
array(
'key' => $key,
'value' => $value,
'key' => $key,
'value' => $value,
)
);
} else {
@ -243,16 +243,16 @@ namespace {
#
###############################################
/**
* This function merely adds the message to the log table. It does not perform any checks,
* everything should have been handled when calling this function
*
* @param string $server_id
* @param string $type
* @param string $message
*
* @return int log_id
*/
/**
* This function merely adds the message to the log table. It does not perform any checks,
* everything should have been handled when calling this function
*
* @param string $server_id
* @param string $type
* @param string $message
*
* @return int log_id
*/
function psm_add_log($server_id, $type, $message)
{
global $db;
@ -260,19 +260,19 @@ namespace {
return $db->save(
PSM_DB_PREFIX . 'log',
array(
'server_id' => $server_id,
'type' => $type,
'message' => $message,
'server_id' => $server_id,
'type' => $type,
'message' => $message,
)
);
}
/**
* This function just adds a user to the log_users table.
*
* @param $log_id
* @param $user_id
*/
/**
* This function just adds a user to the log_users table.
*
* @param $log_id
* @param $user_id
*/
function psm_add_log_user($log_id, $user_id)
{
global $db;
@ -280,19 +280,19 @@ namespace {
$db->save(
PSM_DB_PREFIX . 'log_users',
array(
'log_id' => $log_id,
'user_id' => $user_id,
'log_id' => $log_id,
'user_id' => $user_id,
)
);
}
/**
* This function adds the result of a check to the uptime table for logging purposes.
*
* @param int $server_id
* @param int $status
* @param string $latency
*/
/**
* This function adds the result of a check to the uptime table for logging purposes.
*
* @param int $server_id
* @param int $status
* @param string $latency
*/
function psm_log_uptime($server_id, $status, $latency)
{
global $db;
@ -300,62 +300,62 @@ namespace {
$db->save(
PSM_DB_PREFIX . 'servers_uptime',
array(
'server_id' => $server_id,
'date' => date('Y-m-d H:i:s'),
'status' => $status,
'latency' => $latency,
'server_id' => $server_id,
'date' => date('Y-m-d H:i:s'),
'status' => $status,
'latency' => $latency,
)
);
}
/**
* Converts an interval into a string
*
* @param DateInterval $interval
* @return string
*/
/**
* Converts an interval into a string
*
* @param DateInterval $interval
* @return string
*/
function psm_format_interval(DateInterval $interval)
{
$result = "";
if ($interval->y) {
$result .= $interval->format("%y ") . (($interval->y == 1) ?
psm_get_lang('system', 'year') : psm_get_lang('system', 'years')) . " ";
psm_get_lang('system', 'year') : psm_get_lang('system', 'years')) . " ";
}
if ($interval->m) {
$result .= $interval->format("%m ") . (($interval->m == 1) ?
psm_get_lang('system', 'month') : psm_get_lang('system', 'months')) . " ";
psm_get_lang('system', 'month') : psm_get_lang('system', 'months')) . " ";
}
if ($interval->d) {
$result .= $interval->format("%d ") . (($interval->d == 1) ?
psm_get_lang('system', 'day') : psm_get_lang('system', 'days')) . " ";
psm_get_lang('system', 'day') : psm_get_lang('system', 'days')) . " ";
}
if ($interval->h) {
$result .= $interval->format("%h ") . (($interval->h == 1) ?
psm_get_lang('system', 'hour') : psm_get_lang('system', 'hours')) . " ";
psm_get_lang('system', 'hour') : psm_get_lang('system', 'hours')) . " ";
}
if ($interval->i) {
$result .= $interval->format("%i ") . (($interval->i == 1) ?
psm_get_lang('system', 'minute') : psm_get_lang('system', 'minutes')) . " ";
psm_get_lang('system', 'minute') : psm_get_lang('system', 'minutes')) . " ";
}
if ($interval->s) {
$result .= $interval->format("%s ") . (($interval->s == 1) ?
psm_get_lang('system', 'second') : psm_get_lang('system', 'seconds')) . " ";
psm_get_lang('system', 'second') : psm_get_lang('system', 'seconds')) . " ";
}
return $result;
}
/**
* Parses a string from the language file with the correct variables replaced in the message
*
* @param boolean|null $status
* @param string $type is either 'sms', 'email', 'pushover_title', 'pushover_message' or 'telegram_message'
* @param array $vars server information about the server which may be placed in a message:
* %KEY% will be replaced by your value
* @param boolean $combi parse other message if notifications need to be send combined
* @return string parsed message
*/
/**
* Parses a string from the language file with the correct variables replaced in the message
*
* @param boolean|null $status
* @param string $type is either 'sms', 'email', 'pushover_title', 'pushover_message', 'webhook_title', 'webhook_message' or 'telegram_message'
* @param array $vars server information about the server which may be placed in a message:
* %KEY% will be replaced by your value
* @param boolean $combi parse other message if notifications need to be send combined
* @return string parsed message
*/
function psm_parse_msg($status, $type, $vars, $combi = false)
{
if (is_bool($status)) {
@ -378,20 +378,20 @@ namespace {
return $message;
}
/**
* Shortcut to curl_init(), curl_exec and curl_close()
*
* @param string $href
* @param boolean $header return headers?
* @param boolean $body return body?
* @param int|null $timeout connection timeout in seconds. defaults to PSM_CURL_TIMEOUT (10 secs).
* @param boolean $add_agent add user agent?
* @param string|bool $website_username Username website
* @param string|bool $website_password Password website
* @param string|null $request_method Request method like GET, POST etc.
* @param string|null $post_field POST data
* @return array cURL result
*/
/**
* Shortcut to curl_init(), curl_exec and curl_close()
*
* @param string $href
* @param boolean $header return headers?
* @param boolean $body return body?
* @param int|null $timeout connection timeout in seconds. defaults to PSM_CURL_TIMEOUT (10 secs).
* @param boolean $add_agent add user agent?
* @param string|bool $website_username Username website
* @param string|bool $website_password Password website
* @param string|null $request_method Request method like GET, POST etc.
* @param string|null $post_field POST data
* @return array cURL result
*/
function psm_curl_get(
$href,
$header = false,
@ -419,7 +419,7 @@ namespace {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_CERTINFO, 1);
if (!empty($request_method)) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_method);
}
@ -453,32 +453,32 @@ namespace {
if ($add_agent) {
curl_setopt($ch, CURLOPT_USERAGENT, psm_get_conf('user_agent', 'Mozilla/5.0 (compatible; phpservermon/' .
PSM_VERSION . '; +https://github.com/phpservermon/phpservermon)'));
PSM_VERSION . '; +https://github.com/phpservermon/phpservermon)'));
}
$result['exec'] = curl_exec($ch);
$result['info'] = curl_getinfo($ch);
curl_close($ch);
if (defined('PSM_DEBUG') && PSM_DEBUG === true && psm_is_cli()) {
echo PHP_EOL .
'==============cURL Result for: ' . $href . '===========================================' . PHP_EOL;
'==============cURL Result for: ' . $href . '===========================================' . PHP_EOL;
print_r($result);
echo PHP_EOL .
'==============END cURL Resul for: ' . $href . '===========================================' . PHP_EOL;
'==============END cURL Resul for: ' . $href . '===========================================' . PHP_EOL;
}
return $result;
}
/**
* Get a "nice" timespan message
*
* Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966
* @param string $time
* @return string
*/
/**
* Get a "nice" timespan message
*
* Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966
* @param string $time
* @return string
*/
function psm_timespan($time)
{
if (empty($time) || $time == '0000-00-00 00:00:00') {
@ -489,7 +489,7 @@ namespace {
}
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60 * 60 * 24 * 3) {
$format = psm_get_lang('system', (date('Y') !== date('Y', $time)) ?
'long_day_format' : 'short_day_format');
'long_day_format' : 'short_day_format');
// Check for Windows to find and replace the %e
// modifier correctly
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@ -500,7 +500,7 @@ namespace {
$d = time() - $time;
if ($d >= 60 * 60 * 24) {
$format = psm_get_lang('system', (date('l', time() - 60 * 60 * 24) == date('l', $time)) ?
'yesterday_format' : 'other_day_format');
'yesterday_format' : 'other_day_format');
return strftime($format, $time);
}
if ($d >= 60 * 60 * 2) {
@ -522,11 +522,11 @@ namespace {
return psm_get_lang('system', 'a_second_ago');
}
/**
* Get a localised date from MySQL date format
* @param string $time
* @return string
*/
/**
* Get a localised date from MySQL date format
* @param string $time
* @return string
*/
function psm_date($time)
{
if (empty($time) || $time == '0000-00-00 00:00:00') {
@ -535,12 +535,12 @@ namespace {
return strftime('%x %X', strtotime($time));
}
/**
* Check if an update is available for PHP Server Monitor.
*
* Will only check for new version if user turned updates on in config.
* @return boolean
*/
/**
* Check if an update is available for PHP Server Monitor.
*
* Will only check for new version if user turned updates on in config.
* @return boolean
*/
function psm_update_available()
{
if (!psm_get_conf('show_update')) {
@ -582,14 +582,14 @@ namespace {
return version_compare($latestVersion, $current, '>');
}
/**
* Prepare a new phpmailer instance.
*
* If the from name and email are left blank they will be prefilled from the config.
* @param string $from_name
* @param string $from_email
* @return \PHPMailer\PHPMailer\PHPMailer
*/
/**
* Prepare a new phpmailer instance.
*
* If the from name and email are left blank they will be prefilled from the config.
* @param string $from_name
* @param string $from_email
* @return \PHPMailer\PHPMailer\PHPMailer
*/
function psm_build_mail($from_name = null, $from_email = null)
{
$phpmailer = new \PHPMailer\PHPMailer\PHPMailer();
@ -600,7 +600,7 @@ namespace {
if (psm_get_conf('email_smtp') == '1') {
$phpmailer->IsSMTP();
$phpmailer->Host = psm_get_conf('email_smtp_host');
$phpmailer->Port = (int) psm_get_conf('email_smtp_port');
$phpmailer->Port = (int)psm_get_conf('email_smtp_port');
$phpmailer->SMTPSecure = psm_get_conf('email_smtp_security');
$smtp_user = psm_get_conf('email_smtp_username');
@ -628,11 +628,11 @@ namespace {
return $phpmailer;
}
/**
* Prepare a new Pushover util.
*
* @return \Pushover
*/
/**
* Prepare a new Pushover util.
*
* @return \Pushover
*/
function psm_build_pushover()
{
$pushover = new \Pushover();
@ -641,10 +641,22 @@ namespace {
return $pushover;
}
/**
*
* @return \Telegram
*/
/**
* Prepare a new Webhook util.
*
* @return Webhook
*/
function psm_build_webhook()
{
$webhook = new Webhook();
return $webhook;
}
/**
*
* @return \Telegram
*/
function psm_build_telegram()
{
$telegram = new \Telegram();
@ -656,12 +668,12 @@ namespace {
/**
* Send message via XMPP.
*
* @param string $host
* @param string $username
* @param string $password
* @param array $receivers
* @param string $message
* @param int|null $port
* @param string $host
* @param string $username
* @param string $password
* @param array $receivers
* @param string $message
* @param int|null $port
* @param string|null $domain
*/
function psm_jabber_send_message($host, $username, $password, $receivers, $message, $port = null, $domain = null)
@ -707,11 +719,11 @@ namespace {
}
}
/**
* Prepare a new SMS util.
*
* @return \psm\Txtmsg\TxtmsgInterface
*/
/**
* Prepare a new SMS util.
*
* @return \psm\Txtmsg\TxtmsgInterface
*/
function psm_build_sms()
{
$sms = null;
@ -758,6 +770,9 @@ namespace {
case 'octopush':
$sms = new \psm\Txtmsg\Octopush();
break;
case 'ovhsms':
$sms = new \psm\Txtmsg\OVHsms();
break;
case 'smsgw':
$sms = new \psm\Txtmsg\Smsgw();
break;
@ -793,20 +808,20 @@ namespace {
return $sms;
}
/**
* Generate a new link to the current monitor
* @param array|string $params key value pairs or pre-formatted string
* @param boolean $urlencode urlencode all params?
* @param boolean $htmlentities use entities in url?
* @return string
*/
/**
* Generate a new link to the current monitor
* @param array|string $params key value pairs or pre-formatted string
* @param boolean $urlencode urlencode all params?
* @param boolean $htmlentities use entities in url?
* @return string
*/
function psm_build_url($params = array(), $urlencode = true, $htmlentities = true)
{
if (defined('PSM_BASE_URL') && PSM_BASE_URL !== null) {
$url = PSM_BASE_URL;
} else {
$url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ||
$_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
// on Windows, dirname() adds both back- and forward slashes (http://php.net/dirname).
// for urls, we only want the forward slashes.
$url .= dirname($_SERVER['SCRIPT_NAME']);
@ -833,12 +848,12 @@ namespace {
return $url;
}
/**
* Try existence of a GET var, if not return the alternative
* @param string $key
* @param string $alt
* @return mixed
*/
/**
* Try existence of a GET var, if not return the alternative
* @param string $key
* @param string $alt
* @return mixed
*/
function psm_GET($key, $alt = null)
{
if (isset($_GET[$key])) {
@ -848,12 +863,12 @@ namespace {
}
}
/**
* Try existence of a POST var, if not return the alternative
* @param string $key
* @param string|array|bool $alt
* @return mixed
*/
/**
* Try existence of a POST var, if not return the alternative
* @param string $key
* @param string|array|bool $alt
* @return mixed
*/
function psm_POST($key, $alt = null)
{
if (isset($_POST[$key])) {
@ -863,12 +878,12 @@ namespace {
}
}
/**
* Check if we are in CLI mode
*
* Note, php_sapi cannot be used because cgi-fcgi returns both for web and cli.
* @return boolean
*/
/**
* Check if we are in CLI mode
*
* Note, php_sapi cannot be used because cgi-fcgi returns both for web and cli.
* @return boolean
*/
function psm_is_cli()
{
return (!isset($_SERVER['SERVER_SOFTWARE']) || php_sapi_name() == 'cli');
@ -880,11 +895,11 @@ namespace {
#
###############################################
/**
* Only used for debugging and testing
*
* @param mixed $arr
*/
/**
* Only used for debugging and testing
*
* @param mixed $arr
*/
function pre($arr = null)
{
echo "<pre>";
@ -895,9 +910,9 @@ namespace {
echo "</pre>";
}
/**
* Send headers to the browser to avoid caching
*/
/**
* Send headers to the browser to avoid caching
*/
function psm_no_cache()
{
header("Expires: Mon, 20 Dec 1998 01:00:00 GMT");
@ -906,14 +921,14 @@ namespace {
header("Pragma: no-cache");
}
/**
* Encrypts the password for storage in the database
*
* @param string $key
* @param string $password
* @return string
* @author Pavel Laupe Dvorak <pavel@pavel-dvorak.cz>
*/
/**
* Encrypts the password for storage in the database
*
* @param string $key
* @param string $password
* @return string
* @author Pavel Laupe Dvorak <pavel@pavel-dvorak.cz>
*/
function psm_password_encrypt($key, $password)
{
if (empty($password)) {
@ -942,14 +957,14 @@ namespace {
return $encrypted;
}
/**
* Decrypts password stored in the database for future use
*
* @param string $key
* @param string $encryptedString
* @return string
* @author Pavel Laupe Dvorak <pavel@pavel-dvorak.cz>
*/
/**
* Decrypts password stored in the database for future use
*
* @param string $key
* @param string $encryptedString
* @return string
* @author Pavel Laupe Dvorak <pavel@pavel-dvorak.cz>
*/
function psm_password_decrypt($key, $encryptedString)
{
if (empty($encryptedString)) {
@ -957,7 +972,7 @@ namespace {
}
if (empty($key)) {
throw new \InvalidArgumentException('invalid_encryption_key');
throw new \InvalidArgumentException('invalid_encryption_key');
}
// using open ssl
@ -972,16 +987,16 @@ namespace {
OPENSSL_RAW_DATA,
$iv
);
return $decrypted;
}
/**
* Send notification to Telegram
*
* @return string
* @author Tim Zandbergen <tim@xervion.nl>
*/
/**
* Send notification to Telegram
*
* @return string
* @author Tim Zandbergen <tim@xervion.nl>
*/
class Telegram
{
private $token;
@ -991,12 +1006,14 @@ namespace {
public function setToken($token)
{
$this->token = (string) $token;
$this->token = (string)$token;
}
public function setUser($user)
{
$this->user = (string) $user;
$this->user = (string)$user;
}
public function setMessage($message)
{
$message = str_replace("<ul>", "", $message);
@ -1005,8 +1022,9 @@ namespace {
$message = str_replace("</li>", "\n", $message);
$message = str_replace("<br>", "\n", $message);
$message = str_replace("<br/>", "\n", $message);
$this->message = (string) $message;
$this->message = (string)$message;
}
public function sendurl()
{
$con = curl_init($this->url);
@ -1017,15 +1035,17 @@ namespace {
$response = json_decode($response, true);
return $response;
}
public function send()
{
if (!empty($this->token) && !empty($this->user) && !empty($this->message)) {
$this->url = 'https://api.telegram.org/bot' . urlencode($this->token) .
'/sendMessage?chat_id=' . urlencode($this->user) . '&text=' .
urlencode($this->message) . '&parse_mode=HTML&disable_web_page_preview=True';
'/sendMessage?chat_id=' . urlencode($this->user) . '&text=' .
urlencode($this->message) . '&parse_mode=HTML&disable_web_page_preview=True';
}
return $this->sendurl();
}
// Get the bots username
public function getBotUsername()
{
@ -1035,4 +1055,121 @@ namespace {
return $this->sendurl();
}
}
/**
* Send notification via webhooks
*
* @return string
* @author Malte Grosse
*/
class Webhook
{
protected $url;
protected $json;
protected $message;
/**
* Send Webhook
*
* @return bool|string
* @var string $message
*
*/
public function sendWebhook($message)
{
$error = "";
$success = 1;
$this->setMessage($message);
$jsonMessage = strtr($this->json, array('#message' => $this->message));
$curl = curl_init($this->url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonMessage);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_errno($curl);
if ($err != 0 || $httpcode < 200 || $httpcode >= 300) {
$success = 0;
$error = "HTTP_code: " . $httpcode . ".\ncURL error (" . $err . "): " . $err . ". \nResult: " . $result;
}
curl_close($curl);
if ($success) {
return 1;
}
return $error;
}
/**
* setUrl
*
* @var string $url
*
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* getUrl
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* setJson
*
* @var string $json
*
*/
public function setJson($json)
{
$this->json = $json;
}
/**
* getJson
*
* @return string
*/
public function getJson()
{
return $this->json;
}
/**
* Set message
*
* @return string
* @var string $message
*
*/
public function setMessage($message)
{
$message = str_replace("<ul>", "", $message);
$message = str_replace("</ul>", "\n", $message);
$message = str_replace("<li>", "- ", $message);
$message = str_replace("</li>", "\n", $message);
$message = str_replace("<br>", "\n", $message);
$message = str_replace("<br/>", "\n", $message);
$message = str_replace("<b>", "", $message);
$message = str_replace("<b/>", "", $message);
$message = strip_tags($message);
$this->message = (string)$message;
}
}
}

View File

@ -30,7 +30,7 @@
/**
* Current PSM version
*/
define('PSM_VERSION', '3.5.0');
define('PSM_VERSION', '3.6.0.beta1');
/**
* URL to check for updates. Will not be checked if turned off on config page.

View File

@ -130,6 +130,13 @@ $sm_lang = array(
'jabber' => 'Jabber',
'jabber_label' => 'Jabber',
'jabber_description' => 'You Jabber account',
'webhook' => 'Webhook',
'webhook_description' => 'Send a json webhook to a certain endpoint. <br/> The json can be customized, e.g. {
"text":"servermon: #message"}',
'webhook_url' => 'Webhook Url',
'webhook_url_description' => 'Webhook public endpoint url, should start with https://.',
'webhook_json' => 'Webhook JSON',
'webhook_json_description' => 'Define a custom json, use #message as message variable.',
'delete_title' => 'Delete User',
'delete_message' => 'Are you sure you want to delete user \'%1\'?',
'deleted' => 'User deleted.',
@ -156,6 +163,7 @@ $sm_lang = array(
'sms' => 'SMS',
'discord' => 'Discord',
'pushover' => 'Pushover',
'webhook' => 'Webhook',
'telegram' => 'Telegram',
'jabber' => 'Jabber',
'no_logs' => 'No logs',
@ -219,6 +227,8 @@ $sm_lang = array(
'send_sms' => 'Send SMS',
'discord' => 'Discord',
'send_discord' => 'Send Discord notificationn',
'webhook' => 'Webhook',
'send_webhook' => 'Send Webhook notification',
'pushover' => 'Pushover',
'send_pushover' => 'Send Pushover notification',
'telegram' => 'Telegram',
@ -258,6 +268,7 @@ $sm_lang = array(
'warning_notifications_disabled_sms' => 'SMS notifications are disabled.',
'warning_notifications_disabled_email' => 'Email notifications are disabled.',
'warning_notifications_disabled_discord' => 'Discord notifications are disabled.',
'warning_notifications_disabled_webhook' => 'Webhook notifications are disabled.',
'warning_notifications_disabled_pushover' => 'Pushover notifications are disabled.',
'warning_notifications_disabled_telegram' => 'Telegram notifications are disabled.',
'warning_notifications_disabled_jabber' => 'Jabber notifications are disabled.',
@ -298,6 +309,12 @@ $sm_lang = array(
'sms_gateway_password' => 'Gateway password',
'sms_from' => 'Sender\'s phone number',
'discord_status' => 'Allow sending Discord messages',
'webhook_status' => 'Allow sending webhooks',
'webhook_description' => 'Allow sending webhooks to services like slack. The message payload end endpoint are defined in the profile settings.',
'webhook_url' => 'Webhook Url',
'webhook_url_description' => 'Url to webhook endpoint',
'webhook_json' => 'Webhook Json',
'webhook_json_description' => 'Customized Json, use #message as message variable.',
'pushover_status' => 'Allow sending Pushover messages',
'pushover_description' => 'Pushover is a service that makes it easy to get real-time notifications. See <a href="https://pushover.net/" target="_blank">their website</a> for more info.',
'pushover_clone_app' => 'Click here to create your Pushover app',
@ -335,6 +352,7 @@ $sm_lang = array(
'log_sms' => 'Log text messages sent by the script',
'log_discord' => 'Log Discord messages sent by the script',
'log_pushover' => 'Log pushover messages sent by the script',
'log_webhook' => 'Log webhook messages sent by the script',
'log_telegram' => 'Log Telegram messages sent by the script',
'log_jabber' => 'Log Jabber messages sent by the script',
'updated' => 'The configuration has been updated.',
@ -342,12 +360,14 @@ $sm_lang = array(
'tab_sms' => 'SMS',
'tab_discord' => 'Discord',
'tab_pushover' => 'Pushover',
'tab_webhook' => 'Webhook',
'tab_telegram' => 'Telegram',
'tab_jabber' => 'Jabber',
'settings_email' => 'Email settings',
'settings_sms' => 'Text message settings',
'settings_discord' => 'Discord settings',
'settings_pushover' => 'Pushover settings',
'settings_webhook' => 'Webhook settings',
'settings_telegram' => 'Telegram settings',
'settings_jabber' => 'Jabber settings',
'settings_notification' => 'Notification settings',
@ -360,6 +380,9 @@ $sm_lang = array(
'test_sms' => 'An SMS will be sent to the phone number specified in your user profile.',
'test_discord' => 'A Discord notification will be sent to the webhook specified in your user profile.',
'test_pushover' => 'A Pushover notification will be sent to the user key/device specified in your user profile.',
'test_pushover' => 'A Pushover notification will be sent to the user key/device specified in your user
profile.',
'test_webhook' => 'A webhook notification will be sent to the given url endpoint.',
'test_telegram' => 'A Telegram notification will be sent to the chat id specified in your user profile.',
'test_jabber' => 'A Jabber notification will be sent to the jabber account specified in your user profile.',
'send' => 'Send',
@ -373,6 +396,10 @@ $sm_lang = array(
'discord_sent' => 'Discord notification sent',
'discord_error' => 'An error has occurred while sending the Discord notification: %s',
'discord_error_nowebhook' => 'Unable to send test Discord notification: no valid Discord webhook found in your user profile.',
'webhook_sent' => 'Webhook notification sent',
'webhook_error' => 'An error has occurred while sending the webhook notification: %s',
'webhook_error_nourl' => 'Unable to send test notification: no url found in user profile.',
'webhook_error_nojson' => 'Unable to send test notification: no json found in user profile.',
'pushover_sent' => 'Pushover notification sent',
'pushover_error' => 'An error has occurred while sending the Pushover notification: %s',
'pushover_error_noapp' => 'Unable to send test notification: no Pushover App API token found in the global configuration.',
@ -396,35 +423,77 @@ $sm_lang = array(
'off_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is DOWN',
'off_email_body' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'off_discord_message' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'off_email_body' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port:
%PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'off_webhook_title' => 'Server \'%LABEL%\' is DOWN',
'off_webhook_message' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP:
%IP%<br>Port: %PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'off_pushover_title' => 'Server \'%LABEL%\' is DOWN',
'off_pushover_message' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'off_telegram_message' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'off_jabber_message' => 'Failed to connect to the following server:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Error: %ERROR%<br>Date: %DATE%',
'on_sms' => 'Server \'%LABEL%\' is RUNNING: ip=%IP%, port=%PORT%, it was down for %LAST_OFFLINE_DURATION%',
'on_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is RUNNING',
'on_email_body' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date: %DATE%',
'on_discord_message' => 'Server \'%LABEL%\' is running again, it was down for: %LAST_OFFLINE_DURATION%<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date: %DATE%',
'on_email_body' => 'Server \'%LABEL%\' is running again, it was down for
%LAST_OFFLINE_DURATION%:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date:
%DATE%',
'on_discord_message' => 'Server \'%LABEL%\' is running again, it was down for:
%LAST_OFFLINE_DURATION%<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date: %DATE%',
'on_webhook_title' => 'Server \'%LABEL%\' is RUNNING',
'on_webhook_message' => 'Server \'%LABEL%\' is running again, it was down for
%LAST_OFFLINE_DURATION%:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date:
%DATE%',
'on_pushover_title' => 'Server \'%LABEL%\' is RUNNING',
'on_pushover_message' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date: %DATE%',
'on_telegram_message' => 'Server \'%LABEL%\' is running again, it was down for: %LAST_OFFLINE_DURATION%<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date: %DATE%',
'on_jabber_message' => 'Server \'%LABEL%\' is running again, it was down for: %LAST_OFFLINE_DURATION%<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date: %DATE%',
'combi_off_email_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Error: %ERROR%</li><li>Date: %DATE%</li></ul>',
'combi_off_discord_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Error: %ERROR%<br>- Date: %DATE%<br><br>',
'combi_off_pushover_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Error: %ERROR%</li><li>Date: %DATE%</li></ul>',
'combi_off_telegram_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Error: %ERROR%<br>- Date: %DATE%<br><br>',
'combi_off_jabber_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Error: %ERROR%<br>- Date: %DATE%<br><br>',
'combi_on_email_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Downtime: %LAST_OFFLINE_DURATION%</li><li>Date: %DATE%</li></ul>',
'combi_on_discord_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Downtime: %LAST_OFFLINE_DURATION%<br>- Date: %DATE%<br><br>',
'combi_on_pushover_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Downtime: %LAST_OFFLINE_DURATION%</li><li>Date: %DATE%</li></ul>',
'combi_on_telegram_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Downtime: %LAST_OFFLINE_DURATION%<br>- Date: %DATE%<br><br>',
'combi_on_jabber_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Downtime: %LAST_OFFLINE_DURATION%<br>- Date: %DATE%<br><br>',
'on_pushover_message' => 'Server \'%LABEL%\' is running again, it was down for
%LAST_OFFLINE_DURATION%:<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date:
%DATE%',
'on_telegram_message' => 'Server \'%LABEL%\' is running again, it was down for:
%LAST_OFFLINE_DURATION%<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date:
%DATE%',
'on_jabber_message' => 'Server \'%LABEL%\' is running again, it was down for:
%LAST_OFFLINE_DURATION%<br><br>Server: %LABEL%<br>IP: %IP%<br>Port: %PORT%<br>Date:
%DATE%',
'combi_off_email_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Error:
%ERROR%</li><li>Date: %DATE%</li></ul>',
'combi_off_discord_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Error: %ERROR%<br>-
Date: %DATE%<br><br>',
'combi_off_webhook_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Error:
%ERROR%</li><li>Date: %DATE%</li></ul>',
'combi_off_pushover_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Error:
%ERROR%</li><li>Date: %DATE%</li></ul>',
'combi_off_telegram_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Error: %ERROR%<br>-
Date: %DATE%<br><br>',
'combi_off_jabber_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Error: %ERROR%<br>-
Date: %DATE%<br><br>',
'combi_on_email_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port: %PORT%</li><li>Downtime:
%LAST_OFFLINE_DURATION%</li><li>Date: %DATE%</li></ul>',
'combi_on_webhook_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port:
%PORT%</li><li>Downtime: %LAST_OFFLINE_DURATION%</li><li>Date:
%DATE%</li></ul>',
'combi_on_discord_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>-
Downtime: %LAST_OFFLINE_DURATION%<br>- Date: %DATE%<br><br>',
'combi_on_pushover_message' => '<ul><li>Server: %LABEL%</li><li>IP: %IP%</li><li>Port:
%PORT%</li><li>Downtime: %LAST_OFFLINE_DURATION%</li><li>Date:
%DATE%</li></ul>',
'combi_on_telegram_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Downtime:
%LAST_OFFLINE_DURATION%<br>- Date: %DATE%<br><br>',
'combi_on_jabber_message' => '- Server: %LABEL%<br>- IP: %IP%<br>- Port: %PORT%<br>- Downtime:
%LAST_OFFLINE_DURATION%<br>- Date: %DATE%<br><br>',
'combi_email_subject' => 'IMPORTANT: \'%UP%\' servers UP again, \'%DOWN%\' servers DOWN',
'combi_webhook_subject' => '\'%UP%\' servers UP again, \'%DOWN%\' servers DOWN',
'combi_pushover_subject' => '\'%UP%\' servers UP again, \'%DOWN%\' servers DOWN',
'combi_email_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following servers are up again:</b><br>%UP_SERVERS%',
'combi_discord_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following servers are up again:</b><br>%UP_SERVERS%',
'combi_pushover_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following servers are up again:</b><br>%UP_SERVERS%',
'combi_telegram_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following servers are up again:</b><br>%UP_SERVERS%',
'combi_jabber_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following servers are up again:</b><br>%UP_SERVERS%',
'combi_email_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following
servers are up again:</b><br>%UP_SERVERS%',
'combi_discord_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following
servers are up again:</b><br>%UP_SERVERS%',
'combi_webhook_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following
servers are up again:</b><br>%UP_SERVERS%',
'combi_pushover_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following
servers are up again:</b><br>%UP_SERVERS%',
'combi_telegram_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following
servers are up again:</b><br>%UP_SERVERS%',
'combi_jabber_message' => '<b>The following servers went down:</b><br>%DOWN_SERVERS%<br><b>The following
servers are up again:</b><br>%UP_SERVERS%',
),
'login' => array(
'welcome_usermenu' => 'Welcome, %user_name%',

View File

@ -45,6 +45,7 @@ class ConfigController extends AbstractController
'sms_status',
'discord_status',
'pushover_status',
'webhook_status',
'telegram_status',
'jabber_status',
'log_status',
@ -52,6 +53,7 @@ class ConfigController extends AbstractController
'log_sms',
'log_discord',
'log_pushover',
'log_webhook',
'log_telegram',
'log_jabber',
'show_update',
@ -74,6 +76,8 @@ class ConfigController extends AbstractController
'sms_gateway_username',
'sms_gateway_password',
'sms_from',
'webhook_url',
'webhook_json',
'pushover_api_token',
'telegram_api_token',
'jabber_host',
@ -210,7 +214,8 @@ class ConfigController extends AbstractController
$tpl_data[$this->default_tab . '_active'] = 'active';
$testmodals = array('email', 'sms', 'discord', 'pushover', 'telegram', 'jabber');
$testmodals = array('email', 'sms', 'discord', 'webhook', 'pushover', 'telegram', 'jabber');
foreach ($testmodals as $modal_id) {
$modal = new \psm\Util\Module\Modal(
$this->twig,
@ -276,6 +281,8 @@ class ConfigController extends AbstractController
$this->testDiscord();
} elseif (!empty($_POST['test_pushover'])) {
$this->testPushover();
}elseif (!empty($_POST['test_webhook'])) {
$this->testWebhook();
} elseif (!empty($_POST['test_telegram'])) {
$this->testTelegram();
} elseif (!empty($_POST['test_jabber'])) {
@ -297,6 +304,8 @@ class ConfigController extends AbstractController
$this->default_tab = 'discord';
} elseif (isset($_POST['pushover_submit']) || !empty($_POST['test_pushover'])) {
$this->default_tab = 'pushover';
} elseif (isset($_POST['webhook_submit']) || !empty($_POST['test_webhook'])) {
$this->default_tab = 'webhook';
} elseif (isset($_POST['telegram_submit']) || !empty($_POST['test_telegram'])) {
$this->default_tab = 'telegram';
} elseif (isset($_POST['jabber_submit']) || !empty($_POST['test_jabber'])) {
@ -353,7 +362,7 @@ class ConfigController extends AbstractController
}
/**
* Execute SMS test
* Execute Discord test
*
* @todo move test to separate class
*/
@ -406,6 +415,34 @@ class ConfigController extends AbstractController
}
}
* Execute webhook test
*
* @todo move test to separate class
*/
protected function testWebhook()
{
$user = $this->getUser()->getUser();
if (empty($user->webhook_url)) {
$this->addMessage(psm_get_lang('config', 'webhook_error_nourl'), 'error');
} elseif (empty($user->webhook_json)) {
$this->addMessage(psm_get_lang('config', 'webhook_error_nojson'), 'error');
} else {
$webhook = psm_build_webhook();
$webhook->setUrl($user->webhook_url);
$webhook->setJson($user->webhook_json);
$message = (psm_get_lang('config', 'test_message'));
$result = $webhook->sendWebhook($message);
if ($result==1) {
$this->addMessage(psm_get_lang('config', 'webhook_sent'), 'success');
} else {
$this->addMessage(sprintf(psm_get_lang('config', 'webhook_error'), $result), 'error');
}
}
}
/**
* Execute pushover test
*
@ -506,11 +543,13 @@ class ConfigController extends AbstractController
'label_tab_sms' => psm_get_lang('config', 'tab_sms'),
'label_tab_discord' => psm_get_lang('config', 'tab_discord'),
'label_tab_pushover' => psm_get_lang('config', 'tab_pushover'),
'label_tab_webhook' => psm_get_lang('config', 'tab_webhook'),
'label_tab_telegram' => psm_get_lang('config', 'tab_telegram'),
'label_tab_jabber' => psm_get_lang('config', 'tab_jabber'),
'label_settings_email' => psm_get_lang('config', 'settings_email'),
'label_settings_sms' => psm_get_lang('config', 'settings_sms'),
'label_settings_discord' => psm_get_lang('config', 'settings_discord'),
'label_settings_webhook' => psm_get_lang('config', 'settings_webhook'),
'label_settings_pushover' => psm_get_lang('config', 'settings_pushover'),
'label_settings_telegram' => psm_get_lang('config', 'settings_telegram'),
'label_settings_jabber' => psm_get_lang('config', 'settings_jabber'),
@ -543,6 +582,12 @@ class ConfigController extends AbstractController
'label_sms_from' => psm_get_lang('config', 'sms_from'),
'label_discord_status' => psm_get_lang('config', 'discord_status'),
'label_discord_description' => psm_get_lang('config', 'discord_description'),
'label_webhook_description' => psm_get_lang('config', 'webhook_description'),
'label_webhook_status' => psm_get_lang('config', 'webhook_status'),
'label_webhook_url' => psm_get_lang('config', 'webhook_url'),
'label_webhook_url_description' => psm_get_lang('config', 'webhook_url_description'),
'label_webhook_json' => psm_get_lang('config', 'webhook_json'),
'label_webhook_json_description' => psm_get_lang('config', 'webhook_json_description'),
'label_pushover_description' => psm_get_lang('config', 'pushover_description'),
'label_pushover_status' => psm_get_lang('config', 'pushover_status'),
'label_pushover_clone_app' => psm_get_lang('config', 'pushover_clone_app'),
@ -578,6 +623,7 @@ class ConfigController extends AbstractController
'label_log_sms' => psm_get_lang('config', 'log_sms'),
'label_log_discord' => psm_get_lang('config', 'log_discord'),
'label_log_pushover' => psm_get_lang('config', 'log_pushover'),
'label_log_webhook' => psm_get_lang('config', 'log_webhook'),
'label_log_telegram' => psm_get_lang('config', 'log_telegram'),
'label_log_jabber' => psm_get_lang('config', 'log_jabber'),
'label_alert_proxy' => psm_get_lang('config', 'alert_proxy'),

View File

@ -303,6 +303,8 @@ class InstallController extends AbstractController
'level' => PSM_USER_ADMIN,
'pushover_key' => '',
'pushover_device' => '',
'webhook_url' => '',
'webhook_json' => '',
'telegram_id' => '',
'jabber' => ''
);

View File

@ -81,7 +81,8 @@ abstract class AbstractServerController extends AbstractController
`s`.`active`,
`s`.`email`,
`s`.`sms`,
`s`.`discord`,
`s`.`discord`,
`s`.`webhook`,
`s`.`pushover`,
`s`.`telegram`,
`s`.`jabber`,

View File

@ -57,6 +57,7 @@ class LogController extends AbstractServerController
'label_sms' => psm_get_lang('log', 'sms'),
'label_discord' => psm_get_lang('log', 'discord'),
'label_pushover' => psm_get_lang('log', 'pushover'),
'label_webhook' => psm_get_lang('log', 'webhook'),
'label_telegram' => psm_get_lang('log', 'telegram'),
'label_jabber' => psm_get_lang('log', 'jabber'),
'label_title' => psm_get_lang('log', 'title'),
@ -90,7 +91,7 @@ class LogController extends AbstractServerController
);
}
$log_types = array('status', 'email', 'sms', 'discord', 'pushover', 'telegram', 'jabber');
$log_types = array('status', 'email', 'sms', 'discord', 'webhook', 'pushover', 'telegram', 'jabber');
foreach ($log_types as $key) {
$records = $this->getEntries($key);

View File

@ -102,6 +102,7 @@ class ServerController extends AbstractServerController
'sms' => 'icon-mobile',
'discord' => 'icon-discord',
'pushover' => 'icon-pushover',
'webhook' => 'icon-webhook',
'telegram' => 'icon-telegram',
'jabber' => 'icon-jabber'
);
@ -132,6 +133,7 @@ class ServerController extends AbstractServerController
$tpl_data['config']['email'] = psm_get_conf('email_status');
$tpl_data['config']['sms'] = psm_get_conf('sms_status');
$tpl_data['config']['discord'] = psm_get_conf('discord_status');
$tpl_data['config']['webhook'] = psm_get_conf('webhook_status');
$tpl_data['config']['pushover'] = psm_get_conf('pushover_status');
$tpl_data['config']['telegram'] = psm_get_conf('telegram_status');
@ -240,13 +242,14 @@ class ServerController extends AbstractServerController
'edit_email_selected' => $edit_server['email'],
'edit_sms_selected' => $edit_server['sms'],
'edit_discord_selected' => $edit_server['discord'],
'edit_webhook_selected' => $edit_server['webhook'],
'edit_pushover_selected' => $edit_server['pushover'],
'edit_telegram_selected' => $edit_server['telegram'],
'edit_jabber_selected' => $edit_server['jabber'],
));
}
$notifications = array('email', 'sms', 'discord', 'pushover', 'telegram', 'jabber');
$notifications = array('email', 'sms', 'pushover', 'discord', 'webhook', 'telegram', 'jabber');
foreach ($notifications as $notification) {
if (psm_get_conf($notification . '_status') == 0) {
$tpl_data['warning_' . $notification] = true;
@ -316,6 +319,7 @@ class ServerController extends AbstractServerController
'sms' => in_array($_POST['sms'], array('yes', 'no')) ? $_POST['sms'] : 'no',
'discord' => in_array($_POST['discord'], array('yes', 'no')) ? $_POST['discord'] : 'no',
'pushover' => in_array($_POST['pushover'], array('yes', 'no')) ? $_POST['pushover'] : 'no',
'webhook' => in_array($_POST['webhook'], array('yes', 'no')) ? $_POST['webhook'] : 'no',
'telegram' => in_array($_POST['telegram'], array('yes', 'no')) ? $_POST['telegram'] : 'no',
'jabber' => in_array($_POST['jabber'], array('yes', 'no')) ? $_POST['jabber'] : 'no',
);
@ -597,9 +601,12 @@ class ServerController extends AbstractServerController
'label_send_discord' => psm_get_lang('servers', 'send_discord'),
'label_pushover' => psm_get_lang('servers', 'pushover'),
'label_send_pushover' => psm_get_lang('servers', 'send_pushover'),
'label_send_webhook' => psm_get_lang('servers', 'send_webhook'),
'label_telegram' => psm_get_lang('servers', 'telegram'),
'label_jabber' => psm_get_lang('servers', 'jabber'),
'label_send_jabber' => psm_get_lang('servers', 'send_jabber'),
'label_webhook' => psm_get_lang('servers', 'webhook'),
'label_pushover' => psm_get_lang('servers', 'pushover'),
'label_send_telegram' => psm_get_lang('servers', 'send_telegram'),
'label_users' => psm_get_lang('servers', 'users'),
'label_warning_threshold' => psm_get_lang('servers', 'warning_threshold'),

View File

@ -39,7 +39,7 @@ class ProfileController extends AbstractController
* @var array $profile_fields
*/
protected $profile_fields =
array('name', 'user_name', 'email', 'mobile', 'discord', 'pushover_key', 'pushover_device', 'telegram_id', 'jabber');
array('name', 'user_name', 'email', 'mobile', 'pushover_key', 'pushover_device', 'discord', 'webhook_url', 'webhook_json', 'telegram_id', 'jabber');
public function __construct(Database $db, \Twig_Environment $twig)
{
@ -78,6 +78,12 @@ class ProfileController extends AbstractController
'label_password_repeat' => psm_get_lang('users', 'password_repeat'),
'label_level' => psm_get_lang('users', 'level'),
'label_mobile' => psm_get_lang('users', 'mobile'),
'label_webhook' => psm_get_lang('users', 'webhook'),
'label_webhook_description' => psm_get_lang('users', 'webhook_description'),
'label_webhook_url' => psm_get_lang('users', 'webhook_url'),
'label_webhook_url_description' => psm_get_lang('users', 'webhook_url_description'),
'label_webhook_json' => psm_get_lang('users', 'webhook_json'),
'label_webhook_json_description' => psm_get_lang('users', 'webhook_json_description'),
'label_pushover' => psm_get_lang('users', 'pushover'),
'label_pushover_description' => psm_get_lang('users', 'pushover_description'),
'label_pushover_key' => psm_get_lang('users', 'pushover_key'),

View File

@ -159,6 +159,8 @@ class UserController extends AbstractController
'user_name',
'mobile',
'discord',
'webhook_url',
'webhook_json',
'pushover_key',
'pushover_device',
'telegram_id',
@ -257,6 +259,8 @@ class UserController extends AbstractController
'level',
'mobile',
'discord',
'webhook_url',
'webhook_json',
'pushover_key',
'pushover_device',
'telegram_id',
@ -396,6 +400,12 @@ class UserController extends AbstractController
'label_mobile' => psm_get_lang('users', 'mobile'),
'label_discord' => psm_get_lang('users', 'discord'),
'label_discord_description' => psm_get_lang('users', 'discord_description'),
'label_webhook' => psm_get_lang('users', 'webhook'),
'label_webhook_description' => psm_get_lang('users', 'webhook_description'),
'label_webhook_url' => psm_get_lang('users', 'webhook_url'),
'label_webhook_url_description' => psm_get_lang('users', 'webhook_url_description'),
'label_webhook_json' => psm_get_lang('users', 'webhook_json'),
'label_webhook_json_description' => psm_get_lang('users', 'webhook_json_description'),
'label_pushover' => psm_get_lang('users', 'pushover'),
'label_pushover_description' => psm_get_lang('users', 'pushover_description'),
'label_pushover_key' => psm_get_lang('users', 'pushover_key'),

101
src/psm/Txtmsg/OVHsms.php Normal file
View File

@ -0,0 +1,101 @@
<?php
/**
* PHP Server Monitor
* Monitor your servers and websites.
*
* This file is part of PHP Server Monitor.
* PHP Server Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PHP Server Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
*
* @package phpservermon
* @author Alexis Urien <Alexis.urien@free.fr>
* @Author Tim Zandbergen <Tim@Xervion.nl>
* @author Ward Pieters <ward@wardpieters.nl>
* @author Alexandre ZANELLI <alexandre@les-z.org>
* @copyright Copyright (c) 2016 Alexis Urien <alexis.urien@free.fr>
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@
* @link http://www.phpservermonitor.org/
* @since phpservermon 3.5
**/
namespace psm\Txtmsg;
class OVHsms extends Core {
/**
* Send sms using the OVH http2sms gateway
* Online documentation :https://docs.ovh.com/fr/sms/envoyer_des_sms_depuis_une_url_-_http2sms/
* Ovh need Account and Login, then use format login@account in username field.
*
* @var string $message
* @var string $this->username
* @var string $this->password
* @var array $this->recipients
* @var array $this->originator
*
* @var resource $curl
* @var SimpleXMLElement $xmlResults
* @var string $err
* @var string $recipient
* @var mixed $result
*
* @var int $success
* @var string $error
*
* @return bool|string
*/
public function sendSMS($message) {
$error = "";
$success = 1;
$account_login = explode('@',$this->username);
$recipients = join(',', $this->recipients);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://www.ovh.com/cgi-bin/sms/http2sms.cgi?".http_build_query(
array(
"account" => $account_login[1],
"login" => $account_login[0],
"password" => $this->password,
"from" => str_replace('+', '00', $this->originator),
"to" => $recipients,
"message" => $message,
"contentType" => "text/xml",
"noStop" => 1,
)
)
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$xmlResults = simplexml_load_string($result);
$err = curl_errno($curl);
if ($err != 0 || $httpcode != 200 || $xmlResults === false ||($xmlResults->status != '100' && $xmlResults->status != '101')) {
$success = 0;
$error = "HTTP_code: ".$httpcode.".\ncURL error (".$err."): ".curl_strerror($err).". \nResult: ".$xmlResults->status." \n".$xmlResults->Message;
}
curl_close($curl);
if ($success) {
return 1;
}
return $error;
}
}

View File

@ -63,7 +63,7 @@ class Octopush extends Core
$recipients = join(',', $this->recipients);
$message = ($smsType == "FR") ? urlencode($message . " STOP au XXXX") : urlencode($message);
$message = ($smsType == "FR") ? rawurlencode($message . " STOP au XXXXX") : rawurlencode($message);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.octopush-dm.com/api/sms/?" . http_build_query(

View File

@ -134,11 +134,11 @@ class Installer
$queries = array();
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "servers` (
`ip`, `port`, `label`, `type`, `pattern`, `pattern_online`, `redirect_check`,
`status`, `rtime`, `active`, `email`, `sms`, `pushover`, `telegram`, `jabber`)
`status`, `rtime`, `active`, `email`, `sms`, `pushover`,`webhook`, `telegram`, `jabber`)
VALUES ('http://sourceforge.net/index.php', 80, 'SourceForge', 'website', '',
'yes', 'bad', 'on', '0.0000000', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes'),
'yes', 'bad', 'on', '0.0000000', 'yes', 'yes', 'yes', 'yes','yes', 'yes', 'yes'),
('smtp.gmail.com', 465, 'Gmail SMTP', 'service', '',
'yes', 'bad','on', '0.0000000', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes')";
'yes', 'bad','on', '0.0000000', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes')";
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users_servers` (`user_id`,`server_id`) VALUES (1, 1), (1, 2);";
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE
('language', 'en_US'),
@ -160,6 +160,7 @@ class Installer
('sms_gateway_username', 'username'),
('sms_gateway_password', 'password'),
('sms_from', '1234567890'),
('webhook_status', '0'),
('pushover_status', '0'),
('pushover_api_token', ''),
('telegram_status', '0'),
@ -176,6 +177,7 @@ class Installer
('log_email', '1'),
('log_sms', '1'),
('log_pushover', '1'),
('log_webhook', '1'),
('log_telegram', '1'),
('log_jabber', '1'),
('discord_status', '0'),
@ -217,7 +219,9 @@ class Installer
`discord` varchar(255) NOT NULL,
`pushover_key` varchar(255) NOT NULL,
`pushover_device` varchar(255) NOT NULL,
`telegram_id` varchar(255) NOT NULL,
`webhook_url` varchar(255) NOT NULL,
`webhook_json` varchar(255) NOT NULL DEFAULT '{\"text\":\"servermon: #message\"}',
`telegram_id` varchar(255) NOT NULL ,
`jabber` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`user_id`),
@ -238,7 +242,7 @@ class Installer
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,
`type` enum('status','email','sms','discord','pushover','telegram', 'jabber') NOT NULL,
`type` enum('status','email','sms','discord','pushover','webhook','telegram', 'jabber') NOT NULL,
`message` TEXT NOT NULL,
`datetime` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`log_id`)
@ -274,6 +278,7 @@ class Installer
`sms` enum('yes','no') NOT NULL default 'no',
`discord` enum('yes','no') NOT NULL default 'yes',
`pushover` enum('yes','no') NOT NULL default 'yes',
`webhook` enum('yes','no') NOT NULL default 'yes',
`telegram` enum('yes','no') NOT NULL default 'yes',
`jabber` enum('yes','no') NOT NULL default 'yes',
`warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1',
@ -361,6 +366,9 @@ class Installer
if (version_compare($version_from, '3.5.0', '<')) {
$this->upgrade350();
}
if (version_compare($version_from, '3.6.0', '<')) {
$this->upgrade360();
}
psm_update_conf('version', $version_to);
}
@ -557,7 +565,7 @@ class Installer
$this->execSQL($queries);
// Create log_users table
// Create log_users table
$this->execSQL("CREATE TABLE `" . PSM_DB_PREFIX . "log_users` (
`log_id` int(11) UNSIGNED NOT NULL ,
`user_id` int(11) UNSIGNED NOT NULL ,
@ -663,7 +671,7 @@ class Installer
$this->execSQL($queries);
$this->log('Combined notifications enabled. Check out the config page for more info.');
}
/**
* Patch for v3.4.2 release
* Version_compare was forgotten in v3.4.1 and query failed.
@ -739,4 +747,26 @@ class Installer
('log_discord', '1');";
$this->execSQL($queries);
}
/**
* Upgrade for v3.6.0 release
*/
protected function upgrade360()
{
$queries = array();
$queries[] = 'ALTER TABLE `' . PSM_DB_PREFIX . 'users`
ADD `webhook_url` VARCHAR( 255 ) NOT NULL AFTER `telegram_id`;';
$queries[] = 'ALTER TABLE `' . PSM_DB_PREFIX . 'users`
ADD `webhook_json` VARCHAR( 255 ) NOT NULL AFTER `telegram_id`;';
$queries[] = "ALTER TABLE `' . PSM_DB_PREFIX . 'log`
CHANGE `type` `type` ENUM('status','email','sms','webhook','pushover','telegram','jabber')
CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;";
$queries[] = "ALTER TABLE `' . PSM_DB_PREFIX . 'servers`
ADD `webhook` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `telegram`;";
$queries[] = "INSERT INTO `' . PSM_DB_PREFIX . 'config` (`key`, `value`) VALUE
('webhook_status', '0'),
('log_webhook', '1')";
$this->execSQL($queries);
}
}

View File

@ -69,7 +69,7 @@ class UpdateManager implements ContainerAwareInterface
}
$sql = "SELECT `s`.`server_id`,`s`.`ip`,`s`.`port`,`s`.`label`,`s`.`type`,`s`.`pattern`,`s`.`header_name`,
`s`.`header_value`,`s`.`status`,`s`.`active`,`s`.`email`,`s`.`sms`,`s`.`pushover`,`s`.`telegram`,
`s`.`header_value`,`s`.`status`,`s`.`active`,`s`.`email`,`s`.`sms`,`s`.`pushover`,`s`.`webhook`,`s`.`telegram`,
`s`.`jabber`
FROM `" . PSM_DB_PREFIX . "servers` AS `s`
{$sql_join}

View File

@ -69,6 +69,12 @@ class StatusNotifier
*/
protected $send_pushover = false;
/**
* Send webhook notification?
* @var boolean $send_webhook
*/
protected $send_webhook = false;
/**
* Send telegram?
* @var boolean $send_telegram
@ -135,6 +141,7 @@ class StatusNotifier
$this->send_emails = (bool)psm_get_conf('email_status');
$this->send_sms = (bool)psm_get_conf('sms_status');
$this->send_discord = (bool)psm_get_conf('discord_status');
$this->send_webhook = (bool)psm_get_conf('webhook_status');
$this->send_pushover = (bool)psm_get_conf('pushover_status');
$this->send_telegram = (bool)psm_get_conf('telegram_status');
$this->send_jabber = (bool)psm_get_conf('jabber_status');
@ -157,6 +164,7 @@ class StatusNotifier
!$this->send_emails &&
!$this->send_sms &&
!$this->send_discord &&
!$this->send_webhook &&
!$this->send_pushover &&
!$this->send_telegram &&
!$this->send_jabber &&
@ -184,6 +192,7 @@ class StatusNotifier
'email',
'sms',
'discord',
'webhook',
'pushover',
'telegram',
'jabber',
@ -261,6 +270,12 @@ class StatusNotifier
$this->combine ? $this->setCombi('discord') : $this->notifyByDiscord($users);
}
// check if webhook is enabled for this server
if ($this->send_webhook && $this->server['webhook'] == 'yes') {
// yay lets wake those nerds up!
$this->combine ? $this->setCombi('webhook') : $this->notifyByWebhook($users);
}
// check if pushover is enabled for this server
if ($this->send_pushover && $this->server['pushover'] == 'yes') {
// yay lets wake those nerds up!
@ -577,7 +592,48 @@ class StatusNotifier
$pushover->send();
}
}
/**
* This functions performs the webhook notifications
*
* @param \PDOStatement $users
* @param array $combi contains message and subject (optional)
* @return void
*/
protected function notifyByWebhook($users, $combi = array())
{
foreach ($users as $k => $user) {
if (trim($user['webhook_url']) == '') {
unset($users[$k]);
}
}
$webhook = psm_build_webhook();
$message = key_exists('message', $combi) ?
$combi['message'] :
psm_parse_msg($this->status_new, 'webhook_message', $this->server);
$message = str_replace('<br/>', "\n", $message);
$message = str_replace('<br>', "\n", $message);
$title = key_exists('subject', $combi) ?
$combi['subject'] :
psm_parse_msg($this->status_new, 'webhook_title', $this->server);
// Log
if (psm_get_conf('log_webhook')) {
$log_id = psm_add_log($this->server_id, 'webhook', $message);
}
// send notifications to all users
foreach ($users as $user) {
// Log
if (!empty($log_id)) {
psm_add_log_user($log_id, $user['user_id']);
}
$webhook->setUrl($user['webhook_url']);
$webhook->setJson($user['webhook_json']);
$webhook->sendWebhook($message);
}
}
/**
* This functions performs the text message notifications
*
@ -714,8 +770,8 @@ class StatusNotifier
{
// find all the users with this server listed
$users = $this->db->query('
SELECT `u`.`user_id`, `u`.`name`,`u`.`email`, `u`.`mobile`, `u`.`discord`, `u`.`pushover_key`,
`u`.`pushover_device`, `u`.`telegram_id`,
SELECT `u`.`user_id`, `u`.`name`,`u`.`email`, `u`.`mobile`, `u`.`pushover_key`, `u`.`discord`, `u`.`webhook_url`,`u`.`webhook_json`,
`u`.`pushover_device`, `u`.`telegram_id`,
`u`.`jabber`
FROM `' . PSM_DB_PREFIX . 'users` AS `u`
JOIN `' . PSM_DB_PREFIX . "users_servers` AS `us` ON (

View File

@ -76,7 +76,7 @@
</footer>
{% endblock %}
{% endif %}
<script src="src/templates/default/static/plugin/jquery/jquery-3.3.1.min.js"></script>
<script src="src/templates/default/static/plugin/jquery/jquery-3.5.1.min.js"></script>
<script src="src/templates/default/static/plugin/popper.js/popper.min.js"></script>
<script src="src/templates/default/static/plugin/bootstrap/js/dist/index.js"></script>
<script src="src/templates/default/static/plugin/bootstrap/js/dist/util.js"></script>

View File

@ -35,7 +35,12 @@
<li class="nav-item">
<a class="nav-link {{ jabber_active }}" id="config-jabber-tab" data-toggle="tab" href="#config-jabber"
role="tab" aria-controls="config-jabber" aria-selected="{% if jabber_active %}true{% else %}false{% endif %}">{{
label_tab_jabber }}</a>
label_tab_jabber }}</a>
</li>
<li class="nav-item">
<a class="nav-link {{ webhook_active }}" id="config-webhook-tab" data-toggle="tab" href="#config-webhook" role="tab"
aria-controls="config-webhook" aria-selected="{% if webhook_active %}true{% else %}false{% endif %}">{{
label_tab_webhook }}</a>
</li>
</ul>
<!-- Tab panes -->
@ -200,6 +205,24 @@
{{ macro.button_save("jabber_submit", label_save) }}
</fieldset>
</div>
<div class="tab-pane {{ webhook_active }}" id="config-webhook" role="tabpanel" aria-labelledby="config-webhook-tab">
<fieldset>
<legend>{{ label_settings_webhook }}</legend>
<p>{{ label_webhook_description|raw }}</p>
<!-- enable webhooks -->
{{ macro.input_checkbox("webhook_status", "webhook_status", label_webhook_status, webhook_status_checked) }}
<!-- enable webhook log -->
{{ macro.input_checkbox("log_webhook", "log_webhook", label_log_webhook, log_webhook_checked) }}
<!-- webhook url -->
<!-- {{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, webhook_url, label_webhook_url, "255", "webhook_url_help", label_webhook_url_description) }} -->
<!-- webhook json -->
<!-- {{ macro.input_field("text", "webhook_json", null, "webhook_json", label_webhook_json, webhook_json, label_webhook_json, "255", "webhook_json_help", label_webhook_json_description) }} -->
{{ macro.button_test("testWebhook", label_test) }}
{{ macro.input_hidden("test_webhook", "0") }}
{{ macro.button_save("webhook_submit", label_save) }}
</fieldset>
</div>
</div>
{{ macro.input_csrf() }}
</form>

View File

@ -76,7 +76,10 @@
<i class="fas fa-circle" title="{{ label_jabber }}"></i>
<span class="fa-layers-text fa-inverse" style="font-weight:400; font-size:75%">J</span>
</span>
{% endif %}
{% endif %}
{% if server.webhook|lower == 'yes' and config.webhook|lower %}
<i class="fas fa-hashtag" title="{{ label_webhook }}"></i>
{% endif %}
</td>
{% if user_level == 10 %}
<td>

View File

@ -145,7 +145,9 @@
<!-- Telegram -->
{{ macro.input_select_monitoring("telegram", "telegram", label_send_telegram, edit_telegram_selected, label_yes, label_no, warning_telegram, label_warning_telegram) }}
<!-- Jabber -->
{{ macro.input_select_monitoring("jabber", "jabber", label_send_jabber, edit_jabber_selected, label_yes, label_no, warning_jabber, label_warning_jabber) }}
{{ macro.input_select_monitoring("jabber", "jabber", label_send_jabber, edit_jabber_selected, label_yes, label_no, warning_jabber, label_warning_jabber) }}
<!-- Webhook -->
{{ macro.input_select_monitoring("webhook", "webhook", label_send_webhook, edit_webhook_selected, label_yes, label_no, warning_webhook, label_warning_webhook) }}
</div>
</fieldset>
<fieldset>

View File

@ -360,7 +360,20 @@
<i class="fas fa-question-circle float-right" title="Value from database should either be yes or no."></i>
<noscript>&#8263</noscript>
{% endif %}
</li>
</li>
<li class="list-group-item">
{{ label_webhook }}:
{% if webhook|lower == 'yes' %}
<i class="fas fa-bell float-right"></i>
<noscript>&#10003</noscript>
{% elseif webhook|lower == 'no' %}
<i class="fas fa-bell-slash float-right"></i>
<noscript>&#10005</noscript>
{% else %}
<i class="fas fa-question-circle float-right" title="Value from database should either be yes or no."></i>
<noscript>&#8263</noscript>
{% endif %}
</li>
</ul>
</div>
</div>

View File

@ -24,9 +24,9 @@
<legend>{{ label_pushover }}</legend>
<p>{{ label_pushover_description|raw }}</p>
<!-- pushover key -->
{{ macro.input_field("text", "pushover_key", null, "pushover_key", label_pushover_key, pushover_key, label_pushover_key, "255", "pushover_key_help", pushover_key_description) }}
{{ macro.input_field("text", "pushover_key", null, "pushover_key", label_pushover_key, pushover_key, label_pushover_key, "255", "pushover_key_help", label_pushover_key_description) }}
<!-- pushover device -->
{{ macro.input_field("text", "pushover_device", null, "pushover_device", label_pushover_device, pushover_device, label_pushover_device, "255", "pushover_device_help", pushover_device_description) }}
{{ macro.input_field("text", "pushover_device", null, "pushover_device", label_pushover_device, pushover_device, label_pushover_device, "255", "pushover_device_help", label_pushover_device_description) }}
</fieldset>
<!-- Discord settings -->
<fieldset>
@ -42,7 +42,7 @@
<div class="form-group">
<a class="btn btn-primary mb-2" href="{{ telegram_get_chat_id_url }}">{{ label_telegram_get_chat_id }}</a>
</div>
{{ macro.input_field("text", "telegram_id", null, "telegram_id", label_telegram_chat_id, telegram_id, label_telegram_chat_id, "255", "telegram_id_help", telegram_id_description) }}
{{ macro.input_field("text", "telegram_id", null, "telegram_id", label_telegram_chat_id, telegram_id, label_telegram_chat_id, "255", "telegram_id_help", label_telegram_id_description) }}
<button class="btn btn-primary show-modal" data-toggle="modal" data-modal-id="activateTelegram">{{ label_activate_telegram }}</button>
{{ macro.input_hidden("activate_telegram", "0") }}
</fieldset>
@ -50,7 +50,16 @@
<fieldset>
<legend>{{ label_jabber }}</legend>
<!-- jabber -->
{{ macro.input_field("text", "jabber", null, "jabber", label_jabber, jabber, label_jabber, "255", "jabber_help", jabber_description) }}
</fieldset>
{{ macro.input_field("text", "jabber", null, "jabber", label_jabber, jabber, label_jabber, "255", "jabber_help", label_jabber_description) }}
</fieldset>
<!-- Webhook settings -->
<fieldset>
<legend>{{ label_webhook }}</legend>
<p>{{ label_webhook_description|raw }}</p>
<!-- webhook url -->
{{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, webhook_url, "https://test.com/api/abcde", "255", "webhook_url_help", label_webhook_url_description) }}
<!-- webhook json -->
{{ macro.input_field("text", "webhook_json", null, "webhook_json", label_webhook_json, webhook_json, "{\"text\":\"servermon: #message\"}", "255", "webhook_json_help", label_webhook_json_description) }}
</fieldset>
{{ macro.button_save(null, label_save) }}
</form>

View File

@ -17,8 +17,12 @@
{{ macro.input_field("email", "email", null, "email", label_email, edit_value_email, null, "255") }}
<!-- Mobile -->
{{ macro.input_field("tel", "mobile", null, "mobile", label_mobile, edit_value_mobile, null, "20") }}
<!-- Discord -->
<!-- Discord -->
{{ macro.input_field("text", "discord", null, "discord", label_discord, edit_value_discord, null, "255") }}
<!-- Webhook_url -->
{{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, edit_value_webhook_url, null, "255") }}
<!-- Webhook_json -->
{{ macro.input_field("text", "webhook_json", null, "webhook_json", label_webhook_json, edit_value_webhook_json, null, "255") }}
<!-- Pushover_key -->
{{ macro.input_field("text", "pushover_key", null, "pushover_key", label_pushover_key, edit_value_pushover_key, null, "255") }}
<!-- Pushover_device -->

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long