From a9f0f64c78ea9cc6442b2c784a53d7a59663cc96 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Thu, 12 Dec 2019 22:00:31 +0100 Subject: [PATCH 001/112] Public server page --- public.php | 35 +++++++++++++++++++++++++++ src/bootstrap.php | 13 ++++++++++ src/lang/en_US.lang.php | 1 + src/psm/Module/AbstractController.php | 2 +- src/psm/Service/User.php | 11 +++++++++ src/psm/Util/User/UserValidator.php | 2 +- 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 public.php diff --git a/public.php b/public.php new file mode 100644 index 00000000..35299784 --- /dev/null +++ b/public.php @@ -0,0 +1,35 @@ +. + * + * @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 { + define('PSM_PUBLIC_PAGE', true); + + require __DIR__ . '/src/bootstrap.php'; + + $router->run('server'); +} diff --git a/src/bootstrap.php b/src/bootstrap.php index 9037beef..e6dd3338 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -108,6 +108,19 @@ namespace { } } + // check for a public page var + // This should be defined in the config + if (!defined('PSM_PUBLIC')) { + define('PSM_PUBLIC', false); + } + + // check for a public page + // This variable is for internal use + // and should not be changed by the user manualy + if (!defined('PSM_PUBLIC_PAGE')) { + define('PSM_PUBLIC_PAGE', false); + } + $lang = psm_get_conf('language', 'en_US'); psm_load_lang($lang); } diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 621a6aed..c836511f 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -106,6 +106,7 @@ $sm_lang = array( 'level' => 'Level', 'level_10' => 'Administrator', 'level_20' => 'User', + 'level_30' => 'Anonymous', 'level_description' => 'Administrators have full access: they can manage servers, users and edit the global configuration.
Users can only view and run the updater for the servers that have been assigned to them.', diff --git a/src/psm/Module/AbstractController.php b/src/psm/Module/AbstractController.php index 260543e6..2fe2209b 100644 --- a/src/psm/Module/AbstractController.php +++ b/src/psm/Module/AbstractController.php @@ -124,7 +124,7 @@ abstract class AbstractController implements ControllerInterface * @var int $user_level_required * @see setMinUserLevelRequired() */ - protected $user_level_required = PSM_USER_USER; + protected $user_level_required = (PSM_PUBLIC && PSM_PUBLIC_PAGE) ? PSM_USER_ANONYMOUS : PSM_USER_USER; /** * Required user level for certain actions diff --git a/src/psm/Service/User.php b/src/psm/Service/User.php index fb50e475..fce6213b 100644 --- a/src/psm/Service/User.php +++ b/src/psm/Service/User.php @@ -100,6 +100,17 @@ class User } $this->session = $session; + if (PSM_PUBLIC === true && PSM_PUBLIC_PAGE === true) { + $query_user = $this->db_connection->prepare('SELECT * FROM ' . + PSM_DB_PREFIX . 'users WHERE user_name = :user_name and level = :level'); + $query_user->bindValue(':user_name', "__PUBLIC__", \PDO::PARAM_STR); + $query_user->bindValue(':level', PSM_USER_ANONYMOUS, \PDO::PARAM_STR); + $query_user->execute(); + + // get result row (as an object) + $this->setUserLoggedIn($query_user->fetchObject()->user_id); + } + if ((!defined('PSM_INSTALL') || !PSM_INSTALL)) { // check the possible login actions: // 1. login via session data (happens each time user opens a page on your php project AFTER diff --git a/src/psm/Util/User/UserValidator.php b/src/psm/Util/User/UserValidator.php index 65f322e0..b7277ce8 100644 --- a/src/psm/Util/User/UserValidator.php +++ b/src/psm/Util/User/UserValidator.php @@ -39,7 +39,7 @@ class UserValidator * Available editable user levels * @var array $user_levels */ - protected $user_levels = array(PSM_USER_ADMIN, PSM_USER_USER); + protected $user_levels = array(PSM_USER_ADMIN, PSM_USER_USER, PSM_USER_ANONYMOUS); /** * User service From ae6367b2a003b08d45c89d2d53e112431d947390 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Fri, 13 Dec 2019 14:13:15 +0100 Subject: [PATCH 002/112] Changed page to status page --- public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public.php b/public.php index 35299784..28f21a7e 100644 --- a/public.php +++ b/public.php @@ -31,5 +31,5 @@ namespace { require __DIR__ . '/src/bootstrap.php'; - $router->run('server'); + $router->run('server_status'); } From 424fca1eb7ee04ce3489b70891fdf9b7af41547c Mon Sep 17 00:00:00 2001 From: imsoftware Date: Wed, 6 May 2020 18:24:20 +0200 Subject: [PATCH 003/112] change http to https (#900) --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5c453239..b6a29294 100644 --- a/README.rst +++ b/README.rst @@ -105,7 +105,7 @@ If you are familiar with Vagrant (https://www.vagrantup.com):: Documentation ------------- -The documentation is available in the docs folder or http://docs.phpservermonitor.org. +The documentation is available in the docs folder or https://docs.phpservermonitor.org. License @@ -122,7 +122,7 @@ 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/. +along with PHP Server Monitor. If not, see https://www.gnu.org/licenses/. Docker ------- From 7bee25cc1e11093526cebf83df6c248624cc4911 Mon Sep 17 00:00:00 2001 From: wienfuchs <44177781+wienfuchs@users.noreply.github.com> Date: Fri, 15 May 2020 16:55:57 +0200 Subject: [PATCH 004/112] Re-adding support PHP 5.5.9/7.0.x (#915) Resolves #908. --- README.rst | 2 +- docs/requirements.rst | 2 +- src/psm/Module/Install/Controller/InstallController.php | 4 ++-- src/psm/Module/User/UserEvents.php | 6 +++--- src/psm/Txtmsg/CMBulkSMS.php | 4 ++-- src/psm/Util/Module/Modal.php | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index b6a29294..fec739aa 100644 --- a/README.rst +++ b/README.rst @@ -77,7 +77,7 @@ Requirements * Web server * MySQL database -* For PHP5: 5.6.0+ +* For PHP5: 5.5.9+ * For PHP7: 7.0.8+ * PHP cURL package * PHP PDO mysql driver diff --git a/docs/requirements.rst b/docs/requirements.rst index 0a0f9838..636dde40 100644 --- a/docs/requirements.rst +++ b/docs/requirements.rst @@ -5,7 +5,7 @@ Requirements * Web server * MySQL database -* For PHP5: 5.6.0+ +* For PHP5: 5.5.9+ * For PHP7: 7.0.8+ * PHP cURL package * PHP PDO mysql driver diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index cd1e38e0..4dc7aa1d 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -75,11 +75,11 @@ class InstallController extends AbstractController $phpv = phpversion(); if ( - version_compare($phpv, '5.6.0', '<') || + version_compare($phpv, '5.5.9', '<') || (version_compare($phpv, '7.0.8', '<') && version_compare($phpv, '7.0.0', '>=')) ) { $errors++; - $this->addMessage('PHP 5.6.0+ or 7.0.8+ is required to run PHP Server Monitor. You\'re using ' . + $this->addMessage('PHP 5.5.9+ or 7.0.8+ is required to run PHP Server Monitor. You\'re using ' . $phpv . '.', 'error'); } else { $this->addMessage('PHP version: ' . $phpv, 'success'); diff --git a/src/psm/Module/User/UserEvents.php b/src/psm/Module/User/UserEvents.php index 33767928..de5ca932 100644 --- a/src/psm/Module/User/UserEvents.php +++ b/src/psm/Module/User/UserEvents.php @@ -35,15 +35,15 @@ final class UserEvents /** * @var string */ - public const USER_ADD = 'user.add'; + const USER_ADD = 'user.add'; /** * @var string */ - public const USER_EDIT = 'user.edit'; + const USER_EDIT = 'user.edit'; /** * @var string */ - public const USER_DELETE = 'user.delete'; + const USER_DELETE = 'user.delete'; } diff --git a/src/psm/Txtmsg/CMBulkSMS.php b/src/psm/Txtmsg/CMBulkSMS.php index a009d252..9a20c126 100644 --- a/src/psm/Txtmsg/CMBulkSMS.php +++ b/src/psm/Txtmsg/CMBulkSMS.php @@ -67,10 +67,10 @@ class CMBulkSMS extends Core protected $messageBody; /** @var string JSON Gateway API URL */ - public const GATEWAY_URL_JSON = "https://gw.cmtelecom.com/v1.0/message"; + const GATEWAY_URL_JSON = "https://gw.cmtelecom.com/v1.0/message"; /** @var string XML Gateway API URL */ - public const GATEWAY_URL_XML = "https://sgw01.cm.nl/gateway.ashx"; + const GATEWAY_URL_XML = "https://sgw01.cm.nl/gateway.ashx"; /** * Build the message and send cURL request to the sms gateway diff --git a/src/psm/Util/Module/Modal.php b/src/psm/Util/Module/Modal.php index 76d27ee6..fba72822 100644 --- a/src/psm/Util/Module/Modal.php +++ b/src/psm/Util/Module/Modal.php @@ -32,9 +32,9 @@ namespace psm\Util\Module; class Modal implements ModalInterface { - public const MODAL_TYPE_OK = 0; - public const MODAL_TYPE_OKCANCEL = 1; - public const MODAL_TYPE_DANGER = 2; + const MODAL_TYPE_OK = 0; + const MODAL_TYPE_OKCANCEL = 1; + const MODAL_TYPE_DANGER = 2; /** * prefix used for modal dialog box elements From 7daab77f8d898b3972ab0e70e505da7df591a19d Mon Sep 17 00:00:00 2001 From: Michael <33117529+mtelgkamp@users.noreply.github.com> Date: Fri, 15 May 2020 17:22:54 +0200 Subject: [PATCH 005/112] Adjust required php extensions (#904) af5334a0 introduced the following requirements: - ext-hash - ext-json - ext-libxml - ext-openssl - ext-pcre - ext-sockets Maybe also the functionality that needs the extension could be mentioned, so someone that does not need jabber, could install with `--ignore-platform-reqs` when not having these extensions available. --- README.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index fec739aa..11837483 100644 --- a/README.rst +++ b/README.rst @@ -79,10 +79,19 @@ Requirements * MySQL database * For PHP5: 5.5.9+ * For PHP7: 7.0.8+ -* PHP cURL package -* PHP PDO mysql driver -* PHP-XML +* PHP Extensions (modules) + * ext-curl + * ext-ctype + * ext-filter + * ext-hash + * ext-json + * ext-libxml + * ext-openssl + * ext-pdo + * ext-pcre + * ext-sockets + * ext-xml Install ------- From c0e0b260d5a67cd41615810190c2786b57991583 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Sun, 17 May 2020 21:03:42 +0200 Subject: [PATCH 006/112] Indent to space --- src/includes/functions.inc.php | 2 +- .../Config/Controller/ConfigController.php | 76 ++++++------- .../Install/Controller/InstallController.php | 2 +- .../Server/Controller/LogController.php | 8 +- .../Server/Controller/ServerController.php | 10 +- .../User/Controller/ProfileController.php | 4 +- src/psm/Util/Server/UpdateManager.php | 18 ++-- .../Util/Server/Updater/StatusNotifier.php | 102 +++++++++--------- src/psm/Util/Server/Updater/StatusUpdater.php | 12 +-- 9 files changed, 117 insertions(+), 117 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 8fb1c449..c1754cdd 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -689,7 +689,7 @@ namespace { $client->add_cb('on_auth_success', function () use ($client, $receivers, $message) { JAXLLogger::info('got on_auth_success cb'); foreach ($receivers as $receiver) { - $client->send_chat_msg($receiver, $message); + $client->send_chat_msg($receiver, $message); } $client->send_end_stream(); }); diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index 4c6a7e5d..01216e2a 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -74,10 +74,10 @@ class ConfigController extends AbstractController 'sms_from', 'pushover_api_token', 'telegram_api_token', - 'jabber_host', - 'jabber_port', - 'jabber_username', - 'jabber_domain' + 'jabber_host', + 'jabber_port', + 'jabber_username', + 'jabber_domain' ); /** @@ -86,7 +86,7 @@ class ConfigController extends AbstractController */ protected $encryptedFields = [ 'email_smtp_password', - 'jabber_password' + 'jabber_password' ]; private $default_tab = 'general'; @@ -221,7 +221,7 @@ class ConfigController extends AbstractController protected function executeSave() { if (!empty($_POST)) { - // save new config + // save new config $clean = array( 'language' => $_POST['language'], 'sms_gateway' => $_POST['sms_gateway'], @@ -234,7 +234,7 @@ class ConfigController extends AbstractController 'log_retention_period' => intval(psm_POST('log_retention_period', 365)), 'password_encrypt_key' => psm_POST('password_encrypt_key', sha1(microtime())) ); - foreach ($this->checkboxes as $input_key) { + foreach ($this->checkboxes as $input_key) { $clean[$input_key] = (isset($_POST[$input_key])) ? '1' : '0'; } foreach ($this->fields as $input_key) { @@ -264,7 +264,7 @@ class ConfigController extends AbstractController } elseif (!empty($_POST['test_telegram'])) { $this->testTelegram(); } elseif (!empty($_POST['test_jabber'])) { - $this->testJabber(); + $this->testJabber(); } if ($language_refresh) { @@ -283,7 +283,7 @@ class ConfigController extends AbstractController } elseif (isset($_POST['telegram_submit']) || !empty($_POST['test_telegram'])) { $this->default_tab = 'telegram'; } elseif (isset($_POST['jabber_submit']) || !empty($_POST['test_jabber'])) { - $this->default_tab = 'jabber'; + $this->default_tab = 'jabber'; } } return $this->runAction('index'); @@ -408,24 +408,24 @@ class ConfigController extends AbstractController } } - /** - * Test Jabber. - */ + /** + * Test Jabber. + */ protected function testJabber() { - $user = $this->getUser()->getUser(); - psm_jabber_send_message( - psm_get_conf('jabber_host'), - psm_get_conf('jabber_username'), - psm_password_decrypt(psm_get_conf('password_encrypt_key'), psm_get_conf('jabber_password')), - [$user->jabber], - psm_get_lang('config', 'test_message'), - (trim(psm_get_conf('jabber_port')) !== '' ? (int)psm_get_conf('jabber_port') : null), - (trim(psm_get_conf('jabber_domain')) !== '' ? psm_get_conf('jabber_domain') : null) - ); - // no message - async ... so just info - $this->addMessage(psm_get_lang('config', 'jabber_check'), 'info'); - // @todo possible to set message via ajax with callback ... + $user = $this->getUser()->getUser(); + psm_jabber_send_message( + psm_get_conf('jabber_host'), + psm_get_conf('jabber_username'), + psm_password_decrypt(psm_get_conf('password_encrypt_key'), psm_get_conf('jabber_password')), + [$user->jabber], + psm_get_lang('config', 'test_message'), + (trim(psm_get_conf('jabber_port')) !== '' ? (int)psm_get_conf('jabber_port') : null), + (trim(psm_get_conf('jabber_domain')) !== '' ? psm_get_conf('jabber_domain') : null) + ); + // no message - async ... so just info + $this->addMessage(psm_get_lang('config', 'jabber_check'), 'info'); + // @todo possible to set message via ajax with callback ... } protected function getLabels() @@ -435,12 +435,12 @@ class ConfigController extends AbstractController '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_tab_jabber' => psm_get_lang('config', 'tab_jabber'), + '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_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'), + 'label_settings_jabber' => psm_get_lang('config', 'settings_jabber'), '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'), @@ -482,17 +482,17 @@ class ConfigController extends AbstractController '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_jabber_status' => psm_get_lang('config', 'jabber_status'), - 'label_jabber_description' => psm_get_lang('config', 'jabber_description'), + 'label_jabber_description' => psm_get_lang('config', 'jabber_description'), 'label_jabber_host' => psm_get_lang('config', 'jabber_host'), - 'label_jabber_host_description' => psm_get_lang('config', 'jabber_host_description'), - 'label_jabber_port' => psm_get_lang('config', 'jabber_port'), - 'label_jabber_port_description' => psm_get_lang('config', 'jabber_port_description'), - 'label_jabber_username' => psm_get_lang('config', 'jabber_username'), - 'label_jabber_username_description' => psm_get_lang('config', 'jabber_username_description'), - 'label_jabber_domain' => psm_get_lang('config', 'jabber_domain'), - 'label_jabber_domain_description' => psm_get_lang('config', 'jabber_domain_description'), - 'label_jabber_password' => psm_get_lang('config', 'jabber_password'), - 'label_jabber_password_description' => psm_get_lang('config', 'jabber_password_description'), + 'label_jabber_host_description' => psm_get_lang('config', 'jabber_host_description'), + 'label_jabber_port' => psm_get_lang('config', 'jabber_port'), + 'label_jabber_port_description' => psm_get_lang('config', 'jabber_port_description'), + 'label_jabber_username' => psm_get_lang('config', 'jabber_username'), + 'label_jabber_username_description' => psm_get_lang('config', 'jabber_username_description'), + 'label_jabber_domain' => psm_get_lang('config', 'jabber_domain'), + 'label_jabber_domain_description' => psm_get_lang('config', 'jabber_domain_description'), + 'label_jabber_password' => psm_get_lang('config', 'jabber_password'), + 'label_jabber_password_description' => psm_get_lang('config', 'jabber_password_description'), 'label_alert_type' => psm_get_lang('config', 'alert_type'), 'label_alert_type_description' => psm_get_lang('config', 'alert_type_description'), 'label_combine_notifications' => psm_get_lang('config', 'combine_notifications'), @@ -503,7 +503,7 @@ class ConfigController extends AbstractController '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_log_jabber' => psm_get_lang('config', 'log_jabber'), + 'label_log_jabber' => psm_get_lang('config', 'log_jabber'), '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'), diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index 4dc7aa1d..8acb471f 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -257,7 +257,7 @@ class InstallController extends AbstractController 'pushover_key' => '', 'pushover_device' => '', 'telegram_id' => '', - 'jabber' => '' + 'jabber' => '' ); $validator = $this->container->get('util.user.validator'); diff --git a/src/psm/Module/Server/Controller/LogController.php b/src/psm/Module/Server/Controller/LogController.php index 72685baf..8046af99 100644 --- a/src/psm/Module/Server/Controller/LogController.php +++ b/src/psm/Module/Server/Controller/LogController.php @@ -57,7 +57,7 @@ class LogController extends AbstractServerController 'label_sms' => psm_get_lang('log', 'sms'), 'label_pushover' => psm_get_lang('log', 'pushover'), 'label_telegram' => psm_get_lang('log', 'telegram'), - 'label_jabber' => psm_get_lang('log', 'jabber'), + 'label_jabber' => psm_get_lang('log', 'jabber'), 'label_title' => psm_get_lang('log', 'title'), 'label_server' => psm_get_lang('servers', 'server'), 'label_type' => psm_get_lang('log', 'type'), @@ -161,9 +161,9 @@ class LogController extends AbstractServerController if ($this->getUser()->getUserLevel() > PSM_USER_ADMIN) { // restrict by user_id $sql_join = "JOIN `" . PSM_DB_PREFIX . "users_servers` AS `us` ON ( - `us`.`user_id`={$this->getUser()->getUserId()} - AND `us`.`server_id`=`servers`.`server_id` - )"; + `us`.`user_id`={$this->getUser()->getUserId()} + AND `us`.`server_id`=`servers`.`server_id` + )"; } $entries = $this->db->query( 'SELECT ' . diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index 16f0860d..1c2cb299 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -102,7 +102,7 @@ class ServerController extends AbstractServerController 'sms' => 'icon-mobile', 'pushover' => 'icon-pushover', 'telegram' => 'icon-telegram', - 'jabber' => 'icon-jabber' + 'jabber' => 'icon-jabber' ); $servers = $this->getServers(); @@ -236,7 +236,7 @@ class ServerController extends AbstractServerController 'edit_sms_selected' => $edit_server['sms'], 'edit_pushover_selected' => $edit_server['pushover'], 'edit_telegram_selected' => $edit_server['telegram'], - 'edit_jabber_selected' => $edit_server['jabber'], + 'edit_jabber_selected' => $edit_server['jabber'], )); } @@ -310,7 +310,7 @@ class ServerController extends AbstractServerController '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', - 'jabber' => in_array($_POST['jabber'], array('yes', 'no')) ? $_POST['jabber'] : 'no', + 'jabber' => in_array($_POST['jabber'], array('yes', 'no')) ? $_POST['jabber'] : 'no', ); // make sure websites start with http:// if ( @@ -579,10 +579,10 @@ class ServerController extends AbstractServerController 'label_send_sms' => psm_get_lang('servers', 'send_sms'), 'label_send_pushover' => psm_get_lang('servers', 'send_pushover'), 'label_telegram' => psm_get_lang('servers', 'telegram'), - 'label_jabber' => psm_get_lang('servers', 'jabber'), + 'label_jabber' => psm_get_lang('servers', 'jabber'), 'label_pushover' => psm_get_lang('servers', 'pushover'), 'label_send_telegram' => psm_get_lang('servers', 'send_telegram'), - 'label_send_jabber' => psm_get_lang('servers', 'send_jabber'), + 'label_send_jabber' => psm_get_lang('servers', 'send_jabber'), '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 09f88691..47efc335 100644 --- a/src/psm/Module/User/Controller/ProfileController.php +++ b/src/psm/Module/User/Controller/ProfileController.php @@ -90,8 +90,8 @@ class ProfileController extends AbstractController 'label_activate_telegram' => psm_get_lang('users', 'activate_telegram'), 'label_telegram_get_chat_id' => psm_get_lang('users', 'telegram_get_chat_id'), 'telegram_get_chat_id_url' => PSM_TELEGRAM_GET_ID_URL, - 'label_jabber' => psm_get_lang('users', 'jabber'), - 'label_jabber_description' => psm_get_lang('users', 'jabber_description'), + 'label_jabber' => psm_get_lang('users', 'jabber'), + 'label_jabber_description' => psm_get_lang('users', 'jabber_description'), 'label_email' => psm_get_lang('users', 'email'), 'label_save' => psm_get_lang('system', 'save'), 'form_action' => psm_build_url(array( diff --git a/src/psm/Util/Server/UpdateManager.php b/src/psm/Util/Server/UpdateManager.php index 2e3ee42c..e5429df6 100644 --- a/src/psm/Util/Server/UpdateManager.php +++ b/src/psm/Util/Server/UpdateManager.php @@ -53,9 +53,9 @@ class UpdateManager implements ContainerAwareInterface */ public function run($skip_perms = false, $status = null) { - if (false === in_array($status, ['on', 'off'], true)) { - $status = null; - } + if (false === in_array($status, ['on', 'off'], true)) { + $status = null; + } // check if we need to restrict the servers to a certain user $sql_join = ''; @@ -63,17 +63,17 @@ class UpdateManager implements ContainerAwareInterface if (!$skip_perms && $this->container->get('user')->getUserLevel() > PSM_USER_ADMIN) { // restrict by user_id $sql_join = "JOIN `" . PSM_DB_PREFIX . "users_servers` AS `us` ON ( - `us`.`user_id`={$this->container->get('user')->getUserId()} - AND `us`.`server_id`=`s`.`server_id` - )"; + `us`.`user_id`={$this->container->get('user')->getUserId()} + AND `us`.`server_id`=`s`.`server_id` + )"; } $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`.`jabber` - FROM `" . PSM_DB_PREFIX . "servers` AS `s` - {$sql_join} - WHERE `active`='yes' " . ($status !== null ? ' AND `status` = \'' . $status . '\'' : ''); + FROM `" . PSM_DB_PREFIX . "servers` AS `s` + {$sql_join} + WHERE `active`='yes' " . ($status !== null ? ' AND `status` = \'' . $status . '\'' : ''); $servers = $this->container->get('db')->query($sql); diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index 5b0672a6..d1db8ae7 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -69,10 +69,10 @@ class StatusNotifier */ protected $send_telegram = false; - /** - * Send Jabber? - * @var bool - */ + /** + * Send Jabber? + * @var bool + */ protected $send_jabber = false; /** @@ -258,7 +258,7 @@ class StatusNotifier } if ($this->send_jabber && $this->server['jaber'] == 'yes') { - $this->combine ? $this->setCombi('jabber') : $this->notifyByJabber($users); + $this->combine ? $this->setCombi('jabber') : $this->notifyByJabber($users); } return $notify; @@ -562,52 +562,52 @@ class StatusNotifier } } - /** - * @param array $users - * @param array $combi - */ + /** + * @param array $users + * @param array $combi + */ protected function notifyByJabber($users, $combi = []) { - // Remove users that have no jabber - foreach ($users as $k => $user) { - if (trim($user['jabber']) === '') { - unset($users[$k]); - } - } + // Remove users that have no jabber + foreach ($users as $k => $user) { + if (trim($user['jabber']) === '') { + unset($users[$k]); + } + } - // Validation - if (empty($users)) { - return; - } + // Validation + if (empty($users)) { + return; + } - // Message - $message = key_exists('message', $combi) ? - $combi['message'] : - psm_parse_msg($this->status_new, 'jabber_message', $this->server); + // Message + $message = key_exists('message', $combi) ? + $combi['message'] : + psm_parse_msg($this->status_new, 'jabber_message', $this->server); - // Log - if (psm_get_conf('log_jabber')) { - $log_id = psm_add_log($this->server_id, 'jabber', $message); - } + // Log + if (psm_get_conf('log_jabber')) { + $log_id = psm_add_log($this->server_id, 'jabber', $message); + } - $usersJabber = []; - foreach ($users as $user) { - // Log - if (!empty($log_id)) { - psm_add_log_user($log_id, $user['user_id']); - } - $usersJabber[] = $user['jabber']; - } - // Jabber - psm_jabber_send_message( - psm_get_conf('jabber_host'), - psm_get_conf('jabber_username'), - psm_password_decrypt(psm_get_conf('password_encrypt_key'), psm_get_conf('jabber_password')), - $usersJabber, - $message, - (trim(psm_get_conf('jabber_port')) !== '' ? (int)psm_get_conf('jabber_port') : null), - (trim(psm_get_conf('jabber_domain')) !== '' ? psm_get_conf('jabber_domain') : null) - ); + $usersJabber = []; + foreach ($users as $user) { + // Log + if (!empty($log_id)) { + psm_add_log_user($log_id, $user['user_id']); + } + $usersJabber[] = $user['jabber']; + } + // Jabber + psm_jabber_send_message( + psm_get_conf('jabber_host'), + psm_get_conf('jabber_username'), + psm_password_decrypt(psm_get_conf('password_encrypt_key'), psm_get_conf('jabber_password')), + $usersJabber, + $message, + (trim(psm_get_conf('jabber_port')) !== '' ? (int)psm_get_conf('jabber_port') : null), + (trim(psm_get_conf('jabber_domain')) !== '' ? psm_get_conf('jabber_domain') : null) + ); } /** @@ -622,12 +622,12 @@ class StatusNotifier SELECT `u`.`user_id`, `u`.`name`,`u`.`email`, `u`.`mobile`, `u`.`pushover_key`, `u`.`pushover_device`, `u`.`telegram_id`, `u`.`jabber` - FROM `' . PSM_DB_PREFIX . 'users` AS `u` - JOIN `' . PSM_DB_PREFIX . "users_servers` AS `us` ON ( - `us`.`user_id`=`u`.`user_id` - AND `us`.`server_id` = {$server_id} - ) - "); + FROM `' . PSM_DB_PREFIX . 'users` AS `u` + JOIN `' . PSM_DB_PREFIX . "users_servers` AS `us` ON ( + `us`.`user_id`=`u`.`user_id` + AND `us`.`server_id` = {$server_id} + ) + "); return $users; } } diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 6d6ff34b..af3a8cdd 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -182,9 +182,9 @@ class StatusUpdater // Execute ping $pingCommand = 'ping6'; $serverIp = $this->server['ip']; - if (filter_var($serverIp,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false){ + if (filter_var($serverIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { $pingCommand = 'ping'; - } + } $txt = exec($pingCommand . " -c " . $max_runs . " " . $serverIp . " 2>&1", $output); // Non-greedy match on filler $re1 = '.*?'; @@ -197,9 +197,9 @@ class StatusUpdater if (preg_match_all("/" . $re1 . $re2 . $re3 . $re4 . "/is", $txt, $matches)) { $result = $matches[1][0]; } - if (substr($output[0],0,4) == 'PING' && strpos($output[count($output)-2],'packets transmitted')){ - $result = 0; - } + if (substr($output[0], 0, 4) == 'PING' && strpos($output[count($output) - 2], 'packets transmitted')) { + $result = 0; + } if (!is_null($result)) { $this->header = $output[0]; $status = true; @@ -233,7 +233,7 @@ class StatusUpdater $starttime = microtime(true); $serverIp = $this->server['ip']; - if (filter_var($serverIp,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false){ + if (filter_var($serverIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { $serverIp = "[$serverIp]"; } $fp = @fsockopen($serverIp, $this->server['port'], $errno, $this->error, $timeout); From 586c01136e61944de780501a04e30cad81d5d22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C5=82ek?= Date: Mon, 18 May 2020 00:28:15 +0200 Subject: [PATCH 007/112] SMSAPI gateway --- docs/credits.rst | 4 + src/includes/functions.inc.php | 3 + src/psm/Txtmsg/SMSAPI.php | 150 +++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100755 src/psm/Txtmsg/SMSAPI.php diff --git a/docs/credits.rst b/docs/credits.rst index 6786fb1d..75a1aadc 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -85,6 +85,10 @@ The following people have contributed to the development of PHP Server Monitor: * Nexmo SMS gateway +* Mateusz Małek - https://github.com/mateuszmalek + + * SMSAPI gateway + Translators +++++++++++ diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 8fb1c449..a4398029 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -779,6 +779,9 @@ namespace { case 'solutionsinfini': $sms = new \psm\Txtmsg\SolutionsInfini(); break; + case 'smsapi': + $sms = new \psm\Txtmsg\SMSAPI(); + break; } // copy login information from the config file diff --git a/src/psm/Txtmsg/SMSAPI.php b/src/psm/Txtmsg/SMSAPI.php new file mode 100755 index 00000000..e446c169 --- /dev/null +++ b/src/psm/Txtmsg/SMSAPI.php @@ -0,0 +1,150 @@ +. + * + * @package phpservermon + * @author Mateusz Małek + * @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 3.5 + **/ + +namespace psm\Txtmsg; + +class SMSAPI extends Core +{ + const VARIANT_INTERNATIONAL = 1; + const VARIANT_POLISH = 2; + + /** + * SMSAPI comes with two variants - designed for polish or international customers. + * + * @var int + */ + private $variant = self::VARIANT_INTERNATIONAL; + + /** + * Name of the sender. As a default the sender name is set to "Test". + * Only verified names are being accepted. + * Sender name may be set after logging into Customer Portal on Sendernames. + * @see https://www.smsapi.com/docs/#2-single-sms + * + * @var string + */ + protected $originator; + + /** + * Token used to authenticate in SMSAPI system. + * @see https://www.smsapi.com/docs/#authentication + * + * @var string + */ + protected $password; + + /** + * Send sms using the SMSAPI + * + * @var string $message + * @var array $this->recipients + * @var array $this->originator + * @var string $this->password + * @var array $recipients_chunk + * @var string $host + * + * @var mixed $result + * @var array $headers + * + * @var int $success + * @var string $error + * + * @return bool|string + */ + + public function sendSMS($message) + { + $tld = ($this->variant === static::VARIANT_INTERNATIONAL) ? "com" : "pl"; + $host = "api.smsapi.{$tld}"; + $backupHost = "api2.smsapi.{$tld}"; + + // One user at a time. + $recipients_chunk = array_chunk($this->recipients, 1); + foreach ($recipients_chunk as $recipient) + { + try { + $response = $this->processSendOperation($host, $recipient, $message); + } catch (\RuntimeException $e) { + try { + $response = $this->processSendOperation($backupHost, $recipient, $message); + } catch (\RuntimeException $e) { + return "({$recipient}) " . $e->getMessage(); + } + } + + if (isset($response->error)) { + return $response->message; + } + + return 1; + } + } + + /** + * Perform actual SMS sending operation + * + * @param $host + * @param $recipient + * @param $message + * @return object + * @throws RuntimeException + */ + private function processSendOperation($host, $recipient, $message) + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://{$host}/sms.do"); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array( + "access_token" => $this->password, + "from" => $this->originator, + "to" => $recipient, + "message" => $message, + "encoding" => "utf-8", + "normalize" => "1", + "format" => "json" + ))); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + + $result = curl_exec($ch); + + $error = false; + if (curl_errno($ch)) { + $error = curl_error($ch); + } + + curl_close($ch); + + if ($error !== false) { + throw new \RuntimeException($error); + } + + return json_decode($result); + } +} From 72de1479fa92c72f6502a16b5a0a37e76a05697a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C5=82ek?= Date: Mon, 18 May 2020 09:10:16 +0200 Subject: [PATCH 008/112] Add SMSAPI to list of supported SMS gateways --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 11837483..52c184f7 100644 --- a/README.rst +++ b/README.rst @@ -60,6 +60,7 @@ The following SMS gateways are currently available: * SolutionsInfini - * Plivo - * Callr - +* SMSAPI - From 875b0208b59c01f2bde27fdbfd0d2d309668f14c Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Mon, 18 May 2020 19:41:08 +0200 Subject: [PATCH 009/112] Indentation --- src/psm/Txtmsg/SMSAPI.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/psm/Txtmsg/SMSAPI.php b/src/psm/Txtmsg/SMSAPI.php index e446c169..83601e05 100755 --- a/src/psm/Txtmsg/SMSAPI.php +++ b/src/psm/Txtmsg/SMSAPI.php @@ -86,8 +86,7 @@ class SMSAPI extends Core // One user at a time. $recipients_chunk = array_chunk($this->recipients, 1); - foreach ($recipients_chunk as $recipient) - { + foreach ($recipients_chunk as $recipient) { try { $response = $this->processSendOperation($host, $recipient, $message); } catch (\RuntimeException $e) { From 489465389113d1e829adf968527045432ee5a035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C5=82ek?= Date: Mon, 18 May 2020 19:42:24 +0200 Subject: [PATCH 010/112] Show recent status logs on server details page (#921) --- .../Server/Controller/ServerController.php | 51 +++++++++++++++++++ .../module/server/server/view.tpl.html | 29 +++++++++++ 2 files changed, 80 insertions(+) diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index 1c2cb299..28c03f8d 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -518,6 +518,15 @@ class ServerController extends AbstractServerController if (strlen($tpl_data['last_error_output']) > 255) { $tpl_data['last_error_output_truncated'] = substr($tpl_data['last_error_output'], 0, 255) . '...'; } + + // fetch server status logs + $log_entries = $this->getServerLogs($this->server_id); + for ($x = 0; $x < count($log_entries); $x++) { + $record = &$log_entries[$x]; + $record['datetime_format'] = psm_date($record['datetime']); + } + + $tpl_data['log_entries'] = $log_entries; return $this->twig->render('module/server/server/view.tpl.html', $tpl_data); } @@ -606,6 +615,10 @@ class ServerController extends AbstractServerController 'label_settings' => psm_get_lang('system', 'settings'), 'label_output' => psm_get_lang('servers', 'output'), 'label_search' => psm_get_lang('system', 'search'), + 'label_log_title' => psm_get_lang('log', 'title'), + 'label_log_no_logs' => psm_get_lang('log', 'no_logs'), + 'label_date' => psm_get_lang('system', 'date'), + 'label_message' => psm_get_lang('system', 'message'), ); } @@ -627,4 +640,42 @@ class ServerController extends AbstractServerController } return $result; } + + /** + * Get logs for a server + * @param int $server_id + * @param string $type status/email/sms + * @return \PDOStatement array + */ + protected function getServerLogs($server_id, $type = 'status') + { + $sql_join = ''; + if ($this->getUser()->getUserLevel() > PSM_USER_ADMIN) { + // restrict by user_id + $sql_join = "JOIN `" . PSM_DB_PREFIX . "users_servers` AS `us` ON ( + `us`.`user_id`={$this->getUser()->getUserId()} + AND `us`.`server_id`=`servers`.`server_id` + )"; + } + $entries = $this->db->query( + 'SELECT ' . + '`servers`.`label`, ' . + '`servers`.`ip`, ' . + '`servers`.`port`, ' . + '`servers`.`type` AS server_type, ' . + '`log`.`log_id`, ' . + '`log`.`type`, ' . + '`log`.`message`, ' . + '`log`.`datetime` ' . + 'FROM `' . PSM_DB_PREFIX . 'log` AS `log` ' . + 'JOIN `' . PSM_DB_PREFIX . 'servers` AS `servers` ON (`servers`.`server_id`=`log`.`server_id`) ' . + $sql_join . + 'WHERE `log`.`type`=\'' . $type . '\' ' . + 'AND `log`.`server_id`=' . $server_id . ' ' . + 'ORDER BY `datetime` DESC ' . + 'LIMIT 0,20' + ); + + return $entries; + } } diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index 20218480..7b22a0f0 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -354,6 +354,35 @@
{{ html_history|raw }}
+ {% if log_entries %} +
+
+
+ {{ label_log_title }} +
+
+
+ + + + + + + + + {% for entry in log_entries %} + + + + + {% endfor %} + +
{{ label_date }}{{ label_message }}
{{ entry.message|raw }}
+
+
+
+
+ {% endif %} {% if graph.id == 'history_short' %} diff --git a/src/templates/default/module/server/server/list.tpl.html b/src/templates/default/module/server/server/list.tpl.html index 110c1261..8fd94464 100644 --- a/src/templates/default/module/server/server/list.tpl.html +++ b/src/templates/default/module/server/server/list.tpl.html @@ -9,7 +9,7 @@ {{ label_domain }} {{ label_port }} {{ label_type }} - {{ label_rtime }} + {{ label_rtime }} (ms) {{ label_last_online }} {{ label_last_offline }} {{ label_monitoring }} @@ -41,7 +41,7 @@
{{ server.ip|raw }}
{{ server.port }} {{ server.type }} - {{ server.rtime }} + {{ (server.rtime * 1000)|round(2) }}
{{ server.last_online }}
{{ server.last_offline }}
diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index 7b22a0f0..f418b4ee 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -51,7 +51,7 @@
  • {{ label_rtime }}:
    -
    {{ rtime }} {{ label_seconds }}
    +
    {{ (rtime * 1000)|round(2) }} {{ label_milliseconds }}
  • diff --git a/src/templates/default/module/server/status/index.tpl.html b/src/templates/default/module/server/status/index.tpl.html index 7a564127..77a98877 100644 --- a/src/templates/default/module/server/status/index.tpl.html +++ b/src/templates/default/module/server/status/index.tpl.html @@ -37,7 +37,7 @@

    {{ label_last_online }}: {{ server.last_online_nice }}
    {{ label_last_offline }}: {{ server.last_offline_nice }} {{ server.last_offline_duration_nice }}
    - {{ label_rtime }}: {{ server.rtime }} + {{ label_rtime }}: {{ (server.rtime * 1000)|round(2) }} ms

    @@ -97,7 +97,7 @@ {{ server.label }} ({{ label_online }}) {{ server.last_online_nice }} {{ server.last_offline_nice }} {{ server.last_offline_duration_nice }} - {{ server.rtime }}s + {{ (server.rtime * 1000)|round(2) }} ms {% endfor %} From 7856de4bbbb22cb4bec416489c7e4f443e61f049 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 18 May 2020 20:43:13 +0200 Subject: [PATCH 015/112] Better fit for bigger screens (#875) Fixes #857. --- src/templates/default/main/body.tpl.html | 24 ++++++++++--------- .../module/server/server/view.tpl.html | 2 +- .../module/server/status/index.tpl.html | 8 +++---- .../default/static/css/style.min.css | 2 +- .../default/static/css/style.min.css.map | 2 +- src/templates/default/static/scss/style.scss | 4 ++++ 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/templates/default/main/body.tpl.html b/src/templates/default/main/body.tpl.html index 7a1c3523..86d01332 100644 --- a/src/templates/default/main/body.tpl.html +++ b/src/templates/default/main/body.tpl.html @@ -31,31 +31,33 @@ {{ html_modal|raw }} -
    +
    {% if not user_level and subtitle %}

    {{ subtitle }}

    {% endif %} -
    {{ header_accessories|raw }}
    +
    {{ header_accessories|raw }}
    {% for msg in messages %} {% endfor %} -
    +
    {{ html_sidebar|raw }}
    {{ html_content|raw }}
    diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index f418b4ee..be5906f4 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -1,6 +1,6 @@ {% import 'main/macros.tpl.html' as macro %} {{ macro.input_csrf() }} -
    +
    diff --git a/src/templates/default/module/server/status/index.tpl.html b/src/templates/default/module/server/status/index.tpl.html index 77a98877..6102ef64 100644 --- a/src/templates/default/module/server/status/index.tpl.html +++ b/src/templates/default/module/server/status/index.tpl.html @@ -1,10 +1,10 @@ {% import 'main/macros.tpl.html' as macro %} {{ macro.input_csrf() }} -
    +
    {% for server in servers_offline %} -
    +
    @@ -17,7 +17,7 @@
    {% endfor %} {% for server in servers_warning %} -
    +
    @@ -30,7 +30,7 @@
    {% endfor %} {% for server in servers_online %} -
    +
    diff --git a/src/templates/default/static/css/style.min.css b/src/templates/default/static/css/style.min.css index 5bc79370..a0236f19 100644 --- a/src/templates/default/static/css/style.min.css +++ b/src/templates/default/static/css/style.min.css @@ -1,2 +1,2 @@ -html{position:relative;min-height:100%}html[dir='rtl'] #auto_refresh_description,html[dir='rtl'] #log_retention_period_help{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}html[dir='ltr'] #auto_refresh_description,html[dir='ltr'] #log_retention_period_help{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}body{padding-top:4.5rem;margin-bottom:80px}.footer{position:absolute;bottom:0;width:100%;height:60px;line-height:60px;background-color:#f5f5f5}.navbar-dark .navbar-nav .nav-link{color:rgba(255,255,255,0.64)}.navbar-dark .navbar-nav .nav-link:focus,.navbar-dark .navbar-nav .nav-link:hover{color:rgba(255,255,255,0.85)}dl,dt,dd{margin-bottom:0}footer .text-muted{color:#4C5557 !important}a,button,.nav-link{min-height:44px !important;min-width:44px !important}a.icon{text-decoration:none;cursor:pointer;padding-left:10px}form.form-signin input[type="text"],form.form-reset input[type="text"]{border-bottom-left-radius:0;border-bottom-right-radius:0}form.form-signin input[type="password"]{border-top-left-radius:0;border-top-right-radius:0}form.form-reset input#input-password{border-radius:0}form.form-reset input#input-password-repeat{border-top-left-radius:0;border-top-right-radius:0}form.form-signin,form.form-forgot,form.form-reset{margin:auto}table{table-layout:fixed}th,td{max-width:1px}.content{word-wrap:break-word;overflow-wrap:break-word}table tr[visible='false'],.no-result{display:none}table tr[visible='true']{display:table-row}.bootstrap-select>.dropdown-toggle.bs-placeholder,.bootstrap-select>.dropdown-toggle.bs-placeholder:active,.bootstrap-select>.dropdown-toggle.bs-placeholder:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder:hover{color:unset}#meter{border-radius:200px 200px 0 0;height:100px;margin:50px auto 0;overflow:hidden;position:relative;width:200px}#meter:before{background:#fbfbfb;border-radius:200px 200px 0 0;-webkit-box-shadow:3px 1px 8px rgba(0,0,0,0.15) inset;box-shadow:3px 1px 8px rgba(0,0,0,0.15) inset;content:"";height:100px;position:absolute;width:200px}#meter:after{background:#fff;border-radius:140px 140px 0 0;bottom:0;-webkit-box-shadow:3px 1px 8px rgba(0,0,0,0.15);box-shadow:3px 1px 8px rgba(0,0,0,0.15);content:"\a" attr(data-value) "%\a" attr(translation);font-size:1.5em;font-weight:100;height:80px;left:20px;line-height:25px;position:absolute;text-align:center;width:160px;z-index:3;white-space:pre}#needle{background:rgba(52,52,64,0.7);border-radius:4px;bottom:-4px;-webkit-box-shadow:3px -1px 4px rgba(0,0,0,0.4);box-shadow:3px -1px 4px rgba(0,0,0,0.4);display:block;height:8px;left:5px;position:absolute;width:95px;-webkit-transform-origin:100% 4px;transform-origin:100% 4px;-webkit-transition:all 1s;transition:all 1s;border-radius:4px;bottom:-4px;box-shadow:3px -1px 4px rgba(0,0,0,0.4);display:block;height:8px;left:5px;position:absolute;width:95px;transform-origin:100% 4px;transition:all 1s}.dropdown-menu.show{left:inherit;right:0px} +html{position:relative;min-height:100%}html[dir='rtl'] #auto_refresh_description,html[dir='rtl'] #log_retention_period_help{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}html[dir='ltr'] #auto_refresh_description,html[dir='ltr'] #log_retention_period_help{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}body{padding-top:4.5rem;margin-bottom:80px}.container-fluid{max-width:1920px}.footer{position:absolute;bottom:0;width:100%;height:60px;line-height:60px;background-color:#f5f5f5}.navbar-dark .navbar-nav .nav-link{color:rgba(255,255,255,0.64)}.navbar-dark .navbar-nav .nav-link:focus,.navbar-dark .navbar-nav .nav-link:hover{color:rgba(255,255,255,0.85)}dl,dt,dd{margin-bottom:0}footer .text-muted{color:#4C5557 !important}a,button,.nav-link{min-height:44px !important;min-width:44px !important}a.icon{text-decoration:none;cursor:pointer;padding-left:10px}form.form-signin input[type="text"],form.form-reset input[type="text"]{border-bottom-left-radius:0;border-bottom-right-radius:0}form.form-signin input[type="password"]{border-top-left-radius:0;border-top-right-radius:0}form.form-reset input#input-password{border-radius:0}form.form-reset input#input-password-repeat{border-top-left-radius:0;border-top-right-radius:0}form.form-signin,form.form-forgot,form.form-reset{margin:auto}table{table-layout:fixed}th,td{max-width:1px}.content{word-wrap:break-word;overflow-wrap:break-word}table tr[visible='false'],.no-result{display:none}table tr[visible='true']{display:table-row}.bootstrap-select>.dropdown-toggle.bs-placeholder,.bootstrap-select>.dropdown-toggle.bs-placeholder:active,.bootstrap-select>.dropdown-toggle.bs-placeholder:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder:hover{color:unset}#meter{border-radius:200px 200px 0 0;height:100px;margin:50px auto 0;overflow:hidden;position:relative;width:200px}#meter:before{background:#fbfbfb;border-radius:200px 200px 0 0;-webkit-box-shadow:3px 1px 8px rgba(0,0,0,0.15) inset;box-shadow:3px 1px 8px rgba(0,0,0,0.15) inset;content:"";height:100px;position:absolute;width:200px}#meter:after{background:#fff;border-radius:140px 140px 0 0;bottom:0;-webkit-box-shadow:3px 1px 8px rgba(0,0,0,0.15);box-shadow:3px 1px 8px rgba(0,0,0,0.15);content:"\a" attr(data-value) "%\a" attr(translation);font-size:1.5em;font-weight:100;height:80px;left:20px;line-height:25px;position:absolute;text-align:center;width:160px;z-index:3;white-space:pre}#needle{background:rgba(52,52,64,0.7);border-radius:4px;bottom:-4px;-webkit-box-shadow:3px -1px 4px rgba(0,0,0,0.4);box-shadow:3px -1px 4px rgba(0,0,0,0.4);display:block;height:8px;left:5px;position:absolute;width:95px;-webkit-transform-origin:100% 4px;transform-origin:100% 4px;-webkit-transition:all 1s;transition:all 1s;border-radius:4px;bottom:-4px;box-shadow:3px -1px 4px rgba(0,0,0,0.4);display:block;height:8px;left:5px;position:absolute;width:95px;transform-origin:100% 4px;transition:all 1s}.dropdown-menu.show{left:inherit;right:0px} /*# sourceMappingURL=style.min.css.map */ \ No newline at end of file diff --git a/src/templates/default/static/css/style.min.css.map b/src/templates/default/static/css/style.min.css.map index e9d01194..39e49a9c 100644 --- a/src/templates/default/static/css/style.min.css.map +++ b/src/templates/default/static/css/style.min.css.map @@ -1,6 +1,6 @@ { "version": 3, - "mappings": "AAAA,AAAA,IAAI,AAAC,CACD,QAAQ,CAAE,QAAQ,CAClB,UAAU,CAAE,IAAI,CACnB,AAED,AACI,IADA,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EACD,yBAAyB,CAD7B,IAAI,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EAED,0BAA0B,AAAC,CACvB,sBAAsB,CAAE,MAAM,CAC9B,yBAAyB,CAAE,MAAM,CACpC,AAGL,AACI,IADA,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EACD,yBAAyB,CAD7B,IAAI,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EAED,0BAA0B,AAAC,CACvB,uBAAuB,CAAE,MAAM,CAC/B,0BAA0B,CAAE,MAAM,CACrC,AAGL,AAAA,IAAI,AAAC,CACD,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,IAAI,CACtB,AAED,AAAA,OAAO,AAAC,CACJ,QAAQ,CAAE,QAAQ,CAClB,MAAM,CAAE,CAAC,CACT,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,WAAW,CAAE,IAAI,CACjB,gBAAgB,CAAE,OAAO,CAC5B,AAED,AAAA,YAAY,CAAC,WAAW,CAAC,SAAS,AAAC,CAC/B,KAAK,CAAE,sBAAwB,CAMlC,AAPD,AAGI,YAHQ,CAAC,WAAW,CAAC,SAAS,AAG7B,MAAM,CAHX,YAAY,CAAC,WAAW,CAAC,SAAS,AAI7B,MAAM,AAAC,CACJ,KAAK,CAAE,sBAAwB,CAClC,AAGL,AAAA,EAAE,CACF,EAAE,CACF,EAAE,AAAC,CACC,aAAa,CAAE,CAAC,CACnB,AAED,AAAA,MAAM,CAAC,WAAW,AAAC,CACf,KAAK,CAAE,kBAAkB,CAC5B,AAED,AAAA,CAAC,CACD,MAAM,CACN,SAAS,AAAC,CACN,UAAU,CAAE,eAAe,CAC3B,SAAS,CAAE,eAAe,CAC7B,AAED,AAAA,CAAC,AAAA,KAAK,AAAC,CACH,eAAe,CAAE,IAAI,CACrB,MAAM,CAAE,OAAO,CACf,YAAY,CAAE,IAAI,CACrB,AAED,AAAA,IAAI,AAAA,YAAY,CAAC,KAAK,CAAA,AAAA,IAAC,CAAK,MAAM,AAAX,EACvB,IAAI,AAAA,WAAW,CAAC,KAAK,CAAA,AAAA,IAAC,CAAK,MAAM,AAAX,CAAa,CAC/B,yBAAyB,CAAE,CAAC,CAC5B,0BAA0B,CAAE,CAAC,CAChC,AAED,AAAA,IAAI,AAAA,YAAY,CAAC,KAAK,CAAA,AAAA,IAAC,CAAK,UAAU,AAAf,CAAiB,CACpC,sBAAsB,CAAE,CAAC,CACzB,uBAAuB,CAAE,CAAC,CAC7B,AAED,AACI,IADA,AAAA,WAAW,CACX,KAAK,AAAA,eAAe,AAAC,CACjB,aAAa,CAAE,CAAC,CACnB,AAHL,AAKI,IALA,AAAA,WAAW,CAKX,KAAK,AAAA,sBAAsB,AAAC,CACxB,sBAAsB,CAAE,CAAC,CACzB,uBAAuB,CAAE,CAAC,CAC7B,AAGL,AAAA,IAAI,AAAA,YAAY,CAChB,IAAI,AAAA,YAAY,CAChB,IAAI,AAAA,WAAW,AAAC,CACZ,MAAM,CAAE,IAAI,CACf,AAED,AAAA,KAAK,AAAC,CACF,YAAY,CAAE,KAAK,CACtB,AAED,AAAA,EAAE,CAAE,EAAE,AAAC,CACH,SAAS,CAAC,GAAG,CAChB,AACD,AAAA,QAAQ,AAAC,CACL,SAAS,CAAC,UAAU,CACpB,aAAa,CAAC,UAAU,CAC3B,AAED,AAAA,KAAK,CAAC,EAAE,CAAA,AAAA,OAAC,CAAQ,OAAO,AAAf,EACT,UAAU,AAAC,CACP,OAAO,CAAE,IAAI,CAChB,AAED,AAAA,KAAK,CAAC,EAAE,CAAA,AAAA,OAAC,CAAQ,MAAM,AAAd,CAAgB,CACrB,OAAO,CAAE,SAAS,CACrB,AAED,AAAA,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,CACjD,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,AAAA,OAAO,CACxD,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,AAAA,MAAM,CACvD,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,AAAA,MAAM,AAAC,CACpD,KAAK,CAAE,KAAK,CACf,AAED,AAAA,MAAM,AAAC,CACH,aAAa,CAAE,eAAe,CAC9B,MAAM,CAAE,KAAK,CACb,MAAM,CAAE,WAAW,CACnB,QAAQ,CAAE,MAAM,CAChB,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,KAAK,CA4Bf,AAlCD,AAOI,MAPE,AAOD,OAAO,AAAC,CACL,UAAU,CAAE,OAAO,CACnB,aAAa,CAAE,eAAe,CAC9B,UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CAAC,KAAK,CACjD,OAAO,CAAE,EAAE,CACX,MAAM,CAAE,KAAK,CACb,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,KAAK,CACf,AAfL,AAgBI,MAhBE,AAgBD,MAAM,AAAC,CACJ,UAAU,CAAE,IAAI,CAChB,aAAa,CAAE,eAAe,CAC9B,MAAM,CAAE,CAAC,CACT,kBAAkB,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CACnD,UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CAC3C,OAAO,CAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAA,iBAAiB,CACrD,SAAS,CAAE,KAAK,CAChB,WAAW,CAAE,GAAG,CAChB,MAAM,CAAE,IAAI,CACZ,IAAI,CAAE,IAAI,CACV,WAAW,CAAE,IAAI,CACjB,QAAQ,CAAE,QAAQ,CAClB,UAAU,CAAE,MAAM,CAClB,KAAK,CAAE,KAAK,CACZ,OAAO,CAAE,CAAC,CACV,WAAW,CAAE,GAAG,CACnB,AAGL,AAAA,OAAO,AAAC,CACJ,UAAU,CAAE,kBAAqB,CACjC,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,GAAG,CAAE,IAAG,CAAC,GAAG,CAAC,eAAkB,CAC3C,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,GAAG,CACX,IAAI,CAAE,GAAG,CACT,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,IAAI,CACX,gBAAgB,CAAE,QAAQ,CAC1B,UAAU,CAAE,MAAM,CAClB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,GAAG,CAAE,IAAG,CAAC,GAAG,CAAC,eAAkB,CAC3C,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,GAAG,CACX,IAAI,CAAE,GAAG,CACT,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,IAAI,CACX,gBAAgB,CAAE,QAAQ,CAC1B,UAAU,CAAE,MAAM,CACrB,AAED,AAAA,cAAc,AAAA,KAAK,AAAC,CAChB,IAAI,CAAE,OAAO,CACb,KAAK,CAAE,GAAG,CACb", + "mappings": "AAAA,AAAA,IAAI,AAAC,CACD,QAAQ,CAAE,QAAQ,CAClB,UAAU,CAAE,IAAI,CACnB,AAED,AACI,IADA,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EACD,yBAAyB,CAD7B,IAAI,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EAED,0BAA0B,AAAC,CACvB,sBAAsB,CAAE,MAAM,CAC9B,yBAAyB,CAAE,MAAM,CACpC,AAGL,AACI,IADA,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EACD,yBAAyB,CAD7B,IAAI,CAAA,AAAA,GAAC,CAAI,KAAK,AAAT,EAED,0BAA0B,AAAC,CACvB,uBAAuB,CAAE,MAAM,CAC/B,0BAA0B,CAAE,MAAM,CACrC,AAGL,AAAA,IAAI,AAAC,CACD,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,IAAI,CACtB,AAED,AAAA,gBAAgB,AAAC,CACb,SAAS,CAAE,MAAM,CACpB,AAED,AAAA,OAAO,AAAC,CACJ,QAAQ,CAAE,QAAQ,CAClB,MAAM,CAAE,CAAC,CACT,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,WAAW,CAAE,IAAI,CACjB,gBAAgB,CAAE,OAAO,CAC5B,AAED,AAAA,YAAY,CAAC,WAAW,CAAC,SAAS,AAAC,CAC/B,KAAK,CAAE,sBAAwB,CAMlC,AAPD,AAGI,YAHQ,CAAC,WAAW,CAAC,SAAS,AAG7B,MAAM,CAHX,YAAY,CAAC,WAAW,CAAC,SAAS,AAI7B,MAAM,AAAC,CACJ,KAAK,CAAE,sBAAwB,CAClC,AAGL,AAAA,EAAE,CACF,EAAE,CACF,EAAE,AAAC,CACC,aAAa,CAAE,CAAC,CACnB,AAED,AAAA,MAAM,CAAC,WAAW,AAAC,CACf,KAAK,CAAE,kBAAkB,CAC5B,AAED,AAAA,CAAC,CACD,MAAM,CACN,SAAS,AAAC,CACN,UAAU,CAAE,eAAe,CAC3B,SAAS,CAAE,eAAe,CAC7B,AAED,AAAA,CAAC,AAAA,KAAK,AAAC,CACH,eAAe,CAAE,IAAI,CACrB,MAAM,CAAE,OAAO,CACf,YAAY,CAAE,IAAI,CACrB,AAED,AAAA,IAAI,AAAA,YAAY,CAAC,KAAK,CAAA,AAAA,IAAC,CAAK,MAAM,AAAX,EACvB,IAAI,AAAA,WAAW,CAAC,KAAK,CAAA,AAAA,IAAC,CAAK,MAAM,AAAX,CAAa,CAC/B,yBAAyB,CAAE,CAAC,CAC5B,0BAA0B,CAAE,CAAC,CAChC,AAED,AAAA,IAAI,AAAA,YAAY,CAAC,KAAK,CAAA,AAAA,IAAC,CAAK,UAAU,AAAf,CAAiB,CACpC,sBAAsB,CAAE,CAAC,CACzB,uBAAuB,CAAE,CAAC,CAC7B,AAED,AACI,IADA,AAAA,WAAW,CACX,KAAK,AAAA,eAAe,AAAC,CACjB,aAAa,CAAE,CAAC,CACnB,AAHL,AAKI,IALA,AAAA,WAAW,CAKX,KAAK,AAAA,sBAAsB,AAAC,CACxB,sBAAsB,CAAE,CAAC,CACzB,uBAAuB,CAAE,CAAC,CAC7B,AAGL,AAAA,IAAI,AAAA,YAAY,CAChB,IAAI,AAAA,YAAY,CAChB,IAAI,AAAA,WAAW,AAAC,CACZ,MAAM,CAAE,IAAI,CACf,AAED,AAAA,KAAK,AAAC,CACF,YAAY,CAAE,KAAK,CACtB,AAED,AAAA,EAAE,CAAE,EAAE,AAAC,CACH,SAAS,CAAC,GAAG,CAChB,AACD,AAAA,QAAQ,AAAC,CACL,SAAS,CAAC,UAAU,CACpB,aAAa,CAAC,UAAU,CAC3B,AAED,AAAA,KAAK,CAAC,EAAE,CAAA,AAAA,OAAC,CAAQ,OAAO,AAAf,EACT,UAAU,AAAC,CACP,OAAO,CAAE,IAAI,CAChB,AAED,AAAA,KAAK,CAAC,EAAE,CAAA,AAAA,OAAC,CAAQ,MAAM,AAAd,CAAgB,CACrB,OAAO,CAAE,SAAS,CACrB,AAED,AAAA,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,CACjD,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,AAAA,OAAO,CACxD,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,AAAA,MAAM,CACvD,iBAAiB,CAAC,gBAAgB,AAAA,eAAe,AAAA,MAAM,AAAC,CACpD,KAAK,CAAE,KAAK,CACf,AAED,AAAA,MAAM,AAAC,CACH,aAAa,CAAE,eAAe,CAC9B,MAAM,CAAE,KAAK,CACb,MAAM,CAAE,WAAW,CACnB,QAAQ,CAAE,MAAM,CAChB,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,KAAK,CA4Bf,AAlCD,AAOI,MAPE,AAOD,OAAO,AAAC,CACL,UAAU,CAAE,OAAO,CACnB,aAAa,CAAE,eAAe,CAC9B,UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CAAC,KAAK,CACjD,OAAO,CAAE,EAAE,CACX,MAAM,CAAE,KAAK,CACb,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,KAAK,CACf,AAfL,AAgBI,MAhBE,AAgBD,MAAM,AAAC,CACJ,UAAU,CAAE,IAAI,CAChB,aAAa,CAAE,eAAe,CAC9B,MAAM,CAAE,CAAC,CACT,kBAAkB,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CACnD,UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CAC3C,OAAO,CAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAA,iBAAiB,CACrD,SAAS,CAAE,KAAK,CAChB,WAAW,CAAE,GAAG,CAChB,MAAM,CAAE,IAAI,CACZ,IAAI,CAAE,IAAI,CACV,WAAW,CAAE,IAAI,CACjB,QAAQ,CAAE,QAAQ,CAClB,UAAU,CAAE,MAAM,CAClB,KAAK,CAAE,KAAK,CACZ,OAAO,CAAE,CAAC,CACV,WAAW,CAAE,GAAG,CACnB,AAGL,AAAA,OAAO,AAAC,CACJ,UAAU,CAAE,kBAAqB,CACjC,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,GAAG,CAAE,IAAG,CAAC,GAAG,CAAC,eAAkB,CAC3C,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,GAAG,CACX,IAAI,CAAE,GAAG,CACT,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,IAAI,CACX,gBAAgB,CAAE,QAAQ,CAC1B,UAAU,CAAE,MAAM,CAClB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,GAAG,CAAE,IAAG,CAAC,GAAG,CAAC,eAAkB,CAC3C,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,GAAG,CACX,IAAI,CAAE,GAAG,CACT,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,IAAI,CACX,gBAAgB,CAAE,QAAQ,CAC1B,UAAU,CAAE,MAAM,CACrB,AAED,AAAA,cAAc,AAAA,KAAK,AAAC,CAChB,IAAI,CAAE,OAAO,CACb,KAAK,CAAE,GAAG,CACb", "sources": [ "../scss/style.scss" ], diff --git a/src/templates/default/static/scss/style.scss b/src/templates/default/static/scss/style.scss index 6114ad76..35e7ea9b 100644 --- a/src/templates/default/static/scss/style.scss +++ b/src/templates/default/static/scss/style.scss @@ -24,6 +24,10 @@ body { margin-bottom: 80px; } +.container-fluid { + max-width: 1920px; +} + .footer { position: absolute; bottom: 0; From ea33ba07ca786a77669d386f2c8f73e792b4101e Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 18 May 2020 22:05:19 +0200 Subject: [PATCH 016/112] Updated ping check (#919) Check if transmitted and received packets is equal. --- src/psm/Util/Server/Updater/StatusUpdater.php | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index af3a8cdd..47d4abf7 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -179,36 +179,42 @@ class StatusUpdater $max_runs = 1; } $result = null; - // Execute ping + // Choose right ping version, ping6 for IPV6, ping for IPV4 $pingCommand = 'ping6'; $serverIp = $this->server['ip']; if (filter_var($serverIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { $pingCommand = 'ping'; } + + // execute PING $txt = exec($pingCommand . " -c " . $max_runs . " " . $serverIp . " 2>&1", $output); - // Non-greedy match on filler - $re1 = '.*?'; - // Uninteresting: float - $re2 = '[+-]?\\d*\\.\\d+(?![-+0-9\\.])'; - // Non-greedy match on filler - $re3 = '.*?'; - // Float 1 - $re4 = '([+-]?\\d*\\.\\d+)(?![-+0-9\\.])'; - if (preg_match_all("/" . $re1 . $re2 . $re3 . $re4 . "/is", $txt, $matches)) { - $result = $matches[1][0]; - } - if (substr($output[0], 0, 4) == 'PING' && strpos($output[count($output) - 2], 'packets transmitted')) { - $result = 0; - } - if (!is_null($result)) { - $this->header = $output[0]; + + // Check if output is PING and if transmitted packets is equal to received packets. + preg_match('/^(\d{1,3}) packets transmitted, (\d{1,3}).*$/', $output[count($output) - 2], $output_package_loss); + + if ( + substr($output[0], 0, 4) == 'PING' && + !empty($output_package_loss) && + $output_package_loss[1] === $output_package_loss[2] + ) { + // Gets avg from 'round-trip min/avg/max/stddev = 7.109/7.109/7.109/0.000 ms' + preg_match_all("/(\d+\.\d+)/", $output[count($output) - 1], $result); + $result = floatval($result[0][1]); + + $this->header = ""; + foreach ($output as $key => $value) { + $this->header .= $value . "\n"; + } $status = true; } else { $this->header = "-"; - $this->error = $output[0]; + foreach ($output as $key => $value) { + $this->header .= $value . "\n"; + } + $this->error = $output[count($output) - 2]; $status = false; } - //Divide by a thousand to convert to milliseconds + // To miliseconds $this->rtime = $result / 1000; // check if server is available and rerun if asked. From 96d0c3fa575710e873d36d5e0e2b9719df6f98e0 Mon Sep 17 00:00:00 2001 From: wienfuchs <44177781+wienfuchs@users.noreply.github.com> Date: Sun, 24 May 2020 23:31:19 +0200 Subject: [PATCH 017/112] use openssl_x509_parse to parse certinfo (avoid literal case conflict) (#931) --- src/psm/Util/Server/Updater/StatusUpdater.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 47d4abf7..3b071fcd 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -431,7 +431,9 @@ class StatusUpdater !empty($this->curl_info['certinfo']) && $server['ssl_cert_expiry_days'] > 0 ) { - $cert_expiration_date = strtotime($this->curl_info['certinfo'][0]['Expire date']); + $certinfo = reset($this->curl_info['certinfo']); + $certinfo = openssl_x509_parse($certinfo['Cert']); + $cert_expiration_date = $certinfo['validTo_time_t']; $expiration_time = round((int)($cert_expiration_date - time()) / 86400); $latest_time = time() + (86400 * $server['ssl_cert_expiry_days']); From 07abc7d2946e9b460ba17d26b65d3b1aa6e7a4c0 Mon Sep 17 00:00:00 2001 From: wienfuchs <44177781+wienfuchs@users.noreply.github.com> Date: Sun, 24 May 2020 23:40:19 +0200 Subject: [PATCH 018/112] use OS specific ping count parameter (#932) * use OS specific ping count parameter * Reorganized and complied with PSR-12 Co-authored-by: TimZ99 --- src/psm/Util/Server/Updater/StatusUpdater.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 3b071fcd..b57d1af6 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -175,19 +175,28 @@ class StatusUpdater */ protected function updatePing($max_runs, $run = 1) { + // Settings if ($max_runs == null || $max_runs > 1) { $max_runs = 1; } - $result = null; - // Choose right ping version, ping6 for IPV6, ping for IPV4 - $pingCommand = 'ping6'; $serverIp = $this->server['ip']; + $pingCommand = 'ping6'; + $ping_count = " -c "; + + $result = null; + + // Choose right ping version, ping6 for IPV6, ping for IPV4 if (filter_var($serverIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { $pingCommand = 'ping'; } + // Use -n instead of -c for Windows machines + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $ping_count = " -n "; + } + // execute PING - $txt = exec($pingCommand . " -c " . $max_runs . " " . $serverIp . " 2>&1", $output); + $txt = exec($pingCommand . $ping_count . $max_runs . " " . $serverIp . " 2>&1", $output); // Check if output is PING and if transmitted packets is equal to received packets. preg_match('/^(\d{1,3}) packets transmitted, (\d{1,3}).*$/', $output[count($output) - 2], $output_package_loss); From f02d55635eff5f3404a429c2998a16c7838736e2 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 25 May 2020 14:39:30 +0200 Subject: [PATCH 019/112] Changed ping6 to ping -6 for windows (#936) Resolving #935. --- src/psm/Util/Server/Updater/StatusUpdater.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index b57d1af6..8b2155dc 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -179,24 +179,24 @@ class StatusUpdater if ($max_runs == null || $max_runs > 1) { $max_runs = 1; } - $serverIp = $this->server['ip']; - $pingCommand = 'ping6'; - $ping_count = " -c "; - + $server_ip = $this->server['ip']; + $ping_command = 'ping'; + $ping_count = "-c"; + $os_is_windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; $result = null; // Choose right ping version, ping6 for IPV6, ping for IPV4 - if (filter_var($serverIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { - $pingCommand = 'ping'; + if (filter_var($server_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $ping_command = $os_is_windows ? 'ping -6' : 'ping6'; } // Use -n instead of -c for Windows machines - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $ping_count = " -n "; + if ($os_is_windows) { + $ping_count = "-n"; } // execute PING - $txt = exec($pingCommand . $ping_count . $max_runs . " " . $serverIp . " 2>&1", $output); + $txt = exec($ping_command . " " . $ping_count . " " . $max_runs . " " . $server_ip . " 2>&1", $output); // Check if output is PING and if transmitted packets is equal to received packets. preg_match('/^(\d{1,3}) packets transmitted, (\d{1,3}).*$/', $output[count($output) - 2], $output_package_loss); From 7deac0815afb010cce81e964fd710b8c7bcaab25 Mon Sep 17 00:00:00 2001 From: wienfuchs <44177781+wienfuchs@users.noreply.github.com> Date: Mon, 25 May 2020 18:10:10 +0200 Subject: [PATCH 020/112] changing Windows ping routine back to socket usage, leaving Linux changes made (#938) * use openssl_x509_parse to parse certinfo (avoid literal case conflict) * use OS specific ping (CLI/socket) * Moved Windows and non-Windows check to a private class Co-authored-by: TimZ99 --- src/psm/Util/Server/Updater/StatusUpdater.php | 135 ++++++++++++------ 1 file changed, 88 insertions(+), 47 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 8b2155dc..88f31ee6 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -176,55 +176,13 @@ class StatusUpdater protected function updatePing($max_runs, $run = 1) { // Settings - if ($max_runs == null || $max_runs > 1) { - $max_runs = 1; - } - $server_ip = $this->server['ip']; - $ping_command = 'ping'; - $ping_count = "-c"; + $max_runs = ($max_runs == null || $max_runs > 1) ? 1 : $max_runs; + $server_ip = escapeshellcmd($this->server['ip']); $os_is_windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; - $result = null; - // Choose right ping version, ping6 for IPV6, ping for IPV4 - if (filter_var($server_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $ping_command = $os_is_windows ? 'ping -6' : 'ping6'; - } - - // Use -n instead of -c for Windows machines - if ($os_is_windows) { - $ping_count = "-n"; - } - - // execute PING - $txt = exec($ping_command . " " . $ping_count . " " . $max_runs . " " . $server_ip . " 2>&1", $output); - - // Check if output is PING and if transmitted packets is equal to received packets. - preg_match('/^(\d{1,3}) packets transmitted, (\d{1,3}).*$/', $output[count($output) - 2], $output_package_loss); - - if ( - substr($output[0], 0, 4) == 'PING' && - !empty($output_package_loss) && - $output_package_loss[1] === $output_package_loss[2] - ) { - // Gets avg from 'round-trip min/avg/max/stddev = 7.109/7.109/7.109/0.000 ms' - preg_match_all("/(\d+\.\d+)/", $output[count($output) - 1], $result); - $result = floatval($result[0][1]); - - $this->header = ""; - foreach ($output as $key => $value) { - $this->header .= $value . "\n"; - } - $status = true; - } else { - $this->header = "-"; - foreach ($output as $key => $value) { - $this->header .= $value . "\n"; - } - $this->error = $output[count($output) - 2]; - $status = false; - } - // To miliseconds - $this->rtime = $result / 1000; + $status = $os_is_windows ? + $this->pingFromWindowsMachine($server_ip, $max_runs) : + $this->pingFromNonWindowsMachine($server_ip, $max_runs); // check if server is available and rerun if asked. if (!$status && $run < $max_runs) { @@ -466,4 +424,87 @@ class StatusUpdater $this->db->save(PSM_DB_PREFIX . 'servers', $save, array('server_id' => $this->server_id)); } } + + /** + * Ping from a Windows Machine + * @param string $server_id + * @param int $max_runs + * @return boolean + */ + private function pingFromWindowsMachine($server_ip, $max_runs) + { + // Windows / Linux variant: use socket on Windows, commandline on Linux + // socket ping - Code from http://stackoverflow.com/a/20467492 + // save response time + $starttime = microtime(true); + + // set ping payload + $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost"; + + $socket = socket_create(AF_INET, SOCK_RAW, 1); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 0)); + socket_connect($socket, $server_ip, null); + socket_send($socket, $package, strLen($package), 0); + // socket_read returns a string or false + $status = socket_read($socket, 255) !== false ? true : false; + + if ($status) { + $this->header = "Success."; + } else { + $this->error = "Couldn't create socket [" . $errorcode . "]: " . socket_strerror(socket_last_error()); + } + + $this->rtime = microtime(true) - $starttime; + socket_close($socket); + + return $status; + } + + /** + * Ping from a non Windows Machine + * @param string $server_id + * @param int $max_runs + * @param string $ping_command + * @return boolean + */ + private function pingFromNonWindowsMachine($server_ip, $max_runs) + { + + // Choose right ping version, ping6 for IPV6, ping for IPV4 + $ping_command = filter_var($server_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false ? 'ping6' : 'ping'; + + // execute PING + exec($ping_command . " -c " . $max_runs . " " . $server_ip . " 2>&1", $output); + + // Check if output is PING and if transmitted packets is equal to received packets. + preg_match( + '/^(\d{1,3}) packets transmitted, (\d{1,3}).*$/', + $output[count($output) - 2], + $output_package_loss + ); + + if ( + substr($output[0], 0, 4) == 'PING' && + !empty($output_package_loss) && + $output_package_loss[1] === $output_package_loss[2] + ) { + // Gets avg from 'round-trip min/avg/max/stddev = 7.109/7.109/7.109/0.000 ms' + preg_match_all("/(\d+\.\d+)/", $output[count($output) - 1], $result); + // Converted to milliseconds + $this->rtime = floatval($result[0][1]) / 1000; + + $this->header = ""; + foreach ($output as $key => $value) { + $this->header .= $value . "\n"; + } + return true; + } + + $this->header = "-"; + foreach ($output as $key => $value) { + $this->header .= $value . "\n"; + } + $this->error = $output[count($output) - 2]; + return false; + } } From 2a15b31ecddbeddd372c92b15d8ee4aa2d4fd5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C5=82ek?= Date: Mon, 25 May 2020 18:12:43 +0200 Subject: [PATCH 021/112] Ability to pan & zoom on charts (#926) * Add ability to pan & zoom on charts * Added map * Added rangeMax and zoom speed Co-authored-by: TimZ99 --- docs/credits.rst | 1 + .../default/module/server/history.tpl.html | 40 +++++++++++++++++++ .../static/plugin/chartjs/plugin-zoom.min.js | 11 +++++ .../static/plugin/hammer/hammer.min.js | 7 ++++ .../static/plugin/hammer/hammer.min.js.map | 1 + 5 files changed, 60 insertions(+) create mode 100755 src/templates/default/static/plugin/chartjs/plugin-zoom.min.js create mode 100755 src/templates/default/static/plugin/hammer/hammer.min.js create mode 100644 src/templates/default/static/plugin/hammer/hammer.min.js.map diff --git a/docs/credits.rst b/docs/credits.rst index 75a1aadc..e1c89471 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -196,3 +196,4 @@ The following libraries are being used by PHP Server Monitor: * PHP-Pushover - https://github.com/kryap/php-pushover * Symfony - https://symfony.com * Random_compat - https://github.com/paragonie/random_compat +* Hammer.js - https://github.com/hammerjs/hammer.js \ No newline at end of file diff --git a/src/templates/default/module/server/history.tpl.html b/src/templates/default/module/server/history.tpl.html index 91027166..163c01d9 100644 --- a/src/templates/default/module/server/history.tpl.html +++ b/src/templates/default/module/server/history.tpl.html @@ -1,5 +1,7 @@ + + {% for graph in graphs %}
    Your browser does not support the canvas element. @@ -72,6 +74,25 @@ source: 'auto', } }] + }, + plugins: { + zoom: { + pan: { + enabled: true, + mode: 'x', + rangeMax: { + x: new Date, + }, + }, + zoom: { + enabled: true, + mode: 'x', + rangeMax: { + x: new Date, + }, + speed: 0.05, + } + } } } }); @@ -133,6 +154,25 @@ source: 'auto', } }] + }, + plugins: { + zoom: { + pan: { + enabled: true, + mode: 'x', + rangeMax: { + x: new Date, + }, + }, + zoom: { + enabled: true, + mode: 'x', + rangeMax: { + x: new Date, + }, + speed: 0.05, + } + } } } }); diff --git a/src/templates/default/static/plugin/chartjs/plugin-zoom.min.js b/src/templates/default/static/plugin/chartjs/plugin-zoom.min.js new file mode 100755 index 00000000..51b054d6 --- /dev/null +++ b/src/templates/default/static/plugin/chartjs/plugin-zoom.min.js @@ -0,0 +1,11 @@ +/*! + * @license + * chartjs-plugin-zoom + * http://chartjs.org/ + * Version: 0.7.7 + * + * Copyright 2020 Chart.js Contributors + * Released under the MIT license + * https://github.com/chartjs/chartjs-plugin-zoom/blob/master/LICENSE.md + */ +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("chart.js"),require("hammerjs")):"function"==typeof define&&define.amd?define(["chart.js","hammerjs"],o):(e=e||self).ChartZoom=o(e.Chart,e.Hammer)}(this,(function(e,o){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,o=o&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o;var t=e.helpers,n=e.Zoom=e.Zoom||{},a=n.zoomFunctions=n.zoomFunctions||{},i=n.panFunctions=n.panFunctions||{};function m(e,o){var n={};void 0!==e.options.pan&&(n.pan=e.options.pan),void 0!==e.options.zoom&&(n.zoom=e.options.zoom);var a=e.$zoom;o=a._options=t.merge({},[o,n]);var i=a._node,m=o.zoom&&o.zoom.enabled,r=o.zoom.drag;m&&!r?i.addEventListener("wheel",a._wheelHandler):i.removeEventListener("wheel",a._wheelHandler),m&&r?(i.addEventListener("mousedown",a._mouseDownHandler),i.ownerDocument.addEventListener("mouseup",a._mouseUpHandler)):(i.removeEventListener("mousedown",a._mouseDownHandler),i.removeEventListener("mousemove",a._mouseMoveHandler),i.ownerDocument.removeEventListener("mouseup",a._mouseUpHandler))}function r(e){var o=e.$zoom._originalOptions;t.each(e.scales,(function(e){o[e.id]||(o[e.id]=t.clone(e.options))})),t.each(o,(function(t,n){e.scales[n]||delete o[n]}))}function l(e,o,t){return void 0===e||("string"==typeof e?-1!==e.indexOf(o):"function"==typeof e&&-1!==e({chart:t}).indexOf(o))}function s(e,o){if(e.scaleAxes&&e.rangeMax&&!t.isNullOrUndef(e.rangeMax[e.scaleAxes])){var n=e.rangeMax[e.scaleAxes];o>n&&(o=n)}return o}function c(e,o){if(e.scaleAxes&&e.rangeMin&&!t.isNullOrUndef(e.rangeMin[e.scaleAxes])){var n=e.rangeMin[e.scaleAxes];o=c&&s<=u?(i.min=l,i.max=s):lu&&(a=u-r,i.max=u,i.min=m+a)}function v(e,o,t){var n=i[e.type];n&&n(e,o,t)}e.Zoom.defaults=e.defaults.global.plugins.zoom={pan:{enabled:!1,mode:"xy",speed:20,threshold:10},zoom:{enabled:!1,mode:"xy",sensitivity:3,speed:.1}},n.zoomFunctions.category=function(e,o,t,a){var i=e.chart.data.labels,m=e.minIndex,r=i.length-1,l=e.maxIndex,u=a.sensitivity,d=e.isHorizontal()?e.left+e.width/2:e.top+e.height/2,p=e.isHorizontal()?t.x:t.y;n.zoomCumulativeDelta=o>1?n.zoomCumulativeDelta+1:n.zoomCumulativeDelta-1,Math.abs(n.zoomCumulativeDelta)>u&&(n.zoomCumulativeDelta<0?(p>=d?m<=0?l=Math.min(r,l+1):m=Math.max(0,m-1):p=r?m=Math.max(0,m-1):l=Math.min(r,l+1)),n.zoomCumulativeDelta=0):n.zoomCumulativeDelta>0&&(p>=d?m=mm?l=Math.max(m,l-1):l),n.zoomCumulativeDelta=0),e.options.ticks.min=c(a,i[m]),e.options.ticks.max=s(a,i[l]))},n.zoomFunctions.time=function(e,o,t,n){u(e,o,t,n);var a=e.options;a.time&&(a.time.min&&(a.time.min=a.ticks.min),a.time.max&&(a.time.max=a.ticks.max))},n.zoomFunctions.linear=u,n.zoomFunctions.logarithmic=u,n.panFunctions.category=function(e,o,t){var a,i=e.chart.data.labels,m=i.length-1,r=Math.max(e.ticks.length,1),l=t.speed,u=e.minIndex,d=Math.round(e.width/(r*l));n.panCumulativeDelta+=o,u=n.panCumulativeDelta>d?Math.max(0,u-1):n.panCumulativeDelta<-d?Math.min(m-r+1,u+1):u,n.panCumulativeDelta=u!==e.minIndex?0:n.panCumulativeDelta,a=Math.min(m,u+r-1),e.options.ticks.min=c(t,i[u]),e.options.ticks.max=s(t,i[a])},n.panFunctions.time=function(e,o,t){f(e,o,t);var n=e.options;n.time&&(n.time.min&&(n.time.min=n.ticks.min),n.time.max&&(n.time.max=n.ticks.max))},n.panFunctions.linear=f,n.panFunctions.logarithmic=f,n.panCumulativeDelta=0,n.zoomCumulativeDelta=0;var h={id:"zoom",afterInit:function(e){e.resetZoom=function(){r(e);var o=e.$zoom._originalOptions;t.each(e.scales,(function(e){var t=e.options.time,n=e.options.ticks;o[e.id]?(t&&(t.min=o[e.id].time.min,t.max=o[e.id].time.max),n&&(n.min=o[e.id].ticks.min,n.max=o[e.id].ticks.max)):(t&&(delete t.min,delete t.max),n&&(delete n.min,delete n.max))})),e.update()}},beforeUpdate:function(e,o){m(e,o)},beforeInit:function(e,a){e.$zoom={_originalOptions:{}};var i=e.$zoom._node=e.ctx.canvas;m(e,a);var s=e.$zoom._options,c=s.pan&&s.pan.threshold;e.$zoom._mouseDownHandler=function(o){i.addEventListener("mousemove",e.$zoom._mouseMoveHandler),e.$zoom._dragZoomStart=o},e.$zoom._mouseMoveHandler=function(o){e.$zoom._dragZoomStart&&(e.$zoom._dragZoomEnd=o,e.update(0))},e.$zoom._mouseUpHandler=function(o){if(e.$zoom._dragZoomStart){i.removeEventListener("mousemove",e.$zoom._mouseMoveHandler);var t=e.$zoom._dragZoomStart,n=t.target.getBoundingClientRect().left,a=Math.min(t.clientX,o.clientX)-n,m=Math.max(t.clientX,o.clientX)-n,r=t.target.getBoundingClientRect().top,c=Math.min(t.clientY,o.clientY)-r,u=m-a,d=Math.max(t.clientY,o.clientY)-r-c;e.$zoom._dragZoomStart=null,e.$zoom._dragZoomEnd=null;var f=s.zoom&&s.zoom.threshold||0;if(!(u<=f&&d<=f)){var v=e.chartArea,h=e.$zoom._options.zoom,x=v.right-v.left,g=l(h.mode,"x",e)&&u?1+(x-u)/x:1,z=v.bottom-v.top,y=l(h.mode,"y",e);p(e,g,y&&d?1+(z-d)/z:1,{x:(a-v.left)/(1-u/x)+v.left,y:(c-v.top)/(1-d/z)+v.top},void 0,h.drag.animationDuration),"function"==typeof h.onZoomComplete&&h.onZoomComplete({chart:e})}}};var u=null;if(e.$zoom._wheelHandler=function(o){if(o.cancelable&&o.preventDefault(),void 0!==o.deltaY){var t=o.target.getBoundingClientRect(),n={x:o.clientX-t.left,y:o.clientY-t.top},a=e.$zoom._options.zoom,i=a.speed;o.deltaY>=0&&(i=-i),p(e,1+i,1+i,n),clearTimeout(u),u=setTimeout((function(){"function"==typeof a.onZoomComplete&&a.onZoomComplete({chart:e})}),250)}},o){var d,f=new o.Manager(i);f.add(new o.Pinch),f.add(new o.Pan({threshold:c}));var h=function(o){var t=1/d*o.scale,n=o.target.getBoundingClientRect(),a={x:o.center.x-n.left,y:o.center.y-n.top},i=Math.abs(o.pointers[0].clientX-o.pointers[1].clientX),m=Math.abs(o.pointers[0].clientY-o.pointers[1].clientY),r=i/m;p(e,t,t,a,r>.3&&r<1.7?"xy":i>m?"x":"y");var l=e.$zoom._options.zoom;"function"==typeof l.onZoomComplete&&l.onZoomComplete({chart:e}),d=o.scale};f.on("pinchstart",(function(){d=1})),f.on("pinch",h),f.on("pinchend",(function(e){h(e),d=null,n.zoomCumulativeDelta=0}));var x=null,g=null,z=!1,y=function(o){if(null!==x&&null!==g){z=!0;var n=o.deltaX-x,a=o.deltaY-g;x=o.deltaX,g=o.deltaY,function(e,o,n){r(e);var a=e.$zoom._options.pan;if(a.enabled){var i="function"==typeof a.mode?a.mode({chart:e}):a.mode;t.each(e.scales,(function(t){t.isHorizontal()&&l(i,"x",e)&&0!==o?(a.scaleAxes="x",v(t,o,a)):!t.isHorizontal()&&l(i,"y",e)&&0!==n&&(a.scaleAxes="y",v(t,n,a))})),e.update(0),"function"==typeof a.onPan&&a.onPan({chart:e})}}(e,n,a)}};f.on("panstart",(function(e){x=0,g=0,y(e)})),f.on("panmove",y),f.on("panend",(function(){x=null,g=null,n.panCumulativeDelta=0,setTimeout((function(){z=!1}),500);var o=e.$zoom._options.pan;"function"==typeof o.onPanComplete&&o.onPanComplete({chart:e})})),e.$zoom._ghostClickHandler=function(e){z&&e.cancelable&&(e.stopImmediatePropagation(),e.preventDefault())},i.addEventListener("click",e.$zoom._ghostClickHandler),e._mc=f}},beforeDatasetsDraw:function(e){var o=e.ctx;if(e.$zoom._dragZoomEnd){var t=function(e){for(var o=e.scales,t=Object.keys(o),n=0;n0&&(o.lineWidth=v.borderWidth,o.strokeStyle=v.borderColor||"rgba(225,225,225)",o.strokeRect(m,s,p,f)),o.restore()}},destroy:function(e){if(e.$zoom){var o=e.$zoom,t=o._node;t.removeEventListener("mousedown",o._mouseDownHandler),t.removeEventListener("mousemove",o._mouseMoveHandler),t.ownerDocument.removeEventListener("mouseup",o._mouseUpHandler),t.removeEventListener("wheel",o._wheelHandler),t.removeEventListener("click",o._ghostClickHandler),delete e.$zoom;var n=e._mc;n&&(n.remove("pinchstart"),n.remove("pinch"),n.remove("pinchend"),n.remove("panstart"),n.remove("pan"),n.remove("panend"),n.destroy())}}};return e.plugins.register(h),h})); \ No newline at end of file diff --git a/src/templates/default/static/plugin/hammer/hammer.min.js b/src/templates/default/static/plugin/hammer/hammer.min.js new file mode 100755 index 00000000..34a8c86f --- /dev/null +++ b/src/templates/default/static/plugin/hammer/hammer.min.js @@ -0,0 +1,7 @@ +/*! Hammer.JS - v2.0.7 - 2016-04-22 + * http://hammerjs.github.io/ + * + * Copyright (c) 2016 Jorik Tangelder; + * Licensed under the MIT license */ +!function(a,b,c,d){"use strict";function e(a,b,c){return setTimeout(j(a,c),b)}function f(a,b,c){return Array.isArray(a)?(g(a,c[b],c),!0):!1}function g(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",f=a.console&&(a.console.warn||a.console.log);return f&&f.call(a.console,e,d),b.apply(this,arguments)}}function i(a,b,c){var d,e=b.prototype;d=a.prototype=Object.create(e),d.constructor=a,d._super=e,c&&la(d,c)}function j(a,b){return function(){return a.apply(b,arguments)}}function k(a,b){return typeof a==oa?a.apply(b?b[0]||d:d,b):a}function l(a,b){return a===d?b:a}function m(a,b,c){g(q(b),function(b){a.addEventListener(b,c,!1)})}function n(a,b,c){g(q(b),function(b){a.removeEventListener(b,c,!1)})}function o(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function p(a,b){return a.indexOf(b)>-1}function q(a){return a.trim().split(/\s+/g)}function r(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;dc[b]}):d.sort()),d}function u(a,b){for(var c,e,f=b[0].toUpperCase()+b.slice(1),g=0;g1&&!c.firstMultiple?c.firstMultiple=D(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=E(d);b.timeStamp=ra(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=I(h,i),b.distance=H(h,i),B(c,b),b.offsetDirection=G(b.deltaX,b.deltaY);var j=F(b.deltaTime,b.deltaX,b.deltaY);b.overallVelocityX=j.x,b.overallVelocityY=j.y,b.overallVelocity=qa(j.x)>qa(j.y)?j.x:j.y,b.scale=g?K(g.pointers,d):1,b.rotation=g?J(g.pointers,d):0,b.maxPointers=c.prevInput?b.pointers.length>c.prevInput.maxPointers?b.pointers.length:c.prevInput.maxPointers:b.pointers.length,C(c,b);var k=a.element;o(b.srcEvent.target,k)&&(k=b.srcEvent.target),b.target=k}function B(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};b.eventType!==Ea&&f.eventType!==Ga||(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function C(a,b){var c,e,f,g,h=a.lastInterval||b,i=b.timeStamp-h.timeStamp;if(b.eventType!=Ha&&(i>Da||h.velocity===d)){var j=b.deltaX-h.deltaX,k=b.deltaY-h.deltaY,l=F(i,j,k);e=l.x,f=l.y,c=qa(l.x)>qa(l.y)?l.x:l.y,g=G(j,k),a.lastInterval=b}else c=h.velocity,e=h.velocityX,f=h.velocityY,g=h.direction;b.velocity=c,b.velocityX=e,b.velocityY=f,b.direction=g}function D(a){for(var b=[],c=0;ce;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:pa(c/b),y:pa(d/b)}}function F(a,b,c){return{x:b/a||0,y:c/a||0}}function G(a,b){return a===b?Ia:qa(a)>=qa(b)?0>a?Ja:Ka:0>b?La:Ma}function H(a,b,c){c||(c=Qa);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function I(a,b,c){c||(c=Qa);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function J(a,b){return I(b[1],b[0],Ra)+I(a[1],a[0],Ra)}function K(a,b){return H(b[0],b[1],Ra)/H(a[0],a[1],Ra)}function L(){this.evEl=Ta,this.evWin=Ua,this.pressed=!1,x.apply(this,arguments)}function M(){this.evEl=Xa,this.evWin=Ya,x.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function N(){this.evTarget=$a,this.evWin=_a,this.started=!1,x.apply(this,arguments)}function O(a,b){var c=s(a.touches),d=s(a.changedTouches);return b&(Ga|Ha)&&(c=t(c.concat(d),"identifier",!0)),[c,d]}function P(){this.evTarget=bb,this.targetIds={},x.apply(this,arguments)}function Q(a,b){var c=s(a.touches),d=this.targetIds;if(b&(Ea|Fa)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=s(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return o(a.target,i)}),b===Ea)for(e=0;e-1&&d.splice(a,1)};setTimeout(e,cb)}}function U(a){for(var b=a.srcEvent.clientX,c=a.srcEvent.clientY,d=0;d=f&&db>=g)return!0}return!1}function V(a,b){this.manager=a,this.set(b)}function W(a){if(p(a,jb))return jb;var b=p(a,kb),c=p(a,lb);return b&&c?jb:b||c?b?kb:lb:p(a,ib)?ib:hb}function X(){if(!fb)return!1;var b={},c=a.CSS&&a.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(d){b[d]=c?a.CSS.supports("touch-action",d):!0}),b}function Y(a){this.options=la({},this.defaults,a||{}),this.id=v(),this.manager=null,this.options.enable=l(this.options.enable,!0),this.state=nb,this.simultaneous={},this.requireFail=[]}function Z(a){return a&sb?"cancel":a&qb?"end":a&pb?"move":a&ob?"start":""}function $(a){return a==Ma?"down":a==La?"up":a==Ja?"left":a==Ka?"right":""}function _(a,b){var c=b.manager;return c?c.get(a):a}function aa(){Y.apply(this,arguments)}function ba(){aa.apply(this,arguments),this.pX=null,this.pY=null}function ca(){aa.apply(this,arguments)}function da(){Y.apply(this,arguments),this._timer=null,this._input=null}function ea(){aa.apply(this,arguments)}function fa(){aa.apply(this,arguments)}function ga(){Y.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function ha(a,b){return b=b||{},b.recognizers=l(b.recognizers,ha.defaults.preset),new ia(a,b)}function ia(a,b){this.options=la({},ha.defaults,b||{}),this.options.inputTarget=this.options.inputTarget||a,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=a,this.input=y(this),this.touchAction=new V(this,this.options.touchAction),ja(this,!0),g(this.options.recognizers,function(a){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[3])},this)}function ja(a,b){var c=a.element;if(c.style){var d;g(a.options.cssProps,function(e,f){d=u(c.style,f),b?(a.oldCssProps[d]=c.style[d],c.style[d]=e):c.style[d]=a.oldCssProps[d]||""}),b||(a.oldCssProps={})}}function ka(a,c){var d=b.createEvent("Event");d.initEvent(a,!0,!0),d.gesture=c,c.target.dispatchEvent(d)}var la,ma=["","webkit","Moz","MS","ms","o"],na=b.createElement("div"),oa="function",pa=Math.round,qa=Math.abs,ra=Date.now;la="function"!=typeof Object.assign?function(a){if(a===d||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;ch&&(b.push(a),h=b.length-1):e&(Ga|Ha)&&(c=!0),0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Za={touchstart:Ea,touchmove:Fa,touchend:Ga,touchcancel:Ha},$a="touchstart",_a="touchstart touchmove touchend touchcancel";i(N,x,{handler:function(a){var b=Za[a.type];if(b===Ea&&(this.started=!0),this.started){var c=O.call(this,a,b);b&(Ga|Ha)&&c[0].length-c[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:za,srcEvent:a})}}});var ab={touchstart:Ea,touchmove:Fa,touchend:Ga,touchcancel:Ha},bb="touchstart touchmove touchend touchcancel";i(P,x,{handler:function(a){var b=ab[a.type],c=Q.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:za,srcEvent:a})}});var cb=2500,db=25;i(R,x,{handler:function(a,b,c){var d=c.pointerType==za,e=c.pointerType==Ba;if(!(e&&c.sourceCapabilities&&c.sourceCapabilities.firesTouchEvents)){if(d)S.call(this,b,c);else if(e&&U.call(this,c))return;this.callback(a,b,c)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var eb=u(na.style,"touchAction"),fb=eb!==d,gb="compute",hb="auto",ib="manipulation",jb="none",kb="pan-x",lb="pan-y",mb=X();V.prototype={set:function(a){a==gb&&(a=this.compute()),fb&&this.manager.element.style&&mb[a]&&(this.manager.element.style[eb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return g(this.manager.recognizers,function(b){k(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),W(a.join(" "))},preventDefaults:function(a){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=p(d,jb)&&!mb[jb],f=p(d,lb)&&!mb[lb],g=p(d,kb)&&!mb[kb];if(e){var h=1===a.pointers.length,i=a.distance<2,j=a.deltaTime<250;if(h&&i&&j)return}return g&&f?void 0:e||f&&c&Na||g&&c&Oa?this.preventSrc(b):void 0},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var nb=1,ob=2,pb=4,qb=8,rb=qb,sb=16,tb=32;Y.prototype={defaults:{},set:function(a){return la(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(f(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=_(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return f(a,"dropRecognizeWith",this)?this:(a=_(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(f(a,"requireFailure",this))return this;var b=this.requireFail;return a=_(a,this),-1===r(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(f(a,"dropRequireFailure",this))return this;a=_(a,this);var b=r(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function b(b){c.manager.emit(b,a)}var c=this,d=this.state;qb>d&&b(c.options.event+Z(d)),b(c.options.event),a.additionalEvent&&b(a.additionalEvent),d>=qb&&b(c.options.event+Z(d))},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=tb)},canEmit:function(){for(var a=0;af?Ja:Ka,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?Ia:0>g?La:Ma,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return aa.prototype.attrTest.call(this,a)&&(this.state&ob||!(this.state&ob)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=$(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),i(ca,aa,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[jb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&ob)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),i(da,Y,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[hb]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,!d||!c||a.eventType&(Ga|Ha)&&!f)this.reset();else if(a.eventType&Ea)this.reset(),this._timer=e(function(){this.state=rb,this.tryEmit()},b.time,this);else if(a.eventType&Ga)return rb;return tb},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===rb&&(a&&a.eventType&Ga?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=ra(),this.manager.emit(this.options.event,this._input)))}}),i(ea,aa,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[jb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&ob)}}),i(fa,aa,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Na|Oa,pointers:1},getTouchAction:function(){return ba.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Na|Oa)?b=a.overallVelocity:c&Na?b=a.overallVelocityX:c&Oa&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&qa(b)>this.options.velocity&&a.eventType&Ga},emit:function(a){var b=$(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),i(ga,Y,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[ib]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance Date: Tue, 26 May 2020 01:06:57 +0530 Subject: [PATCH 022/112] Installer checks for needed PHP functions (#939) Closes #903. --- .../Install/Controller/InstallController.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index 8acb471f..f51de403 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -101,6 +101,53 @@ class InstallController extends AbstractController if (!in_array('mysql', \PDO::getAvailableDrivers())) { $errors++; $this->addMessage('The PDO MySQL driver needs to be installed.', 'error'); + } else { + $this->addMessage('PHP PDO MySQL driver found', 'success'); + } + if (!extension_loaded('filter')) { + $this->addMessage('PHP is installed without the filter module. Please install filter.', 'warning'); + } else { + $this->addMessage('PHP filter module found', 'success'); + } + if (!extension_loaded('ctype')) { + $this->addMessage('PHP is installed without the ctype module. Please install ctype.', 'warning'); + } else { + $this->addMessage('PHP ctype module found', 'success'); + } + if (!extension_loaded('hash')) { + $this->addMessage('PHP is installed without the hash module. Please install hash.', 'warning'); + } else { + $this->addMessage('PHP hash module found', 'success'); + } + if (!extension_loaded('json')) { + $this->addMessage('PHP is installed without the json module. Please install json.', 'warning'); + } else { + $this->addMessage('PHP json module found', 'success'); + } + if (!extension_loaded('libxml')) { + $this->addMessage('PHP is installed without the libxml module. Please install libxml.', 'warning'); + } else { + $this->addMessage('PHP libxml module found', 'success'); + } + if (!extension_loaded('openssl')) { + $this->addMessage('PHP is installed without the openssl module. Please install openssl.', 'warning'); + } else { + $this->addMessage('PHP openssl module found', 'success'); + } + if (!extension_loaded('pcre')) { + $this->addMessage('PHP is installed without the pcre module. Please install pcre.', 'warning'); + } else { + $this->addMessage('PHP pcre module found', 'success'); + } + if (!extension_loaded('sockets')) { + $this->addMessage('PHP is installed without the sockets module. Please install sockets.', 'warning'); + } else { + $this->addMessage('PHP sockets module found', 'success'); + } + if (!extension_loaded('xml')) { + $this->addMessage('PHP is installed without the xml module. Please install xml.', 'warning'); + } else { + $this->addMessage('PHP xml module found', 'success'); } if (!ini_get('date.timezone')) { $this->addMessage( From 5ecdc75dcf3c156d6694ac261a6e04df560d6134 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 May 2020 16:47:48 +0000 Subject: [PATCH 023/112] Bump phpmailer/phpmailer from 6.1.3 to 6.1.6 (#941) --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 1ffbcc76..6ce79bb8 100644 --- a/composer.lock +++ b/composer.lock @@ -160,16 +160,16 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.1.3", + "version": "v6.1.6", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "a25ae38e03de4ee4031725498a600012364787c7" + "reference": "c2796cb1cb99d7717290b48c4e6f32cb6c60b7b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/a25ae38e03de4ee4031725498a600012364787c7", - "reference": "a25ae38e03de4ee4031725498a600012364787c7", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/c2796cb1cb99d7717290b48c4e6f32cb6c60b7b3", + "reference": "c2796cb1cb99d7717290b48c4e6f32cb6c60b7b3", "shasum": "" }, "require": { @@ -218,7 +218,7 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", - "time": "2019-11-21T09:37:46+00:00" + "time": "2020-05-27T12:24:03+00:00" }, { "name": "psr/container", From 97d61a972c21b82c4bf655ddde4e9f6efb652679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Farr=C3=A9?= Date: Wed, 12 Aug 2020 15:31:09 +0200 Subject: [PATCH 024/112] Update Octopush.php (#968) Replace `urlencode` by `rawurlencode` and `XXXX` by `XXXXX` otherwise you get error 121 (see https://www.octopush-dm.com/en/errors) --- src/psm/Txtmsg/Octopush.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Txtmsg/Octopush.php b/src/psm/Txtmsg/Octopush.php index 942f91b5..5d1731d0 100644 --- a/src/psm/Txtmsg/Octopush.php +++ b/src/psm/Txtmsg/Octopush.php @@ -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( From 60955f799edde71f52faef0844e5ba62d8658e29 Mon Sep 17 00:00:00 2001 From: Alexandre ZANELLI Date: Wed, 12 Aug 2020 15:33:48 +0200 Subject: [PATCH 025/112] Adding OVH SMS Gateway. (#953) Co-authored-by: Alexandre ZANELLI --- README.rst | 1 + src/includes/functions.inc.php | 3 + src/psm/Txtmsg/OVHsms.php | 101 +++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 src/psm/Txtmsg/OVHsms.php diff --git a/README.rst b/README.rst index d72d8f95..832f23e3 100644 --- a/README.rst +++ b/README.rst @@ -61,6 +61,7 @@ The following SMS gateways are currently available: * Plivo - * Callr - * SMSAPI - +* OVH SMS PRO - diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index db077969..960c04ba 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -758,6 +758,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; diff --git a/src/psm/Txtmsg/OVHsms.php b/src/psm/Txtmsg/OVHsms.php new file mode 100644 index 00000000..709f9d19 --- /dev/null +++ b/src/psm/Txtmsg/OVHsms.php @@ -0,0 +1,101 @@ +. + * + * @package phpservermon + * @author Alexis Urien + * @Author Tim Zandbergen + * @author Ward Pieters + * @author Alexandre ZANELLI + * @copyright Copyright (c) 2016 Alexis Urien + * @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; + } +} From 14f6e491cf304995265d188ee06fc2f049d0d2fe Mon Sep 17 00:00:00 2001 From: Malte Grosse Date: Wed, 12 Aug 2020 19:27:13 +0200 Subject: [PATCH 026/112] webhook support (#951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added webhook support * Added missing upgrade lines * Removed todo * Removed linebreak * Moved webhook below Jabber * Fixed description not showing * Moved webhook below jabber * Indentation and table name fix * Bumped version * Fixed “header already sent” error Co-authored-by: TimZ99 --- src/includes/functions.inc.php | 620 +++++++++++------- src/includes/psmconfig.inc.php | 2 +- src/lang/en_US.lang.php | 40 ++ .../Config/Controller/ConfigController.php | 47 +- .../Install/Controller/InstallController.php | 2 + .../Controller/AbstractServerController.php | 1 + .../Server/Controller/LogController.php | 3 +- .../Server/Controller/ServerController.php | 8 +- .../User/Controller/ProfileController.php | 8 +- .../Module/User/Controller/UserController.php | 10 + src/psm/Util/Install/Installer.php | 45 +- src/psm/Util/Server/UpdateManager.php | 2 +- .../Util/Server/Updater/StatusNotifier.php | 58 +- .../default/module/config/config.tpl.html | 25 +- .../module/server/server/list.tpl.html | 5 +- .../module/server/server/update.tpl.html | 4 +- .../module/server/server/view.tpl.html | 15 +- .../default/module/user/profile.tpl.html | 19 +- .../default/module/user/user/update.tpl.html | 4 + 19 files changed, 651 insertions(+), 267 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 960c04ba..73128915 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -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; @@ -796,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']); @@ -836,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])) { @@ -851,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])) { @@ -866,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'); @@ -883,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 "
    ";
    @@ -898,9 +910,9 @@ namespace {
             echo "
    "; } -/** - * 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"); @@ -909,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 - */ + /** + * Encrypts the password for storage in the database + * + * @param string $key + * @param string $password + * @return string + * @author Pavel Laupe Dvorak + */ function psm_password_encrypt($key, $password) { if (empty($password)) { @@ -945,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 - */ + /** + * Decrypts password stored in the database for future use + * + * @param string $key + * @param string $encryptedString + * @return string + * @author Pavel Laupe Dvorak + */ function psm_password_decrypt($key, $encryptedString) { if (empty($encryptedString)) { @@ -960,7 +972,7 @@ namespace { } if (empty($key)) { - throw new \InvalidArgumentException('invalid_encryption_key'); + throw new \InvalidArgumentException('invalid_encryption_key'); } // using open ssl @@ -975,16 +987,16 @@ namespace { OPENSSL_RAW_DATA, $iv ); - + return $decrypted; } -/** -* Send notification to Telegram -* -* @return string -* @author Tim Zandbergen -*/ + /** + * Send notification to Telegram + * + * @return string + * @author Tim Zandbergen + */ class Telegram { private $token; @@ -994,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("
      ", "", $message); @@ -1008,8 +1022,9 @@ namespace { $message = str_replace("", "\n", $message); $message = str_replace("
      ", "\n", $message); $message = str_replace("
      ", "\n", $message); - $this->message = (string) $message; + $this->message = (string)$message; } + public function sendurl() { $con = curl_init($this->url); @@ -1020,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() { @@ -1038,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("
        ", "", $message); + $message = str_replace("
      ", "\n", $message); + $message = str_replace("
    • ", "- ", $message); + $message = str_replace("
    • ", "\n", $message); + $message = str_replace("
      ", "\n", $message); + $message = str_replace("
      ", "\n", $message); + $message = str_replace("", "", $message); + $message = str_replace("", "", $message); + $message = strip_tags($message); + $this->message = (string)$message; + } + } } diff --git a/src/includes/psmconfig.inc.php b/src/includes/psmconfig.inc.php index 601cd3c3..25d33fb8 100644 --- a/src/includes/psmconfig.inc.php +++ b/src/includes/psmconfig.inc.php @@ -30,7 +30,7 @@ /** * Current PSM version */ -define('PSM_VERSION', '3.5.2'); +define('PSM_VERSION', '3.6.0.beta1'); /** * URL to check for updates. Will not be checked if turned off on config page. diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index fc6cf710..acec4425 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -138,6 +138,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.
      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.', @@ -164,6 +171,7 @@ $sm_lang = array( 'email' => 'Email', 'sms' => 'SMS', 'pushover' => 'Pushover', + 'webhook' => 'Webhook', 'telegram' => 'Telegram', 'jabber' => 'Jabber', 'no_logs' => 'No logs', @@ -229,6 +237,8 @@ $sm_lang = array( 'send_email' => 'Send Email', 'sms' => 'SMS', 'send_sms' => 'Send SMS', + 'webhook' => 'Webhook', + 'send_webhook' => 'Send Webhook notification', 'pushover' => 'Pushover', 'send_pushover' => 'Send Pushover notification', 'telegram' => 'Telegram', @@ -268,6 +278,7 @@ $sm_lang = array( 'chart_short_time_format' => '%H:%M', 'warning_notifications_disabled_sms' => 'SMS notifications are disabled.', 'warning_notifications_disabled_email' => 'Email 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.', @@ -309,6 +320,12 @@ $sm_lang = array( 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', 'sms_from' => 'Sender\'s phone number', + '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 their website for more info.', @@ -363,17 +380,20 @@ $sm_lang = array( 'log_email' => 'Log emails sent by the script', 'log_sms' => 'Log text 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.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_pushover' => 'Pushover', + 'tab_webhook' => 'Webhook', 'tab_telegram' => 'Telegram', 'tab_jabber' => 'Jabber', 'settings_email' => 'Email settings', 'settings_sms' => 'Text message settings', 'settings_pushover' => 'Pushover settings', + 'settings_webhook' => 'Webhook settings', 'settings_telegram' => 'Telegram settings', 'settings_jabber' => 'Jabber settings', 'settings_notification' => 'Notification settings', @@ -387,6 +407,7 @@ $sm_lang = array( 'test_sms' => 'An SMS will be sent to the phone number 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', @@ -397,6 +418,10 @@ $sm_lang = array( 'sms_sent' => 'SMS sent', 'sms_error' => 'An error has occurred while sending the SMS: %s', 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your 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 @@ -424,6 +449,9 @@ $sm_lang = array( 'off_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is DOWN', 'off_email_body' => 'Failed to connect to the following server:

      Server: %LABEL%
      IP: %IP%
      Port: %PORT%
      Error: %ERROR%
      Date: %DATE%', + 'off_webhook_title' => 'Server \'%LABEL%\' is DOWN', + 'off_webhook_message' => 'Failed to connect to the following server:

      Server: %LABEL%
      IP: + %IP%
      Port: %PORT%
      Error: %ERROR%
      Date: %DATE%', 'off_pushover_title' => 'Server \'%LABEL%\' is DOWN', 'off_pushover_message' => 'Failed to connect to the following server:

      Server: %LABEL%
      IP: %IP%
      Port: %PORT%
      Error: %ERROR%
      Date: %DATE%', @@ -435,6 +463,10 @@ $sm_lang = array( 'on_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is RUNNING', 'on_email_body' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:

      Server: %LABEL%
      IP: %IP%
      Port: %PORT%
      Date: + %DATE%', + 'on_webhook_title' => 'Server \'%LABEL%\' is RUNNING', + 'on_webhook_message' => 'Server \'%LABEL%\' is running again, it was down for + %LAST_OFFLINE_DURATION%:

      Server: %LABEL%
      IP: %IP%
      Port: %PORT%
      Date: %DATE%', 'on_pushover_title' => 'Server \'%LABEL%\' is RUNNING', 'on_pushover_message' => 'Server \'%LABEL%\' is running again, it was down for @@ -447,6 +479,8 @@ $sm_lang = array( %LAST_OFFLINE_DURATION%

      Server: %LABEL%
      IP: %IP%
      Port: %PORT%
      Date: %DATE%', 'combi_off_email_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Error: + %ERROR%
      • Date: %DATE%
      ', + 'combi_off_webhook_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Error: %ERROR%
      • Date: %DATE%
      ', 'combi_off_pushover_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Error: %ERROR%
      • Date: %DATE%
      ', @@ -456,6 +490,9 @@ $sm_lang = array( Date: %DATE%

      ', 'combi_on_email_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Downtime: %LAST_OFFLINE_DURATION%
      • Date: %DATE%
      ', + 'combi_on_webhook_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: + %PORT%
      • Downtime: %LAST_OFFLINE_DURATION%
      • Date: + %DATE%
      ', 'combi_on_pushover_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Downtime: %LAST_OFFLINE_DURATION%
      • Date: %DATE%
      ', @@ -464,8 +501,11 @@ $sm_lang = array( 'combi_on_jabber_message' => '- Server: %LABEL%
      - IP: %IP%
      - Port: %PORT%
      - Downtime: %LAST_OFFLINE_DURATION%
      - Date: %DATE%

      ', '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' => 'The following servers went down:
      %DOWN_SERVERS%
      The following + servers are up again:
      %UP_SERVERS%', + 'combi_webhook_message' => 'The following servers went down:
      %DOWN_SERVERS%
      The following servers are up again:
      %UP_SERVERS%', 'combi_pushover_message' => 'The following servers went down:
      %DOWN_SERVERS%
      The following servers are up again:
      %UP_SERVERS%', diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index 7bb78e65..8cf996e3 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -44,12 +44,14 @@ class ConfigController extends AbstractController 'email_smtp', 'sms_status', 'pushover_status', + 'webhook_status', 'telegram_status', 'jabber_status', 'log_status', 'log_email', 'log_sms', 'log_pushover', + 'log_webhook', 'log_telegram', 'log_jabber', 'show_update', @@ -72,6 +74,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', @@ -208,7 +212,7 @@ class ConfigController extends AbstractController $tpl_data[$this->default_tab . '_active'] = 'active'; - $testmodals = array('email', 'sms', 'pushover', 'telegram', 'jabber'); + $testmodals = array('email', 'sms', 'pushover','webhook', 'telegram', 'jabber'); foreach ($testmodals as $modal_id) { $modal = new \psm\Util\Module\Modal( $this->twig, @@ -272,6 +276,8 @@ class ConfigController extends AbstractController $this->testSMS(); } 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'])) { @@ -291,6 +297,8 @@ class ConfigController extends AbstractController $this->default_tab = 'sms'; } 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'])) { @@ -346,6 +354,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 * @@ -445,10 +481,12 @@ class ConfigController extends AbstractController '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_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_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'), @@ -479,6 +517,12 @@ class ConfigController extends AbstractController 'label_sms_gateway_username' => psm_get_lang('config', 'sms_gateway_username'), 'label_sms_gateway_password' => psm_get_lang('config', 'sms_gateway_password'), 'label_sms_from' => psm_get_lang('config', 'sms_from'), + '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'), @@ -513,6 +557,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_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'), diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index f51de403..b1b9bc0b 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -303,6 +303,8 @@ class InstallController extends AbstractController 'level' => PSM_USER_ADMIN, 'pushover_key' => '', 'pushover_device' => '', + 'webhook_url' => '', + 'webhook_json' => '', 'telegram_id' => '', 'jabber' => '' ); diff --git a/src/psm/Module/Server/Controller/AbstractServerController.php b/src/psm/Module/Server/Controller/AbstractServerController.php index 26ed2c9d..5d191fe3 100644 --- a/src/psm/Module/Server/Controller/AbstractServerController.php +++ b/src/psm/Module/Server/Controller/AbstractServerController.php @@ -81,6 +81,7 @@ abstract class AbstractServerController extends AbstractController `s`.`active`, `s`.`email`, `s`.`sms`, + `s`.`webhook`, `s`.`pushover`, `s`.`telegram`, `s`.`jabber`, diff --git a/src/psm/Module/Server/Controller/LogController.php b/src/psm/Module/Server/Controller/LogController.php index 8046af99..05f26c0d 100644 --- a/src/psm/Module/Server/Controller/LogController.php +++ b/src/psm/Module/Server/Controller/LogController.php @@ -56,6 +56,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_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'), @@ -89,7 +90,7 @@ class LogController extends AbstractServerController ); } - $log_types = array('status', 'email', 'sms', 'pushover', 'telegram', 'jabber'); + $log_types = array('status', 'email', 'sms', 'pushover', 'webhook','telegram', 'jabber'); 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 47e24d9e..1a8ea05f 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -101,6 +101,7 @@ class ServerController extends AbstractServerController 'email' => 'icon-envelope', 'sms' => 'icon-mobile', 'pushover' => 'icon-pushover', + 'webhook' => 'icon-webhook', 'telegram' => 'icon-telegram', 'jabber' => 'icon-jabber' ); @@ -130,6 +131,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']['webhook'] = psm_get_conf('webhook_status'); $tpl_data['config']['pushover'] = psm_get_conf('pushover_status'); $tpl_data['config']['telegram'] = psm_get_conf('telegram_status'); @@ -237,13 +239,14 @@ class ServerController extends AbstractServerController 'edit_active_selected' => $edit_server['active'], 'edit_email_selected' => $edit_server['email'], 'edit_sms_selected' => $edit_server['sms'], + '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', 'pushover', 'telegram', 'jabber'); + $notifications = array('email', 'sms', 'pushover','webhook', 'telegram', 'jabber'); foreach ($notifications as $notification) { if (psm_get_conf($notification . '_status') == 0) { $tpl_data['warning_' . $notification] = true; @@ -312,6 +315,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', + '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', ); @@ -590,8 +594,10 @@ class ServerController extends AbstractServerController 'label_sms' => psm_get_lang('servers', 'sms'), 'label_send_sms' => psm_get_lang('servers', 'send_sms'), '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_webhook' => psm_get_lang('servers', 'webhook'), 'label_pushover' => psm_get_lang('servers', 'pushover'), 'label_send_telegram' => psm_get_lang('servers', 'send_telegram'), 'label_send_jabber' => psm_get_lang('servers', 'send_jabber'), diff --git a/src/psm/Module/User/Controller/ProfileController.php b/src/psm/Module/User/Controller/ProfileController.php index 47efc335..74aeec9d 100644 --- a/src/psm/Module/User/Controller/ProfileController.php +++ b/src/psm/Module/User/Controller/ProfileController.php @@ -39,7 +39,7 @@ class ProfileController extends AbstractController * @var array $profile_fields */ protected $profile_fields = - array('name', 'user_name', 'email', 'mobile', 'pushover_key', 'pushover_device', 'telegram_id', 'jabber'); + array('name', 'user_name', 'email', 'mobile', 'pushover_key', 'pushover_device','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'), diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index 1104a4d0..a648ee68 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -158,6 +158,8 @@ class UserController extends AbstractController 'name', 'user_name', 'mobile', + 'webhook_url', + 'webhook_json', 'pushover_key', 'pushover_device', 'telegram_id', @@ -255,6 +257,8 @@ class UserController extends AbstractController 'password_repeat', 'level', 'mobile', + 'webhook_url', + 'webhook_json', 'pushover_key', 'pushover_device', 'telegram_id', @@ -392,6 +396,12 @@ class UserController extends AbstractController 'label_level' => psm_get_lang('users', 'level'), 'label_level_description' => psm_get_lang('users', 'level_description'), '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'), diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index 888af309..a1476467 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -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'), ('log_retention_period', '365'), @@ -214,7 +216,9 @@ class Installer `mobile` varchar(15) 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`), @@ -235,7 +239,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','pushover','telegram', 'jabber') NOT NULL, + `type` enum('status','email','sms','pushover','webhook','telegram', 'jabber') NOT NULL, `message` TEXT NOT NULL, `datetime` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`log_id`) @@ -270,6 +274,7 @@ class Installer `email` enum('yes','no') NOT NULL default 'yes', `sms` enum('yes','no') NOT NULL default 'no', `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', @@ -357,6 +362,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); } @@ -553,7 +561,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 , @@ -659,7 +667,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. @@ -715,4 +723,27 @@ class Installer $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); + } } diff --git a/src/psm/Util/Server/UpdateManager.php b/src/psm/Util/Server/UpdateManager.php index e5429df6..2ba6ff0a 100644 --- a/src/psm/Util/Server/UpdateManager.php +++ b/src/psm/Util/Server/UpdateManager.php @@ -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} diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index 080f0fbc..263bfdf1 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -63,6 +63,12 @@ class StatusNotifier */ protected $send_pushover = false; + /** + * Send webhook notification? + * @var boolean $send_webhook + */ + protected $send_webhook = false; + /** * Send telegram? * @var boolean $send_telegram @@ -128,6 +134,7 @@ class StatusNotifier $this->send_emails = (bool)psm_get_conf('email_status'); $this->send_sms = (bool)psm_get_conf('sms_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'); @@ -149,6 +156,7 @@ class StatusNotifier if ( !$this->send_emails && !$this->send_sms && + !$this->send_webhook && !$this->send_pushover && !$this->send_telegram && !$this->send_jabber && @@ -175,6 +183,7 @@ class StatusNotifier 'error', 'email', 'sms', + 'webhook', 'pushover', 'telegram', 'jabber', @@ -245,7 +254,11 @@ class StatusNotifier // yay lets wake those nerds up! $this->notifyByTxtMsg($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! @@ -482,7 +495,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('
      ', "\n", $message); + $message = str_replace('
      ', "\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 * @@ -619,7 +673,7 @@ 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`.`pushover_key`, + SELECT `u`.`user_id`, `u`.`name`,`u`.`email`, `u`.`mobile`, `u`.`pushover_key`, `u`.`webhook_url`,`u`.`webhook_json`, `u`.`pushover_device`, `u`.`telegram_id`, `u`.`jabber` FROM `' . PSM_DB_PREFIX . 'users` AS `u` diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index 1472bc61..a9c4f6c0 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -30,7 +30,12 @@ +
    @@ -183,6 +188,24 @@ {{ macro.button_save("jabber_submit", label_save) }}
    +
    +
    + {{ label_settings_webhook }} +

    {{ label_webhook_description|raw }}

    + + {{ macro.input_checkbox("webhook_status", "webhook_status", label_webhook_status, webhook_status_checked) }} + + {{ macro.input_checkbox("log_webhook", "log_webhook", label_log_webhook, log_webhook_checked) }} + + + + + + {{ macro.button_test("testWebhook", label_test) }} + {{ macro.input_hidden("test_webhook", "0") }} + {{ macro.button_save("webhook_submit", label_save) }} +
    +
    {{ macro.input_csrf() }} diff --git a/src/templates/default/module/server/server/list.tpl.html b/src/templates/default/module/server/server/list.tpl.html index 8fd94464..c32c86b1 100644 --- a/src/templates/default/module/server/server/list.tpl.html +++ b/src/templates/default/module/server/server/list.tpl.html @@ -73,7 +73,10 @@ J - {% endif %} + {% endif %} + {% if server.webhook|lower == 'yes' and config.webhook|lower %} + + {% endif %} {% if user_level == 10 %} diff --git a/src/templates/default/module/server/server/update.tpl.html b/src/templates/default/module/server/server/update.tpl.html index 38292434..0cefdd98 100644 --- a/src/templates/default/module/server/server/update.tpl.html +++ b/src/templates/default/module/server/server/update.tpl.html @@ -143,7 +143,9 @@ {{ macro.input_select_monitoring("telegram", "telegram", label_send_telegram, edit_telegram_selected, label_yes, label_no, warning_telegram, label_warning_telegram) }} - {{ 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) }} + + {{ macro.input_select_monitoring("webhook", "webhook", label_send_webhook, edit_webhook_selected, label_yes, label_no, warning_webhook, label_warning_webhook) }}
    diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index be5906f4..154ea26c 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -347,7 +347,20 @@ {% endif %} - + +
  • + {{ label_webhook }}: + {% if webhook|lower == 'yes' %} + + + {% elseif webhook|lower == 'no' %} + + + {% else %} + + + {% endif %} +
  • diff --git a/src/templates/default/module/user/profile.tpl.html b/src/templates/default/module/user/profile.tpl.html index 93caa951..abed8ad7 100644 --- a/src/templates/default/module/user/profile.tpl.html +++ b/src/templates/default/module/user/profile.tpl.html @@ -24,9 +24,9 @@ {{ label_pushover }}

    {{ label_pushover_description|raw }}

    - {{ 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) }} - {{ 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) }}
    @@ -36,7 +36,7 @@ - {{ 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) }} {{ macro.input_hidden("activate_telegram", "0") }}
    @@ -44,7 +44,16 @@
    {{ label_jabber }} - {{ macro.input_field("text", "jabber", null, "jabber", label_jabber, jabber, label_jabber, "255", "jabber_help", jabber_description) }} -
    + {{ macro.input_field("text", "jabber", null, "jabber", label_jabber, jabber, label_jabber, "255", "jabber_help", label_jabber_description) }} + + +
    + {{ label_webhook }} +

    {{ label_webhook_description|raw }}

    + + {{ 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) }} + + {{ 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) }} +
    {{ macro.button_save(null, label_save) }} \ 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 0e86d617..bde98390 100644 --- a/src/templates/default/module/user/user/update.tpl.html +++ b/src/templates/default/module/user/user/update.tpl.html @@ -17,6 +17,10 @@ {{ macro.input_field("email", "email", null, "email", label_email, edit_value_email, null, "255") }} {{ macro.input_field("tel", "mobile", null, "mobile", label_mobile, edit_value_mobile, null, "20") }} + + {{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, edit_value_webhook_url, null, "255") }} + + {{ macro.input_field("text", "webhook_json", null, "webhook_json", label_webhook_json, edit_value_webhook_json, null, "255") }} {{ macro.input_field("text", "pushover_key", null, "pushover_key", label_pushover_key, edit_value_pushover_key, null, "255") }} From c090a398d1f0603c57e8ea814a257d9a4faba409 Mon Sep 17 00:00:00 2001 From: wienfuchs <44177781+wienfuchs@users.noreply.github.com> Date: Wed, 12 Aug 2020 21:11:50 +0200 Subject: [PATCH 027/112] change rtime to numerical to avoid DB update conflicts (#963) --- src/psm/Util/Server/Updater/StatusUpdater.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 88f31ee6..5cc42f1c 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -89,7 +89,7 @@ class StatusUpdater $this->error = ''; $this->header = ''; $this->curl_info = ''; - $this->rtime = ''; + $this->rtime = 0; // get server info from db $this->server = $this->db->selectRow(PSM_DB_PREFIX . 'servers', array( From 9fe598d774c122849a6e8570a78fa82335d888cd Mon Sep 17 00:00:00 2001 From: milux Date: Wed, 12 Aug 2020 21:23:47 +0200 Subject: [PATCH 028/112] Increased graph data processing speed (#944) --- composer.json | 1 + src/psm/Util/Server/HistoryGraph.php | 166 ++++++++++-------- .../default/module/server/history.tpl.html | 6 +- 3 files changed, 95 insertions(+), 78 deletions(-) diff --git a/composer.json b/composer.json index 88c4658d..0498c033 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "require": { "php": "^5.5.9|>=7.0.8", "ext-curl": "*", + "ext-json": "*", "ext-pdo": "*", "ext-xml": "*", "phpmailer/phpmailer": ">=6.0.6 ~6.0", diff --git a/src/psm/Util/Server/HistoryGraph.php b/src/psm/Util/Server/HistoryGraph.php index 3990f993..11425e8b 100644 --- a/src/psm/Util/Server/HistoryGraph.php +++ b/src/psm/Util/Server/HistoryGraph.php @@ -29,7 +29,10 @@ namespace psm\Util\Server; +use DateTime; use psm\Service\Database; +use Twig\Error\Error; +use Twig_Environment; /** * History util, create HTML for server graphs @@ -39,17 +42,17 @@ class HistoryGraph /** * Database service - * @var \psm\Service\Database $db; + * @var Database $db; */ protected $db; /** * Twig environment - * @var \Twig_Environment $twig + * @var Twig_Environment $twig */ protected $twig; - public function __construct(Database $db, \Twig_Environment $twig) + public function __construct(Database $db, Twig_Environment $twig) { $this->db = $db; $this->twig = $twig; @@ -57,7 +60,9 @@ class HistoryGraph /** * Prepare the HTML for the graph - * @return string + * @param string $server_id ID of server to fetch data for + * @return string Created HTML + * @throws Error On twig error */ public function createHTML($server_id) { @@ -65,9 +70,9 @@ class HistoryGraph $archive = new ArchiveManager($this->db); $archive->archive($server_id); - $now = new \DateTime(); - $last_week = new \DateTime('-1 week 0:0:0'); - $last_year = new \DateTime('-1 year -1 week 0:0:0'); + $now = new DateTime(); + $last_week = new DateTime('-1 week 0:0:0'); + $last_year = new DateTime('-1 year -1 week 0:0:0'); $graphs = array( 0 => $this->generateGraphUptime($server_id, $last_week, $now), @@ -101,8 +106,8 @@ class HistoryGraph /** * Generate data for uptime graph * @param int $server_id - * @param \DateTime $start_time Lowest DateTime of the graph - * @param \DateTime $end_time Highest DateTime of the graph + * @param DateTime $start_time Lowest DateTime of the graph + * @param DateTime $end_time Highest DateTime of the graph * @return array */ public function generateGraphUptime($server_id, $start_time, $end_time) @@ -112,9 +117,9 @@ class HistoryGraph 'latency' => array(), ); - $hour = new \DateTime('-1 hour'); - $day = new \DateTime('-1 day'); - $week = new \DateTime('-1 week'); + $hour = new DateTime('-1 hour'); + $day = new DateTime('-1 day'); + $week = new DateTime('-1 week'); $records = $this->getRecords('uptime', $server_id, $start_time, $end_time); @@ -148,8 +153,8 @@ class HistoryGraph /** * Generate data for history graph * @param int $server_id - * @param \DateTime $start_time Lowest DateTime of the graph - * @param \DateTime $end_time Highest DateTime of the graph + * @param DateTime $start_time Lowest DateTime of the graph + * @param DateTime $end_time Highest DateTime of the graph * @return array */ public function generateGraphHistory($server_id, $start_time, $end_time) @@ -160,9 +165,9 @@ class HistoryGraph 'latency_max' => array(), ); - $week = new \DateTime('-2 week 0:0:0'); - $month = new \DateTime('-1 month -1 week 0:0:0'); - $year = new \DateTime('-1 year -1 week 0:0:0'); + $week = new DateTime('-2 week 0:0:0'); + $month = new DateTime('-1 month -1 week 0:0:0'); + $year = new DateTime('-1 year -1 week 0:0:0'); $records = $this->getRecords('history', $server_id, $year, $end_time); @@ -197,8 +202,8 @@ class HistoryGraph * Get all uptime/history records for a server * @param string $type * @param int $server_id - * @param \DateTime $start_time Lowest DateTime of the graph - * @param \DateTime $end_time Highest DateTime of the graph + * @param DateTime $start_time Lowest DateTime of the graph + * @param DateTime $end_time Highest DateTime of the graph * @return array */ protected function getRecords($type, $server_id, $start_time, $end_time) @@ -207,17 +212,19 @@ class HistoryGraph return array(); } - $records = $this->db->execute( - "SELECT * + /** @noinspection SqlNoDataSourceInspection */ + /** @noinspection SqlResolve */ + /** @noinspection PhpUndefinedConstantInspection */ + return $this->db->execute( + "SELECT *, UNIX_TIMESTAMP(CONVERT_TZ(`date`, '+00:00', @@session.time_zone)) AS date_ts FROM `" . PSM_DB_PREFIX . "servers_$type` - WHERE `server_id` = :server_id AND `date` BETWEEN :start_time AND :end_time ORDER BY `date` ASC", + WHERE `server_id` = :server_id AND `date` BETWEEN :start_time AND :end_time ORDER BY `date`", array( 'server_id' => $server_id, 'start_time' => $start_time->format('Y-m-d H:i:s'), 'end_time' => $end_time->format('Y-m-d H:i:s'), ) ); - return $records; } /** @@ -225,12 +232,9 @@ class HistoryGraph * @param array $records All uptime records to parse, MUST BE SORTED BY DATE IN ASCENDING ORDER * @param array $lines Array with keys as line ids to prepare (key must be available in uptime records) * @param string $latency_avg_key which key from uptime records to use for calculating averages - * @param \DateTime $start_time Lowest DateTime of the graph - * @param \DateTime $end_time Highest DateTime of the graph + * @param DateTime $start_time Lowest DateTime of the graph + * @param DateTime $end_time Highest DateTime of the graph * @param boolean $add_uptime Add uptime calculation? - * @param array $prev Previous result - * @param int $downtime Total downtime - * @param int $prev_downtime Timestamp from last offline record. 0 when last record is uptime * @return array */ protected function generateGraphLines( @@ -241,79 +245,90 @@ class HistoryGraph $end_time, $add_uptime = false ) { - $now = new \DateTime(); + $now = new DateTime(); $data = array(); // PLEASE NOTE: all times are in microseconds! because of javascript. $latency_avg = 0; + /** @var array $prev Previous record */ $prev = reset($records); + // Timestamp from last offline record. 0 when last record is up. $prev_downtime = 0; + // Total downtime $downtime = 0; + // The keys of the lines iterated + $line_keys = array_keys($lines); + // Determine whether to process data for the short history graph + $is_short_graph = count($line_keys) === 1 && $line_keys[0] === 'latency'; + // get highest latency record for offline height - $n = count($records); - $highest_latency = 0.0000; - for ($i = 0; $i < $n; $i++) { - if (!array_key_exists('latency', $records[$i])) { - continue; + $highest_latency = 0.0; + if ($is_short_graph) { + foreach ($records as $record) { + $latency = (float) $record['latency']; + if ($latency > $highest_latency) { + $highest_latency = $latency; + } } - // Update if latency is higher - $highest_latency = $highest_latency < floatval($records[$i]['latency']) ? - floatval($records[$i]['latency']) : $highest_latency; + // to ms + $highest_latency = round($highest_latency * 1000); } - // to ms - $highest_latency = round($highest_latency * 1000); // Create the list of points and server down zones foreach ($records as $record) { - $time = strtotime($record['date']); // use the first line to calculate average latency $latency_avg += (float) $record[$latency_avg_key]; - foreach ($lines as $key => $value) { - // add the value for each of the different lines - if (isset($record[$key])) { - if (isset($record['status'])) { - // down - if ($record['status'] == 0) { - $lines['online'][] = $prev['status'] - // Previous datapoint was online - ? '{ x: ' . ($time * 1000) . ', y: ' . $prev['latency'] * 1000 . '}' - // Previous datapoint was offline - : '{ x: ' . ($time * 1000) . ', y: null}'; - // new outage start - $lines['offline'][] = '{ x: ' . ($time * 1000) . ', y:' . $highest_latency . '}'; + if ($is_short_graph) { + $time = (int) $record['date_ts']; + // Timestamp in milliseconds + $time_ms = $time * 1000; + if (!$record['status']) { + // down + $lines['online'][] = $prev['status'] + // Previous datapoint was online + ? ['x' => $time_ms, 'y' => round($prev['latency'] * 1000, 3)] + // Previous datapoint was offline + : ['x' => $time_ms, 'y' => null]; + // new outage start + $lines['offline'][] = ['x' => $time_ms, 'y' => $highest_latency]; - $prev_downtime != 0 ?: $prev_downtime = $time; - } else { - // up - // outage ends - $lines['offline'][] = $prev['status'] - // Previous datapoint was online - ? '{ x: ' . ($time * 1000) . ', y:null}' - // Previous datapoint was offline - : '{ x: ' . ($time * 1000) . ', y:' . $highest_latency . '}'; - $lines['online'][] = '{ x: ' . ($time * 1000) . ', y: ' . - round((float) $record[$key] * 1000, 2) . '}'; - - $prev_downtime == 0 ?: $downtime += ($time - $prev_downtime); - $prev_downtime = 0; - } - } else { - $lines[$key][] = '{ x: \'' . $record['date'] . '\', y: ' . $record[$key] * 1000 . '}'; + if ($prev_downtime === 0) { + $prev_downtime = $time; } - $prev = $record; + } else { + // up + // outage ends + $lines['offline'][] = $prev['status'] + // Previous datapoint was online + ? ['x' => $time_ms, 'y' => null] + // Previous datapoint was offline + : ['x' => $time_ms, 'y' => $highest_latency]; + $lines['online'][] = ['x' => $time_ms, 'y' => round($record['latency'] * 1000, 3)]; + + if ($prev_downtime !== 0) { + $downtime += ($time - $prev_downtime); + } + $prev_downtime = 0; + } + } else { + foreach ($line_keys as $key) { + // add the value for each of the different lines + $lines[$key][] = ['x' => $record['date'], 'y' => $record[$key] * 1000]; } } + $prev = $record; } // Was down before. // Record the first and last date as a string in the down array $prev_downtime == 0 ?: $downtime += ($now->getTimestamp() - $prev_downtime); if ($add_uptime) { - $prev['status'] ?: $lines['offline'][] = - '{ x: ' . ($now->getTimestamp() * 1000) . ', y:' . $highest_latency . '}'; + if (!$prev['status']) { + $lines['offline'][] = ['x' => $now->getTimestamp() * 1000, 'y' => $highest_latency]; + } $data['uptime'] = 100 - ($downtime / ($end_time->getTimestamp() - $start_time->getTimestamp())); } @@ -322,11 +337,12 @@ class HistoryGraph if (empty($line_value)) { continue; } - $lines_merged[$line_key]['value'] = implode(', ', $line_value); + $lines_merged[$line_key]['value'] = json_encode($line_value); $lines_merged[$line_key]['name'] = psm_get_lang('servers', $line_key); } - $data['latency_avg'] = count($records) > 0 ? ($latency_avg / count($records)) : 0; + $n_records = count($records); + $data['latency_avg'] = $n_records > 0 ? ($latency_avg / $n_records) : 0; $data['lines'] = sizeof($lines_merged) ? $lines_merged : ''; $data['end_timestamp'] = number_format($end_time->getTimestamp(), 0, '', '') * 1000; $data['start_timestamp'] = number_format($start_time->getTimestamp(), 0, '', '') * 1000; diff --git a/src/templates/default/module/server/history.tpl.html b/src/templates/default/module/server/history.tpl.html index 163c01d9..7c08a2b3 100644 --- a/src/templates/default/module/server/history.tpl.html +++ b/src/templates/default/module/server/history.tpl.html @@ -32,7 +32,7 @@ data: { datasets: [ { - data: [{{ graph.lines.offline.value }}], + data: {{ graph.lines.offline.value|raw }}, label: '{{ graph.lines.offline.name }}', backgroundColor: '#dc3545', borderColor: '#dc3545', @@ -43,7 +43,7 @@ spanGaps: false, }, { - data: [{{ graph.lines.online.value }}], + data: {{ graph.lines.online.value|raw }}, label: '{{graph.lines.online.name }}', fill: false, spanGaps: false, @@ -120,7 +120,7 @@ datasets: [ {% for key,line in graph.lines %} { - data: [{{ line.value|raw }}], + data: {{ line.value|raw }}, label: '{{ line.name }}', backgroundColor: colors['{{key}}'], borderColor: colors['{{key}}'], From 74b97db66f7d021bfc781906aa854a5b4d776cfc Mon Sep 17 00:00:00 2001 From: Dylan Ysmal Date: Wed, 12 Aug 2020 21:26:28 +0200 Subject: [PATCH 029/112] Add Ysmal.fr SMS gateway (#906) --- src/includes/functions.inc.php | 2 + src/psm/Txtmsg/Ysmal.php | 92 ++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/psm/Txtmsg/Ysmal.php diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 73128915..59717599 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -794,6 +794,8 @@ namespace { case 'solutionsinfini': $sms = new \psm\Txtmsg\SolutionsInfini(); break; + case 'ysmal': + $sms = new \psm\Txtmsg\Ysmal(); case 'smsapi': $sms = new \psm\Txtmsg\SMSAPI(); break; diff --git a/src/psm/Txtmsg/Ysmal.php b/src/psm/Txtmsg/Ysmal.php new file mode 100644 index 00000000..3daf956e --- /dev/null +++ b/src/psm/Txtmsg/Ysmal.php @@ -0,0 +1,92 @@ +. + * + * @package phpservermon + * @author Perri Vardy-Mason + * @author Dylan Ysmal + * @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 3.5 + **/ + +namespace psm\Txtmsg; + +class Ysmal extends Core +{ + + /** + * Send sms using the Hermes SMS API on Ysmal.fr + * @var string $message + * @var array $this->recipients + * @var string $this->password + * + * @var mixed $result + * @var array $headers + * + * @var int $success + * @var string $error + * + * @return bool|string + */ + + public function sendSMS($message) + { + $success = 1; + $error = ''; + + foreach ($this->recipients as $recipient) { + $opts['http'] = [ + 'method' => 'POST', + 'header' => "Content-Type: application/x-www-form-urlencoded\r\n" . + 'User-Agent: PHPServerMonitor (+https://phpservermonitor.org)', + 'content' => http_build_query([ + 'key' => $this->password, + 'number' => $recipient, + 'message' => $message + ]), + 'ignore_errors' => true + ]; + + $api = 'https://sms-api.ysmal.fr/'; + $ctx = stream_context_create($opts); + $res = file_get_contents($api, false, $ctx); + + $json = json_decode($res, true); + if ($json === NULL) { + $success = 0; + $error = "($recipient) json_decode_error"; + break; + } + + if ($json['status'] !== 'success') { + $success = 0; + $error = "($recipient) $json[error]"; + break; + } + } + + if ($success) { + return 1; + } + return $error; + } +} From fe9cdab4373187d9a3fff03cc274b6ce831c1d64 Mon Sep 17 00:00:00 2001 From: imsoftware Date: Wed, 12 Aug 2020 21:27:12 +0200 Subject: [PATCH 030/112] add info about updater.sh (#899) --- docs/install.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/install.rst b/docs/install.rst index 66165614..771b7edb 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -50,6 +50,8 @@ For a regular upgrade, follow these steps: * Follow the steps * Enjoy +Alternatively you can use updater.sh script. + From 2.0 -------- From d0f5d18fc4799eb4d53f8aaf4343a0307adde433 Mon Sep 17 00:00:00 2001 From: Daniel Krusky <11585632+dkrusky@users.noreply.github.com> Date: Wed, 12 Aug 2020 15:33:44 -0400 Subject: [PATCH 031/112] Added support for Discord using Webhooks (#971) * Added support for Discord using Webhooks * Bumped version * Fixed broken upgrade * Moved discord below Jabber * Fixed broken comment * Added missing translation * Updated version * Typo * Moved Discord under Jabber * Fixed icons * Moved Webhook and discord after Jabber Co-authored-by: Tim --- README.rst | 4 +- docs/conf.py | 4 +- docs/credits.rst | 6 +- src/includes/psmconfig.inc.php | 2 +- src/lang/en_US.lang.php | 133 ++++++++---------- .../Config/Controller/ConfigController.php | 70 ++++++++- .../Controller/AbstractServerController.php | 1 + .../Server/Controller/LogController.php | 5 +- .../Server/Controller/ServerController.php | 15 +- .../User/Controller/ProfileController.php | 6 +- .../Module/User/Controller/UserController.php | 4 + src/psm/Util/Install/Installer.php | 38 +++-- .../Util/Server/Updater/StatusNotifier.php | 99 ++++++++++++- src/templates/default/main/body.tpl.html | 3 +- .../default/module/config/config.tpl.html | 19 ++- .../module/server/server/list.tpl.html | 19 +-- .../module/server/server/update.tpl.html | 2 + .../module/server/server/view.tpl.html | 13 ++ .../default/module/user/profile.tpl.html | 9 +- .../default/module/user/user/update.tpl.html | 2 + 20 files changed, 336 insertions(+), 118 deletions(-) diff --git a/README.rst b/README.rst index 832f23e3..26e51041 100644 --- a/README.rst +++ b/README.rst @@ -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.2 +Version 3.6.0.beta2 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, @@ -16,7 +16,7 @@ Features: --------- * Monitor services and websites (see below). -* Email, SMS, Pushover, Telegram and Jabber notifications. +* Email, SMS, Discord, Pushover, Telegram and Jabber notifications. * View history graphs of uptime and latency. * User authentication with 2 levels (administrator and regular user). * Logs of connection errors, outgoing emails and text messages. diff --git a/docs/conf.py b/docs/conf.py index 13b77a40..826a5acf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,9 +51,9 @@ copyright = u'2008-2017, Pepijn Over' # built documents. # # The short X.Y version. -version = '3.5' +version = '3.6' # The full version, including alpha/beta/rc tags. -release = '3.5.2' +release = '3.6.0.beta2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/credits.rst b/docs/credits.rst index e1c89471..83ee5bf7 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -89,6 +89,10 @@ The following people have contributed to the development of PHP Server Monitor: * SMSAPI gateway +* Daniel Krusky - https://github.com/dkrusky + + * Discord webhook support + Translators +++++++++++ @@ -196,4 +200,4 @@ The following libraries are being used by PHP Server Monitor: * PHP-Pushover - https://github.com/kryap/php-pushover * Symfony - https://symfony.com * Random_compat - https://github.com/paragonie/random_compat -* Hammer.js - https://github.com/hammerjs/hammer.js \ No newline at end of file +* Hammer.js - https://github.com/hammerjs/hammer.js diff --git a/src/includes/psmconfig.inc.php b/src/includes/psmconfig.inc.php index 25d33fb8..862ccda4 100644 --- a/src/includes/psmconfig.inc.php +++ b/src/includes/psmconfig.inc.php @@ -30,7 +30,7 @@ /** * Current PSM version */ -define('PSM_VERSION', '3.6.0.beta1'); +define('PSM_VERSION', '3.6.0.beta2'); /** * URL to check for updates. Will not be checked if turned off on config page. diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index acec4425..e6c412e7 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -50,9 +50,7 @@ $sm_lang = array( 'no' => 'No', 'insert' => 'Insert', 'add_new' => 'Add new', - 'update_available' => 'A new version ({version}) is available. Click here to download the update.', + 'update_available' => 'A new version ({version}) is available. Click here to download the update.', 'back_to_top' => 'Back to top', 'go_back' => 'Go back', 'ok' => 'OK', @@ -108,31 +106,25 @@ $sm_lang = array( 'level' => 'Level', 'level_10' => 'Administrator', 'level_20' => 'User', - 'level_description' => 'Administrators have full access: they can manage servers, users and edit the - global configuration.
    Users can only view and run the updater for the - servers that have been assigned to them.', + 'level_description' => 'Administrators have full access: they can manage servers, users and edit the global configuration.
    Users can only view and run the updater for the servers that have been assigned to them.', 'mobile' => 'Mobile', 'email' => 'Email', 'pushover' => 'Pushover', - 'pushover_description' => 'Pushover is a service that makes it easy to get real-time notifications. See their website for more info.', + 'pushover_description' => 'Pushover is a service that makes it easy to get real-time notifications. See their website for more info.', 'pushover_key' => 'Pushover Key', 'pushover_device' => 'Pushover Device', 'pushover_device_description' => 'Device name to send the message to. Leave empty to send it to all devices.', + 'discord' => 'Discord', + 'discord_label' => 'Discord', + 'discord_description' => 'Put your webhook here.', 'telegram' => 'Telegram', - 'telegram_description' => 'Telegram is a chat app that - makes it easy to get real-time notifications. Visit the documentation for more - info and an install guide.', + 'telegram_description' => 'Telegram is a chat app that makes it easy to get real-time notifications. Visit the documentation for more info and an install guide.', 'telegram_chat_id' => 'Telegram chat id', 'telegram_chat_id_description' => 'The message will be send to the corresponding chat.', 'telegram_get_chat_id' => 'Click here to get your chat id', 'activate_telegram' => 'Activate Telegram notifications', - 'activate_telegram_description' => 'Allow Telegram notifications to be sent to the specified chat id. Without - this permission, Telegram doesn\'t allow us to send notifications to you.', - 'telegram_bot_username_found' => 'The bot was found!

    This will open a chat - with the bot. Here you need to press start or type /start.', + 'activate_telegram_description' => 'Allow Telegram notifications to be sent to the specified chat id. Without this permission, Telegram doesn\'t allow us to send notifications to you.', + 'telegram_bot_username_found' => 'The bot was found!

    This will open a chat with the bot. Here you need to press start or type /start.', 'telegram_bot_username_error_token' => '401 - Unauthorized. Please make sure that the API token is valid.', 'telegram_bot_error' => 'An error has occurred while activating Telegram notification: %s', 'jabber' => 'Jabber', @@ -153,8 +145,7 @@ $sm_lang = array( 'profile' => 'Profile', 'profile_updated' => 'Your profile has been updated.', 'error_user_name_bad_length' => 'Usernames must be between 2 and 64 characters.', - 'error_user_name_invalid' => 'The username may only contain alphabetic characters (a-z, A-Z), digits (0-9), - dots (.) and underscores (_).', + 'error_user_name_invalid' => 'The username may only contain alphabetic characters (a-z, A-Z), digits (0-9), dots (.) and underscores (_).', 'error_user_name_exists' => 'The given username already exists in the database.', 'error_user_email_bad_length' => 'Email addresses must be between 5 and 255 characters.', 'error_user_email_invalid' => 'The email address is invalid.', @@ -170,6 +161,7 @@ $sm_lang = array( 'status' => 'Status', 'email' => 'Email', 'sms' => 'SMS', + 'discord' => 'Discord', 'pushover' => 'Pushover', 'webhook' => 'Webhook', 'telegram' => 'Telegram', @@ -209,17 +201,13 @@ $sm_lang = array( 'type_service' => 'Service', 'type_ping' => 'Ping', 'pattern' => 'Search string/pattern', - 'pattern_description' => 'If this pattern is not found on the website, the server will be marked - online/offline. Regular expressions are allowed.', + 'pattern_description' => 'If this pattern is not found on the website, the server will be marked online/offline. Regular expressions are allowed.', 'pattern_online' => 'Pattern indicates website is', - 'pattern_online_description' => 'Online: If this pattern was found on the website, the server will be marked - online. Offline: If this pattern was not found on the website, the server - will be marked offline.', + 'pattern_online_description' => 'Online: If this pattern was found on the website, the server will be marked online. Offline: If this pattern was not found on the website, the server will be marked offline.', 'redirect_check' => 'Redirecting to another domain is', 'redirect_check_description' => 'Redirect to another domain is usually a bad sign.', 'allow_http_status' => 'Allow HTTP status code', - 'allow_http_status_description' => 'Mark website as online. HTTP Status codes lower then 400 are marked as - online by default. Seperate with |.', + 'allow_http_status_description' => 'Mark website as online. HTTP Status codes lower then 400 are marked as online by default. Seperate with |.', 'header_name' => 'Header name', 'header_value' => 'Header value', 'header_name_description' => 'Case-sensitive.', @@ -237,6 +225,8 @@ $sm_lang = array( 'send_email' => 'Send Email', 'sms' => 'SMS', 'send_sms' => 'Send SMS', + 'discord' => 'Discord', + 'send_discord' => 'Send Discord notification', 'webhook' => 'Webhook', 'send_webhook' => 'Send Webhook notification', 'pushover' => 'Pushover', @@ -266,8 +256,7 @@ $sm_lang = array( 'warning_threshold' => 'Warning threshold', 'warning_threshold_description' => 'Number of failed checks required before it is marked offline.', 'ssl_cert_expiry_days' => 'SSL Certificate Validity', - 'ssl_cert_expiry_days_description' => 'The minimum remaining days the SSL certificate is still valid. Use 0 to - disable check.', + 'ssl_cert_expiry_days_description' => 'The minimum remaining days the SSL certificate is still valid. Use 0 to disable check.', 'ssl_cert_expired' => 'SSL certificate expired since', 'ssl_cert_expiring' => 'SSL certificate expiring:', 'chart_last_week' => 'Last week', @@ -278,6 +267,7 @@ $sm_lang = array( 'chart_short_time_format' => '%H:%M', '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.', @@ -289,8 +279,7 @@ $sm_lang = array( 'error_server_ip_bad_website' => 'The website URL is not valid.', 'error_server_type_invalid' => 'The selected server type is invalid.', 'error_server_warning_threshold_invalid' => 'The warning threshold must be a valid integer greater than 0.', - 'error_server_ssl_cert_expiry_days' => 'The remaining days for SSL certificate validity must be a valid - integer greater than or equal to 0.', + 'error_server_ssl_cert_expiry_days' => 'The remaining days for SSL certificate validity must be a valid integer greater than or equal to 0.', ), 'config' => array( 'general' => 'General', @@ -298,8 +287,7 @@ $sm_lang = array( 'language' => 'Language', 'show_update' => 'Check for updates?', 'password_encrypt_key' => 'The encryption key password', - 'password_encrypt_key_note' => 'This key is used to encrypt passwords that are stored on servers for access to - websites. If the key will change the stored password is invalid!', + 'password_encrypt_key_note' => 'This key is used to encrypt passwords that are stored on servers for access to websites. If the key will change the stored password is invalid!', 'proxy' => 'Enable proxy', 'proxy_url' => 'Proxy URL', 'proxy_user' => 'Proxy username', @@ -320,6 +308,8 @@ $sm_lang = array( 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', 'sms_from' => 'Sender\'s phone number', + 'discord_status' => 'Allow sending Discord messages', + 'discord_description' => 'Discord is a service that makes it easy to get real-time notifications. See their website for more info.', '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', @@ -327,26 +317,16 @@ $sm_lang = array( '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 their website for more info.', + 'pushover_description' => 'Pushover is a service that makes it easy to get real-time notifications. See their website for more info.', 'pushover_clone_app' => 'Click here to create your Pushover app', 'pushover_api_token' => 'Pushover App API Token', - 'pushover_api_token_description' => 'Before you can use Pushover, you need to register an App at their website and enter the App API - Token here.', + 'pushover_api_token_description' => 'Before you can use Pushover, you need to register an App at their website and enter the App API Token here.', 'telegram_status' => 'Allow sending Telegram messages', - 'telegram_description' => 'Telegram is a chat app that - makes it easy to get real-time notifications. Visit the documentation for more - info and an install guide.', + 'telegram_description' => 'Telegram is a chat app that makes it easy to get real-time notifications. Visit the documentation for more info and an install guide.', 'telegram_api_token' => 'Telegram API Token', - 'telegram_api_token_description' => 'Before you can use Telegram, you need to get a API token. Visit the documentation for help.', + 'telegram_api_token_description' => 'Before you can use Telegram, you need to get a API token. Visit the documentation for help.', 'jabber_status' => 'Allow sending Jabber (XMPP) messages', - 'jabber_description' => 'Visit the documentation for more info and an - install guide.', + 'jabber_description' => 'Visit the documentation for more info and an install guide.', 'jabber_host' => 'Host', 'jabber_host_description' => 'Host of your Jabber account provider. For Google Account use talk.google.com.', 'jabber_port' => 'Port', @@ -359,26 +339,19 @@ $sm_lang = array( 'jabber_password_description' => 'Fill only to set or change.', 'jabber_check' => 'Check your Jabber account if message was received.', 'alert_type' => 'Select when you\'d like to be notified.', - 'alert_type_description' => 'Status change: You will receive a notification when a server has a change - in status. So from online -> offline or offline -> online.

    Offline: - You will receive a notification when a server goes offline for the *FIRST TIME - ONLY*. For example, your cronjob is every 15 minutes and your server goes down at - 1 am and stays down till 6 am. You will get 1 notification at 1 am and that\'s - it.

    Always: You will receive a notification every time the script - runs and a site is down, even if the site has been offline for hours.', + 'alert_type_description' => 'Status change: You will receive a notification when a server has a change in status. So from online -> offline or offline -> online.

    Offline: You will receive a notification when a server goes offline for the *FIRST TIME ONLY*. For example, your cronjob is every 15 minutes and your server goes down at 1 am and stays down till 6 am. You will get 1 notification at 1 am and that\'s it.

    Always: You will receive a notification every time the script runs and a site is down, even if the site has been offline for hours.', 'alert_type_status' => 'Status change', 'alert_type_offline' => 'Offline', 'alert_type_always' => 'Always', 'combine_notifications' => 'Combine notifications', - 'combine_notifications_description' => 'Reduces the amount of notification by combining the notifications into - 1 single notification. (This does not affect SMS notifications.)', + 'combine_notifications_description' => 'Reduces the amount of notification by combining the notifications into 1 single notification. (This does not affect SMS notifications.)', 'alert_proxy' => 'Even if enabled, proxy is never used for services', 'alert_proxy_url' => 'Format: host:port', 'log_status' => 'Log status', - 'log_status_description' => 'If log status is set to TRUE, the monitor will log the event whenever the - notification settings are passed.', + 'log_status_description' => 'If log status is set to TRUE, the monitor will log the event whenever the notification settings are passed.', 'log_email' => 'Log emails sent by the script', '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', @@ -386,12 +359,14 @@ $sm_lang = array( 'updated' => 'The configuration has been updated.', 'tab_email' => 'Email', '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', @@ -400,11 +375,12 @@ $sm_lang = array( 'settings_log' => 'Log settings', 'settings_proxy' => 'Proxy settings', 'auto_refresh' => 'Auto-refresh', - 'auto_refresh_description' => 'Auto-refresh servers page.
    Time in seconds, if 0 the - page won\'t refresh.', + 'auto_refresh_description' => 'Auto-refresh servers page.
    Time in seconds, if 0 the page won\'t refresh.', 'test' => 'Test', 'test_email' => 'An email will be sent to the address specified in your user profile.', '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.', @@ -418,28 +394,27 @@ $sm_lang = array( 'sms_sent' => 'SMS sent', 'sms_error' => 'An error has occurred while sending the SMS: %s', 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', + '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.', + 'pushover_error_noapp' => 'Unable to send test notification: no Pushover App API token found in the global configuration.', 'pushover_error_nokey' => 'Unable to send test notification: no Pushover key found in your profile.', 'telegram_sent' => 'Telegram notification sent', 'telegram_error' => 'An error has occurred while sending the Telegram notification: %s', - 'telegram_error_notoken' => 'Unable to send test notification: no Telegram API token found in the global - configuration.', + 'telegram_error_notoken' => 'Unable to send test notification: no Telegram API token found in the global configuration.', 'telegram_error_noid' => 'Unable to send test notification: no chat id found in your profile.', 'jabber_sent' => 'Telegram notification sent', 'jabber_error' => 'An error has occurred while sending the Telegram notification: %s', - 'jabber_error_noconfig' => 'Unable to send test notification: no Jabber account set in the global - configuration.', + 'jabber_error_noconfig' => 'Unable to send test notification: no Jabber account set in the global configuration.', 'jabber_error_noaccount' => 'Unable to send test notification: no Jabber account found in your profile.', 'log_retention_period' => 'Log retention period', - 'log_retention_period_description' => 'Number of days to keep logs of notifications and archives of server - uptime. Enter 0 to disable log cleanup.', + 'log_retention_period_description' => 'Number of days to keep logs of notifications and archives of server uptime. Enter 0 to disable log cleanup.', 'log_retention_days' => 'days', 'user_agent' => 'User Agent', 'user_agent_key_note' => 'Custom user agent used by monitor within communication with external services.', @@ -447,23 +422,24 @@ $sm_lang = array( 'notifications' => array( 'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%', 'off_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is DOWN', + 'off_email_body' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', + 'off_discord_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', 'off_email_body' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', 'off_webhook_title' => 'Server \'%LABEL%\' is DOWN', 'off_webhook_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', 'off_pushover_title' => 'Server \'%LABEL%\' is DOWN', - 'off_pushover_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: - %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', - 'off_telegram_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: - %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', - 'off_jabber_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: - %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', + 'off_pushover_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', + 'off_telegram_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    Date: %DATE%', + 'off_jabber_message' => 'Failed to connect to the following server:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Error: %ERROR%
    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%:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Date: %DATE%', + 'on_discord_message' => 'Server \'%LABEL%\' is running again, it was down for: + %LAST_OFFLINE_DURATION%

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Date: %DATE%', 'on_webhook_title' => 'Server \'%LABEL%\' is RUNNING', 'on_webhook_message' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Date: @@ -480,6 +456,8 @@ $sm_lang = array( %DATE%', 'combi_off_email_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Error: %ERROR%
    • Date: %DATE%
    ', + 'combi_off_discord_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Error: %ERROR%
    - + Date: %DATE%

    ', 'combi_off_webhook_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Error: %ERROR%
    • Date: %DATE%
    ', 'combi_off_pushover_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Error: @@ -493,6 +471,8 @@ $sm_lang = array( 'combi_on_webhook_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Downtime: %LAST_OFFLINE_DURATION%
      • Date: %DATE%
      ', + 'combi_on_discord_message' => '- Server: %LABEL%
      - IP: %IP%
      - Port: %PORT%
      - + Downtime: %LAST_OFFLINE_DURATION%
      - Date: %DATE%

      ', 'combi_on_pushover_message' => '
      • Server: %LABEL%
      • IP: %IP%
      • Port: %PORT%
      • Downtime: %LAST_OFFLINE_DURATION%
      • Date: %DATE%
      ', @@ -504,6 +484,8 @@ $sm_lang = array( 'combi_webhook_subject' => '\'%UP%\' servers UP again, \'%DOWN%\' servers DOWN', 'combi_pushover_subject' => '\'%UP%\' servers UP again, \'%DOWN%\' servers DOWN', 'combi_email_message' => 'The following servers went down:
      %DOWN_SERVERS%
      The following + servers are up again:
      %UP_SERVERS%', + 'combi_discord_message' => 'The following servers went down:
      %DOWN_SERVERS%
      The following servers are up again:
      %UP_SERVERS%', 'combi_webhook_message' => 'The following servers went down:
      %DOWN_SERVERS%
      The following servers are up again:
      %UP_SERVERS%', @@ -529,8 +511,7 @@ $sm_lang = array( 'password_forgot' => 'Forgot password?', 'password_reset' => 'Reset password', 'password_reset_email_subject' => 'Reset your password for PHP Server Monitor', - 'password_reset_email_body' => 'Please use the following link to reset your password. Please note it expires - in 1 hour.

      %link%', + 'password_reset_email_body' => 'Please use the following link to reset your password. Please note it expires in 1 hour.

      %link%', 'error_user_incorrect' => 'The provided username could not be found.', 'error_login_incorrect' => 'The information is incorrect.', 'error_login_passwords_nomatch' => 'The provided passwords do not match.', diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index 8cf996e3..df524c4d 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -43,6 +43,7 @@ class ConfigController extends AbstractController 'email_status', 'email_smtp', 'sms_status', + 'discord_status', 'pushover_status', 'webhook_status', 'telegram_status', @@ -50,6 +51,7 @@ class ConfigController extends AbstractController 'log_status', 'log_email', 'log_sms', + 'log_discord', 'log_pushover', 'log_webhook', 'log_telegram', @@ -212,7 +214,8 @@ class ConfigController extends AbstractController $tpl_data[$this->default_tab . '_active'] = 'active'; - $testmodals = array('email', 'sms', 'pushover','webhook', 'telegram', 'jabber'); + $testmodals = array('email', 'sms', 'discord', 'webhook', 'pushover', 'telegram', 'jabber'); + foreach ($testmodals as $modal_id) { $modal = new \psm\Util\Module\Modal( $this->twig, @@ -274,6 +277,8 @@ class ConfigController extends AbstractController $this->testEmail(); } elseif (!empty($_POST['test_sms'])) { $this->testSMS(); + } elseif (!empty($_POST['test_discord'])) { + $this->testDiscord(); } elseif (!empty($_POST['test_pushover'])) { $this->testPushover(); }elseif (!empty($_POST['test_webhook'])) { @@ -295,6 +300,8 @@ class ConfigController extends AbstractController $this->default_tab = 'email'; } elseif (isset($_POST['sms_submit']) || !empty($_POST['test_sms'])) { $this->default_tab = 'sms'; + } elseif (isset($_POST['discord_submit']) || !empty($_POST['test_discord'])) { + $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'])) { @@ -355,7 +362,60 @@ class ConfigController extends AbstractController } /** - * Execute webhook test + * Execute Discord test + * + * @todo move test to separate class + */ + protected function testDiscord() + { + $user = $this->getUser()->getUser(); + if (empty($user->discord)) { + $this->addMessage(psm_get_lang('config', 'discord_error_nowebhook'), 'error'); + } else { + $success = 0; + $result = 'An unknown error has occurred.'; + try { + $curl = curl_init($user->discord); + $json = json_decode( + '{"content":""}', + true + ); + $json['content'] = psm_get_lang('config', 'test_message'); + $msg = "payload_json=" . urlencode(json_encode($json)); + if(isset($curl)) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($curl, CURLOPT_TIMEOUT, 30); + curl_setopt($curl, CURLOPT_POSTFIELDS, $msg); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $err = curl_errno($curl); + + if ($err != 0 || $httpcode != 204) { + $success = 0; + // $result = ($result == '') ? 'Wrong input, please check if all values are correct!' : $result; + $error = "HTTP_code: " . $httpcode . ".\ncURL error (" . $err . "): " . + curl_strerror($err) . ". \nResult: " . $result; + $result = $error; + } else { + $success = 1; + } + curl_close($curl); + } + } catch (Exception $e) { + $success = 0; + $result = $e->getMessage(); + } + + if ($success === 1) { + $this->addMessage(psm_get_lang('config', 'discord_sent'), 'success'); + } else { + $this->addMessage(sprintf(psm_get_lang('config', 'discord_error'), $result), 'error'); + } + } + } + + /** Execute webhook test * * @todo move test to separate class */ @@ -382,6 +442,7 @@ class ConfigController extends AbstractController } } } + /** * Execute pushover test * @@ -480,12 +541,14 @@ class ConfigController extends AbstractController return array( 'label_tab_email' => psm_get_lang('config', 'tab_email'), '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'), @@ -517,6 +580,8 @@ class ConfigController extends AbstractController 'label_sms_gateway_username' => psm_get_lang('config', 'sms_gateway_username'), 'label_sms_gateway_password' => psm_get_lang('config', 'sms_gateway_password'), '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'), @@ -556,6 +621,7 @@ class ConfigController extends AbstractController 'label_log_status_description' => psm_get_lang('config', 'log_status_description'), 'label_log_email' => psm_get_lang('config', 'log_email'), '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'), diff --git a/src/psm/Module/Server/Controller/AbstractServerController.php b/src/psm/Module/Server/Controller/AbstractServerController.php index 5d191fe3..8ae2968c 100644 --- a/src/psm/Module/Server/Controller/AbstractServerController.php +++ b/src/psm/Module/Server/Controller/AbstractServerController.php @@ -81,6 +81,7 @@ abstract class AbstractServerController extends AbstractController `s`.`active`, `s`.`email`, `s`.`sms`, + `s`.`discord`, `s`.`webhook`, `s`.`pushover`, `s`.`telegram`, diff --git a/src/psm/Module/Server/Controller/LogController.php b/src/psm/Module/Server/Controller/LogController.php index 05f26c0d..39817695 100644 --- a/src/psm/Module/Server/Controller/LogController.php +++ b/src/psm/Module/Server/Controller/LogController.php @@ -55,6 +55,7 @@ class LogController extends AbstractServerController 'label_status' => psm_get_lang('log', 'status'), 'label_email' => psm_get_lang('log', 'email'), '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'), @@ -78,7 +79,7 @@ class LogController extends AbstractServerController $modal->setTitle(psm_get_lang('log', 'delete_title')); $modal->setMessage(psm_get_lang('log', 'delete_message')); $modal->setOKButtonLabel(psm_get_lang('system', 'delete')); - + $sidebar->addButton( 'clear_logn', psm_get_lang('log', 'clear'), @@ -90,7 +91,7 @@ class LogController extends AbstractServerController ); } - $log_types = array('status', 'email', 'sms', 'pushover', 'webhook','telegram', 'jabber'); + $log_types = array('status', 'email', 'sms', 'pushover', 'telegram', 'jabber', 'discord', 'webhook'); 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 1a8ea05f..cb08e5fc 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -100,6 +100,7 @@ class ServerController extends AbstractServerController $icons = array( 'email' => 'icon-envelope', 'sms' => 'icon-mobile', + 'discord' => 'icon-discord', 'pushover' => 'icon-pushover', 'webhook' => 'icon-webhook', 'telegram' => 'icon-telegram', @@ -131,6 +132,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'); @@ -239,6 +241,7 @@ class ServerController extends AbstractServerController 'edit_active_selected' => $edit_server['active'], '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'], @@ -246,7 +249,7 @@ class ServerController extends AbstractServerController )); } - $notifications = array('email', 'sms', 'pushover','webhook', '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; @@ -274,7 +277,7 @@ class ServerController extends AbstractServerController // We need the server id to encrypt the password. Encryption will be done after the server is added $encrypted_password = ''; - + if (!empty($_POST['website_password'])) { $new_password = psm_POST('website_password'); @@ -314,6 +317,7 @@ class ServerController extends AbstractServerController 'active' => in_array($_POST['active'], array('yes', 'no')) ? $_POST['active'] : 'no', 'email' => in_array($_POST['email'], array('yes', 'no')) ? $_POST['email'] : 'no', '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', @@ -593,14 +597,17 @@ class ServerController extends AbstractServerController 'label_send_email' => psm_get_lang('servers', 'send_email'), 'label_sms' => psm_get_lang('servers', 'sms'), 'label_send_sms' => psm_get_lang('servers', 'send_sms'), + 'label_discord' => psm_get_lang('servers', 'discord'), + '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_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_send_jabber' => psm_get_lang('servers', 'send_jabber'), '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 74aeec9d..6b9b0cf1 100644 --- a/src/psm/Module/User/Controller/ProfileController.php +++ b/src/psm/Module/User/Controller/ProfileController.php @@ -39,7 +39,7 @@ class ProfileController extends AbstractController * @var array $profile_fields */ protected $profile_fields = - array('name', 'user_name', 'email', 'mobile', 'pushover_key', 'pushover_device','webhook_url', 'webhook_json', '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) { @@ -89,6 +89,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_discord' => psm_get_lang('users', 'discord'), + 'label_discord_description' => psm_get_lang('users', 'discord_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'), diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index a648ee68..91f0e423 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -158,6 +158,7 @@ class UserController extends AbstractController 'name', 'user_name', 'mobile', + 'discord', 'webhook_url', 'webhook_json', 'pushover_key', @@ -257,6 +258,7 @@ class UserController extends AbstractController 'password_repeat', 'level', 'mobile', + 'discord', 'webhook_url', 'webhook_json', 'pushover_key', @@ -396,6 +398,8 @@ class UserController extends AbstractController 'label_level' => psm_get_lang('users', 'level'), 'label_level_description' => psm_get_lang('users', 'level_description'), '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'), diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index a1476467..fa011771 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -180,6 +180,8 @@ class Installer ('log_webhook', '1'), ('log_telegram', '1'), ('log_jabber', '1'), + ('discord_status', '0'), + ('log_jdiscord', '1'), ('log_retention_period', '365'), ('version', '" . PSM_VERSION . "'), ('version_update_check', '" . PSM_VERSION . "'), @@ -187,7 +189,7 @@ class Installer ('show_update', '1'), ('last_update_check', '0'), ('cron_running', '0'), - ('cron_running_time', '0'), + ('cron_running_time', '0'), ('cron_off_running', '0'), ('cron_off_running_time', '0');"; $this->execSQL($queries); @@ -214,6 +216,7 @@ class Installer `level` tinyint(2) unsigned NOT NULL DEFAULT '20', `name` varchar(255) NOT NULL, `mobile` varchar(15) NOT NULL, + `discord` varchar(255) NOT NULL, `pushover_key` varchar(255) NOT NULL, `pushover_device` varchar(255) NOT NULL, `webhook_url` varchar(255) NOT NULL, @@ -239,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','pushover','webhook','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`) @@ -273,6 +276,7 @@ class Installer `active` enum('yes','no') NOT NULL default 'yes', `email` enum('yes','no') NOT NULL default 'yes', `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', @@ -705,9 +709,9 @@ class Installer $this->log('SMTP password is now encrypted.'); } - $queries[] = 'ALTER TABLE `' . PSM_DB_PREFIX . 'users` ADD `jabber` VARCHAR( 255 ) + $queries[] = 'ALTER TABLE `' . PSM_DB_PREFIX . 'users` ADD `jabber` VARCHAR( 255 ) NOT NULL AFTER `telegram_id`;'; - $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `jabber` ENUM( 'yes','no' ) + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `jabber` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `telegram`;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `type` `type` ENUM( 'status', 'email', 'sms', 'pushover', 'telegram', 'jabber' ) @@ -725,25 +729,31 @@ class Installer } /** - * Upgrade for v3.6.0 release + * Patch for v3.6.0 release + * Added support for Discord and webhooks */ 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') + $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','discord','webhook','pushover','telegram','jabber') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"; - $queries[] = "ALTER TABLE `' . PSM_DB_PREFIX . 'servers` + $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 + $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE + ('discord_status', '0'), + ('log_discord', '1'), ('webhook_status', '0'), ('log_webhook', '1')"; - + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` + ADD `discord` VARCHAR( 255 ) NOT NULL AFTER `mobile`;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` + ADD `discord` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `sms`;"; $this->execSQL($queries); } } diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index 263bfdf1..dd145db7 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -57,6 +57,12 @@ class StatusNotifier */ protected $send_sms = false; + /** + * Send Discord notification? + * @var boolean $send_discord + */ + protected $send_discord = false; + /** * Send Pushover notification? * @var boolean $send_pushover @@ -134,6 +140,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'); @@ -156,6 +163,7 @@ class StatusNotifier if ( !$this->send_emails && !$this->send_sms && + !$this->send_discord && !$this->send_webhook && !$this->send_pushover && !$this->send_telegram && @@ -183,6 +191,7 @@ class StatusNotifier 'error', 'email', 'sms', + 'discord', 'webhook', 'pushover', 'telegram', @@ -254,11 +263,19 @@ class StatusNotifier // yay lets wake those nerds up! $this->notifyByTxtMsg($users); } + + // check if discord is enabled for this server + if ($this->send_discord && $this->server['discord'] == 'yes') { + // yay lets wake those nerds up! + $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! @@ -430,6 +447,86 @@ class StatusNotifier } } + + /** + * This functions performs the discord notifications + * + * @param \PDOStatement $users + * @param array $combi contains message and subject (optional) + * @return void + */ + protected function notifyByDiscord($users, $combi = array()) + { + + $message_log = key_exists('message', $combi) ? + $combi['message'] : + psm_parse_msg($this->status_new, 'discord_message', $this->server); + + + // Remove users that have no Discord webhook + foreach ($users as $k => $user) { + if (trim($user['discord']) == '') { + unset($users[$k]); + } + } + + // Validation + if (empty($users)) { + return; + } + + // fix message for Discord viewing + $message = str_replace(array('', ''), array('**', '**'), $message_log); + $message = str_replace(array('
        ', '
      '), array('', ''), $message); + $message = str_replace(array('
      ', '
    • '), array("\n", "\n"), $message); + $message = str_replace('
    • ', " * ", $message); + + + $json = json_decode( + '{"content":""}', + true + ); + $json['content'] = $message; + + // Log + if (psm_get_conf('log_discord')) { + $log_id = psm_add_log($this->server_id, 'discord', $message_log); + } + + foreach ($users as $user) { + // Log + if (!empty($log_id)) { + psm_add_log_user($log_id, $user['user_id']); + } + + // set discord webhook and send + try { + $msg = "payload_json=" . urlencode(json_encode($json)); + $curl = curl_init(trim($user['discord'])); + if(isset($curl)) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($curl, CURLOPT_TIMEOUT, 30); + curl_setopt($curl, CURLOPT_POSTFIELDS, $msg); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $err = curl_errno($curl); + + if ($err != 0 || $httpcode != 204) { + // $result = ($result == '') ? 'Wrong input, please check if all values are correct!' : $result; + $error = "HTTP_code: " . $httpcode . ".\ncURL error (" . $err . "): " . + curl_strerror($err) . ". \nResult: " . $result; + $log_id = psm_add_log($this->server_id, 'discord', $error); + } + curl_close($curl); + } + } catch (Exception $e) { + $log_id = psm_add_log($this->server_id, 'discord', $e->getMessage()); + } + } + } + + /** * This functions performs the pushover notifications * @@ -673,7 +770,7 @@ 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`.`pushover_key`, `u`.`webhook_url`,`u`.`webhook_json`, + 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` diff --git a/src/templates/default/main/body.tpl.html b/src/templates/default/main/body.tpl.html index d294556c..31b96f98 100644 --- a/src/templates/default/main/body.tpl.html +++ b/src/templates/default/main/body.tpl.html @@ -89,7 +89,8 @@ - + + diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index a9c4f6c0..ffb36a54 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -32,6 +32,11 @@ role="tab" aria-controls="config-jabber" aria-selected="{% if jabber_active %}true{% else %}false{% endif %}">{{ label_tab_jabber }}
    • +
    +
    +
    + {{ label_settings_discord }} + + {{ macro.input_checkbox("discord_status", "discord_status[]", label_discord_status, discord_status_checked) }} + + {{ macro.input_checkbox("log_discord", "log_discord[]", label_log_discord, log_discord_checked) }} + {{ macro.button_test("testDiscord", label_test) }} + {{ macro.input_hidden("test_discord", "0") }} + {{ macro.button_save("discord_submit", label_save) }} +
    +
    {{ label_settings_pushover }} diff --git a/src/templates/default/module/server/server/list.tpl.html b/src/templates/default/module/server/server/list.tpl.html index c32c86b1..c0b62b89 100644 --- a/src/templates/default/module/server/server/list.tpl.html +++ b/src/templates/default/module/server/server/list.tpl.html @@ -63,19 +63,22 @@ {% endif %} {% if server.telegram|lower == 'yes' and config.telegram|lower%} - - - T - + {% endif %} {% if server.jabber|lower == 'yes'%} - - J - + + J + + {% endif %} + {% if server.discord|lower == 'yes' and config.discord|lower %} + {% endif %} {% if server.webhook|lower == 'yes' and config.webhook|lower %} - + + + W + {% endif %} {% if user_level == 10 %} diff --git a/src/templates/default/module/server/server/update.tpl.html b/src/templates/default/module/server/server/update.tpl.html index 0cefdd98..286a05d3 100644 --- a/src/templates/default/module/server/server/update.tpl.html +++ b/src/templates/default/module/server/server/update.tpl.html @@ -144,6 +144,8 @@ {{ macro.input_select_monitoring("telegram", "telegram", label_send_telegram, edit_telegram_selected, label_yes, label_no, warning_telegram, label_warning_telegram) }} {{ 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("discord", "discord", label_send_discord, edit_discord_selected, label_yes, label_no, warning_discord, label_warning_discord) }} {{ macro.input_select_monitoring("webhook", "webhook", label_send_webhook, edit_webhook_selected, label_yes, label_no, warning_webhook, label_warning_webhook) }}
    diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index 154ea26c..e6d37498 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -309,6 +309,19 @@ {% endif %} +
  • + {{ label_discord }}: + {% if discord|lower == 'yes' %} + + + {% elseif discord|lower == 'no' %} + + + {% else %} + + + {% endif %} +
  • {{ label_pushover }}: {% if pushover|lower == 'yes' %} diff --git a/src/templates/default/module/user/profile.tpl.html b/src/templates/default/module/user/profile.tpl.html index abed8ad7..3cb8f315 100644 --- a/src/templates/default/module/user/profile.tpl.html +++ b/src/templates/default/module/user/profile.tpl.html @@ -34,7 +34,7 @@

    {{ label_telegram_description|raw }}

    {{ 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) }} @@ -46,6 +46,11 @@ {{ macro.input_field("text", "jabber", null, "jabber", label_jabber, jabber, label_jabber, "255", "jabber_help", label_jabber_description) }} + +
    + {{ label_discord }} + {{ macro.input_field("text", "discord", null, "discord", label_discord, discord, "https://discordapp.com/api/webhooks/xxxxx", "255", "discord_help", label_discord_description) }} +
    {{ label_webhook }} @@ -56,4 +61,4 @@ {{ 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) }}
    {{ macro.button_save(null, label_save) }} - \ 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 bde98390..932700e1 100644 --- a/src/templates/default/module/user/user/update.tpl.html +++ b/src/templates/default/module/user/user/update.tpl.html @@ -17,6 +17,8 @@ {{ macro.input_field("email", "email", null, "email", label_email, edit_value_email, null, "255") }} {{ macro.input_field("tel", "mobile", null, "mobile", label_mobile, edit_value_mobile, null, "20") }} + + {{ macro.input_field("text", "discord", null, "discord", label_discord, edit_value_discord, null, "255") }} {{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, edit_value_webhook_url, null, "255") }} From ba0fa251e9f9dded91ec72bec02a12cb47c13592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Farr=C3=A9?= Date: Fri, 14 Aug 2020 17:56:13 +0200 Subject: [PATCH 032/112] Update Octopush.php (#975) With the low cost default value, SMS are sometimes received many hours after. For a monitoring software, this has no sense, we need to be sure to receive the alert by SMS instantly to repair the problem as quick as possible. Otherwise, SMS is useless, email is free and good enough. Moreover, the price difference between low cost and premium is small. --- src/psm/Txtmsg/Octopush.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Txtmsg/Octopush.php b/src/psm/Txtmsg/Octopush.php index 5d1731d0..f14eb464 100644 --- a/src/psm/Txtmsg/Octopush.php +++ b/src/psm/Txtmsg/Octopush.php @@ -59,7 +59,7 @@ class Octopush extends Core { $error = ""; $success = 1; - $smsType = "XXX"; //FR = premium, WWW = world, XXX = Low cost + $smsType = "FR"; //FR = premium, WWW = world, XXX = Low cost $recipients = join(',', $this->recipients); From 7745c752d1e39d1b9f8365111c86582e00f135b2 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Tue, 18 Aug 2020 17:49:44 +0200 Subject: [PATCH 033/112] Updated docs --- public.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public.php b/public.php index 28f21a7e..03c035b0 100644 --- a/public.php +++ b/public.php @@ -19,11 +19,12 @@ * along with PHP Server Monitor. If not, see . * * @package phpservermon - * @author Pepijn Over + * @author Tim Zandbergen * @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 3.6.0 **/ namespace { From 7d11f7bd1f8a0bad06da3bd62137c2f7bf7fa380 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Tue, 18 Aug 2020 17:50:06 +0200 Subject: [PATCH 034/112] Prevent unautorized warning --- public.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public.php b/public.php index 03c035b0..9848ffbd 100644 --- a/public.php +++ b/public.php @@ -33,4 +33,8 @@ namespace { require __DIR__ . '/src/bootstrap.php'; $router->run('server_status'); + + // By destroying the session the login will show when going to another page + session_destroy(); + } From b94d66bfc02131467db846ebab9722047be9df85 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Tue, 18 Aug 2020 17:50:22 +0200 Subject: [PATCH 035/112] Added user on upgrade --- src/psm/Util/Install/Installer.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index 010b9fbf..114eba65 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -341,6 +341,9 @@ class Installer if (version_compare($version_from, '3.4.2', '<')) { $this->upgrade342(); } + if (version_compare($version_from, '3.6.0', '<')) { + $this->upgrade360(); + } psm_update_conf('version', $version_to); } @@ -655,4 +658,14 @@ class Installer $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `last_output` `last_output` TEXT;"; $this->execSQL($queries); } + + protected function upgrade360() + { + $queries = array(); + $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users` ( + `user_name`, `level`, `name`, `email`) + VALUES ('__PUBLIC__', 30, 'Public page', 'publicpage@psm.psm')"; + $this->execSQL($queries); + $this->log('Added user \'__PUBLIC__\'.'); + } } From 27d9bd6a70658b27313922a0060621a2f8bd6f1d Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Tue, 18 Aug 2020 17:53:18 +0200 Subject: [PATCH 036/112] Only __public__ can be anonymous --- src/lang/en_US.lang.php | 1 + src/psm/Module/User/Controller/UserController.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index c836511f..21dabb9e 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -152,6 +152,7 @@ $sm_lang = array( 'error_user_password_invalid' => 'The entered password is invalid.', 'error_user_password_no_match' => 'The entered passwords do not match.', 'error_user_admin_cant_be_deleted' => 'You can\'t remove the last administrator.', + 'error_user_cant_be_anonymous' => 'Only user \'__public__\' can have the level anonymous.' ), 'log' => array( 'title' => 'Log entries', diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index cbc3ff64..a45f24a7 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -274,6 +274,14 @@ class UserController extends AbstractController $user_validator->username($clean['user_name'], $user_id); $user_validator->email($clean['email']); $user_validator->level($clean['level']); + + // Won't allow anonymous level for users other than __PUBLIC__ + if ($clean['user_name'] !== "__PUBLIC__" && (int) $clean['level'] === (int) PSM_USER_ANONYMOUS) { + $this->addMessage(psm_get_lang('users', 'error_user_cant_be_anonymous'), 'error'); + $clean['level'] = PSM_USER_USER; + } + + // Won't allow removing the last admin if ( count($this->db->select(PSM_DB_PREFIX . 'users', array('level' => PSM_USER_ADMIN))) == 1 && $this->getUser()->getUserLevel() == PSM_USER_ADMIN From 8cbf2dd7bf008f759aff47e88a1d5d80a9576bac Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Tue, 18 Aug 2020 17:53:26 +0200 Subject: [PATCH 037/112] Bumped version --- README.rst | 2 +- src/includes/psmconfig.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index d0a633ee..1940063c 100755 --- a/README.rst +++ b/README.rst @@ -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.4.5 +Version 3.6.0 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, diff --git a/src/includes/psmconfig.inc.php b/src/includes/psmconfig.inc.php index 530753c8..c70d24e5 100644 --- a/src/includes/psmconfig.inc.php +++ b/src/includes/psmconfig.inc.php @@ -30,7 +30,7 @@ /** * Current PSM version */ -define('PSM_VERSION', '3.4.5'); +define('PSM_VERSION', '3.6.0'); /** * URL to check for updates. Will not be checked if turned off on config page. From 56b122471b82607f6d4cb290fa688c66ca6a127e Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Mon, 24 Aug 2020 22:11:09 +0200 Subject: [PATCH 038/112] Added documentation --- docs/faq.rst | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/faq.rst b/docs/faq.rst index 0fdfb03c..a2f88ecb 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -10,7 +10,7 @@ Users What are the differences between the user levels? ------------------------------------------------- -There are 2 user levels available: regular user and administrator. +There are 3 user levels available: anonymous, regular user and administrator. Administrators: @@ -24,6 +24,16 @@ Regular users: * View the history and logs of their assigned servers. * Run the updater on their assigned servers. +Anonymous: +Only meant for user '__PUBLIC__' and can't be assigned to any other user. + +* View the status of their assigned servers without password. + +I removed user '__PUBLIC__', what now? +-------------------------------------- + +* Go to users -> create new user. +* Set the username to '__PUBLIC__', level to 'anonymous' and the rest is up to you. Servers +++++++ @@ -101,6 +111,14 @@ After upgrading, my email stopped working. Run 'php composer.phar update' and you should be good to go! +Setting up a public page. +------------------------- + +1. Set PSM_PUBLIC to true in config.php. +2. If not yet existing, create a user with username '__PUBLIC__'. See Users -> "I removed user '__PUBLIC__', what now?" for help. +3. Add servers to user '__PUBLIC__'. +4. Go to /public.php. + Notifications +++++++++++++ From 57e53d77c4d30d84378395602ea3752cc63fb041 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Mon, 24 Aug 2020 22:11:32 +0200 Subject: [PATCH 039/112] Added PSM_PUBLIC --- config.php.sample | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.php.sample b/config.php.sample index 31d490d7..a892215c 100755 --- a/config.php.sample +++ b/config.php.sample @@ -5,4 +5,5 @@ define('PSM_DB_PASS', 'db_pass'); define('PSM_DB_NAME', 'db_name'); define('PSM_DB_HOST', 'localhost'); define('PSM_DB_PORT', '3306'); //3306 is the default port for MySQL. If no specfic port is used, leave it empty. -define('PSM_BASE_URL', ''); \ No newline at end of file +define('PSM_BASE_URL', ''); +define('PSM_PUBLIC', true); \ No newline at end of file From 36e33b32154c1e803b2a00cc9533822fbcf52a09 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 26 Aug 2020 15:17:23 +0200 Subject: [PATCH 040/112] Removed old check Removal of last admin has been fixed with 3568a570. --- src/psm/Module/User/Controller/UserController.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index 0704cc39..cd667a29 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -289,15 +289,6 @@ class UserController extends AbstractController $clean['level'] = PSM_USER_USER; } - // Won't allow removing the last admin - if ( - count($this->db->select(PSM_DB_PREFIX . 'users', array('level' => PSM_USER_ADMIN))) == 1 && - $this->getUser()->getUserLevel() == PSM_USER_ADMIN - ) { - $this->addMessage(psm_get_lang('users', 'error_user_admin_cant_be_deleted'), 'warning'); - $clean['level'] = PSM_USER_ADMIN; - } - // always validate password for new users, // but only validate it for existing users when they change it. if ($user_id == 0 || ($user_id > 0 && $clean['password'] != '')) { From 99bcc90c0325e9f261c80cb3589cfa115211af81 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Wed, 26 Aug 2020 15:58:58 +0200 Subject: [PATCH 041/112] Auto gen password for __PUBLIC__ and hide fields --- .../Module/User/Controller/UserController.php | 9 ++++++++- src/templates/default/static/js/scripts.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index cd667a29..ba55a0e2 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -291,9 +291,16 @@ class UserController extends AbstractController // always validate password for new users, // but only validate it for existing users when they change it. - if ($user_id == 0 || ($user_id > 0 && $clean['password'] != '')) { + if (($user_id == 0 || ($user_id > 0 && $clean['password'] != '')) && $clean['user_name'] != '__PUBLIC__') { $user_validator->password($clean['password'], $clean['password_repeat']); } + + // Auto generate password for __PUBLIC__ user + if ($clean['user_name'] === '__PUBLIC__') { + $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*_"; + $clean['password'] = substr(str_shuffle($chars), 0, 24); + } + if ($user_id > 0) { $user_validator->userId($user_id); } diff --git a/src/templates/default/static/js/scripts.js b/src/templates/default/static/js/scripts.js index acd8b2ca..5184e3fb 100644 --- a/src/templates/default/static/js/scripts.js +++ b/src/templates/default/static/js/scripts.js @@ -51,6 +51,7 @@ $().ready(function () { } $('#label').focus(); }); + $("#type").change(function () { switch ($("select#type option:checked").val()) { case "website": @@ -103,6 +104,21 @@ $("select#popular_ports").change(function () { } }).change(); +$("#user_name").change(function () +{ + switch ($("#user_name").val()) { + case "__PUBLIC__": + $('#password').parent().slideUp(); + $('#password_repeat').parent().slideUp(); + $("select#level").val('30'); + $("#name").val('Public page'); + break; + default: + $('#password').parent().slideDown(); + $('#password_repeat').parent().slideDown(); + } +}).change(); + function psm_xhr(mod, params, method, on_complete, options) { method = (typeof method === 'undefined') ? 'GET' : method; From f1df99c5ae70587f5623966c25a7b429ae04a051 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Wed, 26 Aug 2020 15:59:46 +0200 Subject: [PATCH 042/112] Moved update script to 3.6.0 --- src/psm/Util/Install/Installer.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index b36d13a1..ab9e5fef 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -724,12 +724,7 @@ class Installer ('jabber_username', ''), ('jabber_domain', ''), ('jabber_password', '');"; - - $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users` ( - `user_name`, `level`, `name`, `email`) - VALUES ('__PUBLIC__', 30, 'Public page', 'publicpage@psm.psm')"; $this->execSQL($queries); - $this->log('Added user \'__PUBLIC__\'.'); } /** @@ -758,6 +753,11 @@ class Installer ADD `discord` VARCHAR( 255 ) NOT NULL AFTER `mobile`;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `discord` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `sms`;"; + $queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users` ( + `user_name`, `level`, `name`, `email`) + VALUES ('__PUBLIC__', 30, 'Public page', 'publicpage@psm.psm')"; $this->execSQL($queries); + + $this->log('Public page is now available. Added user \'__PUBLIC__\'. See documentation for more info.'); } } From 66983a0a6688946c438369320d0579f2005b3d93 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Wed, 26 Aug 2020 16:00:27 +0200 Subject: [PATCH 043/112] Indentation and changed readonly to required --- src/templates/default/module/user/user/update.tpl.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/default/module/user/user/update.tpl.html b/src/templates/default/module/user/user/update.tpl.html index 932700e1..5da431cb 100644 --- a/src/templates/default/module/user/user/update.tpl.html +++ b/src/templates/default/module/user/user/update.tpl.html @@ -4,9 +4,9 @@ {{ titlemode }}
    - {{ macro.input_field("text", "user_name", null, "user_name", label_user_name, edit_value_user_name, null, "255", null, null, null, true, true) }} + {{ macro.input_field("text", "user_name", null, "user_name", label_user_name, edit_value_user_name, null, "255", null, null, null, null, true) }} - {{ macro.input_field("text", "name", null, "name", label_name, edit_value_name, null, "255", null, null, null, true) }} + {{ macro.input_field("text", "name", null, "name", label_name, edit_value_name, null, "255", null, null, null, null, true) }} {{ macro.input_select("level", "level", label_level, levels, user_level) }} @@ -17,7 +17,7 @@ {{ macro.input_field("email", "email", null, "email", label_email, edit_value_email, null, "255") }} {{ macro.input_field("tel", "mobile", null, "mobile", label_mobile, edit_value_mobile, null, "20") }} - + {{ macro.input_field("text", "discord", null, "discord", label_discord, edit_value_discord, null, "255") }} {{ macro.input_field("text", "webhook_url", null, "webhook_url", label_webhook_url, edit_value_webhook_url, null, "255") }} From fd820dea067c9507ab4ed1ba186dcac69925199a Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 26 Aug 2020 17:05:52 +0200 Subject: [PATCH 044/112] Create dependabot.yml --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..bc3ab5c1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "daily" From 474b90c12387b99e2cee3967e6c40f9e46606e47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 17:08:59 +0200 Subject: [PATCH 045/112] Bump symfony/config from 3.4.36 to 3.4.43 (#987) Bumps [symfony/config](https://github.com/symfony/config) from 3.4.36 to 3.4.43. - [Release notes](https://github.com/symfony/config/releases) - [Changelog](https://github.com/symfony/config/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/config/compare/v3.4.36...v3.4.43) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 66 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/composer.lock b/composer.lock index 6ce79bb8..244e8195 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f78e950e2dfef7debe88d7b64e2b4aec", + "content-hash": "b24d7cc3989b64b679b388afafb16d09", "packages": [ { "name": "jaxl/jaxl", @@ -218,6 +218,12 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "funding": [ + { + "url": "https://github.com/synchro", + "type": "github" + } + ], "time": "2020-05-27T12:24:03+00:00" }, { @@ -271,16 +277,16 @@ }, { "name": "symfony/config", - "version": "v3.4.36", + "version": "v3.4.43", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe" + "reference": "9e2aa97f0d51f114983666f5aa362426d53e004a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a599a867d0e4a07c342b5f1e656b3915a540ddbe", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe", + "url": "https://api.github.com/repos/symfony/config/zipball/9e2aa97f0d51f114983666f5aa362426d53e004a", + "reference": "9e2aa97f0d51f114983666f5aa362426d53e004a", "shasum": "" }, "require": { @@ -331,7 +337,21 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2019-12-01T10:45:41+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-23T09:37:51+00:00" }, { "name": "symfony/dependency-injection", @@ -573,16 +593,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.1", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", "shasum": "" }, "require": { @@ -594,7 +614,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -627,7 +651,21 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -825,8 +863,10 @@ "platform": { "php": "^5.5.9|>=7.0.8", "ext-curl": "*", + "ext-json": "*", "ext-pdo": "*", "ext-xml": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } From 118d1e624e6a149b591384f85f90d38d83ea47ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 17:09:35 +0200 Subject: [PATCH 046/112] Bump symfony/http-foundation from 3.4.36 to 3.4.43 (#988) Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.4.36 to 3.4.43. - [Release notes](https://github.com/symfony/http-foundation/releases) - [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/http-foundation/compare/v3.4.36...v3.4.43) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 84 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/composer.lock b/composer.lock index 244e8195..c820a59c 100644 --- a/composer.lock +++ b/composer.lock @@ -539,16 +539,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.4.36", + "version": "v3.4.43", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593" + "reference": "5219dba1253aa07ed3ad82f73c08146fb3f517d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d2d0cfe8e319d9df44c4cca570710fcf221d4593", - "reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5219dba1253aa07ed3ad82f73c08146fb3f517d0", + "reference": "5219dba1253aa07ed3ad82f73c08146fb3f517d0", "shasum": "" }, "require": { @@ -589,7 +589,21 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-11-28T12:52:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-23T09:37:51+00:00" }, { "name": "symfony/polyfill-ctype", @@ -669,16 +683,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", "shasum": "" }, "require": { @@ -690,7 +704,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -724,20 +742,34 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.13.1", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "af23c7bb26a73b850840823662dda371484926c4" + "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/af23c7bb26a73b850840823662dda371484926c4", - "reference": "af23c7bb26a73b850840823662dda371484926c4", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", + "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", "shasum": "" }, "require": { @@ -747,7 +779,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -783,7 +819,21 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "twig/twig", From 2ea03a86505e15eb92a9c69b40982cea0e3c19c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 17:09:51 +0200 Subject: [PATCH 047/112] Bump twig/twig from 1.42.4 to 1.42.5 (#989) Bumps [twig/twig](https://github.com/twigphp/Twig) from 1.42.4 to 1.42.5. - [Release notes](https://github.com/twigphp/Twig/releases) - [Changelog](https://github.com/twigphp/Twig/blob/3.x/CHANGELOG) - [Commits](https://github.com/twigphp/Twig/compare/v1.42.4...v1.42.5) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index c820a59c..6b782c5f 100644 --- a/composer.lock +++ b/composer.lock @@ -837,16 +837,16 @@ }, { "name": "twig/twig", - "version": "v1.42.4", + "version": "v1.42.5", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152" + "reference": "87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/e587180584c3d2d6cb864a0454e777bb6dcb6152", - "reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e", + "reference": "87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e", "shasum": "" }, "require": { @@ -855,8 +855,7 @@ }, "require-dev": { "psr/container": "^1.0", - "symfony/debug": "^3.4|^4.2", - "symfony/phpunit-bridge": "^4.4@dev|^5.0" + "symfony/phpunit-bridge": "^4.4|^5.0" }, "type": "library", "extra": { @@ -885,7 +884,6 @@ }, { "name": "Twig Team", - "homepage": "https://twig.symfony.com/contributors", "role": "Contributors" }, { @@ -899,7 +897,7 @@ "keywords": [ "templating" ], - "time": "2019-11-11T16:49:32+00:00" + "time": "2020-02-11T05:59:23+00:00" } ], "packages-dev": [], From af1ddd691109263247fba5e6ae6b00ceb80becf9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 17:10:42 +0200 Subject: [PATCH 048/112] Bump phpmailer/phpmailer from 6.1.6 to 6.1.7 (#990) Bumps [phpmailer/phpmailer](https://github.com/PHPMailer/PHPMailer) from 6.1.6 to 6.1.7. - [Release notes](https://github.com/PHPMailer/PHPMailer/releases) - [Changelog](https://github.com/PHPMailer/PHPMailer/blob/master/changelog.md) - [Commits](https://github.com/PHPMailer/PHPMailer/compare/v6.1.6...v6.1.7) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 6b782c5f..73a467af 100644 --- a/composer.lock +++ b/composer.lock @@ -160,16 +160,16 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "c2796cb1cb99d7717290b48c4e6f32cb6c60b7b3" + "reference": "2c2370ba3df7034f9eb7b8f387c97b52b2ba5ad0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/c2796cb1cb99d7717290b48c4e6f32cb6c60b7b3", - "reference": "c2796cb1cb99d7717290b48c4e6f32cb6c60b7b3", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/2c2370ba3df7034f9eb7b8f387c97b52b2ba5ad0", + "reference": "2c2370ba3df7034f9eb7b8f387c97b52b2ba5ad0", "shasum": "" }, "require": { @@ -224,7 +224,7 @@ "type": "github" } ], - "time": "2020-05-27T12:24:03+00:00" + "time": "2020-07-14T18:50:27+00:00" }, { "name": "psr/container", From 9fa924d0ccc7683ca324d6c113c76a36d35ad8cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 17:11:41 +0200 Subject: [PATCH 049/112] Bump symfony/event-dispatcher from 3.4.36 to 3.4.43 (#991) Bumps [symfony/event-dispatcher](https://github.com/symfony/event-dispatcher) from 3.4.36 to 3.4.43. - [Release notes](https://github.com/symfony/event-dispatcher/releases) - [Changelog](https://github.com/symfony/event-dispatcher/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/event-dispatcher/compare/v3.4.36...v3.4.43) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 73a467af..de1bec4e 100644 --- a/composer.lock +++ b/composer.lock @@ -426,16 +426,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.4.36", + "version": "v3.4.43", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177" + "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f9031c22ec127d4a2450760f81a8677fe8a10177", - "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/14d978f8e8555f2de719c00eb65376be7d2e9081", + "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081", "shasum": "" }, "require": { @@ -485,7 +485,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-05T15:06:23+00:00" }, { "name": "symfony/filesystem", From 799f512a9232095d45687128342cc7fd9f7cfb5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2020 11:25:51 +0000 Subject: [PATCH 050/112] Bump symfony/dependency-injection from 3.4.36 to 3.4.43 (#992) --- composer.lock | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index de1bec4e..a82d05f2 100644 --- a/composer.lock +++ b/composer.lock @@ -355,16 +355,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v3.4.36", + "version": "v3.4.43", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2" + "reference": "3a14abc01c36e81fc1c4c48b42c103b9dd892ed3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/0d201916bfb3af939fec3c0c8815ea16c60ac1a2", - "reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/3a14abc01c36e81fc1c4c48b42c103b9dd892ed3", + "reference": "3a14abc01c36e81fc1c4c48b42c103b9dd892ed3", "shasum": "" }, "require": { @@ -422,7 +422,21 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2019-12-01T08:33:36+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-23T09:37:51+00:00" }, { "name": "symfony/event-dispatcher", From ba8c7c1c846d898ec03af413d720d38283ea1962 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2020 11:26:46 +0000 Subject: [PATCH 051/112] Bump symfony/filesystem from 3.4.36 to 3.4.43 (#993) --- composer.lock | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index a82d05f2..30b81670 100644 --- a/composer.lock +++ b/composer.lock @@ -517,16 +517,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.4.36", + "version": "v3.4.43", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2" + "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/00cdad0936d06fab136944bc2342b762b1c3a4a2", - "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/0f625d0cb1e59c8c4ba61abb170125175218ff10", + "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10", "shasum": "" }, "require": { @@ -563,7 +563,21 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2019-11-25T16:36:22+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-30T17:48:24+00:00" }, { "name": "symfony/http-foundation", From bc6bd379acb5f16ad2b0fbb6cd185822456080de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2020 09:41:09 +0000 Subject: [PATCH 052/112] Bump symfony/config from 3.4.43 to 3.4.44 (#996) --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 30b81670..de75990f 100644 --- a/composer.lock +++ b/composer.lock @@ -277,16 +277,16 @@ }, { "name": "symfony/config", - "version": "v3.4.43", + "version": "v3.4.44", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "9e2aa97f0d51f114983666f5aa362426d53e004a" + "reference": "801a3bbc17fb1ba44b0d7d41a6db7a0b74953595" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/9e2aa97f0d51f114983666f5aa362426d53e004a", - "reference": "9e2aa97f0d51f114983666f5aa362426d53e004a", + "url": "https://api.github.com/repos/symfony/config/zipball/801a3bbc17fb1ba44b0d7d41a6db7a0b74953595", + "reference": "801a3bbc17fb1ba44b0d7d41a6db7a0b74953595", "shasum": "" }, "require": { @@ -351,7 +351,7 @@ "type": "tidelift" } ], - "time": "2020-07-23T09:37:51+00:00" + "time": "2020-08-10T07:13:15+00:00" }, { "name": "symfony/dependency-injection", From 30fe2c6dcfd6066442a0e5dc14a421671716b7d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2020 09:41:26 +0000 Subject: [PATCH 053/112] Bump symfony/filesystem from 3.4.43 to 3.4.44 (#997) --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index de75990f..93948313 100644 --- a/composer.lock +++ b/composer.lock @@ -517,16 +517,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.4.43", + "version": "v3.4.44", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10" + "reference": "8e6eff546d0fe879996fa701ee2f312767e95e50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/0f625d0cb1e59c8c4ba61abb170125175218ff10", - "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/8e6eff546d0fe879996fa701ee2f312767e95e50", + "reference": "8e6eff546d0fe879996fa701ee2f312767e95e50", "shasum": "" }, "require": { @@ -577,7 +577,7 @@ "type": "tidelift" } ], - "time": "2020-05-30T17:48:24+00:00" + "time": "2020-08-21T12:53:49+00:00" }, { "name": "symfony/http-foundation", From 5dfb66615a3447923c8843d7a0116794f13209e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2020 09:41:39 +0000 Subject: [PATCH 054/112] Bump symfony/event-dispatcher from 3.4.43 to 3.4.44 (#998) --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 93948313..ceef21c1 100644 --- a/composer.lock +++ b/composer.lock @@ -440,16 +440,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.4.43", + "version": "v3.4.44", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081" + "reference": "a0f6858fbf7a524747e87a4c336cab7d0b67c802" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/14d978f8e8555f2de719c00eb65376be7d2e9081", - "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a0f6858fbf7a524747e87a4c336cab7d0b67c802", + "reference": "a0f6858fbf7a524747e87a4c336cab7d0b67c802", "shasum": "" }, "require": { @@ -513,7 +513,7 @@ "type": "tidelift" } ], - "time": "2020-05-05T15:06:23+00:00" + "time": "2020-08-12T14:55:37+00:00" }, { "name": "symfony/filesystem", From 7d31bf7e6bbba59f2959f0e45dd5f90d08805c6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2020 09:43:16 +0000 Subject: [PATCH 055/112] Bump symfony/http-foundation from 3.4.43 to 3.4.44 (#999) --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index ceef21c1..b3f40b79 100644 --- a/composer.lock +++ b/composer.lock @@ -581,16 +581,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.4.43", + "version": "v3.4.44", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "5219dba1253aa07ed3ad82f73c08146fb3f517d0" + "reference": "e5a42880895b43cd53d1a7b92bdcfb7d80c0af1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5219dba1253aa07ed3ad82f73c08146fb3f517d0", - "reference": "5219dba1253aa07ed3ad82f73c08146fb3f517d0", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e5a42880895b43cd53d1a7b92bdcfb7d80c0af1c", + "reference": "e5a42880895b43cd53d1a7b92bdcfb7d80c0af1c", "shasum": "" }, "require": { @@ -645,7 +645,7 @@ "type": "tidelift" } ], - "time": "2020-07-23T09:37:51+00:00" + "time": "2020-08-12T14:55:37+00:00" }, { "name": "symfony/polyfill-ctype", From 51949657c890829e30679c3ea3d72d7aa16a999b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2020 09:43:59 +0000 Subject: [PATCH 056/112] Bump symfony/dependency-injection from 3.4.43 to 3.4.44 (#1000) --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index b3f40b79..3b8d7122 100644 --- a/composer.lock +++ b/composer.lock @@ -355,16 +355,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v3.4.43", + "version": "v3.4.44", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "3a14abc01c36e81fc1c4c48b42c103b9dd892ed3" + "reference": "7d15cf4294d4f3610bc741c8fdd54a6baac586d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/3a14abc01c36e81fc1c4c48b42c103b9dd892ed3", - "reference": "3a14abc01c36e81fc1c4c48b42c103b9dd892ed3", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/7d15cf4294d4f3610bc741c8fdd54a6baac586d4", + "reference": "7d15cf4294d4f3610bc741c8fdd54a6baac586d4", "shasum": "" }, "require": { @@ -436,7 +436,7 @@ "type": "tidelift" } ], - "time": "2020-07-23T09:37:51+00:00" + "time": "2020-08-10T07:13:15+00:00" }, { "name": "symfony/event-dispatcher", From aad1a1eda77ce6e64b41847f1ecd4cd47645f124 Mon Sep 17 00:00:00 2001 From: Edgar Ostrowski <4096780+EdgarOstrowski@users.noreply.github.com> Date: Wed, 9 Sep 2020 11:46:32 +0200 Subject: [PATCH 057/112] Update of Polish translation (#985) --- src/lang/en_US.lang.php | 4 +- src/lang/pl_PL.lang.php | 297 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 286 insertions(+), 15 deletions(-) diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index e6c412e7..c8e6fbe5 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -409,8 +409,8 @@ $sm_lang = array( 'telegram_error' => 'An error has occurred while sending the Telegram notification: %s', 'telegram_error_notoken' => 'Unable to send test notification: no Telegram API token found in the global configuration.', 'telegram_error_noid' => 'Unable to send test notification: no chat id found in your profile.', - 'jabber_sent' => 'Telegram notification sent', - 'jabber_error' => 'An error has occurred while sending the Telegram notification: %s', + 'jabber_sent' => 'Jabber notification sent', + 'jabber_error' => 'An error has occurred while sending the Jabber notification: %s', 'jabber_error_noconfig' => 'Unable to send test notification: no Jabber account set in the global configuration.', 'jabber_error_noaccount' => 'Unable to send test notification: no Jabber account found in your profile.', 'log_retention_period' => 'Log retention period', diff --git a/src/lang/pl_PL.lang.php b/src/lang/pl_PL.lang.php index 1fa25092..c7cfbac1 100644 --- a/src/lang/pl_PL.lang.php +++ b/src/lang/pl_PL.lang.php @@ -22,7 +22,7 @@ * @author Arkadiusz Klenczar * @copyright Copyright (c) 2008-2017 Pepijn Over * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 - * @version Release: @package_version@ + * @version Release: v3.5.2 * @link http://www.phpservermonitor.org/ **/ @@ -43,6 +43,7 @@ $sm_lang = array( 'save' => 'Zapisz', 'edit' => 'Edycja', 'delete' => 'Usuń', + 'view' => 'Zobacz', 'date' => 'Data', 'message' => 'Wiadomość', 'yes' => 'Tak', @@ -54,8 +55,11 @@ $sm_lang = array( rel="noopener">http://www.phpservermonitor.org.', 'back_to_top' => 'Do góry', 'go_back' => 'Wstecz', - 'ok' => 'OK', + 'ok' => 'pożądane', + 'bad' => 'niepożądane', 'cancel' => 'Anuluj', + 'none' => 'Brak', + 'activate' => 'Aktywny', 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', 'yesterday_format' => 'Wczoraj o %k:%M', @@ -67,7 +71,23 @@ $sm_lang = array( 'a_minute_ago' => 'minutę temu', 'seconds_ago' => '%d sekund temu', 'a_second_ago' => 'sekundę temu', - 'seconds' => 'sekund', + 'year' => 'rok', + 'years' => 'lata', + 'month' => 'miesiąc', + 'months' => 'miesiące', + 'day' => 'dzień', + 'days' => 'dni', + 'hour' => 'godzina', + 'hours' => 'godziny', + 'minute' => 'minuta', + 'minutes' => 'minut', + 'second' => 'sekunda', + 'seconds' => 'sekundy', + 'millisecond' => 'milisekunka', + 'milliseconds' => 'milisekundy', + 'current' => 'aktualnie', + 'settings' => 'Ustawienia', + 'search' => 'Szukaj', ), 'menu' => array( 'config' => 'Konfiguracja', @@ -101,6 +121,39 @@ $sm_lang = array( 'pushover_device' => 'Urządzenie dla Pushover', 'pushover_device_description' => 'Nazwa urządzenia do którego wysłać powiadomienie. Pozostaw puste aby wysłać do wszystkich urządzeń.', + 'discord' => 'Discord', + 'discord_label' => 'Discord', + 'discord_description' => 'Podaj swoje webhook tutaj.', + 'telegram' => 'Telegram', + 'telegram_description' => 'Telegram jest komunikatorem + internetowym, który umożliwa notyfikacje w czasie rzeczywistym. Odwiedź stronę + z documentacja aby + uzyskać więcej informacji.', + 'telegram_chat_id' => 'Telegram chat id', + 'telegram_chat_id_description' => 'Wiadomość zostanie wysłana do odpowiedniej rozmowy.', + 'telegram_get_chat_id' => 'Kliknij tutaj żeby otrzywać swój chat id', + 'activate_telegram' => 'Aktywuj notyfikacje Telegram', + 'activate_telegram_description' => 'Zezwól na wysyłanie notyfikacji Telegram do podanego chat id. Bez tej + zgodny Telegram nie zezwoli na wysyłanie notyfikacji do Ciebie.', + 'telegram_bot_username_found' => 'Bot został odnaleziony!
    +
    Następnie otworzy się okno rozmowy z botem. Musisz nacisnąć start + lub wpisać /start.', + 'telegram_bot_username_error_token' => '401 - Błąd autoryzacji. Proszę sprawdzić czy API token jest + prawidłowy.', + 'telegram_bot_error' => 'Wystąpił błąd podczas aktywowania notyfikacji Telegram: %s', + 'jabber' => 'Jabber', + 'jabber_label' => 'Jabber', + 'jabber_description' => 'Twoje konto Jabber', + 'webhook' => 'Webhook', + 'webhook_description' => 'Wyślij json webhook do wybranego endpoint.
    Zapytanie json może być dowolnie + dostosowane np. {"text":"servermon: #message"}', + 'webhook_url' => 'Webhook URL', + 'webhook_url_description' => 'Publiczne webhook endpoint URL powinny się zaczynać od https://.', + 'webhook_json' => 'Webhook JSON', + 'webhook_json_description' => 'Zdefiniuj niestandardowy json, użyj #message jak zmienną z treścią + wiadomości.', 'delete_title' => 'Usuń użytkownika', 'delete_message' => 'Czy jesteś pewny że chcesz usunąć użytkownika \'%1\'?', 'deleted' => 'Użytkownik usunięty.', @@ -118,6 +171,7 @@ $sm_lang = array( 'error_user_no_match' => 'Użytkownik nie został odnaleziony.', 'error_user_password_invalid' => 'Wprowadzone hasło jest nieprawidłowe.', 'error_user_password_no_match' => 'Wprowadzone hasła są różne.', + 'error_user_admin_cant_be_deleted' => 'Nie można usunąć jedynego konta administratora.', ), 'log' => array( 'title' => 'Logi', @@ -125,7 +179,11 @@ $sm_lang = array( 'status' => 'Status', 'email' => 'Email', 'sms' => 'SMS', + 'discord' => 'Discord', 'pushover' => 'Pushover', + 'webhook' => 'Webhook', + 'telegram' => 'Telegram', + 'jabber' => 'Jabber', 'no_logs' => 'Brak logów', 'clear' => 'Wyczyść log', 'delete_title' => 'Wyczyść log', @@ -138,23 +196,70 @@ $sm_lang = array( 'domain' => 'Domena/IP', 'timeout' => 'Timeout', 'timeout_description' => 'Liczba sekund do odczekania na odpowiedź serwera.', + 'authentication_settings' => 'Ustawienia uwierzytelniania', + 'optional' => 'Opcjonalne', + 'website_username' => 'Nazwa użytkownika', + 'website_username_description' => 'Nazwa użytkownika z dostępem do strony (tylko uwierzytelnianie Apache + jest wspierana).', + 'website_password' => 'Hasło', + 'website_password_description' => 'Hasło dostęput do strony. Hasło zostanie zaszyfrowane i zapisane w + badzie danych.', + 'fieldset_monitoring' => 'Monitoring', + 'fieldset_permissions' => 'Uprawnienia', + 'permissions' => 'Serwer będzie widoczny dla następujących użytkowników', 'port' => 'Port', + 'custom_port' => 'Niestandardowy port', + 'popular_ports' => 'Popularne porty', + 'request_method' => 'Metoda HTTP', + 'custom_request_method' => 'Niestandardowe metoda HTTP', + 'popular_request_methods' => 'Popularne metody HTTP', + 'post_field' => 'Pole Post', + 'post_field_description' => 'Dane zostaną wysłane za pomocą wyżej wybranej metody.', + 'please_select' => 'Proszę wybrać', 'type' => 'Typ', 'type_website' => 'Strona', 'type_service' => 'Usługa', + 'type_ping' => 'Ping', 'pattern' => 'Wyszukiwane wyrażenie/wzorzec', - 'pattern_description' => 'Jeśli wzorzec nie zostanie odnaleziony, status zostanie ustawiony na offline. - Wyrażenia regularne są dozwolone.', + 'pattern_description' => 'Jeśli wzorzec nie zostanie odnaleziony, status zostanie zmieniony. Dozwolone są + wyrażenia regularne.', + 'pattern_online' => 'Wykrycie wzorca oznacza, że strona jest', + 'pattern_online_description' => 'Online: jeżeli wzorzec zostanie wykryty na stronie to server zostanie + oznaczony jako online. Offline: jeżeli wzorzec nie zostanie wykryty na + stronie to serwer zostanie oznaczony jako offline.', + 'redirect_check' => 'Przekierowanie na inną domenę jest', + 'redirect_check_description' => 'Przekierowanie na inną domenę zazwyczaj jest niepożądanym zachowaniem.', + 'allow_http_status' => 'Dozwolone kody odpowiedzi HTTP', + 'allow_http_status_description' => 'Podaj listę dozwolonych kodów odpowiedzi HTTP, kolejne wartości + oddzielone za pomocą |. Domyślnie odpowiedzi o wartości poniżej 400 + zostaną uznane jako prawidłowe.', + 'header_name' => 'Nazwa nagłówka', + 'header_value' => 'Wartość nagłówka', + 'header_name_description' => 'Wielkość liter ma znaczenie.', + 'header_value_description' => 'Dozwolone są wyrażenia regularne.', 'last_check' => 'Ostatnie sprawdzenie', 'last_online' => 'Ostatnio online', 'last_offline' => 'Ostatnio offline', + 'last_output' => 'Ostatni prawidłowy wynik', + 'last_error' => 'Ostatni bląd', + 'last_error_output' => 'Ostatni wynik blądu', + 'output' => 'Wynik', 'monitoring' => 'Monitorowany', 'no_monitoring' => 'Brak monitoringu', 'email' => 'Email', 'send_email' => 'Wyślij Email', 'sms' => 'SMS', 'send_sms' => 'Wyślij SMS', + 'discord' => 'Discord', + 'send_discord' => 'Wyślij powiadomienie Discord', + 'webhook' => 'Webook', + 'send_webhook' => 'Wyślij powiadomienie Webhook', 'pushover' => 'Pushover', + 'send_pushover' => 'Wyślij powiadomienie Pushover', + 'telegram' => 'Telegram', + 'send_telegram' => 'Wyślij powiadomienie Telegram', + 'jabber' => 'Jabber', + 'send_jabber' => 'Wyślij powiadomienie Jabber', 'users' => 'Użytkownicy', 'delete_title' => 'Usuń serwer', 'delete_message' => 'Czy jesteś pewny że chcesz usunąć serwer \'%1\'?', @@ -165,6 +270,8 @@ $sm_lang = array( 'latency_max' => 'Opóźnienie (maksymalne)', 'latency_min' => 'Opóźnienie (minimalne)', 'latency_avg' => 'Opóźnienie (średnie)', + 'online' => 'online', + 'offline' => 'offline', 'uptime' => 'Czas dostępności', 'year' => 'Rok', 'month' => 'Miesiąc', @@ -173,6 +280,12 @@ $sm_lang = array( 'hour' => 'Godzina', 'warning_threshold' => 'Próg ostrzeżeń', 'warning_threshold_description' => 'Ilość wymaganych niepowodzeń przed oznaczeniem serwera jako offline.', + 'ssl_cert_expiry_days' => 'Ważność certyfikatu SSL', + 'ssl_cert_expiry_days_description' => 'Minimalna ilość dni, których certyfikat SSL musi być ważny. + Ustawienie wartości 0 spowoduje, że ważność certyfikatu nie + będzie sprawdzana.', + 'ssl_cert_expired' => 'Certyfikat SSL wygasł', + 'ssl_cert_expiring' => 'Certyfikat SSL wygaśnie:', 'chart_last_week' => 'Ostatni tydzień', 'chart_history' => 'Historia', 'chart_day_format' => '%Y-%m-%d', @@ -181,7 +294,11 @@ $sm_lang = array( 'chart_short_time_format' => '%H:%M', 'warning_notifications_disabled_sms' => 'Powiadomienia SMS są wyłączone.', 'warning_notifications_disabled_email' => 'Powiadomienia Email są wyłączone.', + 'warning_notifications_disabled_discord' => 'Powiadomienia Discord są wyłączone.', + 'warning_notifications_disabled_webhook' => 'Powiadomienia Webhook są wyłączone.', 'warning_notifications_disabled_pushover' => 'Powiadomienia Pushover są wyłączone.', + 'warning_notifications_disabled_telegram' => 'Powiadomienia Telegram są wyłączone.', + 'warning_notifications_disabled_jabber' => 'Powiadomienia Jabber są wyłączone.', 'error_server_no_match' => 'Nie odnaleziono serwera.', 'error_server_label_bad_length' => 'Etykieta musi mieć pomiędzy 1 a 255 znaków.', 'error_server_ip_bad_length' => 'Domena/IP musi mieć pomiędzy 1 a 255 znaków.', @@ -189,12 +306,22 @@ $sm_lang = array( 'error_server_ip_bad_website' => 'Adres URL jest nieprawidłowy.', 'error_server_type_invalid' => 'Wybrany typ serwera jest nieprawidłowy.', 'error_server_warning_threshold_invalid' => 'Próg ostrzeżeń musi być liczbą całkowitą większą od 0.', + 'error_server_ssl_cert_expiry_days' => 'Minimalna ilość dla ważności certyfikatu SSL musi być liczbą + całkowitą większą lub równą 0.', ), 'config' => array( 'general' => 'Ogólne', 'site_title' => 'Tytuł strony', 'language' => 'Język', 'show_update' => 'Sprawdzić aktualizacje?', + 'password_encrypt_key' => 'Klucz szyfrowania haseł', + 'password_encrypt_key_note' => 'Klucz będzie użyty do szyfrowania haseł, które są zapisane w ustawieniach + serwerów żeby mieć dostęp do stron. Jeżeli klucz zostanie zmienione to + zapisane hasła będą nieprawidłowe!', + 'proxy' => 'Włącz proxy', + 'proxy_url' => 'Proxy ULR', + 'proxy_user' => 'Użytkownik proxy', + 'proxy_password' => 'Hasło proxy', 'email_status' => 'Pozwól na wysyłkę email', 'email_from_email' => 'Email z adresu', 'email_from_name' => 'Email od(nazwa)', @@ -205,13 +332,24 @@ $sm_lang = array( 'email_smtp_security_none' => 'None', 'email_smtp_username' => 'SMTP login', 'email_smtp_password' => 'SMTP hasło', - 'email_smtp_noauth' => 'Pozostaw puste dla braku autentykacji', + 'email_smtp_noauth' => 'Pozostaw puste dla braku uwierzytelniania', 'sms_status' => 'Pozwól na wysyłkę SMS', 'sms_gateway' => 'Bramka SMS', 'sms_gateway_username' => 'Login do bramki', 'sms_gateway_password' => 'Hasło do bramki', 'sms_from' => 'Numer nadawcy', - 'pushover_status' => 'Pozwól na wysyłkę notyfikacji Pushover', + 'discord_status' => 'Zezwól na wysyłanie powiadomień Discord', + 'discord_description' => 'Discord jest serwisem, który umożliwia wysyłania powiadomień w czasie + rzeczywistym. Odwiedź stronę + serwisu żeby otrzymać więcej informacji.', + 'webhook_status' => 'Zezwól na wysyłanie powiadomień webhooks.', + 'webhook_description' => 'Zezwól na wysyłanie powiadomień webhooks do serwisów takich jak Slack. Endpoint + dla payload wiadomości jest zdefiniowany w ustawieniach profilu użytkownika.', + 'webhook_url' => 'Webhook URL', + 'webhook_url_description' => 'URL dla webhook endpoint', + 'webhook_json' => 'Webhook Json', + 'webhook_json_description' => 'Niestandardowsy Json, użyj #message jak zmienną z treścią wiadomości.', + 'pushover_status' => 'Zezwól na wysyłanie powiadomień Pushover', 'pushover_description' => 'Pushover jest usługą ułatwiającą otrzymywanie powiadomień w czasie rzeczywistym. Sprawdź ich stronę aby uzyskać więcej informacji.', @@ -220,6 +358,30 @@ $sm_lang = array( 'pushover_api_token_description' => 'Zanim zaczniesz używać Pushover, musisz zarejestrować aplikację na ich stronie internetowej i wpisać tutaj App API Token.', + 'telegram_status' => 'Zezwól na wysyłanie powiadomień Telegram', + 'telegram_description' => 'Telegram jest komunikatorem + internetowym, który umożliwa notyfikacje w czasie rzeczywistym. Odwiedź stronę + z documentacja aby + uzyskać więcej informacji.', + 'telegram_api_token' => 'Telegram API Token', + 'telegram_api_token_description' => 'Zanim zaczniesz używać Telegram, potrzebujesz uzyskać API Token. + Odwiedź strone z dokumentacją żeby uzyskać pomocy.', + 'jabber_status' => 'Zezwól na wysyłanie powiadomień Jabber (XMPP)', + 'jabber_description' => 'Odwiedź stronę dokumentacją aby + uzyskać więcej informaji oraz przewodnik po instalacji.', + 'jabber_host' => 'Host', + 'jabber_host_description' => 'Adres host dostawcy Twojego konta Jabber. Dla konta Google użyj + talk.google.com.', + 'jabber_port' => 'Port', + 'jabber_port_description' => 'Port Twojego dostawcy Jabber. Domyślnie 5222. Dla konta Google użyj 5223.', + 'jabber_username' => 'Nazwa użytkownika', + 'jabber_username_description' => 'Dla konta Google użyj razem z domeną np. example@google.com.', + 'jabber_domain' => 'Domena', + 'jabber_domain_description' => 'Domena Twojego dostawy Jabber. Zostaw puste dla konta Google.', + 'jabber_password' => 'Hasło', + 'jabber_password_description' => 'Wypełnij tylko żeby ustawić lub zmienić.', + 'jabber_check' => 'Sprawdź swoje konto Jabber czy powiadomienie zostało odebrane.', 'alert_type' => 'Wybierz kiedy chcesz być powiadomiony.', 'alert_type_description' => 'Zmiana statusu: Otrzymasz powiadomienie gdy serwer zmieni status. Z online -> offline lub offline -> online.

    Offline: Otrzymasz @@ -231,29 +393,53 @@ $sm_lang = array( 'alert_type_status' => 'Zmiana statusu', 'alert_type_offline' => 'Offline', 'alert_type_always' => 'Zawsze', + 'combine_notifications' => 'Scalanie powiadomień', + 'combine_notifications_description' => 'Ogranicza ilość wysyłanych powiadomień poprzez scalanie wszystkich + powiadomień w jedną wiadomość (nie dotyczy powiadomień SMS).', + 'alert_proxy' => 'Jeżeli włączone to proxy nigdy nie bedzie użyte dla serwisów', + 'alert_proxy_url' => 'Fomat: host:port', 'log_status' => 'Status logowania', 'log_status_description' => 'Jeśli status logowania ustawiony jest na TRUE, monitor będzie logował wydarzenia.', 'log_email' => 'Emaile wysłane przez skrypt', 'log_sms' => 'SMS wysłane przez skrypt', + 'log_discord' => 'Notyfikacje Discord wysłane przez skrypt', 'log_pushover' => 'Notyfikacje Pushover wysłane przez skrypt', + 'log_webhook' => 'Notyfikacje Webhook wysłane przez skrypt', + 'log_telegram' => 'Notyfikacje Telegram wysłane przez skrypt', + 'log_jabber' => 'Notyfikacje Jabber wysłane przez skrypt', 'updated' => 'Konfiguracja została zaktualizowana.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', + 'tab_discord' => 'Discord', 'tab_pushover' => 'Pushover', + 'tab_webhook' => 'Webhook', + 'tab_telegram' => 'Telegram', + 'tab_jabber' => 'Jabber', 'settings_email' => 'Ustawienia Email', 'settings_sms' => 'Ustawienia SMS', + 'settings_discord' => 'Ustawienie Discord', 'settings_pushover' => 'Ustawienia Pushover', + 'settings_webhook' => 'Ustawienia Webhook', + 'settings_telegram' => 'Ustawienia Telegram', + 'settings_jabber' => 'Ustawienia Jabber', 'settings_notification' => 'Ustawienia powiadomień', 'settings_log' => 'Ustawienia Logowania', + 'settings_proxy' => 'Ustawienia serwera Proxy', 'auto_refresh' => 'Auto-odświeżanie', 'auto_refresh_description' => 'Auto-odświeżanie strony serwera.
    Czas w sekundach, dla czasu 0 strona nie będzie odświeżana.', 'test' => 'Test', 'test_email' => 'Email zostanie wysłany na adres podany w Twoim profilu.', 'test_sms' => 'SMS zostanie wysłany na numer podany w Twoim profilu.', - 'test_pushover' => 'Powiadomienie Pushover zostanie wysłany na klucz użytkownika/urządzenie podane w Twoim - profilu..', + 'test_discord' => 'Powiadomienie Discord zostanie wysłane do webhook, który został podany w Twoim profilu + użytkownika.', + 'test_pushover' => 'Powiadomienie Pushover zostanie wysłane na klucz użytkownika/urządzenie podane w Twoim + profilu użytkownika.', + 'test_webhook' => 'Powiadomienia Webhook zostanie wysłane do endpoint o podanym URL.', + 'test_telegram' => 'Powiadomienie Telegram zostanie wysłane na chat id podane w Twoim profilu użytkownika.', + 'test_jabber' => 'Powiadomienie Telegram zostanie wysłane na konto Jabber podane w Twoim profilu + użytkownika.', 'send' => 'Wyślij', 'test_subject' => 'Test', 'test_message' => 'Testowa wiadomość', @@ -262,38 +448,123 @@ $sm_lang = array( 'sms_sent' => 'Sms wysłany', 'sms_error' => 'Błąd podczas wysyłania sms. %s', 'sms_error_nomobile' => 'Nie udało się wysłać testowego SMS: brak poprawnego telefonu w Twoim profilu.', + 'discord_sent' => 'Powiadomienie Discord wysłane', + 'discord_error' => 'Błąd podczas wysyłania powiadomienia Pushover: %s', + 'discord_error_nowebhook' => 'Błąd podczas wysyłania powiadomienia Discord: brak prawidłowego Discord + webhook w profilu użytkownika.', + 'webhook_sent' => 'Powiadomienie Webhook wysłane', + 'webhook_error' => 'Błąd podczas wysyłania powiadomienia Webhook: %s', + 'webhook_error_nourl' => 'Błąd podczas wysyłania testowego powiadomienia: brak Webhook URL w profilu + użytkownika.', + 'webhook_error_nojson' => 'Błąd podczas wysyłania testowego powiadomienia: brak json w profilu + użytkownika.', 'pushover_sent' => 'Powiadomienie Pushover wysłane.', 'pushover_error' => 'Błąd podczas wysyłania powiadomienia Pushover: %s', 'pushover_error_noapp' => 'Błąd podczas wysyłania testowego powiadomienia: brak Pushover App API token w - konfuguracji globalnej.', + konfiguracji globalnej.', 'pushover_error_nokey' => 'Błąd podczas wysyłania testowego powiadomienia: brak Pushover key na Twoim profilu.', + 'telegram_sent' => 'Powiadomienie Telegram zostało wysłane', + 'telegram_error' => 'Wystąpił błąd podczas wysyłania powiadomienia Telegram: %s', + 'telegram_error_notoken' => 'Nie można wysłać testowego powiadomienia: brak Telegram API token w głównych + ustawieniach systemu.', + 'telegram_error_noid' => 'Nie można wysłać testowego powiadomienia: brak chat id w ustawieniach profilu + Twojego użytkownika.', + 'jabber_sent' => 'Powiadomienie Jabber zostało wysłane', + 'jabber_error' => 'Wystąpił błąd podczas wysyłania powiadomienia Jabber: %s', + 'jabber_error_noconfig' => 'Nie można wysłać testowego powiadomienia: brak konfiguracji konta Jabber w + głównych ustawieniach systemu.', + 'jabber_error_noaccount' => 'Nie można wysłać testowego powiadomienia: brak konfiguracji konta Jabber w + ustawieniach profilu Twojego użytkownika.', 'log_retention_period' => 'Czas rotacji logów', 'log_retention_period_description' => 'Liczba dni przez którą należy przetrzymywać logi powiadomień i archiwizować uptime serwera. Wpisz 0 aby wyłączyć czyszczenie logów.', 'log_retention_days' => 'dni', 'user_agent' => 'User Agent', - 'user_agent_key_note' => 'Nazwa używana przez monitoring do identyfikacji ze sprawdzaną usługą.', + 'user_agent_key_note' => 'Niestandardowy user agent używany przez monitor do komunikacji z zewnętrznymi + serwisami.', ), 'notifications' => array( 'off_sms' => 'Serwer \'%LABEL%\' przestał odpowiadać: ip=%IP%, port=%PORT%. Błąd=%ERROR%', 'off_email_subject' => 'Uwaga: Serwer \'%LABEL%\' nie odpowiada', 'off_email_body' => 'Błąd połączenia do serwera:

    Serwer: %LABEL%
    IP: %IP%
    Port: + %PORT%
    Błąd: %ERROR%
    Data: %DATE%', + 'off_discord_message' => 'Błąd połączenia do serwera:

    Serwer: %LABEL%
    IP: %IP%
    Port: + %PORT%
    Błąd: %ERROR%
    Data: %DATE%', + 'off_webhook_title' => 'Serwer \'%LABEL%\' nie odpowiada', + 'off_webhook_message' => 'Błąd połączenia do serwera:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Błąd: %ERROR%
    Data: %DATE%', 'off_pushover_title' => 'Serwer \'%LABEL%\' nie odpowiada', 'off_pushover_message' => 'Błąd połączenia do serwera:

    Serwer: %LABEL%
    IP: %IP%
    Port: + %PORT%
    Błąd: %ERROR%
    Data: %DATE%', + 'off_telegram_message' => 'Błąd połączenia do serwera:

    Serwer: %LABEL%
    IP: %IP%
    Port: + %PORT%
    Błąd: %ERROR%
    Data: %DATE%', + 'off_jabber_message' => 'Błąd połączenia do serwera:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Błąd: %ERROR%
    Data: %DATE%', 'on_sms' => 'Serwer \'%LABEL%\' działa poprawnie: ip=%IP%, port=%PORT%, it was down for %LAST_OFFLINE_DURATION%', 'on_email_subject' => 'Uwaga: Serwer \'%LABEL%\' działa poprawnie', - 'on_email_body' => 'Serwer \'%LABEL%\' znów odpowiada, it was down for + 'on_email_body' => 'Serwer \'%LABEL%\' znów odpowiada, był offline przez + %LAST_OFFLINE_DURATION%:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Data: + %DATE%', + 'on_discord_message' => 'Serwer \'%LABEL%\' znów odpowiada, był offline przez + %LAST_OFFLINE_DURATION%:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Data: + %DATE%', + 'on_webhook_title' => 'Serwer \'%LABEL%\' działa poprawnie', + 'on_webhook_message' => 'Serwer \'%LABEL%\' znów odpowiada, był offline przez %LAST_OFFLINE_DURATION%:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Data: %DATE%', 'on_pushover_title' => 'Serwer \'%LABEL%\' działa poprawnie', - 'on_pushover_message' => 'Serwer \'%LABEL%\' znów działa poprawnie, it was down for + 'on_pushover_message' => 'Serwer \'%LABEL%\' znów działa poprawnie, był offline przez %LAST_OFFLINE_DURATION%:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Data: %DATE%', + 'on_telegram_message' => 'Serwer \'%LABEL%\' znów działa poprawnie, był offline przez + %LAST_OFFLINE_DURATION%:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Data: + %DATE%', + 'on_jabber_message' => 'Serwer \'%LABEL%\' znów działa poprawnie, był offline przez + %LAST_OFFLINE_DURATION%:

    Serwer: %LABEL%
    IP: %IP%
    Port: %PORT%
    Data: + %DATE%', + 'combi_off_email_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Error: + %ERROR%
    • Date: %DATE%
    ', + 'combi_off_discord_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Error: %ERROR%
    - + Date: %DATE%

    ', + 'combi_off_webhook_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Error: + %ERROR%
    • Date: %DATE%
    ', + 'combi_off_pushover_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Error: + %ERROR%
    • Date: %DATE%
    ', + 'combi_off_telegram_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Error: %ERROR%
    - + Date: %DATE%

    ', + 'combi_off_jabber_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Error: %ERROR%
    - + Date: %DATE%

    ', + 'combi_on_email_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Downtime: + %LAST_OFFLINE_DURATION%
    • Date: %DATE%
    ', + 'combi_on_webhook_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: %PORT%
    • Downtime: + %LAST_OFFLINE_DURATION%
    • Date: %DATE%
    ', + 'combi_on_discord_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Downtime: + %LAST_OFFLINE_DURATION%
    - Date: %DATE%

    ', + 'combi_on_pushover_message' => '
    • Server: %LABEL%
    • IP: %IP%
    • Port: + %PORT%
    • Downtime: %LAST_OFFLINE_DURATION%
    • Date: + %DATE%
    ', + 'combi_on_telegram_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Downtime: + %LAST_OFFLINE_DURATION%
    - Date: %DATE%

    ', + 'combi_on_jabber_message' => '- Server: %LABEL%
    - IP: %IP%
    - Port: %PORT%
    - Downtime: + %LAST_OFFLINE_DURATION%
    - Date: %DATE%

    ', + 'combi_email_subject' => 'WAŻNE: \'%UP%\' serverów znowu ONLINE, \'%DOWN%\' serverów jest OFFLINE', + 'combi_webhook_subject' => '\'%UP%\' serverów jest znowu ONLINE UP, \'%DOWN%\' serverów jest OFFLINE', + 'combi_pushover_subject' => '\'%UP%\' serverów jest znowu ONLINE UP, \'%DOWN%\' serverów jest OFFLINE', + 'combi_email_message' => 'Następujące serwery są offline:
    %DOWN_SERVERS%
    Następujące + serwery są znowu online:
    %UP_SERVERS%', + 'combi_discord_message' => 'Następujące serwery są offline:
    %DOWN_SERVERS%
    Następujące + serwery są znowu online:
    %UP_SERVERS%', + 'combi_webhook_message' => 'Następujące serwery są offline:
    %DOWN_SERVERS%
    Następujące + serwery są znowu online:
    %UP_SERVERS%', + 'combi_pushover_message' => 'Następujące serwery są offline:
    %DOWN_SERVERS%
    Następujące + serwery są znowu online:
    %UP_SERVERS%', + 'combi_telegram_message' => 'Następujące serwery są offline:
    %DOWN_SERVERS%
    Następujące + serwery są znowu online:
    %UP_SERVERS%', + 'combi_jabber_message' => 'Następujące serwery są offline:
    %DOWN_SERVERS%
    Następujące + serwery są znowu online:
    %UP_SERVERS%', ), 'login' => array( 'welcome_usermenu' => 'Witaj, %user_name%', From 3cf9a6e444c6bcd3f2d6d9dfec726306942573d5 Mon Sep 17 00:00:00 2001 From: Samuel Denis-D'Ortun Date: Sun, 1 Nov 2020 11:08:53 -0500 Subject: [PATCH 058/112] Set public to false by default. --- config.php.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.php.sample b/config.php.sample index fd0775f4..a9537ed0 100644 --- a/config.php.sample +++ b/config.php.sample @@ -7,4 +7,4 @@ define('PSM_DB_HOST', 'localhost'); define('PSM_DB_PORT', '3306'); //3306 is the default port for MySQL. If no specfic port is used, leave it empty. define('PSM_BASE_URL', ''); define('PSM_WEBCRON_KEY', ''); -define('PSM_PUBLIC', true); \ No newline at end of file +define('PSM_PUBLIC', false); From 31e987a1d55563b91cc77930f818ae0dae07e144 Mon Sep 17 00:00:00 2001 From: Mario Rothauer Date: Tue, 15 Dec 2020 23:48:01 +0100 Subject: [PATCH 059/112] Improved german translation (#1071) --- src/lang/de_DE.lang.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index 9f0473de..9777fec2 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -125,10 +125,10 @@ $sm_lang = array( 'email' => 'E-Mail', 'sms' => 'SMS', 'pushover' => 'Pushover', - 'no_logs' => 'Keine Logs vorhanden.', - 'clear' => 'Protokoll Logs', - 'delete_title' => 'Protokoll Logs', - 'delete_message' => 'Bist du sicher, dass du alle logs löschen möchtest?', + 'no_logs' => 'Keine Protokolle vorhanden.', + 'clear' => 'Protokoll löschen', + 'delete_title' => 'Protokoll löschen', + 'delete_message' => 'Bist du sicher, dass du alle Protokolle löschen möchtest?', ), 'servers' => array( 'server' => 'Server', From 0d44af0ee0abd0c4f332b3920a91680be8dad867 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 22:48:38 +0000 Subject: [PATCH 060/112] Bump symfony/event-dispatcher from 3.4.44 to 3.4.47 (#1058) --- composer.lock | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index 3b8d7122..f1a95b6c 100644 --- a/composer.lock +++ b/composer.lock @@ -440,16 +440,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.4.44", + "version": "v3.4.47", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a0f6858fbf7a524747e87a4c336cab7d0b67c802" + "reference": "31fde73757b6bad247c54597beef974919ec6860" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a0f6858fbf7a524747e87a4c336cab7d0b67c802", - "reference": "a0f6858fbf7a524747e87a4c336cab7d0b67c802", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/31fde73757b6bad247c54597beef974919ec6860", + "reference": "31fde73757b6bad247c54597beef974919ec6860", "shasum": "" }, "require": { @@ -461,6 +461,7 @@ "require-dev": { "psr/log": "~1.0", "symfony/config": "~2.8|~3.0|~4.0", + "symfony/debug": "~3.4|~4.4", "symfony/dependency-injection": "~3.3|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/stopwatch": "~2.8|~3.0|~4.0" @@ -470,11 +471,6 @@ "symfony/http-kernel": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" @@ -513,7 +509,7 @@ "type": "tidelift" } ], - "time": "2020-08-12T14:55:37+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { "name": "symfony/filesystem", From 0a7844536f5d48136b56edb37448a48329d0d8a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 22:48:52 +0000 Subject: [PATCH 061/112] Bump symfony/dependency-injection from 3.4.44 to 3.4.47 (#1059) --- composer.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index f1a95b6c..bdb58390 100644 --- a/composer.lock +++ b/composer.lock @@ -355,16 +355,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v3.4.44", + "version": "v3.4.47", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "7d15cf4294d4f3610bc741c8fdd54a6baac586d4" + "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/7d15cf4294d4f3610bc741c8fdd54a6baac586d4", - "reference": "7d15cf4294d4f3610bc741c8fdd54a6baac586d4", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b", "shasum": "" }, "require": { @@ -393,11 +393,6 @@ "symfony/yaml": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\DependencyInjection\\": "" @@ -436,7 +431,7 @@ "type": "tidelift" } ], - "time": "2020-08-10T07:13:15+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { "name": "symfony/event-dispatcher", From d406f69231f95ede8fd5f9c67ee723ad5c0ffca3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 22:50:33 +0000 Subject: [PATCH 062/112] Bump symfony/http-foundation from 3.4.44 to 3.4.47 (#1060) --- composer.lock | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/composer.lock b/composer.lock index bdb58390..37134931 100644 --- a/composer.lock +++ b/composer.lock @@ -572,16 +572,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.4.44", + "version": "v3.4.47", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "e5a42880895b43cd53d1a7b92bdcfb7d80c0af1c" + "reference": "b9885fcce6fe494201da4f70a9309770e9d13dc8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e5a42880895b43cd53d1a7b92bdcfb7d80c0af1c", - "reference": "e5a42880895b43cd53d1a7b92bdcfb7d80c0af1c", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/b9885fcce6fe494201da4f70a9309770e9d13dc8", + "reference": "b9885fcce6fe494201da4f70a9309770e9d13dc8", "shasum": "" }, "require": { @@ -593,11 +593,6 @@ "symfony/expression-language": "~2.8|~3.0|~4.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\HttpFoundation\\": "" @@ -636,7 +631,7 @@ "type": "tidelift" } ], - "time": "2020-08-12T14:55:37+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { "name": "symfony/polyfill-ctype", @@ -716,16 +711,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.18.1", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + "reference": "b5f7b932ee6fa802fc792eabd77c4c88084517ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", - "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b5f7b932ee6fa802fc792eabd77c4c88084517ce", + "reference": "b5f7b932ee6fa802fc792eabd77c4c88084517ce", "shasum": "" }, "require": { @@ -737,7 +732,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-main": "1.19-dev" }, "thanks": { "name": "symfony/polyfill", @@ -789,20 +784,20 @@ "type": "tidelift" } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-10-23T09:01:57+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.18.1", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3" + "reference": "3fe414077251a81a1b15b1c709faf5c2fbae3d4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", - "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/3fe414077251a81a1b15b1c709faf5c2fbae3d4e", + "reference": "3fe414077251a81a1b15b1c709faf5c2fbae3d4e", "shasum": "" }, "require": { @@ -812,7 +807,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-main": "1.19-dev" }, "thanks": { "name": "symfony/polyfill", @@ -866,7 +861,7 @@ "type": "tidelift" } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-10-23T09:01:57+00:00" }, { "name": "twig/twig", From 3a58a562dd96984f0d8bf0ea329744b970316302 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 22:50:59 +0000 Subject: [PATCH 063/112] Bump symfony/config from 3.4.44 to 3.4.47 (#1061) --- composer.lock | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/composer.lock b/composer.lock index 37134931..a391f5a2 100644 --- a/composer.lock +++ b/composer.lock @@ -277,16 +277,16 @@ }, { "name": "symfony/config", - "version": "v3.4.44", + "version": "v3.4.47", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "801a3bbc17fb1ba44b0d7d41a6db7a0b74953595" + "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/801a3bbc17fb1ba44b0d7d41a6db7a0b74953595", - "reference": "801a3bbc17fb1ba44b0d7d41a6db7a0b74953595", + "url": "https://api.github.com/repos/symfony/config/zipball/bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", "shasum": "" }, "require": { @@ -308,11 +308,6 @@ "symfony/yaml": "To use the yaml reference dumper" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Config\\": "" @@ -351,7 +346,7 @@ "type": "tidelift" } ], - "time": "2020-08-10T07:13:15+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { "name": "symfony/dependency-injection", @@ -635,16 +630,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.18.1", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", - "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", "shasum": "" }, "require": { @@ -656,7 +651,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-main": "1.19-dev" }, "thanks": { "name": "symfony/polyfill", @@ -707,7 +702,7 @@ "type": "tidelift" } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-10-23T09:01:57+00:00" }, { "name": "symfony/polyfill-mbstring", From 10f111c8300633daa609112a0f2b1b7fe5bd7070 Mon Sep 17 00:00:00 2001 From: Lukas <35193662+NixNotCastey@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:52:16 +0100 Subject: [PATCH 064/112] PromoSMS Gateway (#1064) --- docs/credits.rst | 4 ++ src/includes/functions.inc.php | 3 ++ src/psm/Txtmsg/PromoSMS.php | 93 ++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 src/psm/Txtmsg/PromoSMS.php diff --git a/docs/credits.rst b/docs/credits.rst index 83ee5bf7..e34fee17 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -93,6 +93,10 @@ The following people have contributed to the development of PHP Server Monitor: * Discord webhook support +* Łukasz Szczepański - https://github.com/NixNotCastey + + * PromoSMS gateway + Translators +++++++++++ diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 59717599..6a70408f 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -799,6 +799,9 @@ namespace { case 'smsapi': $sms = new \psm\Txtmsg\SMSAPI(); break; + case 'promosms': + $sms = new \psm\Txtmsg\PromoSMS(); + break; } // copy login information from the config file diff --git a/src/psm/Txtmsg/PromoSMS.php b/src/psm/Txtmsg/PromoSMS.php new file mode 100644 index 00000000..ccb024bb --- /dev/null +++ b/src/psm/Txtmsg/PromoSMS.php @@ -0,0 +1,93 @@ +. + * + * @package phpservermon + * @author Łukasz Szczepański + * @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 3.5 + **/ + +namespace psm\Txtmsg; + +class PromoSMS extends Core +{ + + /** + * Send sms using the PromoSMS API + * + * @var string $message + * @var string $this->password + * @var array $this->recipients + * @var array $headers + * + * @var resource $curl + * @var string $err + * @var int $success + * @var string $error + * + * @return bool|string + */ + + public function sendSMS($message) + { + $error = ""; + $success = 1; + + $headers = array(); + $headers[] = "Content-Type: application/x-www-form-urlencoded"; + $headers[] = "Accept: text/json"; + $headers[] = 'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password); + + $curl = curl_init(); + curl_setopt_array($curl, array( + CURLOPT_URL => "https://promosms.com/api/rest/v3_2/sms", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_POST => true, + CURLOPT_HTTPHEADER => $headers, + CURLOPT_POSTFIELDS => http_build_query(array( + 'text' => htmlspecialchars($message), + 'type' => 1, + 'recipients' => $this->recipients, + )) + )); + + $result = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $err = curl_errno($curl); + + if ($err != 0 || ($httpcode != '200' && $httpcode != '201' && $httpcode != '202' && $result != "1")) { + $success = 0; + $error = "HTTP_code: " . $httpcode . ".\ncURL error (" . $err . "): " . + curl_strerror($err) . ". Result: " . $result . ""; + } + curl_close($curl); + + if ($success) { + return 1; + } + return $error; + } +} \ No newline at end of file From 59f4f44107e0ae01716a031cebe2bd985dfe9b91 Mon Sep 17 00:00:00 2001 From: jamgames2 <73676126+jamgames2@users.noreply.github.com> Date: Wed, 16 Dec 2020 05:54:21 +0700 Subject: [PATCH 065/112] Update profile.tpl.html (#1050) - ADD ' type="button" ' for prevent ' Enter Button ' from keyboard that open telegram activation page. --- src/templates/default/module/user/profile.tpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/default/module/user/profile.tpl.html b/src/templates/default/module/user/profile.tpl.html index 3cb8f315..57051839 100644 --- a/src/templates/default/module/user/profile.tpl.html +++ b/src/templates/default/module/user/profile.tpl.html @@ -37,7 +37,7 @@ {{ label_telegram_get_chat_id }}
    {{ 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) }} - + {{ macro.input_hidden("activate_telegram", "0") }} From 54a5e2801c0c410bcdae52d1562e9880739f3874 Mon Sep 17 00:00:00 2001 From: Joseph Helela Date: Wed, 16 Dec 2020 02:01:10 +0300 Subject: [PATCH 066/112] Adding Infobip SMS Gateway (#1012) --- README.rst | 2 +- src/includes/functions.inc.php | 3 ++ src/psm/Txtmsg/Infobip.php | 91 ++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/psm/Txtmsg/Infobip.php diff --git a/README.rst b/README.rst index 26e51041..189d326d 100644 --- a/README.rst +++ b/README.rst @@ -62,7 +62,7 @@ The following SMS gateways are currently available: * Callr - * SMSAPI - * OVH SMS PRO - - +* Infobip - Please note: for these gateways you will need an account with sufficient credits. diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 6a70408f..44b6d129 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -755,6 +755,9 @@ namespace { case 'smsglobal': $sms = new \psm\Txtmsg\Smsglobal(); break; + case 'infobip': + $sms = new \psm\Txtmsg\Infobip(); + break; case 'freevoipdeal': $sms = new \psm\Txtmsg\FreeVoipDeal(); break; diff --git a/src/psm/Txtmsg/Infobip.php b/src/psm/Txtmsg/Infobip.php new file mode 100644 index 00000000..b5edc89d --- /dev/null +++ b/src/psm/Txtmsg/Infobip.php @@ -0,0 +1,91 @@ +. + * + * @package phpservermon + * @author Victor Macko + * @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 3.6.0 + **/ + +namespace psm\Txtmsg; + +class Infobip extends Core +{ + + /** + * Send sms using the infobip.com API + * + * @var string $message + * @var string $this->password + * @var array $this->recipients + * @var array $this->originator + * @var string $recipients + * + * @var resource $curl + * @var string $err + * @var mixed $result + * + * @var int $success + * @var string $error + * + * @return bool|string + */ + + + + public function sendSMS($message) + { + $success = 1; + $error = ''; + foreach ($this->recipients as $recipient) { + $ch = curl_init(); + curl_setopt( + $ch, + CURLOPT_URL, + "https://api.infobip.com/sms/1/text/query?username=" . $this->username . + "&password=" . $this->password . + "&to=" . $recipient . + "&text=" . urlencode($message) . + //add your sender id here + "&from=" + ); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $headers = array(); + $headers[] = "Content-Type: application/x-www-form-urlencoded"; + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $result = curl_exec($ch); + curl_close($ch); + + // Check for errors + if (is_numeric(strpos($result, "FAILED"))) { + $error = $result; + $success = 0; + } + } + if ($success == 1) { + return 1; + } + return $error; + } +} + From 15edba0f1abc53ff3f782f35e05439654e7a7155 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 16 Dec 2020 00:04:35 +0100 Subject: [PATCH 067/112] Added PromoSMS See #1064. --- README.rst | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 189d326d..45b1685f 100644 --- a/README.rst +++ b/README.rst @@ -46,23 +46,24 @@ The following SMS gateways are currently available: * Inetworx - * Messagebird - * Mosms - -* Smsglobal - -* SMSit - +* Smsglobal - +* SMSit - * Spryng - * Textmarketer - * FreeVoipDeal - -* Nexmo - -* OctoPush - -* FreeMobile (FR) - +* Nexmo - +* OctoPush - +* FreeMobile (FR) - * Twilio - -* CM Telecom - -* GatewayAPI - -* SolutionsInfini - -* Plivo - -* Callr - +* CM Telecom - +* GatewayAPI - +* SolutionsInfini - +* Plivo - +* Callr - * SMSAPI - -* OVH SMS PRO - -* Infobip - +* OVH SMS PRO - +* PromoSMS - +* Infobip - Please note: for these gateways you will need an account with sufficient credits. From 28caad2c8538877f5e14ef68f19298dc69964589 Mon Sep 17 00:00:00 2001 From: Philip <3460129+ppac@users.noreply.github.com> Date: Wed, 16 Dec 2020 00:14:05 +0100 Subject: [PATCH 068/112] Update de_DE.lang.php (#1025) * Update de_DE.lang.php Co-authored-by: Tim --- src/lang/de_DE.lang.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index 9777fec2..ae0a7313 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -59,7 +59,7 @@ $sm_lang = array( 'long_day_format' => '%B %e, %Y', 'yesterday_format' => 'Gestern um %k:%M Uhr', 'other_day_format' => '%A um %k:%M Uhr', - 'never' => 'Never', + 'never' => 'Nie', 'hours_ago' => 'vor %d Stunden', 'an_hour_ago' => 'vor über einer Stunde', 'minutes_ago' => 'vor %d Minuten', @@ -202,8 +202,8 @@ $sm_lang = array( 'email_smtp' => 'SMTP-Versand aktivieren', 'email_smtp_host' => 'SMTP Server/Host', 'email_smtp_port' => 'SMTP Port', - 'email_smtp_security' => 'SMTP security', - 'email_smtp_security_none' => 'None', + 'email_smtp_security' => 'SMTP Authentifizierung', + 'email_smtp_security_none' => 'Keine', 'email_smtp_username' => 'SMTP Benutzername', 'email_smtp_password' => 'SMTP Passwort', 'email_smtp_noauth' => 'Feld leer lassen, bei fehlender Authentifizierung', @@ -286,14 +286,14 @@ $sm_lang = array( 'off_pushover_message' => 'Kann keine funktionierende Verbindung zum Dienst bzw. der Webseite aufbauen:

    Dienst/Webseite: %LABEL%
    IP: %IP%
    Port: %PORT%
    Fehler: %ERROR%
    Datum: %DATE% Uhr', - 'on_sms' => 'Dienst/Webseite \'%LABEL%\' ist wieder online: ip=%IP%, port=%PORT%, it was down for + 'on_sms' => 'Dienst/Webseite \'%LABEL%\' ist wieder online: ip=%IP%, port=%PORT%, offline für %LAST_OFFLINE_DURATION%', 'on_email_subject' => 'Hinweis: Dienst/Webseite \'%LABEL%\' ist wieder online.', - 'on_email_body' => 'Dienst/Webseite \'%LABEL%\' ist wieder erreichbar, it was down for + 'on_email_body' => 'Dienst/Webseite \'%LABEL%\' ist wieder erreichbar, offline für %LAST_OFFLINE_DURATION%:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Datum: %DATE% Uhr', 'on_pushover_title' => 'Dienst/Webseite \'%LABEL%\' ist wieder online.', - 'on_pushover_message' => 'Dienst/Webseite \'%LABEL%\' ist wieder erreichbar, it was down for + 'on_pushover_message' => 'Dienst/Webseite \'%LABEL%\' ist wieder erreichbar, offline für %LAST_OFFLINE_DURATION%:

    Server: %LABEL%
    IP: %IP%
    Port: %PORT%
    Datum: %DATE% Uhr', ), @@ -313,7 +313,7 @@ $sm_lang = array( 'password_reset' => 'Passwort zurücksetzen', 'password_reset_email_subject' => 'Setzen Sie Ihr Zugangspasswort für den Server Monitor', 'password_reset_email_body' => 'Benutzen Sie bitte den folgenden Link, um Ihr Zugangspasswort zurückzusetzen. - Bitte beachten Sie: Der Link verfällt in 1 Stunde.

    %link%', + Bitte beachten Sie: Der Link verfällt in einer Stunde.

    %link%', 'error_user_incorrect' => 'Der angegebene Benutzername konnte nicht gefunden werden.', 'error_login_incorrect' => 'Die angegebenen Informationen sind leider nicht korrekt.', 'error_login_passwords_nomatch' => 'Die angegebenen Passwörter stimmen nicht überein.', From a94f8ca677a02a89ccaa5bb9bccdc68135b97adf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:14:56 +0000 Subject: [PATCH 069/112] Bump symfony/filesystem from 3.4.44 to 3.4.47 (#1062) --- composer.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index a391f5a2..58dbc0e3 100644 --- a/composer.lock +++ b/composer.lock @@ -503,16 +503,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.4.44", + "version": "v3.4.47", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "8e6eff546d0fe879996fa701ee2f312767e95e50" + "reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/8e6eff546d0fe879996fa701ee2f312767e95e50", - "reference": "8e6eff546d0fe879996fa701ee2f312767e95e50", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/e58d7841cddfed6e846829040dca2cca0ebbbbb3", + "reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3", "shasum": "" }, "require": { @@ -520,11 +520,6 @@ "symfony/polyfill-ctype": "~1.8" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Filesystem\\": "" @@ -563,7 +558,7 @@ "type": "tidelift" } ], - "time": "2020-08-21T12:53:49+00:00" + "time": "2020-10-24T10:57:07+00:00" }, { "name": "symfony/http-foundation", From 79ccd15a76eb74036d0c16725774823fdc02205c Mon Sep 17 00:00:00 2001 From: hjcday <59719860+hjcday@users.noreply.github.com> Date: Wed, 16 Dec 2020 10:16:05 +1100 Subject: [PATCH 070/112] Fix Plivo SMS encoding (#981) Co-authored-by: hjcday --- src/psm/Txtmsg/Plivo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Txtmsg/Plivo.php b/src/psm/Txtmsg/Plivo.php index e2eec00f..7c164684 100644 --- a/src/psm/Txtmsg/Plivo.php +++ b/src/psm/Txtmsg/Plivo.php @@ -74,7 +74,7 @@ class Plivo extends Core array( "src" => $this->originator, "dst" => $recipients, - "text" => urlencode($message) + "text" => $message ) ), CURLOPT_HTTPHEADER => array( From 17cb13364b5c366d2e9f2d1e2bf2e8d2081857bd Mon Sep 17 00:00:00 2001 From: Viharm Date: Tue, 15 Dec 2020 23:21:45 +0000 Subject: [PATCH 071/112] Feature ldapauth (#507) * Composer dependency added * Updated code for language and config controller * Added LDAP auth code * Added blank discord value for new user during install --- composer.json | 3 +- src/lang/en_US.lang.php | 49 +++++++++++++ .../Config/Controller/ConfigController.php | 69 ++++++++++++++++++- .../Install/Controller/InstallController.php | 1 + src/psm/Service/User.php | 47 ++++++++++--- .../default/module/config/config.tpl.html | 42 +++++++++++ 6 files changed, 201 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 0498c033..31228c8a 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "php-pushover/php-pushover": "dev-master", "paragonie/random_compat": "^2.0", "twig/twig": "~1.35", - "jaxl/jaxl": "^3.1" + "jaxl/jaxl": "^3.1", + "viharm/psm-ldap-auth": "^1.1" }, "autoload": { "files": [ diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index ff6895ac..0d64ce17 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -342,6 +342,53 @@ $sm_lang = array( 'jabber_password' => 'Password', 'jabber_password_description' => 'Fill only to set or change.', 'jabber_check' => 'Check your Jabber account if message was received.', + 'dirauth_status' => 'Authenticate with directory service', + 'authdir_host_locn' => 'Directory host', + 'authdir_host_port' => 'Directory port', + 'authdir_type' => 'Service type', + 'authdir_type_description' => 'OpenLDAP: Directory is an OpenLDAP service.
    AD + DS: Directory is an Active Directory Domain Service.
    AD + LDS: Directory is an Active Directory Lightweight Directory + Service.', + 'authdir_type_openldap' => 'OpenLDAP', + 'authdir_type_adds' => 'AD DS', + 'authdir_type_adlds' => 'AD LDS', + 'authdir_userdomain' => 'Active Directory domain', + 'authdir_userdomain_description' => 'User domain for Active Directory. This is typically the NETBIOS domain + for AD DS and the DNS domain for AD LDS. Not used for OpenLDAP + directories.', + 'authdir_ldapver' => 'LDAP protocol version', + 'authdir_ldapver_description' => 'Version of the LDAP specification. This is typically Version 3 (default). + Version 2 was deprecated in 2003 (RFC3494).', + 'authdir_ldapfollowref' => 'Follow referrals', + 'authdir_ldapfollowref_description' => 'Follow referrals if the specified server refers to another server for + the required information. Leave unchecked if you are unaware of this + functionality.', + 'authdir_basedn' => 'Base DN*', + 'authdir_basedn_description' => 'Base distinguished name (DN) of the directory service. E.g., + dc=domain,dc=tld. This is a required field.', + 'authdir_usernameattrib' => 'Username attribute', + 'authdir_usernameattrib_description' => 'Attribute used by the directory service to refer to the username of + the user.', + 'authdir_groupnameattrib' => 'Group name attribute', + 'authdir_groupnameattrib_description' => 'Attribute used by the directory service to refer to the group name + of a group. This is used to check for group membership.', + 'authdir_groupmemattrib' => 'Group member attribute', + 'authdir_groupmemattrib_description' => 'Attribute used by the directory service to refer to the group(s) of + which the user is a member. This is used to check for group + membership.', + 'authdir_usercontainerrdn' => 'User container RDN', + 'authdir_usercontainerrdn_description' => 'Relative distinguished name of the users container in the + directory. E.g., ou=Users', + 'authdir_groupcontainerrdn' => 'Group container RDN', + 'authdir_groupcontainerrdn_description' => 'Relative distinguished name of the groups container in the + directory. E.g., ou=Groups', + 'authdir_groupname' => 'Authorised directory group', + 'authdir_groupname_description' => 'Directory group authorised to access application. Directory users not + members of this group will not be authenticated (currently not available + for AD).', + 'authdir_defaultrole' => 'Default role', + 'authdir_defaultrole_description' => 'Default role to be assigned to users logging in for the first time.', 'alert_type' => 'Select when you\'d like to be notified.', 'alert_type_description' => 'Status change: You will receive a notification when a server has a change in status. So from online -> offline or offline -> online.

    Offline: You will receive a notification when a server goes offline for the *FIRST TIME ONLY*. For example, your cronjob is every 15 minutes and your server goes down at 1 am and stays down till 6 am. You will get 1 notification at 1 am and that\'s it.

    Always: You will receive a notification every time the script runs and a site is down, even if the site has been offline for hours.', 'alert_type_status' => 'Status change', @@ -368,6 +415,7 @@ $sm_lang = array( 'tab_webhook' => 'Webhook', 'tab_telegram' => 'Telegram', 'tab_jabber' => 'Jabber', + 'tab_auth' => 'Authentication', 'settings_email' => 'Email settings', 'settings_sms' => 'Text message settings', 'settings_discord' => 'Discord settings', @@ -378,6 +426,7 @@ $sm_lang = array( 'settings_notification' => 'Notification settings', 'settings_log' => 'Log settings', 'settings_proxy' => 'Proxy settings', + 'settings_dirauth' => 'LDAP settings', 'auto_refresh' => 'Auto-refresh', 'auto_refresh_description' => 'Auto-refresh servers page.
    Time in seconds, if 0 the page won\'t refresh.', 'test' => 'Test', diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index df524c4d..c93ca375 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -58,6 +58,8 @@ class ConfigController extends AbstractController 'log_jabber', 'show_update', 'combine_notifications', + 'dirauth_status', + 'authdir_ldapfollowref', ); /** @@ -85,7 +87,18 @@ class ConfigController extends AbstractController 'jabber_username', 'jabber_domain', 'user_agent', - 'site_title' + 'site_title', + 'authdir_host_locn', + 'authdir_host_port', + 'authdir_userdomain', + 'authdir_ldapver', + 'authdir_basedn', + 'authdir_usernameattrib', + 'authdir_groupnameattrib', + 'authdir_groupmemattrib', + 'authdir_usercontainerrdn', + 'authdir_groupcontainerrdn', + 'authdir_groupname', ); /** @@ -162,6 +175,20 @@ class ConfigController extends AbstractController ); } + foreach (array("20", "10") as $authdir_defaultrole) { + $tpl_data['authdir_defaultroles'][] = array( + 'value' => $authdir_defaultrole, + 'label' => psm_get_lang('users', 'level_' . $authdir_defaultrole), + ); + } + + foreach (array("openldap", "adds", "adlds") as $authdir_type) { + $tpl_data['authdir_type'][] = array( + 'value' => $authdir_type, + 'label' => psm_get_lang('config', 'authdir_type_' . $authdir_type), + ); + } + $tpl_data['email_smtp_security'] = array( array( 'value' => '', @@ -181,6 +208,10 @@ class ConfigController extends AbstractController $config['sms_gateway'] : current($sms_gateways); $tpl_data['alert_type_selected'] = isset($config['alert_type']) ? $config['alert_type'] : ''; + $tpl_data['authdir_type_selected'] = isset($config['authdir_type']) ? + $config['authdir_type'] : ''; + $tpl_data['authdir_defaultrole_selected'] = isset($config['authdir_defaultrole']) ? + $config['authdir_defaultrole'] : '20'; $tpl_data['email_smtp_security_selected'] = isset($config['email_smtp_security']) ? $config['email_smtp_security'] : ''; $tpl_data['auto_refresh_servers'] = isset($config['auto_refresh_servers']) ? @@ -244,6 +275,8 @@ class ConfigController extends AbstractController 'site_title' => $_POST['site_title'], 'sms_gateway' => $_POST['sms_gateway'], 'alert_type' => $_POST['alert_type'], + 'authdir_defaultrole' => $_POST['authdir_defaultrole'], + 'authdir_type' => $_POST['authdir_type'], 'email_smtp_security' => in_array($_POST['email_smtp_security'], array('', 'ssl', 'tls')) ? $_POST['email_smtp_security'] @@ -296,6 +329,8 @@ class ConfigController extends AbstractController if (isset($_POST['general_submit'])) { $this->default_tab = 'general'; + } elseif (isset($_POST['auth_submit'])) { + $this->default_tab = 'auth'; } elseif (isset($_POST['email_submit']) || !empty($_POST['test_email'])) { $this->default_tab = 'email'; } elseif (isset($_POST['sms_submit']) || !empty($_POST['test_sms'])) { @@ -546,6 +581,7 @@ class ConfigController extends AbstractController '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_tab_auth' => psm_get_lang('config', 'tab_auth'), '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'), @@ -553,6 +589,7 @@ class ConfigController extends AbstractController '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'), + 'label_settings_dirauth' => psm_get_lang('config', 'settings_dirauth'), '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'), @@ -613,6 +650,36 @@ class ConfigController extends AbstractController 'label_jabber_domain_description' => psm_get_lang('config', 'jabber_domain_description'), 'label_jabber_password' => psm_get_lang('config', 'jabber_password'), 'label_jabber_password_description' => psm_get_lang('config', 'jabber_password_description'), + 'label_dirauth_status' => psm_get_lang('config', 'dirauth_status'), + 'label_authdir_host_locn' => psm_get_lang('config', 'authdir_host_locn'), + 'label_authdir_host_port' => psm_get_lang('config', 'authdir_host_port'), + 'label_authdir_type' => psm_get_lang('config', 'authdir_type'), + 'label_authdir_type_description' => psm_get_lang('config', 'authdir_type_description'), + 'label_authdir_userdomain' => psm_get_lang('config', 'authdir_userdomain'), + 'label_authdir_userdomain_description' => psm_get_lang('config', 'authdir_userdomain_description'), + 'label_authdir_ldapver' => psm_get_lang('config', 'authdir_ldapver'), + 'label_authdir_ldapver_description' => psm_get_lang('config', 'authdir_ldapver_description'), + 'label_authdir_ldapfollowref' => psm_get_lang('config', 'authdir_ldapfollowref'), + 'label_authdir_ldapfollowref_description' => psm_get_lang('config', 'authdir_ldapfollowref_description'), + 'label_authdir_basedn' => psm_get_lang('config', 'authdir_basedn'), + 'label_authdir_basedn_description' => psm_get_lang('config', 'authdir_basedn_description'), + 'label_authdir_usernameattrib' => psm_get_lang('config', 'authdir_usernameattrib'), + 'label_authdir_usernameattrib_description' => psm_get_lang('config', 'authdir_usernameattrib_description'), + 'label_authdir_groupnameattrib' => psm_get_lang('config', 'authdir_groupnameattrib'), + 'label_authdir_groupnameattrib_description' => + psm_get_lang('config', 'authdir_groupnameattrib_description'), + 'label_authdir_groupmemattrib' => psm_get_lang('config', 'authdir_groupmemattrib'), + 'label_authdir_groupmemattrib_description' => psm_get_lang('config', 'authdir_groupmemattrib_description'), + 'label_authdir_usercontainerrdn' => psm_get_lang('config', 'authdir_usercontainerrdn'), + 'label_authdir_usercontainerrdn_description' => + psm_get_lang('config', 'authdir_usercontainerrdn_description'), + 'label_authdir_groupcontainerrdn' => psm_get_lang('config', 'authdir_groupcontainerrdn'), + 'label_authdir_groupcontainerrdn_description' => + psm_get_lang('config', 'authdir_groupcontainerrdn_description'), + 'label_authdir_groupname' => psm_get_lang('config', 'authdir_groupname'), + 'label_authdir_groupname_description' => psm_get_lang('config', 'authdir_groupname_description'), + 'label_authdir_defaultrole' => psm_get_lang('config', 'authdir_defaultrole'), + 'label_authdir_defaultrole_description' => psm_get_lang('config', 'authdir_defaultrole_description'), 'label_alert_type' => psm_get_lang('config', 'alert_type'), 'label_alert_type_description' => psm_get_lang('config', 'alert_type_description'), 'label_combine_notifications' => psm_get_lang('config', 'combine_notifications'), diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index b1b9bc0b..7afd97f1 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -306,6 +306,7 @@ class InstallController extends AbstractController 'webhook_url' => '', 'webhook_json' => '', 'telegram_id' => '', + 'discord' => '', 'jabber' => '' ); diff --git a/src/psm/Service/User.php b/src/psm/Service/User.php index fce6213b..bc01db2a 100644 --- a/src/psm/Service/User.php +++ b/src/psm/Service/User.php @@ -230,20 +230,51 @@ class User { $user_name = trim($user_name); $user_password = trim($user_password); + $ldapauthstatus = false; if (empty($user_name) && empty($user_password)) { return false; } + + $dirauthconfig = psm_get_conf('dirauth_status'); + + // LDAP auth enabled + if ($dirauthconfig === '1') { + $ldaplibpath = realpath( + PSM_PATH_SRC . '..' . DIRECTORY_SEPARATOR . + 'vendor' . DIRECTORY_SEPARATOR . + 'viharm' . DIRECTORY_SEPARATOR . + 'psm-ldap-auth' . DIRECTORY_SEPARATOR . + 'psmldapauth.php' + ); + // If the library is found + if ($ldaplibpath) { + // Delegate the authentication to the PsmLDAPauth module. + // If LDAP auth fails or if library not found, fall back to native auth + include_once($ldaplibpath); + $ldapauthstatus = psmldapauth($user_name, $user_password, $GLOBALS['sm_config'], $this->db_connection); + } + } + $user = $this->getUserByUsername($user_name); - // using PHP 5.5's password_verify() function to check if the provided passwords - // fits to the hash of that user's password - if (!isset($user->user_id)) { - password_verify($user_password, 'dummy_call_against_timing'); - return false; - } elseif (!password_verify($user_password, $user->password)) { - return false; - } + // Authenticated + if ($ldapauthstatus === true) { + // Remove password to prevent it from being saved in the DB. + // Otherwise, user may still be authenticated if LDAP is disabled later. + $user_password = null; + @fn_Debug('Authenticated', $user); + } else { + + // using PHP 5.5's password_verify() function to check if the provided passwords + // fits to the hash of that user's password + if (!isset($user->user_id)) { + password_verify($user_password, 'dummy_call_against_timing'); + return false; + } elseif (!password_verify($user_password, $user->password)) { + return false; + } + } // not authenticated $this->setUserLoggedIn($user->user_id, true); diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index ffb36a54..db5ab029 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -7,6 +7,11 @@ role="tab" aria-controls="config-general" aria-selected="{% if general_active %}true{% else %}false{% endif %}">{{ label_general }}
  • +