diff --git a/index.php b/index.php index ed223c87..3252bc2a 100644 --- a/index.php +++ b/index.php @@ -25,6 +25,9 @@ * @link http://www.phpservermonitor.org/ **/ +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); require __DIR__ . '/src/bootstrap.php'; psm_no_cache(); @@ -35,7 +38,9 @@ if(isset($_GET["logout"])) { header('Location: ' . psm_build_url()); die(); } - +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); $mod = psm_GET('mod', PSM_MODULE_DEFAULT); try { @@ -45,4 +50,7 @@ try { // it that somehow also doesnt exist, we have a bit of an issue // and we really have no reason catch it $router->run(PSM_MODULE_DEFAULT); -} \ No newline at end of file +} +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index b509929d..1ef80577 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -491,6 +491,18 @@ function psm_build_pushover() { return $pushover; } +/** + * Prepare a new Telegram util. + * + * @return \Telegram + */ +function psm_build_telegram() { + $telegram = new \Telegram(); + $telegram->setToken(psm_get_conf('telegram_api_token')); + + return $telegram; +} + /** * Prepare a new SMS util. * @@ -712,7 +724,7 @@ function psm_password_decrypt($key, $encryptedString) if (empty($key)) throw new \InvalidArgumentException('invalid_encryption_key'); - + $data = base64_decode($encryptedString); $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); @@ -728,4 +740,4 @@ function psm_password_decrypt($key, $encryptedString) ); return $decrypted; -} \ No newline at end of file +} diff --git a/src/includes/psmconfig.inc.php b/src/includes/psmconfig.inc.php index 3423aa30..93180625 100644 --- a/src/includes/psmconfig.inc.php +++ b/src/includes/psmconfig.inc.php @@ -107,6 +107,12 @@ define('PSM_CURL_TIMEOUT', 10); */ define('PSM_PUSHOVER_CLONE_URL', 'https://pushover.net/apps/clone/php_server_monitor'); +/** + * Get telegram chat id. + */ +define('PSM_TELEGRAM_GET_ID', 'https://t.me/ChatIDBot'); + + /** * By defining the PSM_BASE_URL, you will force the psm_build_url() to use this. * Useful for cronjobs if it cannot be auto-detected. diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index 4c87982e..c0a7a130 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -88,6 +88,9 @@ $sm_lang = array( 'pushover_key' => 'Pushover Key', 'pushover_device' => 'Pushover Device', 'pushover_device_description' => 'Apparaat waar de berichten naar toe gaan. Laat leeg voor alle apparaten.', + 'telegram' => 'Telegram', + 'telegram_description' => 'Telegram is een dienst die het gemakkelijk maakt om real-time notificaties te ontvangen. Zie hun website voor meer informatie.', + 'telegram_key' => 'Telegram Chat ID', 'delete_title' => 'Verwijder gebruiker', 'delete_message' => 'Weet je zeker dat je deze gebruiker wilt verwijderen: \'%1\'?', 'deleted' => 'Gebruiker verwijderd.', @@ -112,6 +115,7 @@ $sm_lang = array( 'email' => 'Email', 'sms' => 'SMS', 'pushover' => 'Pushover', + 'telegram' => 'Telegram', 'no_logs' => 'No logs', ), 'servers' => array( @@ -136,6 +140,7 @@ $sm_lang = array( 'sms' => 'SMS', 'send_sms' => 'Stuur SMS', 'pushover' => 'Pushover', + 'telegram' => 'Telegram', 'users' => 'Gebruikers', 'delete_title' => 'Verwijder server', 'delete_message' => 'Weet je zeker dat je deze server wilt verwijderen: \'%1\'?', @@ -164,6 +169,7 @@ $sm_lang = array( 'warning_notifications_disabled_sms' => 'SMS notificaties zijn uitgeschakeld.', 'warning_notifications_disabled_email' => 'Email notificaties zijn uitgeschakeld.', 'warning_notifications_disabled_pushover' => 'Pushover notificaties zijn uitgeschakeld.', + 'warning_notifications_disabled_telegram' => 'Telegram notificaties zijn uitgeschakeld.', 'error_server_no_match' => 'Server niet gevonden.', 'error_server_label_bad_length' => 'Het label moet tussen de 1 en 255 karakters lang zijn.', 'error_server_ip_bad_length' => 'Het domein / IP moet tussen de 1 en 255 karakters lang zijn.', @@ -208,6 +214,11 @@ $sm_lang = array( 'pushover_clone_app' => 'Klik hier om je Pushover app te maken', 'pushover_api_token' => 'Pushover App API Token', 'pushover_api_token_description' => 'Voordat je Pushover kunt gebruiken moet je een App registreren via hun website, en daarvan de App API Token hier invullen.', + 'telegram_get_id_button' => 'Vind je chat id', + 'telegram_status' => 'Sta Telegram berichten toe?', + 'telegram_description' => 'Telegram is een dienst die het gemakkelijk maakt om real-time notificaties te ontvangen. Zie hun website voor meer informatie.', + 'telegram_api_token' => 'Telegram App API Token', + 'telegram_api_token_description' => 'Voordat je Telegram kunt gebruiken moet je een Bot registreren via hun website @Botfather en daarna de API Token hier invullen.', 'alert_type' => 'Selecteer wanneer je een notificatie wilt', 'alert_type_description' => 'Status verandert: '. 'Je ontvangt alleen bericht wanneer een server van status verandert. Dus van online -> offline of offline -> online.
'. @@ -225,13 +236,16 @@ $sm_lang = array( 'log_email' => 'Log emails verstuurd bij het script?', 'log_sms' => 'Log sms berichten verstuurd bij het script?', 'log_pushover' => 'Log Pushover berichten verstuurd bij het script?', + 'log_telegram' => 'Log Telegram berichten verstuurd bij het script?', 'updated' => 'De configuratie is gewijzigd.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_pushover' => 'Pushover', + 'tab_telegram' => 'Telegram', 'settings_email' => 'Email instellingen', 'settings_sms' => 'SMS instellingen', 'settings_pushover' => 'Pushover instellingen', + 'settings_telegram' => 'Telegram instellingen', 'settings_notification' => 'Notificatie instellingen', 'settings_log' => 'Log instellingen', 'auto_refresh' => 'Auto-refresh', @@ -245,6 +259,7 @@ $sm_lang = array( 'test_email' => 'Er zal een email verstuurd worden naar het email adres in je profiel.', 'test_sms' => 'Er zal een SMS verstuurd worden naar het telefoonnummer in je profiel.', 'test_pushover' => 'Er zal een Pushover notificatie verstuurd worden naar de user key/device in je profiel.', + 'test_telegram' => 'Er zal een Telegram notificatie verstuurd worden naar het chat id in je profiel.', 'send' => 'Verstuur', 'test_subject' => 'Test', 'test_message' => 'Test bericht', @@ -257,6 +272,10 @@ $sm_lang = array( 'pushover_error' => 'De volgende fout is opgetreden bij het versturen van de Pushover notificatie: %s', 'pushover_error_noapp' => 'Kan test notificatie niet verzenden: er is geen Pushover App API token gevonden in de algemene configuratie.', 'pushover_error_nokey' => 'Kan test notificatie niet verzenden: er is geen Pushover key gevonden in je profiel.', + 'telegram_sent' => 'Telegram notificatie verzonden', + 'telegram_error' => 'De volgende fout is opgetreden bij het versturen van de Telegram notificatie: %s', + 'telegram_error_noapi' => 'Kan test notificatie niet verzenden: er is geen Telegram Bot API token gevonden in de algemene configuratie.', + 'telegram_error_noid' => 'Kan test notificatie niet verzenden: er is geen Telegram chat id gevonden in je profiel.', 'log_retention_period' => 'Log retentie periode', 'log_retention_period_description' => 'Aantal dagen dat logs van notificaties en archieven van server uptime worden bewaard. Vul 0 in om log opruiming uit te zetten.', 'log_retention_days' => 'dagen', @@ -268,11 +287,13 @@ $sm_lang = array( 'off_email_body' => "De server kon niet worden bereikt:

Server: %LABEL%
IP: %IP%
Poort: %PORT%
Fout: %ERROR%
Datum: %DATE%", 'off_pushover_title' => 'Server %LABEL% is DOWN', 'off_pushover_message' => "De server kon niet worden bereikt:

Server: %LABEL%
IP: %IP%
Poort: %PORT%
Fout: %ERROR%
Datum: %DATE%", + 'off_telegram_message' => "Server %LABEL% is DOWN \n De server kon niet worden bereikt:\n \n Server: %LABEL% \n IP: %IP% \n Poort: %PORT% \n Fout: %ERROR% \n Datum: %DATE%", 'on_sms' => 'Server %LABEL% is RUNNING: ip=%IP%, poort=%PORT%', 'on_email_subject' => 'BELANGRIJK: Server %LABEL% is RUNNING', 'on_email_body' => "Server %LABEL% is weer online:

Server: %LABEL%
IP: %IP%
Poort: %PORT%
Datum: %DATE%", 'on_pushover_title' => 'Server %LABEL% is RUNNING', 'on_pushover_message' => "Server %LABEL% is weer online:

Server: %LABEL%
IP: %IP%
Poort: %PORT%
Datum: %DATE%", + 'on_telegram_message' => "Server %LABEL% is weer online: \n \n Server: %LABEL% \n IP: %IP% \n Poort: %PORT% \n Datum: %DATE%", ), 'login' => array( 'welcome_usermenu' => 'Welkom, %user_name%', diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index b030234f..b21f9b75 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -1,57 +1,60 @@ . - * - * @package phpservermon - * @author Pepijn Over - * @copyright Copyright (c) 2008-2017 Pepijn Over - * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 - * @version Release: @package_version@ - * @link http://www.phpservermonitor.org/ - **/ +* 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 . +* +* @package phpservermon +* @author Pepijn Over +* @copyright Copyright (c) 2008-2017 Pepijn Over +* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 +* @version Release: @package_version@ +* @link http://www.phpservermonitor.org/ +**/ namespace psm\Module\Config\Controller; use psm\Module\AbstractController; use psm\Service\Database; +use psm\Telegram; class ConfigController extends AbstractController { /** - * Checkboxes - * @var array $checkboxes - */ + * Checkboxes + * @var array $checkboxes + */ protected $checkboxes = array( 'proxy', 'email_status', 'email_smtp', 'sms_status', 'pushover_status', + 'telegram_status', 'log_status', 'log_email', 'log_sms', 'log_pushover', + 'log_telegram', 'show_update', ); /** - * Fields for saving - * @var array $fields - */ + * Fields for saving + * @var array $fields + */ protected $fields = array( 'proxy_url', 'proxy_user', @@ -66,6 +69,7 @@ class ConfigController extends AbstractController { 'sms_gateway_password', 'sms_from', 'pushover_api_token', + 'telegram_api_token', ); private $default_tab = 'general'; @@ -82,10 +86,10 @@ class ConfigController extends AbstractController { } /** - * Populate all the config fields with values from the database - * - * @return string - */ + * Populate all the config fields with values from the database + * + * @return string + */ protected function executeIndex() { $this->twig->addGlobal('subtitle', psm_get_lang('menu', 'config')); $tpl_data = $this->getLabels(); @@ -104,8 +108,8 @@ class ConfigController extends AbstractController { // generate language array $lang_keys = psm_get_langs(); $tpl_data['language_current'] = (isset($config['language'])) - ? $config['language'] - : 'en_US'; + ? $config['language'] + : 'en_US'; $tpl_data['languages'] = array(); foreach($lang_keys as $key => $label) { $tpl_data['languages'][] = array( @@ -125,9 +129,9 @@ class ConfigController extends AbstractController { foreach($this->checkboxes as $input_key) { $tpl_data[$input_key . '_checked'] = - (isset($config[$input_key]) && (int) $config[$input_key] == 1) - ? 'checked="checked"' - : ''; + (isset($config[$input_key]) && (int) $config[$input_key] == 1) + ? 'checked="checked"' + : ''; } foreach($this->fields as $input_key) { $tpl_data[$input_key] = (isset($config[$input_key])) ? $config[$input_key] : ''; @@ -135,7 +139,7 @@ class ConfigController extends AbstractController { $tpl_data[$this->default_tab . '_active'] = 'active'; - $testmodals = array('email', 'sms', 'pushover'); + $testmodals = array('email', 'sms', 'pushover', 'telegram'); foreach($testmodals as $modal_id) { $modal = new \psm\Util\Module\Modal($this->twig, 'test' . ucfirst($modal_id), \psm\Util\Module\Modal::MODAL_TYPE_OKCANCEL); $this->addModal($modal); @@ -148,9 +152,9 @@ class ConfigController extends AbstractController { } /** - * If a post has been done, gather all the posted data - * and save it to the database - */ + * If a post has been done, gather all the posted data + * and save it to the database + */ protected function executeSave() { if(!empty($_POST)) { // save new config @@ -159,9 +163,9 @@ class ConfigController extends AbstractController { 'sms_gateway' => $_POST['sms_gateway'], 'alert_type' => $_POST['alert_type'], 'email_smtp_security' => - in_array($_POST['email_smtp_security'], array('', 'ssl', 'tls')) - ? $_POST['email_smtp_security'] - : '', + in_array($_POST['email_smtp_security'], array('', 'ssl', 'tls')) + ? $_POST['email_smtp_security'] + : '', 'auto_refresh_servers' => intval(psm_POST('auto_refresh_servers', 0)), 'log_retention_period' => intval(psm_POST('log_retention_period', 365)), 'password_encrypt_key' => psm_POST('password_encrypt_key', sha1(microtime())), @@ -186,6 +190,8 @@ class ConfigController extends AbstractController { $this->testSMS(); } elseif(!empty($_POST['test_pushover'])) { $this->testPushover(); + } elseif(!empty($_POST['test_telegram'])) { + $this->testTelegram(); } if($language_refresh) { @@ -201,16 +207,18 @@ class ConfigController extends AbstractController { $this->default_tab = 'sms'; } elseif(isset($_POST['pushover_submit']) || !empty($_POST['test_pushover'])) { $this->default_tab = 'pushover'; + } elseif(isset($_POST['telegram_submit']) || !empty($_POST['test_telegram'])) { + $this->default_tab = 'telegram'; } } return $this->runAction('index'); } /** - * Execute email test - * - * @todo move test to separate class - */ + * Execute email test + * + * @todo move test to separate class + */ protected function testEmail() { $mail = psm_build_mail(); $message = psm_get_lang('config', 'test_message'); @@ -228,10 +236,10 @@ class ConfigController extends AbstractController { } /** - * Execute SMS test - * - * @todo move test to separate class - */ + * Execute SMS test + * + * @todo move test to separate class + */ protected function testSMS() { $sms = psm_build_sms(); if($sms) { @@ -250,10 +258,10 @@ class ConfigController extends AbstractController { } /** - * Execute pushover test - * - * @todo move test to separate class - */ + * Execute pushover test + * + * @todo move test to separate class + */ protected function testPushover() { $pushover = psm_build_pushover(); $pushover->setDebug(true); @@ -287,14 +295,43 @@ class ConfigController extends AbstractController { } } + /** + * Execute telegram test + * + * @todo move test to separate class + */ + protected function testTelegram() { + + $telegram = psm_build_telegram(); + $telegram->setDebug(true); + $user = $this->getUser()->getUser(); + $api_token = psm_get_conf('telegram_api_token'); + + if(!empty($api_token)) { + $this->addMessage(psm_get_lang('config', 'telegram_error_noapi'), 'error'); + } elseif(empty($user->telegram_chat_id)) { + $this->addMessage(psm_get_lang('config', 'telegram_error_noid'), 'error'); + } else { + + $telegram = new Telegram($api_token); + $chat_id = $user['telegram_chat_id']; + $message->setMessage(psm_get_lang('config', 'test_message')); + $content = array('chat_id' => $chat_id, 'text' => $message); + $telegram->sendMessage($content); + } + die($bot_token); + } + protected function getLabels() { return array( 'label_tab_email' => psm_get_lang('config', 'tab_email'), 'label_tab_sms' => psm_get_lang('config', 'tab_sms'), 'label_tab_pushover' => psm_get_lang('config', 'tab_pushover'), + 'label_tab_telegram' => psm_get_lang('config', 'tab_telegram'), 'label_settings_email' => psm_get_lang('config', 'settings_email'), 'label_settings_sms' => psm_get_lang('config', 'settings_sms'), 'label_settings_pushover' => psm_get_lang('config', 'settings_pushover'), + 'label_settings_telegram' => psm_get_lang('config', 'settings_telegram'), 'label_settings_notification' => psm_get_lang('config', 'settings_notification'), 'label_settings_log' => psm_get_lang('config', 'settings_log'), 'label_settings_proxy' => psm_get_lang('config', 'settings_proxy'), @@ -346,6 +383,12 @@ class ConfigController extends AbstractController { psm_get_lang('config', 'pushover_api_token_description'), PSM_PUSHOVER_CLONE_URL ), + 'label_telegram_description' => psm_get_lang('config', 'telegram_description'), + 'label_telegram_status' => psm_get_lang('config', 'telegram_status'), + 'label_telegram_description' => psm_get_lang('config', 'telegram_description'), + 'label_telegram_status' => psm_get_lang('config', 'telegram_status'), + '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_alert_type' => psm_get_lang('config', 'alert_type'), 'label_alert_type_description' => psm_get_lang('config', 'alert_type_description'), 'label_alert_type_status' => psm_get_lang('config', 'alert_type_status'), @@ -356,6 +399,7 @@ class ConfigController extends AbstractController { 'label_log_email' => psm_get_lang('config', 'log_email'), 'label_log_sms' => psm_get_lang('config', 'log_sms'), 'label_log_pushover' => psm_get_lang('config', 'log_pushover'), + 'label_log_telegram' => psm_get_lang('config', 'log_telegram'), 'label_alert_proxy' => psm_get_lang('config', 'alert_proxy'), 'label_alert_proxy_url' => psm_get_lang('config', 'alert_proxy_url'), 'label_auto_refresh' => psm_get_lang('config', 'auto_refresh'), @@ -368,4 +412,4 @@ class ConfigController extends AbstractController { 'label_log_retention_days' => psm_get_lang('config', 'log_retention_days'), ); } -} \ No newline at end of file +} diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index 81ec1f96..33a521af 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -214,6 +214,7 @@ class InstallController extends AbstractController { 'level' => PSM_USER_ADMIN, 'pushover_key' => '', 'pushover_device' => '', + 'telegram_chat_id' => '', ); $validator = $this->container->get('util.user.validator'); diff --git a/src/psm/Module/Server/Controller/AbstractServerController.php b/src/psm/Module/Server/Controller/AbstractServerController.php index de2160dc..13fc03a2 100644 --- a/src/psm/Module/Server/Controller/AbstractServerController.php +++ b/src/psm/Module/Server/Controller/AbstractServerController.php @@ -73,6 +73,7 @@ abstract class AbstractServerController extends AbstractController { `s`.`email`, `s`.`sms`, `s`.`pushover`, + `s`.`telegram`, `s`.`warning_threshold`, `s`.`warning_threshold_counter`, `s`.`timeout`, @@ -104,6 +105,7 @@ abstract class AbstractServerController extends AbstractController { $server['email'] = psm_get_lang('system', $server['email']); $server['sms'] = psm_get_lang('system', $server['sms']); $server['pushover'] = psm_get_lang('system', $server['pushover']); + $server['telegram'] = psm_get_lang('system', $server['telegram']); if($server['status'] == 'on' && $server['warning_threshold_counter'] > 0) { $server['status'] = 'warning'; diff --git a/src/psm/Module/Server/Controller/LogController.php b/src/psm/Module/Server/Controller/LogController.php index e3d7db6c..ca5e9400 100644 --- a/src/psm/Module/Server/Controller/LogController.php +++ b/src/psm/Module/Server/Controller/LogController.php @@ -49,6 +49,7 @@ class LogController extends AbstractServerController { 'label_email' => psm_get_lang('log', 'email'), 'label_sms' => psm_get_lang('log', 'sms'), 'label_pushover' => psm_get_lang('log', 'pushover'), + 'label_telegram' => psm_get_lang('log', 'telegram'), 'label_title' => psm_get_lang('log', 'title'), 'label_server' => psm_get_lang('servers', 'server'), 'label_type' => psm_get_lang('log', 'type'), @@ -58,7 +59,7 @@ class LogController extends AbstractServerController { 'label_no_logs' => psm_get_lang('log', 'no_logs'), 'tabs' => array(), ); - $log_types = array('status', 'email', 'sms', 'pushover'); + $log_types = array('status', 'email', 'sms', 'pushover', 'telegram'); foreach($log_types as $key) { $records = $this->getEntries($key); diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index aa24a2b4..46e04b12 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -92,6 +92,7 @@ class ServerController extends AbstractServerController { 'email' => 'icon-envelope', 'sms' => 'icon-mobile', 'pushover' => 'icon-pushover', + 'telegram' => 'icon-telegram', ); $servers = $this->getServers(); @@ -206,10 +207,11 @@ class ServerController extends AbstractServerController { 'edit_email_selected_' . $edit_server['email'] => 'selected="selected"', 'edit_sms_selected_' . $edit_server['sms'] => 'selected="selected"', 'edit_pushover_selected_' . $edit_server['pushover'] => 'selected="selected"', + 'edit_telegram_selected_' . $edit_server['telegram'] => 'selected="selected"', )); } - $notifications = array('email', 'sms', 'pushover'); + $notifications = array('email', 'sms', 'pushover', 'telegram'); foreach($notifications as $notification) { if(psm_get_conf($notification . '_status') == 0) { $tpl_data['warning_' . $notification] = true; @@ -268,6 +270,7 @@ class ServerController extends AbstractServerController { 'email' => in_array($_POST['email'], array('yes', 'no')) ? $_POST['email'] : 'no', 'sms' => in_array($_POST['sms'], array('yes', 'no')) ? $_POST['sms'] : 'no', 'pushover' => in_array($_POST['pushover'], array('yes', 'no')) ? $_POST['pushover'] : 'no', + 'telegram' => in_array($_POST['telegram'], array('yes', 'no')) ? $_POST['telegram'] : 'no', ); // make sure websites start with http:// if($clean['type'] == 'website' && substr($clean['ip'], 0, 4) != 'http') { @@ -472,6 +475,7 @@ class ServerController extends AbstractServerController { 'label_sms' => psm_get_lang('servers', 'sms'), 'label_send_sms' => psm_get_lang('servers', 'send_sms'), 'label_pushover' => psm_get_lang('servers', 'pushover'), + 'label_telegram' => psm_get_lang('servers', 'telegram'), 'label_users' => psm_get_lang('servers', 'users'), 'label_warning_threshold' => psm_get_lang('servers', 'warning_threshold'), 'label_warning_threshold_description' => psm_get_lang('servers', 'warning_threshold_description'), diff --git a/src/psm/Module/User/Controller/ProfileController.php b/src/psm/Module/User/Controller/ProfileController.php index 0d4630e5..efe53012 100644 --- a/src/psm/Module/User/Controller/ProfileController.php +++ b/src/psm/Module/User/Controller/ProfileController.php @@ -35,7 +35,7 @@ class ProfileController extends AbstractController { * Editable fields for the profile * @var array $profile_fields */ - protected $profile_fields = array('name', 'user_name', 'mobile', 'pushover_key', 'pushover_device', 'email'); + protected $profile_fields = array('name', 'user_name', 'mobile', 'pushover_key', 'pushover_device', 'telegram_chat_id', 'email'); function __construct(Database $db, \Twig_Environment $twig) { parent::__construct($db, $twig); @@ -66,6 +66,10 @@ class ProfileController extends AbstractController { 'label_pushover_key' => psm_get_lang('users', 'pushover_key'), 'label_pushover_device' => psm_get_lang('users', 'pushover_device'), 'label_pushover_device_description' => psm_get_lang('users', 'pushover_device_description'), + 'label_telegram_get_id_button' => psm_get_lang('config', 'telegram_get_id_button'), + 'label_telegram' => psm_get_lang('users', 'telegram'), + 'label_telegram_description' => psm_get_lang('users', 'telegram_description'), + 'label_telegram_chat_id' => psm_get_lang('users', 'telegram_chat_id'), 'label_email' => psm_get_lang('users', 'email'), 'label_save' => psm_get_lang('system', 'save'), 'form_action' => psm_build_url(array( @@ -135,4 +139,4 @@ class ProfileController extends AbstractController { return $this->executeIndex(); } -} \ No newline at end of file +} diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index ef71353c..ce325342 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -89,7 +89,7 @@ class UserController extends AbstractController { $users = $this->db->select( PSM_DB_PREFIX.'users', null, - array('user_id', 'user_name', 'level', 'name', 'mobile', 'pushover_key', 'pushover_device', 'email'), + array('user_id', 'user_name', 'level', 'name', 'mobile', 'pushover_key', 'pushover_device', 'telegram_chat_id', 'email'), null, array('name') ); @@ -133,7 +133,7 @@ class UserController extends AbstractController { */ protected function executeEdit() { $user_id = isset($_GET['id']) ? intval($_GET['id']) : 0; - $fields_prefill = array('name', 'user_name', 'mobile', 'pushover_key', 'pushover_device', 'email'); + $fields_prefill = array('name', 'user_name', 'mobile', 'pushover_key', 'pushover_device', 'telegram_chat_id', 'email'); if($user_id == 0) { // insert mode @@ -215,7 +215,7 @@ class UserController extends AbstractController { } $user_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; - $fields = array('name', 'user_name', 'password', 'password_repeat', 'level', 'mobile', 'pushover_key', 'pushover_device', 'email'); + $fields = array('name', 'user_name', 'password', 'password_repeat', 'level', 'mobile', 'pushover_key', 'pushover_device', 'telegram_chat_id', 'email'); $clean = array(); foreach($fields as $field) { if(isset($_POST[$field])) { @@ -333,6 +333,9 @@ class UserController extends AbstractController { 'label_pushover_key' => psm_get_lang('users', 'pushover_key'), 'label_pushover_device' => psm_get_lang('users', 'pushover_device'), 'label_pushover_device_description' => psm_get_lang('users', 'pushover_device_description'), + 'label_telegram' => psm_get_lang('users', 'telegram'), + 'label_telegram_description' => psm_get_lang('users', 'telegram_description'), + 'label_telegram_chat_id' => psm_get_lang('users', 'telegram_chat_id'), 'label_email' => psm_get_lang('users', 'email'), 'label_servers' => psm_get_lang('menu', 'server'), 'label_action' => psm_get_lang('system', 'action'), diff --git a/src/psm/Telegram/telegram.php b/src/psm/Telegram/telegram.php new file mode 100644 index 00000000..709315bb --- /dev/null +++ b/src/psm/Telegram/telegram.php @@ -0,0 +1,67 @@ +bot_token = $bot_token; + $this->data = $this->getData(); + } + public function endpoint($api, array $content, $post = true) { + $url = 'https://api.telegram.org/bot' . $this->bot_token . '/' . $api; + if ($post) + $reply = $this->sendAPIRequest($url, $content); + else + $reply = $this->sendAPIRequest($url, array(), false); + return json_decode($reply, true); + } + + public function sendMessage(array $content) { + return $this->endpoint("sendMessage", $content); + } + + public function getData() { + if (empty($this->data)) { + $rawData = file_get_contents("php://input"); + return json_decode($rawData, true); + } else { + return $this->data; + } + } + + /// Set the data currently used + public function setData(array $data) { + $this->data = $data; + } + + private function sendAPIRequest($url, array $content, $post = true) { + if (isset($content['chat_id'])) { + $url = $url . "?chat_id=" . $content['chat_id']; + unset($content['chat_id']); + } + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + if ($post) { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $content); + } + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + $result = curl_exec($ch); + if($result === false) { + $result = json_encode(array('ok'=>false, 'curl_error_code' => curl_errno($ch), 'curl_error' => curl_error($ch))); + } + curl_close($ch); + //return $result; + } + die($url); +} diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index 66c649fe..3907c10c 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -1,73 +1,73 @@ . - * - * @package phpservermon - * @author Pepijn Over - * @copyright Copyright (c) 2008-2017 Pepijn Over - * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 - * @version Release: @package_version@ - * @link http://www.phpservermonitor.org/ - * @since phpservermon 2.1.0 - **/ +* 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 . +* +* @package phpservermon +* @author Pepijn Over +* @copyright Copyright (c) 2008-2017 Pepijn Over +* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 +* @version Release: @package_version@ +* @link http://www.phpservermonitor.org/ +* @since phpservermon 2.1.0 +**/ namespace psm\Util\Install; /** - * Installer class. - * - * Executes the queries to install/upgrade phpservermon. - */ +* Installer class. +* +* Executes the queries to install/upgrade phpservermon. +*/ class Installer { /** - * Database service - * @var \psm\Service\Database $db - */ + * Database service + * @var \psm\Service\Database $db + */ protected $db; /** - * Log callback - * @var callable $logger - */ + * Log callback + * @var callable $logger + */ protected $logger; /** - * Log of executed queries - * @var array $queries - */ + * Log of executed queries + * @var array $queries + */ protected $queries = array(); /** - * Open a new installer instance - * @param \psm\Service\Database $db - * @param callable $logger - */ + * Open a new installer instance + * @param \psm\Service\Database $db + * @param callable $logger + */ function __construct(\psm\Service\Database $db, $logger = null) { $this->db = $db; $this->logger = $logger; } /** - * Check if an upgrade is required for the current version. - * @return boolean - * @see upgrade() - */ + * Check if an upgrade is required for the current version. + * @return boolean + * @see upgrade() + */ public function isUpgradeRequired() { $version_db = psm_get_conf('version'); @@ -88,10 +88,10 @@ class Installer { } /** - * Log a message to the logger callable (if any) - * @param string|array $msg - * @return \psm\Util\Install\Installer - */ + * Log a message to the logger callable (if any) + * @param string|array $msg + * @return \psm\Util\Install\Installer + */ protected function log($msg) { if(is_callable($this->logger)) { $msg = (!is_array($msg)) ? array($msg) : $msg; @@ -104,10 +104,10 @@ class Installer { } /** - * Execute one or more queries. Does no fetching or anything, so execute only. - * @param string|array $query - * @return \psm\Util\Install\Installer - */ + * Execute one or more queries. Does no fetching or anything, so execute only. + * @param string|array $query + * @return \psm\Util\Install\Installer + */ protected function execSQL($query) { $query = (!is_array($query)) ? array($query) : $query; @@ -119,148 +119,153 @@ class Installer { } /** - * Retrieve table queries for install - */ + * Retrieve table queries for install + */ public function install() { $this->installTables(); $this->log('Populating database...'); $queries = array(); - $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "servers` (`ip`, `port`, `label`, `type`, `pattern`, `status`, `error`, `rtime`, `last_online`, `last_check`, `active`, `email`, `sms`, `pushover`) VALUES ('http://sourceforge.net/index.php', 80, 'SourceForge', 'website', '', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes', 'yes'), ('smtp.gmail.com', 465, 'Gmail SMTP', 'service', '', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes', 'yes')"; + $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "servers` (`ip`, `port`, `label`, `type`, `pattern`, `status`, `error`, `rtime`, `last_online`, `last_check`, `active`, `email`, `sms`, `pushover`, `telegram`) VALUES ('http://sourceforge.net/index.php', 80, 'SourceForge', 'website', '', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes', 'yes'), ('smtp.gmail.com', 465, 'Gmail SMTP', 'service', '', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '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'), - ('proxy', '0'), - ('proxy_url', ''), - ('proxy_user', ''), - ('proxy_password', ''), - ('email_status', '1'), - ('email_from_email', 'monitor@example.org'), - ('email_from_name', 'Server Monitor'), - ('email_smtp', ''), - ('email_smtp_host', ''), - ('email_smtp_port', ''), - ('email_smtp_security', ''), - ('email_smtp_username', ''), - ('email_smtp_password', ''), - ('sms_status', '0'), - ('sms_gateway', 'mollie'), - ('sms_gateway_username', 'username'), - ('sms_gateway_password', 'password'), - ('sms_from', '1234567890'), - ('pushover_status', '0'), - ('pushover_api_token', ''), - ('password_encrypt_key', '" . sha1(microtime()) . "'), - ('alert_type', 'status'), - ('log_status', '1'), - ('log_email', '1'), - ('log_sms', '1'), - ('log_pushover', '1'), - ('log_retention_period', '365'), - ('version', '" . PSM_VERSION . "'), - ('version_update_check', '" . PSM_VERSION . "'), - ('auto_refresh_servers', '0'), - ('show_update', '1'), - ('last_update_check', '0'), - ('cron_running', '0'), - ('cron_running_time', '0');"; + ('language', 'en_US'), + ('proxy', '0'), + ('proxy_url', ''), + ('proxy_user', ''), + ('proxy_password', ''), + ('email_status', '1'), + ('email_from_email', 'monitor@example.org'), + ('email_from_name', 'Server Monitor'), + ('email_smtp', ''), + ('email_smtp_host', ''), + ('email_smtp_port', ''), + ('email_smtp_security', ''), + ('email_smtp_username', ''), + ('email_smtp_password', ''), + ('sms_status', '0'), + ('sms_gateway', 'mollie'), + ('sms_gateway_username', 'username'), + ('sms_gateway_password', 'password'), + ('sms_from', '1234567890'), + ('pushover_status', '0'), + ('pushover_api_token', ''), + ('telegram_status', '0'), + ('telegram_api_token', ''), + ('password_encrypt_key', '" . sha1(microtime()) . "'), + ('alert_type', 'status'), + ('log_status', '1'), + ('log_email', '1'), + ('log_sms', '1'), + ('log_pushover', '1'), + ('log_telegram', '1'), + ('log_retention_period', '365'), + ('version', '" . PSM_VERSION . "'), + ('version_update_check', '" . PSM_VERSION . "'), + ('auto_refresh_servers', '0'), + ('show_update', '1'), + ('last_update_check', '0'), + ('cron_running', '0'), + ('cron_running_time', '0');"; $this->execSQL($queries); } /** - * Install the tables for the monitor - */ + * Install the tables for the monitor + */ protected function installTables() { $tables = array( PSM_DB_PREFIX . 'config' => "CREATE TABLE `" . PSM_DB_PREFIX . "config` ( - `key` varchar(255) NOT NULL, - `value` varchar(255) NOT NULL, - PRIMARY KEY (`key`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `key` varchar(255) NOT NULL, + `value` varchar(255) NOT NULL, + PRIMARY KEY (`key`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", PSM_DB_PREFIX . 'users' => "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "users` ( - `user_id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `user_name` varchar(64) NOT NULL COMMENT 'user''s name, unique', - `password` varchar(255) NOT NULL COMMENT 'user''s password in salted and hashed format', - `password_reset_hash` char(40) DEFAULT NULL COMMENT 'user''s password reset code', - `password_reset_timestamp` bigint(20) DEFAULT NULL COMMENT 'timestamp of the password reset request', - `rememberme_token` varchar(64) DEFAULT NULL COMMENT 'user''s remember-me cookie token', - `level` tinyint(2) unsigned NOT NULL DEFAULT '20', - `name` varchar(255) NOT NULL, - `mobile` varchar(15) NOT NULL, - `pushover_key` varchar(255) NOT NULL, - `pushover_device` varchar(255) NOT NULL, - `email` varchar(255) NOT NULL, - PRIMARY KEY (`user_id`), - UNIQUE KEY `unique_username` (`user_name`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `user_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user_name` varchar(64) NOT NULL COMMENT 'user''s name, unique', + `password` varchar(255) NOT NULL COMMENT 'user''s password in salted and hashed format', + `password_reset_hash` char(40) DEFAULT NULL COMMENT 'user''s password reset code', + `password_reset_timestamp` bigint(20) DEFAULT NULL COMMENT 'timestamp of the password reset request', + `rememberme_token` varchar(64) DEFAULT NULL COMMENT 'user''s remember-me cookie token', + `level` tinyint(2) unsigned NOT NULL DEFAULT '20', + `name` varchar(255) NOT NULL, + `mobile` varchar(15) NOT NULL, + `pushover_key` varchar(255) NOT NULL, + `pushover_device` varchar(255) NOT NULL, + `telegram_chat_id` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + PRIMARY KEY (`user_id`), + UNIQUE KEY `unique_username` (`user_name`) + ) 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, - `value` varchar(255) NOT NULL, - PRIMARY KEY (`user_id`, `key`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `user_id` int(11) unsigned NOT NULL, + `key` varchar(255) NOT NULL, + `value` varchar(255) NOT NULL, + PRIMARY KEY (`user_id`, `key`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", PSM_DB_PREFIX . 'users_servers' => "CREATE TABLE `" . PSM_DB_PREFIX . "users_servers` ( - `user_id` INT( 11 ) UNSIGNED NOT NULL , - `server_id` INT( 11 ) UNSIGNED NOT NULL , - PRIMARY KEY ( `user_id` , `server_id` ) - ) ENGINE = MYISAM ;", + `user_id` INT( 11 ) UNSIGNED NOT NULL , + `server_id` INT( 11 ) UNSIGNED NOT NULL , + PRIMARY KEY ( `user_id` , `server_id` ) + ) ENGINE = MYISAM ;", 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','pushover') NOT NULL, - `message` varchar(255) NOT NULL, - `datetime` timestamp NOT NULL default CURRENT_TIMESTAMP, - PRIMARY KEY (`log_id`) - ) 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 , - PRIMARY KEY (`log_id`, `user_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `log_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `server_id` int(11) unsigned NOT NULL, + `type` enum('status','email','sms','pushover','telegram') NOT NULL, + `message` varchar(255) NOT NULL, + `datetime` timestamp NOT NULL default CURRENT_TIMESTAMP, + PRIMARY KEY (`log_id`) + ) 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 , + PRIMARY KEY (`log_id`, `user_id`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", 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, - `label` varchar(255) NOT NULL, - `type` enum('ping','service','website') NOT NULL default 'service', - `pattern` varchar(255) NOT NULL, - `status` enum('on','off') NOT NULL default 'on', - `error` varchar(255) NULL, - `rtime` FLOAT(9, 7) NULL, - `last_online` datetime NULL, - `last_check` datetime NULL, - `active` enum('yes','no') NOT NULL default 'yes', - `email` enum('yes','no') NOT NULL default 'yes', - `sms` enum('yes','no') NOT NULL default 'no', - `pushover` enum('yes','no') NOT NULL default 'yes', - `warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1', - `warning_threshold_counter` mediumint(1) unsigned NOT NULL DEFAULT '0', - `timeout` smallint(1) unsigned NULL DEFAULT NULL, - `website_username` varchar(255) DEFAULT NULL, - `website_password` varchar(255) DEFAULT NULL, - PRIMARY KEY (`server_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `server_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `ip` varchar(500) NOT NULL, + `port` int(5) unsigned NOT NULL, + `label` varchar(255) NOT NULL, + `type` enum('ping','service','website') NOT NULL default 'service', + `pattern` varchar(255) NOT NULL, + `status` enum('on','off') NOT NULL default 'on', + `error` varchar(255) NULL, + `rtime` FLOAT(9, 7) NULL, + `last_online` datetime NULL, + `last_check` datetime NULL, + `active` enum('yes','no') NOT NULL default 'yes', + `email` enum('yes','no') NOT NULL default 'yes', + `sms` enum('yes','no') NOT NULL default 'no', + `pushover` enum('yes','no') NOT NULL default 'yes', + `telegram` enum('yes','no') NOT NULL default 'yes', + `warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1', + `warning_threshold_counter` mediumint(1) unsigned NOT NULL DEFAULT '0', + `timeout` smallint(1) unsigned NULL DEFAULT NULL, + `website_username` varchar(255) DEFAULT NULL, + `website_password` varchar(255) DEFAULT NULL, + PRIMARY KEY (`server_id`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", PSM_DB_PREFIX . 'servers_uptime' => "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "servers_uptime` ( - `servers_uptime_id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `server_id` int(11) unsigned NOT NULL, - `date` datetime NOT NULL, - `status` tinyint(1) unsigned NOT NULL, - `latency` float(9,7) DEFAULT NULL, - PRIMARY KEY (`servers_uptime_id`), - KEY `server_id` (`server_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `servers_uptime_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `server_id` int(11) unsigned NOT NULL, + `date` datetime NOT NULL, + `status` tinyint(1) unsigned NOT NULL, + `latency` float(9,7) DEFAULT NULL, + PRIMARY KEY (`servers_uptime_id`), + KEY `server_id` (`server_id`) + ) 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, - `date` date NOT NULL, - `latency_min` float(9,7) NOT NULL, - `latency_avg` float(9,7) NOT NULL, - `latency_max` float(9,7) NOT NULL, - `checks_total` int(11) unsigned NOT NULL, - `checks_failed` int(11) unsigned NOT NULL, - PRIMARY KEY (`servers_history_id`), - UNIQUE KEY `server_id_date` (`server_id`,`date`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + `servers_history_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `server_id` int(11) unsigned NOT NULL, + `date` date NOT NULL, + `latency_min` float(9,7) NOT NULL, + `latency_avg` float(9,7) NOT NULL, + `latency_max` float(9,7) NOT NULL, + `checks_total` int(11) unsigned NOT NULL, + `checks_failed` int(11) unsigned NOT NULL, + PRIMARY KEY (`servers_history_id`), + UNIQUE KEY `server_id_date` (`server_id`,`date`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", ); foreach($tables as $name => $sql) { @@ -276,11 +281,11 @@ class Installer { } /** - * Populate the tables and perform upgrades if necessary - * @param string $version_from - * @param string $version_to - * @see isUpgradeRequired() - */ + * Populate the tables and perform upgrades if necessary + * @param string $version_from + * @param string $version_to + * @see isUpgradeRequired() + */ public function upgrade($version_from, $version_to) { if(version_compare($version_from, '2.1.0', '<')) { $this->upgrade210(); @@ -298,8 +303,8 @@ class Installer { } /** - * Upgrade for v2.1.0 release - */ + * Upgrade for v2.1.0 release + */ protected function upgrade210() { $queries = array(); $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "config` DROP `config_id`;"; @@ -318,8 +323,8 @@ class Installer { } /** - * Upgrade for v3.0.0 release - */ + * Upgrade for v3.0.0 release + */ protected function upgrade300() { $queries = array(); // language is now stored as language code (ISO 639-1) + country code (ISO 3166-1) @@ -347,135 +352,140 @@ class Installer { $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` CHANGE `user_id` `user_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` - ADD `user_name` varchar(64) COLLATE utf8_general_ci NOT NULL COMMENT 'user\'s name, unique' AFTER `user_id`, - ADD `password` varchar(255) COLLATE utf8_general_ci NOT NULL COMMENT 'user\'s password in salted and hashed format' AFTER `user_name`, - ADD `password_reset_hash` char(40) COLLATE utf8_general_ci DEFAULT NULL COMMENT 'user\'s password reset code' AFTER `password`, - ADD `password_reset_timestamp` bigint(20) DEFAULT NULL COMMENT 'timestamp of the password reset request' AFTER `password_reset_hash`, - ADD `rememberme_token` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT 'user\'s remember-me cookie token' AFTER `password_reset_timestamp`, - ADD `level` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '20' AFTER `rememberme_token`;"; + ADD `user_name` varchar(64) COLLATE utf8_general_ci NOT NULL COMMENT 'user\'s name, unique' AFTER `user_id`, + ADD `password` varchar(255) COLLATE utf8_general_ci NOT NULL COMMENT 'user\'s password in salted and hashed format' AFTER `user_name`, + ADD `password_reset_hash` char(40) COLLATE utf8_general_ci DEFAULT NULL COMMENT 'user\'s password reset code' AFTER `password`, + ADD `password_reset_timestamp` bigint(20) DEFAULT NULL COMMENT 'timestamp of the password reset request' AFTER `password_reset_hash`, + ADD `rememberme_token` varchar(64) COLLATE utf8_general_ci DEFAULT NULL COMMENT 'user\'s remember-me cookie token' AFTER `password_reset_timestamp`, + ADD `level` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '20' AFTER `rememberme_token`;"; // make sure all current users are admins (previously we didnt have non-admins): $queries[] = "UPDATE `" . PSM_DB_PREFIX . "users` SET `user_name`=`email`, `level`=10;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` ADD UNIQUE `unique_username` ( `user_name` );"; $queries[] = "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, - `date` datetime NOT NULL, - `status` tinyint(1) unsigned NOT NULL, - `latency` float(9,7) DEFAULT NULL, - PRIMARY KEY (`servers_uptime_id`), - KEY `server_id` (`server_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; + `servers_uptime_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `server_id` int(11) unsigned NOT NULL, + `date` datetime NOT NULL, + `status` tinyint(1) unsigned NOT NULL, + `latency` float(9,7) DEFAULT NULL, + PRIMARY KEY (`servers_uptime_id`), + KEY `server_id` (`server_id`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; - $queries[] = "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, - `date` date NOT NULL, - `latency_min` float(9,7) NOT NULL, - `latency_avg` float(9,7) NOT NULL, - `latency_max` float(9,7) NOT NULL, - `checks_total` int(11) unsigned NOT NULL, - `checks_failed` int(11) unsigned NOT NULL, - PRIMARY KEY (`servers_history_id`), - UNIQUE KEY `server_id_date` (`server_id`,`date`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; + $queries[] = "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, + `date` date NOT NULL, + `latency_min` float(9,7) NOT NULL, + `latency_avg` float(9,7) NOT NULL, + `latency_max` float(9,7) NOT NULL, + `checks_total` int(11) unsigned NOT NULL, + `checks_failed` int(11) unsigned NOT NULL, + PRIMARY KEY (`servers_history_id`), + UNIQUE KEY `server_id_date` (`server_id`,`date`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; - $queries[] = "CREATE TABLE `" . PSM_DB_PREFIX . "users_servers` ( - `user_id` INT( 11 ) UNSIGNED NOT NULL , - `server_id` INT( 11 ) UNSIGNED NOT NULL , - PRIMARY KEY ( `user_id` , `server_id` ) - ) ENGINE = MYISAM ;"; - $this->execSQL($queries); + $queries[] = "CREATE TABLE `" . PSM_DB_PREFIX . "users_servers` ( + `user_id` INT( 11 ) UNSIGNED NOT NULL , + `server_id` INT( 11 ) UNSIGNED NOT NULL , + PRIMARY KEY ( `user_id` , `server_id` ) + ) ENGINE = MYISAM ;"; + $this->execSQL($queries); - // from 3.0 all user-server relations are in a separate table - $users = $this->db->select(PSM_DB_PREFIX . 'users', null, array('user_id', 'server_id')); - foreach($users as $user) { - $idc = array(); - if($user['server_id'] == '') { - continue; - } - if(strpos($user['server_id'], ',') === false) { - $idc[] = $user['server_id']; - } else { - $idc = explode(',', $user['server_id']); - } - foreach($idc as $id) { - $this->db->save(PSM_DB_PREFIX . 'users_servers', array( - 'user_id' => $user['user_id'], - 'server_id' => $id, - )); - } - } - $this->execSQL("ALTER TABLE `".PSM_DB_PREFIX."users` DROP `server_id`;"); - } + // from 3.0 all user-server relations are in a separate table + $users = $this->db->select(PSM_DB_PREFIX . 'users', null, array('user_id', 'server_id')); + foreach($users as $user) { + $idc = array(); + if($user['server_id'] == '') { + continue; + } + if(strpos($user['server_id'], ',') === false) { + $idc[] = $user['server_id']; + } else { + $idc = explode(',', $user['server_id']); + } + foreach($idc as $id) { + $this->db->save(PSM_DB_PREFIX . 'users_servers', array( + 'user_id' => $user['user_id'], + 'server_id' => $id, + )); + } + } + $this->execSQL("ALTER TABLE `".PSM_DB_PREFIX."users` DROP `server_id`;"); + } - /** - * Upgrade for v3.1.0 release - */ - protected function upgrade310() { - $queries = array(); - psm_update_conf('log_retention_period', '365'); + /** + * Upgrade for v3.1.0 release + */ + protected function upgrade310() { + $queries = array(); + psm_update_conf('log_retention_period', '365'); - psm_update_conf('pushover_status', 0); - psm_update_conf('log_pushover', 1); - psm_update_conf('pushover_api_token', ''); - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` ADD `pushover_key` VARCHAR( 255 ) NOT NULL AFTER `mobile`;"; - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` ADD `pushover_device` VARCHAR( 255 ) NOT NULL AFTER `pushover_key`;"; + psm_update_conf('pushover_status', 0); + psm_update_conf('log_pushover', 1); + psm_update_conf('pushover_api_token', ''); + psm_update_conf('telegram_status', 0); + psm_update_conf('log_telegram', 1); + psm_update_conf('telegram_api_token', ''); + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` ADD `pushover_key` VARCHAR( 255 ) NOT NULL AFTER `mobile`;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` ADD `pushover_device` VARCHAR( 255 ) NOT NULL AFTER `pushover_key`;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` ADD `telegram_chat_id` VARCHAR( 255 ) NOT NULL AFTER `pushover_device`;"; - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `pushover` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `sms`;"; - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `type` `type` ENUM( 'status', 'email', 'sms', 'pushover' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `pushover` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `sms`;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `telegram` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `pushover`;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `type` `type` ENUM( 'status', 'email', 'sms', 'pushover', 'telegram' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"; - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` smallint(1) unsigned NULL DEFAULT NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` smallint(1) unsigned NULL DEFAULT NULL;"; - $queries[] = "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "users_preferences` ( + $queries[] = "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "users_preferences` ( `user_id` int(11) unsigned NOT NULL, `key` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, PRIMARY KEY (`user_id`, `key`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; - $this->execSQL($queries); - } + $this->execSQL($queries); + } - /** - * Upgrade for v3.2.0 release - */ - protected function upgrade320() { - $queries = array(); + /** + * Upgrade for v3.2.0 release + */ + protected function upgrade320() { + $queries = array(); - psm_update_conf('password_encrypt_key', sha1(microtime())); - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `ip` `ip` VARCHAR(500) NOT NULL;"; - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `website_username` varchar(255) NULL, ADD `website_password` varchar(255) NULL AFTER `website_username`;"; - $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE - ('proxy', '0'), - ('proxy_url', ''), - ('proxy_user', ''), - ('proxy_password', '');"; + psm_update_conf('password_encrypt_key', sha1(microtime())); + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `ip` `ip` VARCHAR(500) NOT NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `website_username` varchar(255) NULL, ADD `website_password` varchar(255) NULL AFTER `website_username`;"; + $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE + ('proxy', '0'), + ('proxy_url', ''), + ('proxy_user', ''), + ('proxy_password', '');"; - $this->execSQL($queries); + $this->execSQL($queries); - // 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 , - PRIMARY KEY (`log_id`, `user_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); + // 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 , + PRIMARY KEY (`log_id`, `user_id`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - // Migrate the data - $logs = $this->db->select(PSM_DB_PREFIX . 'log', null, array('log_id', 'user_id')); - foreach ($logs as $log) { - // Validation - if (empty($log['user_id']) || trim($log['user_id']) == '') { - continue; - } + // Migrate the data + $logs = $this->db->select(PSM_DB_PREFIX . 'log', null, array('log_id', 'user_id')); + foreach ($logs as $log) { + // Validation + if (empty($log['user_id']) || trim($log['user_id']) == '') { + continue; + } - // Insert into new table - foreach (explode(',', $log['user_id']) as $user_id) { - psm_add_log_user($log['log_id'], $user_id); - } - } + // Insert into new table + foreach (explode(',', $log['user_id']) as $user_id) { + psm_add_log_user($log['log_id'], $user_id); + } + } - // Drop old user_id('s) column - $this->execSQL("ALTER TABLE `" . PSM_DB_PREFIX . "log` DROP COLUMN `user_id`;"); - } -} + // Drop old user_id('s) column + $this->execSQL("ALTER TABLE `" . PSM_DB_PREFIX . "log` DROP COLUMN `user_id`;"); + } + } diff --git a/src/psm/Util/Server/UpdateManager.php b/src/psm/Util/Server/UpdateManager.php index bb8ee4db..aac2d528 100644 --- a/src/psm/Util/Server/UpdateManager.php +++ b/src/psm/Util/Server/UpdateManager.php @@ -56,7 +56,7 @@ class UpdateManager extends ContainerAware { )"; } - $sql = "SELECT `s`.`server_id`,`s`.`ip`,`s`.`port`,`s`.`label`,`s`.`type`,`s`.`pattern`,`s`.`status`,`s`.`active`,`s`.`email`,`s`.`sms`,`s`.`pushover` + $sql = "SELECT `s`.`server_id`,`s`.`ip`,`s`.`port`,`s`.`label`,`s`.`type`,`s`.`pattern`,`s`.`status`,`s`.`active`,`s`.`email`,`s`.`sms`,`s`.`pushover`,`s`.`telegram` FROM `".PSM_DB_PREFIX."servers` AS `s` {$sql_join} WHERE `active`='yes' "; @@ -78,4 +78,4 @@ class UpdateManager extends ContainerAware { $archive->archive(); $archive->cleanup(); } -} \ No newline at end of file +} diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index 755b76ab..a2be32b5 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -33,6 +33,7 @@ */ namespace psm\Util\Server\Updater; use psm\Service\Database; +use psm\Telegram; class StatusNotifier { @@ -55,11 +56,17 @@ class StatusNotifier { protected $send_sms = false; /** - * Send sms? + * Send pushover? * @var boolean $send_pushover */ protected $send_pushover = false; + /** + * Send telegram? + * @var boolean $send_telegram + */ + protected $send_telegram = false; + /** * Save log records? * @var boolean $save_log @@ -96,6 +103,7 @@ class StatusNotifier { $this->send_emails = psm_get_conf('email_status'); $this->send_sms = psm_get_conf('sms_status'); $this->send_pushover = psm_get_conf('pushover_status'); + $this->send_telegram = psm_get_conf('telegram_status'); $this->save_logs = psm_get_conf('log_status'); } @@ -121,7 +129,7 @@ class StatusNotifier { $this->server = $this->db->selectRow(PSM_DB_PREFIX . 'servers', array( 'server_id' => $server_id, ), array( - 'server_id', 'ip', 'port', 'label', 'type', 'pattern', 'status', 'error', 'active', 'email', 'sms', 'pushover', + 'server_id', 'ip', 'port', 'label', 'type', 'pattern', 'status', 'error', 'active', 'email', 'sms', 'pushover', 'telegram', )); if(empty($this->server)) { return false; @@ -188,6 +196,12 @@ class StatusNotifier { $this->notifyByPushover($users); } + // check if telegram is enabled for this server + if($this->send_telegram && $this->server['telegram'] == 'yes') { + // yay lets wake those nerds up! + $this->notifyByTelegram($users); + } + return $notify; } @@ -277,6 +291,46 @@ class StatusNotifier { $pushover->send(); } } + /** + * This functions performs the telegram notifications + * + * @param array $users + * @return boolean + */ + protected function notifyByTelegram($users) { + // Remove users that have no telegram_chat_id + foreach($users as $k => $user) { + if (trim($user['telegram_chat_id']) == '') { + unset($users[$k]); + } + } + + // Validation + if (empty($users)) { + return; + } + + // Telegram + $message = psm_parse_msg($this->status_new, 'telegram_message', $this->server); + $message = str_replace('
', "\n", $message); + + // Log + if(psm_get_conf('log_telegram')) { + $log_id = psm_add_log($this->server_id, 'telegram', $message); + } + + foreach($users as $user) { + // Log + if(!empty($log_id)) { + psm_add_log_user($log_id, $user['user_id']); + } + $bot_token = psm_get_conf('telegram_api_token'); + $telegram = new Telegram($bot_token); + $chat_id = $user['telegram_chat_id']; + $content = array('chat_id' => $chat_id, 'text' => $message); + $telegram->sendMessage($content); + } + } /** * This functions performs the text message notifications @@ -330,4 +384,4 @@ class StatusNotifier { "); return $users; } -} \ No newline at end of file +} diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index 076890d8..b42f29b4 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -1,270 +1,303 @@ {% import 'main/macros.tpl.html' as macro %}
- -
-
-
- {{ label_general }} -
- -
- -
-
-
-
- -
-
-
- -
-  {{ label_seconds }} -
-
-
- -
- -
-
-
-
- {{ label_settings_notification }} -
- -
- -

{{ label_alert_type_description|raw }}

-
-
-
-
- {{ label_settings_log }} -
-
- -
-
-
- -
-  {{ label_log_retention_days }} -
-
- {{ label_settings_proxy }} -
-
- -

{{ label_alert_proxy|raw }}

-
-
-
- -
- -

{{ label_alert_proxy_url|raw }}

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
-
- -
-
- {{ label_settings_sms }} -
-
- -
-
-
-
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
- -
-
-
-
-
- {{ label_settings_pushover }} -
-
- -

{{ label_pushover_description|raw }}

-
-
-
-
- -
-
-
- -
-

- -

{{ label_pushover_api_token_description|raw }}

-
-
-
-
- - -
-
-
- -
-
-
-
- {{ macro.csrf_input() }} -
\ No newline at end of file + +
+
+
+ {{ label_general }} +
+ +
+ +
+
+
+
+ +
+
+
+ +
+  {{ label_seconds }} +
+
+
+ +
+ +
+
+
+
+ {{ label_settings_notification }} +
+ +
+ +

{{ label_alert_type_description|raw }}

+
+
+
+
+ {{ label_settings_log }} +
+
+ +
+
+
+ +
+  {{ label_log_retention_days }} +
+
+ {{ label_settings_proxy }} +
+
+ +

{{ label_alert_proxy|raw }}

+
+
+
+ +
+ +

{{ label_alert_proxy_url|raw }}

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ {{ label_settings_sms }} +
+
+ +
+
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ {{ label_settings_pushover }} +
+
+ +

{{ label_pushover_description|raw }}

+
+
+
+
+ +
+
+
+ +
+

+ +

{{ label_pushover_api_token_description|raw }}

+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ {{ label_settings_telegram }} +
+
+ +

{{ label_telegram_description|raw }}

+
+
+
+
+ +
+
+
+ +
+ +

{{ label_telegram_api_token_description|raw }}

+
+
+
+
+ + +
+
+
+ +
+
+
+
+ {{ macro.csrf_input() }} + diff --git a/src/templates/default/module/server/log.tpl.html b/src/templates/default/module/server/log.tpl.html index c69fbab3..0c51538f 100644 --- a/src/templates/default/module/server/log.tpl.html +++ b/src/templates/default/module/server/log.tpl.html @@ -4,6 +4,7 @@
  • {{ label_email }}
  • {{ label_sms }}
  • {{ label_pushover }}
  • +
  • {{ label_telegram }}
  • {% for tab in tabs %} @@ -57,4 +58,4 @@
    {% endfor %} - \ No newline at end of file + diff --git a/src/templates/default/module/server/server/list.tpl.html b/src/templates/default/module/server/server/list.tpl.html index 08e64db3..4a8e548e 100644 --- a/src/templates/default/module/server/server/list.tpl.html +++ b/src/templates/default/module/server/server/list.tpl.html @@ -23,7 +23,7 @@
    {{ server.type }}
    {{ server.rtime }} s
    {{ server.last_online }}
    -
    +
    @@ -51,7 +51,7 @@
    {{ server.ip_short|raw }}
    - +
    @@ -63,4 +63,4 @@ {% endfor %} - \ No newline at end of file + diff --git a/src/templates/default/module/server/server/update.tpl.html b/src/templates/default/module/server/server/update.tpl.html index 4f26e357..de70aef3 100644 --- a/src/templates/default/module/server/server/update.tpl.html +++ b/src/templates/default/module/server/server/update.tpl.html @@ -139,6 +139,17 @@ +
    + +
    + +
    +
    diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index 17dad262..a9423f7e 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -69,6 +69,10 @@ {{ label_pushover }}: {{ pushover }} + + {{ label_telegram }}: + {{ telegram }} + {{ label_timeout }}: {{ timeout }} s @@ -100,4 +104,4 @@ {% endif %} -{{ html_history|raw }} \ No newline at end of file +{{ html_history|raw }} diff --git a/src/templates/default/module/user/profile.tpl.html b/src/templates/default/module/user/profile.tpl.html index a5f390d5..eaf2b40b 100644 --- a/src/templates/default/module/user/profile.tpl.html +++ b/src/templates/default/module/user/profile.tpl.html @@ -62,6 +62,17 @@ +
    + +
    {{ label_telegram_description|raw }}
    +
    +
    + +
    +

    + +
    +
    @@ -70,4 +81,4 @@
    - \ No newline at end of file + diff --git a/src/templates/default/module/user/user/update.tpl.html b/src/templates/default/module/user/user/update.tpl.html index 7b4ef56d..bead6769 100644 --- a/src/templates/default/module/user/user/update.tpl.html +++ b/src/templates/default/module/user/user/update.tpl.html @@ -1,4 +1,4 @@ -{% import 'main/macros.tpl.html' as macro %} + {% import 'main/macros.tpl.html' as macro %}
    {{ macro.csrf_input() }}
    @@ -55,17 +55,27 @@
    {{ label_pushover_description|raw }}
    - +
    - +
    +
    + +
    {{ label_telegram_description|raw }}
    +
    +
    + +
    + +
    +
    @@ -81,4 +91,4 @@
    -
    \ No newline at end of file +