diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9a4d91e8..76bf26d4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,19 +2,41 @@ Changelog ========= -not yet released +Not yet released ---------------- +* Fixed ping error: Failed to parse address "8.8.8.8" +* Added correct ping error messaging. +* Added Twilio and Telegram to the notification list. +* Directed download url to the release page. +* Changed all http links to https. +* #571 Updated several dependencies and made few fixes. +* #569 Implemented Twilio +* Added Telegram and Pushover.net to in-code documentation. + +v3.2.2 (released March 27, 2018) +-------------------------------- + +* #554 Implemented Telegram notifications. +* #505: Added button to clear the logs. * #436: Nexmo.class.php updates to Nexmo.php. +* #350: Removed utf8_decode. +* Updated credits. * #535: Updated Japanese translation. * #502: Fixed database population bug during installation. * #512: Added username validation during installation and added the dot (.) to allowed characters. * #475: Added Japanese translation. -* #454: Updated HistoryGraph.php timestamp to number_format. + +v3.2.1 (released March 27, 2018) +-------------------------------- + * #343: Added optinal header value check. +* #433: Changed baseurl repoforgeextras. +* #432: Changed baseurl repoforge. * #437: Octopush.class.php updates to Octopush.php. -* #170: Added Nexmo SMS to list in config.tpl.html. +* #435: Added Nexmo SMS to list in config.tpl.html. * #464: Updated attributes pushover_key and pushover_device in update.tpl.html. +* #454: Updated HistoryGraph.php timestamp to number_format. v3.2.0 (released April 15, 2017) -------------------------------- diff --git a/README.rst b/README.rst index 68a0f16f..82046c89 100755 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ PHP Server Monitor .. image:: https://badges.gitter.im/Join%20Chat.svg :alt: Join the chat at https://gitter.im/erickrf/nlpnet :target: https://gitter.im/phpservermon/phpservermon - + Version 3.3.0 (under development) @@ -56,6 +56,7 @@ The following SMS gateways are currently available: * OctoPush - * FreeMobile (FR) - * Twilio - +* CM Telecom - diff --git a/docs/intro.rst b/docs/intro.rst index a6cefe78..e1d0aa9c 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -48,15 +48,19 @@ You can choose for email, text message (SMS), Pushover.net and Telegram notifica The following SMS gateways are currently available: * Clickatell - -* Inetworx - -* Mollie - -* Mosms - -* Smsglobal - -* SMSit - -* Spryng - -* Textmarketer - -* FreeVoipDeal - +* Inetworx - +* Mollie - +* Mosms - +* Smsglobal - +* SMSit - +* Spryng - +* Textmarketer - +* FreeVoipDeal - * Nexmo - +* OctoPush - +* FreeMobile (FR) - +* Twilio - +* CM Telecom - 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 2670a12e..dde0f585 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -278,6 +278,25 @@ function psm_log_uptime($server_id, $status, $latency) { ); } +/** + * 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') ) . " "; } + if ($interval->m) { $result .= $interval->format("%m ") . ( ($interval->m == 1) ? 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') ) . " "; } + if ($interval->h) { $result .= $interval->format("%h ") . ( ($interval->h == 1) ? 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') ) . " "; } + if ($interval->s) { $result .= $interval->format("%s ") . ( ($interval->s == 1) ? 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 * diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index 1b4f4599..ee5b11c2 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'преди минута', 'seconds_ago' => 'преди %d секунди', 'a_second_ago' => 'преди секунда', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Настройки', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Ако този текст не е намерен в интернет страницата (когато имате добавен сайт), той ще бъде маркиран като Офлайн. Регулярните изрази са разрешени.', 'last_check' => 'Последна проверка', 'last_online' => 'Последно на линия', + 'last_offline' => 'Last offline', 'monitoring' => 'Мониторинг', 'no_monitoring' => 'Не се наблюдава', 'email' => 'Имейл', diff --git a/src/lang/cs_CZ.lang.php b/src/lang/cs_CZ.lang.php index 6d721b54..fd3a8fbf 100644 --- a/src/lang/cs_CZ.lang.php +++ b/src/lang/cs_CZ.lang.php @@ -61,6 +61,18 @@ $sm_lang = array( 'a_minute_ago' => 'cca před minutou', 'seconds_ago' => 'před %d vteřinami', 'a_second_ago' => 'před chvílí', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Konfigurace', @@ -143,6 +155,7 @@ $sm_lang = array( 'pattern_description' => 'Pokud vzorek nebude na webu nalezen, bude server označen jako offline. Regulární výrazy jsou povoleny.', 'last_check' => 'Poslední kontrola', 'last_online' => 'Naposledy online', + 'last_offline' => 'Naposledy offline', 'monitoring' => 'Monitoring', 'no_monitoring' => 'Žádné monitorované služby', 'email' => 'E-mail', diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php index efa54f53..cfa62017 100644 --- a/src/lang/da_DK.lang.php +++ b/src/lang/da_DK.lang.php @@ -58,6 +58,18 @@ $sm_lang = array( 'a_minute_ago' => 'omkring et minut siden', 'seconds_ago' => '%d sekunder siden', 'a_second_ago' => 'et sekund siden', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Indstillinger', @@ -130,6 +142,7 @@ $sm_lang = array( 'pattern_description' => 'Hvis dette mønster ikke findes på hjemmesiden, vil serveren blive markeret som værende offline. Regulære udtryk er tilladt.', 'last_check' => 'Sidst kontrolleret', 'last_online' => 'Sidst online', + 'last_offline' => 'Sidst offline', 'monitoring' => 'Overvågning', 'no_monitoring' => 'Ingen overvågning', 'email' => 'E-mail', diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index 818b1876..b4094b07 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'vor über einer Minute', 'seconds_ago' => 'vor %d Sekunden', 'a_second_ago' => 'vor über einer Sekunde', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Einstellungen', @@ -133,6 +145,7 @@ $sm_lang = array( 'pattern_description' => 'Wenn das gesuchte Muster nicht in der Webseite ist, wird die Seite als offline markiert. Reguläre Ausdrücke sind erlaubt.', 'last_check' => 'Letzter Check', 'last_online' => 'Zuletzt online', + 'last_offline' => 'Zuletzt offline', 'monitoring' => 'Monitoring', 'no_monitoring' => 'Monitoring inaktiv', 'email' => 'E-Mail', diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 8d7151bf..73858b4c 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -61,6 +61,18 @@ $sm_lang = array( 'a_minute_ago' => 'about a minute ago', 'seconds_ago' => '%d seconds ago', 'a_second_ago' => 'a second ago', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Config', @@ -160,6 +172,7 @@ $sm_lang = array( 'header_value_description' => 'Header value. Regular expressions are allowed.', 'last_check' => 'Last check', 'last_online' => 'Last online', + 'last_offline' => 'Last offline', 'monitoring' => 'Monitoring', 'no_monitoring' => 'No monitoring', 'email' => 'Email', @@ -327,12 +340,12 @@ $sm_lang = array( '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%", - 'on_sms' => 'Server \'%LABEL%\' is RUNNING: ip=%IP%, port=%PORT%', + '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:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%", + 'on_email_body' => "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:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%', - 'on_telegram_message' => 'Server \'%LABEL%\' is running again:

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

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

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%', ), 'login' => array( 'welcome_usermenu' => 'Welcome, %user_name%', diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index 4e1534d3..aab8ac56 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -62,6 +62,18 @@ $sm_lang = array( 'a_minute_ago' => 'Hace aproximadamente un minuto', 'seconds_ago' => 'Hace %d segundos', 'a_second_ago' => 'Hace aproximadamente un segundo', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Configurar', @@ -134,6 +146,7 @@ $sm_lang = array( 'pattern_description' => 'Si este patrón no se encuentra en el sitio web, el servidor estará marcada como sin conexión. Se permiten expresiones regulares.', 'last_check' => 'Última verificación', 'last_online' => 'Última vez en línea', + 'last_offline' => 'Last offline', 'monitoring' => 'Monitoreo', 'no_monitoring' => 'Sin monitoreo', 'email' => 'Email', diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index be70cf5d..ab97767c 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -61,6 +61,18 @@ $sm_lang = array( 'a_minute_ago' => 'Il y a une minute', 'seconds_ago' => 'Il y a %d secondes', 'a_second_ago' => 'Il y a une seconde', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Configuration', @@ -133,6 +145,7 @@ $sm_lang = array( 'pattern_description' => 'Si ce texte n\'est par retrouvé sur le site web, le serveur est marqué hors-service. Les expressions réguliaires sont autorisées.', 'last_check' => 'Dernière vérification', 'last_online' => 'Dernière fois OK', + 'last_offline' => 'Last offline', 'monitoring' => 'Surveillé', 'no_monitoring' => 'Non surveillé', 'email' => 'Email', diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php index 2396b8dc..4de13b52 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'circa un minuto fa', 'seconds_ago' => '%d secondi fa', 'a_second_ago' => 'un secondo fa', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Configurazione', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Se questo pattern non è trovato nel sito web, il server verrà contrassegnato come fuori linea. Le espressioni regolari sono consentite.', 'last_check' => 'Ultimo Controllo', 'last_online' => 'Ultima volta Online', + 'last_offline' => 'Ultima volta offline', 'monitoring' => 'Monitoraggio', 'no_monitoring' => 'Non monitorato', 'email' => 'Email', diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php index b04b6348..10341ef0 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'about a minute ago', 'seconds_ago' => '%d seconds ago', 'a_second_ago' => 'a second ago', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => '설정', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'If this pattern is not found on the website, the server will be marked offline. Regular expressions are allowed.', 'last_check' => '최근체크', 'last_online' => '최근접속', + 'last_offline' => 'Last offline', 'monitoring' => '확인중', 'no_monitoring' => 'No monitoring', 'email' => '메일 전송', diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index fa5852fe..110e4e69 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'een minuut geleden', 'seconds_ago' => '%d seconden geleden', 'a_second_ago' => 'een seconde geleden', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Configuratie', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Als dit patroon niet gevonden wordt op de website, zal de server als offline gemarkeerd worden. Regular expressions zijn toegestaan.', 'last_check' => 'Laatst gecontroleerd', 'last_online' => 'Laatst online', + 'last_offline' => 'Laatst offline', 'monitoring' => 'Monitoring', 'no_monitoring' => 'Geen monitoring', 'email' => 'Email', diff --git a/src/lang/pl_PL.lang.php b/src/lang/pl_PL.lang.php index d3e8481a..853d3f3c 100644 --- a/src/lang/pl_PL.lang.php +++ b/src/lang/pl_PL.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'minutę temu', 'seconds_ago' => '%d sekund temu', 'a_second_ago' => 'sekundę temu', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Konfiguracja', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Jeśli wzorzec nie zostanie odnaleziony, status zostanie ustawiony na offline. Wyrażenia regularne są dozwolone.', 'last_check' => 'Ostatnie sprawdzenie', 'last_online' => 'Ostatnio online', + 'last_offline' => 'Ostatnio offline', 'monitoring' => 'Monitorowany', 'no_monitoring' => 'Brak monitoringu', 'email' => 'Email', diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index c52c487e..26e51f85 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'cerca de um minuto atrás', 'seconds_ago' => '%d segundos atrás', 'a_second_ago' => 'um segundo atrás', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Configuração', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Se esse padrão não for encontrado no site, o servidor será marcado offline. As expressões regulares são permitidas.', 'last_check' => 'Última verificação', 'last_online' => 'Última vez online', + 'last_offline' => 'Última vez offline', 'monitoring' => 'Monitoramento', 'no_monitoring' => 'Sem monitoring', 'email' => 'Email', diff --git a/src/lang/ru_RU.lang.php b/src/lang/ru_RU.lang.php index 886efb13..4825e56e 100644 --- a/src/lang/ru_RU.lang.php +++ b/src/lang/ru_RU.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'минуту назад', 'seconds_ago' => '%d секунд назад', 'a_second_ago' => 'секунду назад', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Параметры', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Если текст по шаблону не найден на сайте, сервер будет помечен как Оффлайн. Регулярные выражения допустимы.', 'last_check' => 'Последняя проверка', 'last_online' => 'Был онлайн', + 'last_offline' => 'Last offline', 'monitoring' => 'Мониторинг', 'no_monitoring' => 'Нет мониторинга', 'email' => 'E-mail', diff --git a/src/lang/sv_SE.lang.php b/src/lang/sv_SE.lang.php index a79e89e1..9d750e48 100644 --- a/src/lang/sv_SE.lang.php +++ b/src/lang/sv_SE.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'ungefär en minut sen', 'seconds_ago' => '%d sekunder sedan', 'a_second_ago' => 'en sekund sedan', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Inställningar', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Om detta mönster inte hittas i svaret kommer servern att markeras offline. "Regular expressions" är tillåtna.', 'last_check' => 'Senaste kontroll', 'last_online' => 'Senast online', + 'last_offline' => 'Senast offline', 'monitoring' => 'Övervakas', 'no_monitoring' => 'Övervakas inte', 'email' => 'Email', diff --git a/src/lang/tr_TR.lang.php b/src/lang/tr_TR.lang.php index 43ab1e99..e5e498fd 100644 --- a/src/lang/tr_TR.lang.php +++ b/src/lang/tr_TR.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => 'yaklaşık bir dakika önce', 'seconds_ago' => '%d saniye önce', 'a_second_ago' => 'bir saniye önce', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => 'Ayarlar', @@ -132,6 +144,7 @@ $sm_lang = array( 'pattern_description' => 'Bu pattern web sitenizde bulunamaz ise, sunucu offline olarak işaretlenecek. Regular expression\'a izin verilmiştir.', 'last_check' => 'Son kontrol', 'last_online' => 'Son çevrimiçi zamanı', + 'last_offline' => 'Last offline', 'monitoring' => 'Monitoring', 'no_monitoring' => 'No monitoring', 'email' => 'E-posta', diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 736def15..0421d8a6 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -60,6 +60,18 @@ $sm_lang = array( 'a_minute_ago' => '1分钟前', 'seconds_ago' => '%d 秒前', 'a_second_ago' => '刚刚', + 'year' => 'year', + 'years' => 'years', + 'month' => 'month', + 'months' => 'months', + 'day' => 'day', + 'days' => 'days', + 'hour' => 'hour', + 'hours' => 'hours', + 'minute' => 'minute', + 'minutes' => 'minutes', + 'second' => 'second', + 'seconds' => 'seconds', ), 'menu' => array( 'config' => '设置', @@ -142,6 +154,7 @@ $sm_lang = array( 'pattern_description' => '如果在网站上未找到对应匹配内容, 则标记该网站为离线. 支持正则表达式.', 'last_check' => '最后检查', 'last_online' => '最后在线', + 'last_offline' => 'Last offline', 'monitoring' => '监控', 'no_monitoring' => '未监控', 'email' => '邮件', diff --git a/src/psm/Module/Server/Controller/AbstractServerController.php b/src/psm/Module/Server/Controller/AbstractServerController.php index 384324ed..89a9fba0 100644 --- a/src/psm/Module/Server/Controller/AbstractServerController.php +++ b/src/psm/Module/Server/Controller/AbstractServerController.php @@ -72,6 +72,8 @@ abstract class AbstractServerController extends AbstractController { `s`.`rtime`, `s`.`last_check`, `s`.`last_online`, + `s`.`last_offline`, + `s`.`last_offline_duration`, `s`.`active`, `s`.`email`, `s`.`sms`, @@ -103,6 +105,13 @@ abstract class AbstractServerController extends AbstractController { protected function formatServer($server) { $server['rtime'] = round((float) $server['rtime'], 4); $server['last_online'] = psm_timespan($server['last_online']); + $server['last_offline'] = psm_timespan($server['last_offline']); + if ($server['last_offline'] != psm_get_lang('system', 'never')) { + $server['last_offline_duration'] = "(".$server['last_offline_duration'].")"; + } + else { + $server['last_offline_duration'] = ""; + } $server['last_check'] = psm_timespan($server['last_check']); $server['active'] = psm_get_lang('system', $server['active']); $server['email'] = psm_get_lang('system', $server['email']); diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index f972c7b5..b1d32130 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -481,6 +481,7 @@ class ServerController extends AbstractServerController { 'label_last_check' => psm_get_lang('servers', 'last_check'), 'label_rtime' => psm_get_lang('servers', 'latency'), 'label_last_online' => psm_get_lang('servers', 'last_online'), + 'label_last_offline' => psm_get_lang('servers', 'last_offline'), 'label_monitoring' => psm_get_lang('servers', 'monitoring'), 'label_email' => psm_get_lang('servers', 'email'), 'label_send_email' => psm_get_lang('servers', 'send_email'), diff --git a/src/psm/Module/Server/Controller/StatusController.php b/src/psm/Module/Server/Controller/StatusController.php index 2d72a154..12c3ba2f 100644 --- a/src/psm/Module/Server/Controller/StatusController.php +++ b/src/psm/Module/Server/Controller/StatusController.php @@ -55,6 +55,7 @@ class StatusController extends AbstractServerController { $layout_data = array( 'label_last_check' => psm_get_lang('servers', 'last_check'), 'label_last_online' => psm_get_lang('servers', 'last_online'), + 'label_last_offline' => psm_get_lang('servers', 'last_offline'), 'label_rtime' => psm_get_lang('servers', 'latency'), 'block_layout_active' => ($layout == 0) ? 'active' : '', 'list_layout_active' => ($layout != 0) ? 'active' : '', @@ -75,6 +76,11 @@ class StatusController extends AbstractServerController { } $server['last_checked_nice'] = psm_timespan($server['last_check']); $server['last_online_nice'] = psm_timespan($server['last_online']); + $server['last_offline_nice'] = psm_timespan($server['last_offline']); + $server['last_offline_duration_nice'] = ""; + if ($server['last_offline_nice'] != psm_get_lang('system', 'never')) { + $server['last_offline_duration_nice'] = "(".$server['last_offline_duration'].")"; + } $server['url_view'] = psm_build_url(array('mod' => 'server', 'action' => 'view', 'id' => $server['server_id'], 'back_to' => 'server_status')); if ($server['status'] == "off") { diff --git a/src/psm/Txtmsg/CMBulkSMS.php b/src/psm/Txtmsg/CMBulkSMS.php new file mode 100644 index 00000000..07a83b9e --- /dev/null +++ b/src/psm/Txtmsg/CMBulkSMS.php @@ -0,0 +1,233 @@ +. + * + * @package phpservermon + * @author Axel Wehner + * @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.2.1 + **/ + +namespace psm\Txtmsg; + +/** + * CMBulkSMS - Class for CM Telecom's Bulk SMS Gateway API + * + * Sending SMS notifications via the CM Telecom Bulk SMS Gateway + * Please use the gateway password field in your configuration for the CM API-Token + * + * Requirements: cURL v7.18.1+ and OpenSSL 0.9.8j+ + */ +class CMBulkSMS extends Core { + /** @var bool|null True when cURL request succeeded */ + public $result; + + /** @var string|null Contains error message if cURL request failed */ + public $error; + + /** @var bool Set to true for debug output/logging */ + protected $debug = false; + + /** @var bool Set to false if your operator isn't able to handle multipart messages */ + protected $multipartMessage = true; + + /** @var string|null Gateway API URL uses const GATEWAY_URL_XML or GATEWAY_URL_JSON */ + protected $apiUrl; + + /** @var string Gateway API Type: Use 'json' (default) or 'xml' */ + protected $apiType = 'json'; + + /** @var string|null JSON or XML message for cURL request */ + protected $request; + + /** @var string|null HTTP Content-Type for cURL request */ + protected $contentType; + + /** @var string|null Raw sms text message */ + protected $messageBody; + + /** @var string JSON Gateway API URL */ + const GATEWAY_URL_JSON = "https://gw.cmtelecom.com/v1.0/message"; + + /** @var string XML Gateway API URL */ + const GATEWAY_URL_XML = "https://sgw01.cm.nl/gateway.ashx"; + + /** + * Build the message and send cURL request to the sms gateway + * + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests + * @param string $message Your text message + * @return boolean True when cURL request was successful + */ + public function sendSMS($message) { + // Check if recipient and text message are available + if(count($this->recipients) < 1 || empty($message)) { + return false; + } + + // Set message text + $this->messageBody = $message; + + // Prepare the message in CM's XML or JSON format + switch($this->apiType) { + case 'xml': + $this->request = $this->buildMessageXml(); + $this->contentType = 'Content-Type: application/xml'; + $this->apiUrl = self::GATEWAY_URL_XML; + break; + + case 'json': + default: + $this->request = $this->buildMessageJson(); + $this->contentType = 'Content-Type: application/json'; + $this->apiUrl = self::GATEWAY_URL_JSON; + break; + } + + $request = $this->executeCurlRequest(); + + return $request; + } + + /** + * Create a JSON batch sms message using CM's format + * + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cbatch_messages + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cmultipart + * @return string JSON message object + */ + protected function buildMessageJson() { + // Prepare recipient array for batch message + $recipients = array(); + foreach($this->recipients as $recipient) { + $recipients[] = array('number' => $recipient); + } + + // Build message array in CM's Bulk SMS format + $msgArray = array( + 'messages' => array( + 'authentication' => array( + 'producttoken' => $this->password + ), + 'msg' => array( + array( + 'from' => substr($this->originator, 0, 11), + 'to' => $recipients, + 'body' => array( + 'content' => $this->messageBody + ) + ) + ) + ) + ); + + // Multipart message + if($this->multipartMessage) { + $msgArray['messages']['msg'][0]['minimumNumberOfMessageParts'] = 1; + $msgArray['messages']['msg'][0]['maximumNumberOfMessageParts'] = 8; + } + + // Convert array in JSON object + return json_encode($msgArray); + } + + /** + * Create a XML batch sms message in CM's format + * + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cbatch_messages + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests + * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cmultipart + * @return string XML message + */ + protected function buildMessageXml() { + // Create XML string + $xml = new \SimpleXMLElement(''); + + // API-Token + $auth = $xml->addChild('AUTHENTICATION'); + $auth->addChild('PRODUCTTOKEN', $this->password); + + // Message + $msg = $xml->addChild('MSG'); + + // From + $msg->addChild('FROM', substr($this->originator, 0, 11)); + + // Recipients + foreach($this->recipients as $recipient) { + $msg->addChild('TO', $recipient); + } + + // Multipart message + if($this->multipartMessage) { + $msg->addChild('MINIMUMNUMBEROFMESSAGEPARTS', 1); + $msg->addChild('MAXIMUMNUMBEROFMESSAGEPARTS', 8); + } + + // Add body text + $msg->addChild('BODY', $this->messageBody); + + return $xml->asXML(); + } + + /** + * Create and execute the curl request + * + * @return boolean True if message is sent + */ + protected function executeCurlRequest() { + $cr = curl_init(); + curl_setopt_array($cr, array( + CURLOPT_URL => $this->apiUrl, + CURLOPT_HTTPHEADER => array($this->contentType), + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $this->request, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FAILONERROR => true + ) + ); + + // execute curl request and fetch the response/error + $cResponse = curl_exec($cr); + $cError = curl_error($cr); + $cErrorCode = curl_errno($cr); + curl_close($cr); + + $this->result = 1; + // set result and log error if needed + if($cError) { + $this->error = 'Response: CM SMS API:' . $cResponse . ' cURL Error Code: ' . $cErrorCode . '"' . $cError . '"'; + error_log($this->error, E_USER_ERROR); + $this->result = $this->error; + } + + // Debug output + // Note: CM's XML gateway gives no response when message is sent successfully :/ + if($this->debug || PSM_DEBUG) { + $debug = '
Request: '. $this->request . '
Response: ' . $cResponse.'
'; + error_log("Request: $this->request\r\nResponse: $cResponse", E_USER_NOTICE); + echo $debug; + } + + return $this->result; + } +} diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index 1d592b50..c01e208e 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -235,16 +235,18 @@ class Installer { `error` varchar(255) NULL, `rtime` FLOAT(9, 7) NULL, `last_online` datetime NULL, + `last_offline` datetime NULL, + `last_offline_duration` varchar(255) NULL, `last_check` datetime NULL, `active` enum('yes','no') NOT NULL default 'yes', `email` enum('yes','no') NOT NULL default 'yes', `sms` enum('yes','no') NOT NULL default 'no', `pushover` enum('yes','no') NOT NULL default 'yes', - `telegram` enum('yes','no') NOT NULL default 'yes', - `warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1', - `warning_threshold_counter` mediumint(1) unsigned NOT NULL DEFAULT '0', - `timeout` smallint(1) unsigned NULL DEFAULT NULL, - `website_username` varchar(255) DEFAULT NULL, + `telegram` enum('yes','no') NOT NULL default 'yes', + `warning_threshold` mediumint(1) unsigned NOT NULL DEFAULT '1', + `warning_threshold_counter` mediumint(1) unsigned NOT NULL DEFAULT '0', + `timeout` smallint(1) unsigned NULL DEFAULT NULL, + `website_username` varchar(255) DEFAULT NULL, `website_password` varchar(255) DEFAULT NULL, PRIMARY KEY (`server_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", @@ -330,6 +332,8 @@ class Installer { $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `last_online` `last_online` DATETIME NULL;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `last_check` `last_check` DATETIME NULL;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `pattern` VARCHAR( 255 ) NOT NULL AFTER `type`;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `last_offline` DATETIME NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `last_offline_duration` varchar(255) NULL;"; $this->execSQL($queries); } @@ -361,6 +365,8 @@ class Installer { $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `server_id` `server_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `warning_threshold` MEDIUMINT( 1 ) UNSIGNED NOT NULL DEFAULT '1';"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `warning_threshold_counter` MEDIUMINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `last_offline` DATETIME NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `last_offline_duration` varchar(255) NULL;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` CHANGE `user_id` `user_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "users` @@ -443,6 +449,8 @@ class Installer { $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `type` `type` ENUM( 'status', 'email', 'sms', 'pushover' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `timeout` smallint(1) unsigned NULL DEFAULT NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `last_offline` DATETIME NULL;"; + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `last_offline_duration` varchar(255) NULL;"; $queries[] = "CREATE TABLE IF NOT EXISTS `" . PSM_DB_PREFIX . "users_preferences` ( `user_id` int(11) unsigned NOT NULL, @@ -525,6 +533,7 @@ class Installer { */ protected function upgrade330() { $queries = array(); + $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD COLUMN `last_offline` DATETIME NULL AFTER `last_online`, ADD COLUMN `last_offline_duration` varchar(255) NULL AFTER `last_offline`;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `pattern_online` TINYINT( 1 ) unsigned NOT NULL AFTER `pattern`;"; $this->execSQL($queries); } diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index aa5adf3d..33fe8129 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -128,7 +128,7 @@ class StatusNotifier { $this->server = $this->db->selectRow(PSM_DB_PREFIX . 'servers', array( 'server_id' => $server_id, ), array( - 'server_id', 'ip', 'port', 'label', 'type', 'pattern', 'status', 'header_name', 'header_value', 'error', 'active', 'email', 'sms', 'pushover', 'telegram', + 'server_id', 'ip', 'port', 'label', 'type', 'pattern', 'status', 'header_name', 'header_value', 'error', 'active', 'email', 'sms', 'pushover', 'telegram', 'last_online', 'last_offline', 'last_offline_duration', )); if(empty($this->server)) { return false; diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 74ea9af7..48a162a1 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -83,7 +83,7 @@ class StatusUpdater { 'server_id' => $server_id, ), array( 'server_id', 'ip', 'port', 'label', 'type', 'pattern', 'pattern_online', 'header_name', 'header_value', 'status', 'active', 'warning_threshold', - 'warning_threshold_counter', 'timeout', 'website_username', 'website_password' + 'warning_threshold_counter', 'timeout', 'website_username', 'website_password', 'last_offline' )); if(empty($this->server)) { return false; @@ -117,6 +117,12 @@ class StatusUpdater { $save['status'] = 'on'; $save['last_online'] = date('Y-m-d H:i:s'); $save['warning_threshold_counter'] = 0; + if ($this->server['status'] == 'off') { + $online_date = new \DateTime($save['last_online']); + $offline_date = new \DateTime($this->server['last_offline']); + $difference = $online_date->diff($offline_date); + $save['last_offline_duration'] = trim(psm_format_interval($difference)); + } } else { // server is offline, increase the error counter $save['warning_threshold_counter'] = $this->server['warning_threshold_counter'] + 1; @@ -128,6 +134,9 @@ class StatusUpdater { $this->status_new = true; } else { $save['status'] = 'off'; + if ($this->server['status'] == 'on') { + $save['last_offline'] = $save['last_check']; + } } } @@ -150,16 +159,19 @@ class StatusUpdater { // set ping payload $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost"; - $fp = @fsockopen ($this->server['ip'], $this->server['port'], $errno, $this->error, 10); $socket = socket_create(AF_INET, SOCK_RAW, 1); socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 0)); socket_connect($socket, $this->server['ip'], null); - + socket_send($socket, $package, strLen($package), 0); if (socket_read($socket, 255)) { $status = true; } else { $status = false; + + // set error message + $errorcode = socket_last_error(); + $this->error = "Couldn't create socket [".$errorcode."]: ".socket_strerror($errorcode); } $this->rtime = microtime(true) - $starttime; socket_close($socket); @@ -245,7 +257,7 @@ class StatusUpdater { $result = false; } else { $result = true; - + //Okay, the HTTP status is good : 2xx or 3xx. Now we have to test the pattern if it's set up if($this->server['pattern'] != '') { // Check to see if the body should not contain specified pattern diff --git a/src/templates/default/module/install/config_upgrade.tpl.html b/src/templates/default/module/install/config_upgrade.tpl.html index 29803658..f67382d1 100644 --- a/src/templates/default/module/install/config_upgrade.tpl.html +++ b/src/templates/default/module/install/config_upgrade.tpl.html @@ -3,7 +3,6 @@ {% block install %}

We have discovered a previous version.

In the next step we will upgrade your database to the latest version.

-{{ block('results') }}

 

Upgrade to {{ version }}

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/templates/default/module/server/server/list.tpl.html b/src/templates/default/module/server/server/list.tpl.html index ed5d7ae3..9ab2ec66 100644 --- a/src/templates/default/module/server/server/list.tpl.html +++ b/src/templates/default/module/server/server/list.tpl.html @@ -8,6 +8,7 @@ {{ label_type }} {{ label_rtime }} {{ label_last_online }} + {{ label_last_offline }} {{ label_monitoring }} {{ label_action }} @@ -23,6 +24,7 @@
{{ server.type }}
{{ server.rtime }} s
{{ server.last_online }}
+
{{ server.last_offline }} {{ server.last_offline_duration }}
@@ -70,6 +72,7 @@
{{ label_rtime }}:  
{{ server.rtime }} s
{{ label_last_online }}:  
{{ server.last_online }}
+
{{ label_last_offline }}:  
{{ server.last_offline }} {{ server.last_offline_duration }}
diff --git a/src/templates/default/module/server/server/view.tpl.html b/src/templates/default/module/server/server/view.tpl.html index a9423f7e..af5224ea 100644 --- a/src/templates/default/module/server/server/view.tpl.html +++ b/src/templates/default/module/server/server/view.tpl.html @@ -49,6 +49,10 @@ {{ label_last_online }}: {{ last_online }} + + {{ label_last_offline }}: + {{ last_offline }} {{ last_offline_duration }} + {{ label_rtime }}: {{ rtime }} s diff --git a/src/templates/default/module/server/status/index.tpl.html b/src/templates/default/module/server/status/index.tpl.html index c66cde78..3d31ac69 100644 --- a/src/templates/default/module/server/status/index.tpl.html +++ b/src/templates/default/module/server/status/index.tpl.html @@ -16,6 +16,7 @@

{{ server.label }}

{{ label_last_online }}: {{ server.last_online_nice }}

+

{{ label_last_offline }}: {{ server.last_offline_nice }} {{ server.last_offline_duration_nice }}

{{ label_rtime }}: {{ server.rtime }}s

@@ -33,11 +34,13 @@
{{ label_last_online }}:  
{{ server.last_online_nice }}
{{ label_last_check }}:  
{{ server.last_checked_nice }}
+
 
 
{{ label_last_online }}: {{ server.last_online_nice }} {{ label_last_check }}: {{ server.last_checked_nice }} + {% endfor %} {% for server in servers_online %} @@ -46,11 +49,13 @@
{{ label_last_online }}:  
{{ server.last_online_nice }}
+
{{ label_last_offline }}:  
{{ server.last_offline_nice }} {{ server.last_offline_duration_nice }}
{{ label_rtime }}:  
{{ server.rtime }}
{{ label_last_online }}: {{ server.last_online_nice }} + {{ label_last_offline }}: {{ server.last_offline_nice }} {{ server.last_offline_duration_nice }} {{ label_rtime }}: {{ server.rtime }}s {% endfor %}