add feature "add url" to email and telegram
This commit is contained in:
parent
17cb13364b
commit
ed913c68fd
|
@ -196,6 +196,7 @@ $sm_lang = array(
|
||||||
'general' => 'Allgemein',
|
'general' => 'Allgemein',
|
||||||
'language' => 'Sprache',
|
'language' => 'Sprache',
|
||||||
'show_update' => 'Wöchentlich auf Aktualisierungen prüfen?',
|
'show_update' => 'Wöchentlich auf Aktualisierungen prüfen?',
|
||||||
|
'email_add_url' => 'Server URL an E-Mail anhängen?',
|
||||||
'email_status' => 'E-Mail-Versand erlauben?',
|
'email_status' => 'E-Mail-Versand erlauben?',
|
||||||
'email_from_email' => 'Absenderadresse',
|
'email_from_email' => 'Absenderadresse',
|
||||||
'email_from_name' => 'Name des Absenders',
|
'email_from_name' => 'Name des Absenders',
|
||||||
|
@ -221,6 +222,9 @@ $sm_lang = array(
|
||||||
'pushover_api_token_description' => 'Bevor Sie Pushover verwenden können, müssen Sie Ihre <a href="%1$s"
|
'pushover_api_token_description' => 'Bevor Sie Pushover verwenden können, müssen Sie Ihre <a href="%1$s"
|
||||||
target="_blank" rel="noopener">Anwendung hier registrieren</a> und Ihren
|
target="_blank" rel="noopener">Anwendung hier registrieren</a> und Ihren
|
||||||
Anwendungs-API-Token hier eingeben.',
|
Anwendungs-API-Token hier eingeben.',
|
||||||
|
'telegram_status' => 'Telegram Nachrichten erlauben?',
|
||||||
|
'telegram_add_url' => 'Server URL an Nachricht anhängen?',
|
||||||
|
'jabber_status' => 'Allow sending Jabber (XMPP) messages',
|
||||||
'alert_type' => 'Wann möchten Sie benachrichtigt werden?',
|
'alert_type' => 'Wann möchten Sie benachrichtigt werden?',
|
||||||
'alert_type_description' => '<b>Status geändert:</b> ... wenn sich der Status ändert<br>z. B. online ->
|
'alert_type_description' => '<b>Status geändert:</b> ... wenn sich der Status ändert<br>z. B. online ->
|
||||||
offline oder offline -> online.<br><br><b>Offline: </b>Sie bekommen eine
|
offline oder offline -> online.<br><br><b>Offline: </b>Sie bekommen eine
|
||||||
|
@ -237,6 +241,7 @@ $sm_lang = array(
|
||||||
'log_email' => 'E-Mail-Versand protokollieren?',
|
'log_email' => 'E-Mail-Versand protokollieren?',
|
||||||
'log_sms' => 'SMS-Versand protokollieren?',
|
'log_sms' => 'SMS-Versand protokollieren?',
|
||||||
'log_pushover' => 'Pushover-Versand protokollieren?',
|
'log_pushover' => 'Pushover-Versand protokollieren?',
|
||||||
|
'log_telegram' => 'Telegram-Versand protokollieren?',
|
||||||
'updated' => 'Die Einstellungen wurden gespeichert.',
|
'updated' => 'Die Einstellungen wurden gespeichert.',
|
||||||
'tab_email' => 'E-Mail',
|
'tab_email' => 'E-Mail',
|
||||||
'tab_sms' => 'SMS',
|
'tab_sms' => 'SMS',
|
||||||
|
|
|
@ -297,6 +297,7 @@ $sm_lang = array(
|
||||||
'proxy_user' => 'Proxy username',
|
'proxy_user' => 'Proxy username',
|
||||||
'proxy_password' => 'Proxy password',
|
'proxy_password' => 'Proxy password',
|
||||||
'email_status' => 'Allow sending email',
|
'email_status' => 'Allow sending email',
|
||||||
|
'email_add_url' => 'add server url to email',
|
||||||
'email_from_email' => 'Email from address',
|
'email_from_email' => 'Email from address',
|
||||||
'email_from_name' => 'Email from name',
|
'email_from_name' => 'Email from name',
|
||||||
'email_smtp' => 'Enable SMTP',
|
'email_smtp' => 'Enable SMTP',
|
||||||
|
@ -326,6 +327,7 @@ $sm_lang = array(
|
||||||
'pushover_api_token' => 'Pushover App API Token',
|
'pushover_api_token' => 'Pushover App API Token',
|
||||||
'pushover_api_token_description' => 'Before you can use Pushover, you need to <a href="%1$s" target="_blank" rel="noopener">register an App</a> at their website and enter the App API Token here.',
|
'pushover_api_token_description' => 'Before you can use Pushover, you need to <a href="%1$s" target="_blank" rel="noopener">register an App</a> at their website and enter the App API Token here.',
|
||||||
'telegram_status' => 'Allow sending Telegram messages',
|
'telegram_status' => 'Allow sending Telegram messages',
|
||||||
|
'telegram_add_url' => 'add server url to message',
|
||||||
'telegram_description' => '<a href="https://telegram.org/" target="_blank">Telegram</a> is a chat app that makes it easy to get real-time notifications. Visit the <a href="http://docs.phpservermonitor.org/" target="_blank">documentation</a> for more info and an install guide.',
|
'telegram_description' => '<a href="https://telegram.org/" target="_blank">Telegram</a> is a chat app that makes it easy to get real-time notifications. Visit the <a href="http://docs.phpservermonitor.org/" target="_blank">documentation</a> for more info and an install guide.',
|
||||||
'telegram_api_token' => 'Telegram API Token',
|
'telegram_api_token' => 'Telegram API Token',
|
||||||
'telegram_api_token_description' => 'Before you can use Telegram, you need to get a API token. Visit the <a href="http://docs.phpservermonitor.org/" target="_blank">documentation</a> for help.',
|
'telegram_api_token_description' => 'Before you can use Telegram, you need to get a API token. Visit the <a href="http://docs.phpservermonitor.org/" target="_blank">documentation</a> for help.',
|
||||||
|
|
|
@ -41,12 +41,14 @@ class ConfigController extends AbstractController
|
||||||
protected $checkboxes = array(
|
protected $checkboxes = array(
|
||||||
'proxy',
|
'proxy',
|
||||||
'email_status',
|
'email_status',
|
||||||
|
'email_add_url',
|
||||||
'email_smtp',
|
'email_smtp',
|
||||||
'sms_status',
|
'sms_status',
|
||||||
'discord_status',
|
'discord_status',
|
||||||
'pushover_status',
|
'pushover_status',
|
||||||
'webhook_status',
|
'webhook_status',
|
||||||
'telegram_status',
|
'telegram_status',
|
||||||
|
'telegram_add_url',
|
||||||
'jabber_status',
|
'jabber_status',
|
||||||
'log_status',
|
'log_status',
|
||||||
'log_email',
|
'log_email',
|
||||||
|
@ -602,6 +604,7 @@ class ConfigController extends AbstractController
|
||||||
'label_proxy_url' => psm_get_lang('config', 'proxy_url'),
|
'label_proxy_url' => psm_get_lang('config', 'proxy_url'),
|
||||||
'label_proxy_user' => psm_get_lang('config', 'proxy_user'),
|
'label_proxy_user' => psm_get_lang('config', 'proxy_user'),
|
||||||
'label_proxy_password' => psm_get_lang('config', 'proxy_password'),
|
'label_proxy_password' => psm_get_lang('config', 'proxy_password'),
|
||||||
|
'label_email_add_url' => psm_get_lang('config', 'email_add_url'),
|
||||||
'label_email_status' => psm_get_lang('config', 'email_status'),
|
'label_email_status' => psm_get_lang('config', 'email_status'),
|
||||||
'label_email_from_email' => psm_get_lang('config', 'email_from_email'),
|
'label_email_from_email' => psm_get_lang('config', 'email_from_email'),
|
||||||
'label_email_from_name' => psm_get_lang('config', 'email_from_name'),
|
'label_email_from_name' => psm_get_lang('config', 'email_from_name'),
|
||||||
|
@ -636,6 +639,7 @@ class ConfigController extends AbstractController
|
||||||
),
|
),
|
||||||
'label_telegram_description' => psm_get_lang('config', 'telegram_description'),
|
'label_telegram_description' => psm_get_lang('config', 'telegram_description'),
|
||||||
'label_telegram_status' => psm_get_lang('config', 'telegram_status'),
|
'label_telegram_status' => psm_get_lang('config', 'telegram_status'),
|
||||||
|
'label_telegram_add_url' => psm_get_lang('config', 'telegram_add_url'),
|
||||||
'label_telegram_api_token' => psm_get_lang('config', 'telegram_api_token'),
|
'label_telegram_api_token' => psm_get_lang('config', 'telegram_api_token'),
|
||||||
'label_telegram_api_token_description' => psm_get_lang('config', 'telegram_api_token_description'),
|
'label_telegram_api_token_description' => psm_get_lang('config', 'telegram_api_token_description'),
|
||||||
'label_jabber_status' => psm_get_lang('config', 'jabber_status'),
|
'label_jabber_status' => psm_get_lang('config', 'jabber_status'),
|
||||||
|
|
|
@ -1,91 +1,91 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Server Monitor
|
* PHP Server Monitor
|
||||||
* Monitor your servers and websites.
|
* Monitor your servers and websites.
|
||||||
*
|
*
|
||||||
* This file is part of PHP Server Monitor.
|
* This file is part of PHP Server Monitor.
|
||||||
* PHP Server Monitor is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* PHP Server Monitor is distributed in the hope that it will be useful,
|
* PHP Server Monitor is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* 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/>.
|
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* @package phpservermon
|
* @package phpservermon
|
||||||
* @author Victor Macko
|
* @author Victor Macko
|
||||||
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
|
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
|
||||||
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
* @version Release: @package_version@
|
* @version Release: @package_version@
|
||||||
* @link http://www.phpservermonitor.org/
|
* @link http://www.phpservermonitor.org/
|
||||||
* @since phpservermon 3.6.0
|
* @since phpservermon 3.6.0
|
||||||
**/
|
**/
|
||||||
|
|
||||||
namespace psm\Txtmsg;
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
class Infobip extends Core
|
class Infobip extends Core
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send sms using the infobip.com API
|
* Send sms using the infobip.com API
|
||||||
*
|
*
|
||||||
* @var string $message
|
* @var string $message
|
||||||
* @var string $this->password
|
* @var string $this->password
|
||||||
* @var array $this->recipients
|
* @var array $this->recipients
|
||||||
* @var array $this->originator
|
* @var array $this->originator
|
||||||
* @var string $recipients
|
* @var string $recipients
|
||||||
*
|
*
|
||||||
* @var resource $curl
|
* @var resource $curl
|
||||||
* @var string $err
|
* @var string $err
|
||||||
* @var mixed $result
|
* @var mixed $result
|
||||||
*
|
*
|
||||||
* @var int $success
|
* @var int $success
|
||||||
* @var string $error
|
* @var string $error
|
||||||
*
|
*
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function sendSMS($message)
|
public function sendSMS($message)
|
||||||
{
|
{
|
||||||
$success = 1;
|
$success = 1;
|
||||||
$error = '';
|
$error = '';
|
||||||
foreach ($this->recipients as $recipient) {
|
foreach ($this->recipients as $recipient) {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt(
|
curl_setopt(
|
||||||
$ch,
|
$ch,
|
||||||
CURLOPT_URL,
|
CURLOPT_URL,
|
||||||
"https://api.infobip.com/sms/1/text/query?username=" . $this->username .
|
"https://api.infobip.com/sms/1/text/query?username=" . $this->username .
|
||||||
"&password=" . $this->password .
|
"&password=" . $this->password .
|
||||||
"&to=" . $recipient .
|
"&to=" . $recipient .
|
||||||
"&text=" . urlencode($message) .
|
"&text=" . urlencode($message) .
|
||||||
//add your sender id here
|
//add your sender id here
|
||||||
"&from="
|
"&from="
|
||||||
);
|
);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$headers = array();
|
$headers = array();
|
||||||
$headers[] = "Content-Type: application/x-www-form-urlencoded";
|
$headers[] = "Content-Type: application/x-www-form-urlencoded";
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if (is_numeric(strpos($result, "FAILED"))) {
|
if (is_numeric(strpos($result, "FAILED"))) {
|
||||||
$error = $result;
|
$error = $result;
|
||||||
$success = 0;
|
$success = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($success == 1) {
|
if ($success == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ class Installer
|
||||||
('proxy_user', ''),
|
('proxy_user', ''),
|
||||||
('proxy_password', ''),
|
('proxy_password', ''),
|
||||||
('email_status', '1'),
|
('email_status', '1'),
|
||||||
|
('email_add_url', '0'),
|
||||||
('email_from_email', 'monitor@example.org'),
|
('email_from_email', 'monitor@example.org'),
|
||||||
('email_from_name', 'Server Monitor'),
|
('email_from_name', 'Server Monitor'),
|
||||||
('email_smtp', ''),
|
('email_smtp', ''),
|
||||||
|
@ -164,6 +165,7 @@ class Installer
|
||||||
('pushover_status', '0'),
|
('pushover_status', '0'),
|
||||||
('pushover_api_token', ''),
|
('pushover_api_token', ''),
|
||||||
('telegram_status', '0'),
|
('telegram_status', '0'),
|
||||||
|
('telegram_add_url', '0'),
|
||||||
('telegram_api_token', ''),
|
('telegram_api_token', ''),
|
||||||
('jabber_status', '1'),
|
('jabber_status', '1'),
|
||||||
('jabber_host', ''),
|
('jabber_host', ''),
|
||||||
|
|
|
@ -426,7 +426,8 @@ class StatusNotifier
|
||||||
|
|
||||||
$body = key_exists('message', $combi) ?
|
$body = key_exists('message', $combi) ?
|
||||||
$combi['message'] :
|
$combi['message'] :
|
||||||
psm_parse_msg($this->status_new, 'email_body', $this->server);
|
psm_parse_msg($this->status_new, 'email_body', $this->server);
|
||||||
|
if (bool)psm_get_conf('email_add_url')) $body .= PHP_EOL.PHP_EOL.'<a href="'.PSM_BASE_URL.'">'.PSM_BASE_URL.'</a>';
|
||||||
$mail->Body = $body;
|
$mail->Body = $body;
|
||||||
$mail->AltBody = str_replace('<br/>', "\n", $body);
|
$mail->AltBody = str_replace('<br/>', "\n", $body);
|
||||||
|
|
||||||
|
@ -695,8 +696,9 @@ class StatusNotifier
|
||||||
$message = key_exists('message', $combi) ?
|
$message = key_exists('message', $combi) ?
|
||||||
$combi['message'] :
|
$combi['message'] :
|
||||||
psm_parse_msg($this->status_new, 'telegram_message', $this->server);
|
psm_parse_msg($this->status_new, 'telegram_message', $this->server);
|
||||||
|
if (bool)psm_get_conf('telegram_add_url')) $body .= PHP_EOL.PSM_BASE_URL;
|
||||||
$telegram = psm_build_telegram();
|
$telegram = psm_build_telegram();
|
||||||
$telegram->setMessage($message);
|
$telegram->setMessage($message;
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
if (psm_get_conf('log_telegram')) {
|
if (psm_get_conf('log_telegram')) {
|
||||||
|
|
|
@ -142,6 +142,8 @@
|
||||||
{{ macro.input_checkbox("email_status", "email_status[]", label_email_status, email_status_checked) }}
|
{{ macro.input_checkbox("email_status", "email_status[]", label_email_status, email_status_checked) }}
|
||||||
<!-- enable email log -->
|
<!-- enable email log -->
|
||||||
{{ macro.input_checkbox("log_email", "log_email[]", label_log_email, log_email_checked) }}
|
{{ macro.input_checkbox("log_email", "log_email[]", label_log_email, log_email_checked) }}
|
||||||
|
<!-- enable adding url to email -->
|
||||||
|
{{ macro.input_checkbox("email_add_url", "email_add_url[]", label_email_add_url, email_add_url_checked) }}
|
||||||
<!-- email name -->
|
<!-- email name -->
|
||||||
{{ macro.input_field("text", "email_from_name", null, "email_from_name", label_email_from_name, email_from_name, label_email_from_name, "255") }}
|
{{ macro.input_field("text", "email_from_name", null, "email_from_name", label_email_from_name, email_from_name, label_email_from_name, "255") }}
|
||||||
<!-- email address -->
|
<!-- email address -->
|
||||||
|
@ -222,6 +224,8 @@
|
||||||
{{ macro.input_checkbox("telegram_status", "telegram_status[]", label_telegram_status, telegram_status_checked) }}
|
{{ macro.input_checkbox("telegram_status", "telegram_status[]", label_telegram_status, telegram_status_checked) }}
|
||||||
<!-- enable telegram log -->
|
<!-- enable telegram log -->
|
||||||
{{ macro.input_checkbox("log_telegram", "log_telegram[]", label_log_telegram, log_telegram_checked) }}
|
{{ macro.input_checkbox("log_telegram", "log_telegram[]", label_log_telegram, log_telegram_checked) }}
|
||||||
|
<!-- enable adding url to telegram -->
|
||||||
|
{{ macro.input_checkbox("telegram_add_url", "telegram_add_url[]", label_telegram_add_url, telegram_add_url_checked) }}
|
||||||
<!-- telegram key -->
|
<!-- telegram key -->
|
||||||
{{ macro.input_field("text", "telegram_api_token", null, "telegram_api_token", label_telegram_api_token, telegram_api_token, label_telegram_api_token, "255", "telegram_api_token_help", label_telegram_api_token_description) }}
|
{{ macro.input_field("text", "telegram_api_token", null, "telegram_api_token", label_telegram_api_token, telegram_api_token, label_telegram_api_token, "255", "telegram_api_token_help", label_telegram_api_token_description) }}
|
||||||
{{ macro.button_test("testTelegram", label_test) }}
|
{{ macro.button_test("testTelegram", label_test) }}
|
||||||
|
|
Loading…
Reference in New Issue