From a496874d9c5ed61ca2faca0e6843b15ef8d6c018 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Thu, 24 May 2018 06:49:58 +0200 Subject: [PATCH] Rewritten part of the gateway code This is a first commit in order to close #588. - Removed the names from the translation files. - The dropdown menu will now filled with the names of the gateways in the Txtmsg folder. - Changed Mollie to the proper company name: Messagebird. - Everybody that was using Mollie will on upgrade automatically change to Messagebird (replace old name in DB with new name). - Updated: Clickatell, Twilio, Spryng, Textmarketer and Messagebird (Mollie). --- README.rst | 2 +- docs/intro.rst | 2 +- src/bootstrap.php | 1 + src/includes/functions.inc.php | 31 +++++- src/includes/psmconfig.inc.php | 2 +- src/lang/bg_BG.lang.php | 11 -- src/lang/cs_CZ.lang.php | 13 --- src/lang/da_DK.lang.php | 10 -- src/lang/de_DE.lang.php | 11 -- src/lang/en_US.lang.php | 15 --- src/lang/es_ES.lang.php | 13 --- src/lang/et_ET.lang.php | 9 -- src/lang/fa_IR.lang.php | 9 -- src/lang/fi_FI.lang.php | 9 -- src/lang/fr_FR.lang.php | 12 --- src/lang/it_IT.lang.php | 11 -- src/lang/ja_JP.lang.php | 14 --- src/lang/ko_KR.lang.php | 11 -- src/lang/nl_NL.lang.php | 11 -- src/lang/pl_PL.lang.php | 11 -- src/lang/pt_BR.lang.php | 18 +--- src/lang/ru_RU.lang.php | 11 -- src/lang/sk_SK.lang.php | 13 --- src/lang/sl_SI.lang.php | 8 -- src/lang/sv_SE.lang.php | 10 -- src/lang/tr_TR.lang.php | 11 -- src/lang/vi_VN.lang.php | 8 -- src/lang/zh_CN.lang.php | 11 -- .../Config/Controller/ConfigController.php | 36 +++---- .../Controller/AbstractServerController.php | 4 +- .../User/Controller/ProfileController.php | 5 +- src/psm/Txtmsg/CMBulkSMS.php | 7 +- src/psm/Txtmsg/Clickatell.php | 68 ++++++------ src/psm/Txtmsg/Messagebird.php | 79 ++++++++++++++ src/psm/Txtmsg/Mollie.php | 100 ------------------ src/psm/Txtmsg/Spryng.php | 61 ++++------- src/psm/Txtmsg/Textmarketer.php | 53 ++++++---- src/psm/Txtmsg/Twilio.php | 4 +- src/psm/Util/Install/Installer.php | 6 +- .../default/module/config/config.tpl.html | 18 +--- 40 files changed, 231 insertions(+), 508 deletions(-) create mode 100644 src/psm/Txtmsg/Messagebird.php delete mode 100644 src/psm/Txtmsg/Mollie.php diff --git a/README.rst b/README.rst index 82046c89..bec5af18 100755 --- a/README.rst +++ b/README.rst @@ -45,7 +45,7 @@ The following SMS gateways are currently available: * Clickatell - * Inetworx - -* Mollie - +* Messagebird - * Mosms - * Smsglobal - * SMSit - diff --git a/docs/intro.rst b/docs/intro.rst index e1d0aa9c..5c1e77ac 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -49,7 +49,7 @@ The following SMS gateways are currently available: * Clickatell - * Inetworx - -* Mollie - +* Messagebird - * Mosms - * Smsglobal - * SMSit - diff --git a/src/bootstrap.php b/src/bootstrap.php index ec134fe6..1c8e47e0 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -30,6 +30,7 @@ define('PSM_PATH_SRC', __DIR__ . DIRECTORY_SEPARATOR); define('PSM_PATH_CONFIG', PSM_PATH_SRC . 'config' . DIRECTORY_SEPARATOR); define('PSM_PATH_LANG', PSM_PATH_SRC . 'lang' . DIRECTORY_SEPARATOR); +define('PSM_PATH_SMS_GATEWAY', PSM_PATH_SRC . 'psm' . DIRECTORY_SEPARATOR . 'Txtmsg' . DIRECTORY_SEPARATOR); // user levels define('PSM_USER_ADMIN', 10); diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index dde0f585..0232df1f 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -131,6 +131,27 @@ function psm_get_langs() { return $langs; } +/** + * Retrieve a list with available sms gateways + * + * @return array + */ +function psm_get_sms_gateways() { + $sms_gateway_files = glob(PSM_PATH_SMS_GATEWAY . '*.php'); + $sms_gateways = array(); + + foreach($sms_gateway_files as $file) { + $name = basename($file, ".php"); + // filter system files out + if($name != "Core" && $name != "TxtmsgInterface"){ + $sms_gateways[strtolower($name)] = $name; + } + } + + ksort($sms_gateways); + return $sms_gateways; +} + /** * Get a setting from the config. * @@ -530,7 +551,7 @@ function psm_build_sms() { $sms = null; // open the right class - // not making this any more dynamic, because perhaps some gateways need custom settings (like Mollie) + // not making this any more dynamic, because perhaps some gateways need custom settings switch(strtolower(psm_get_conf('sms_gateway'))) { case 'mosms': $sms = new \psm\Txtmsg\Mosms(); @@ -541,9 +562,8 @@ function psm_build_sms() { case 'inetworx': $sms = new \psm\Txtmsg\Inetworx(); break; - case 'mollie': - $sms = new \psm\Txtmsg\Mollie(); - $sms->setGateway(1); + case 'messagebird': + $sms = new \psm\Txtmsg\Messagebird(); break; case 'spryng': $sms = new \psm\Txtmsg\Spryng(); @@ -578,6 +598,9 @@ function psm_build_sms() { case 'twilio': $sms = new \psm\Txtmsg\Twilio(); break; + case 'cmbulksms': + $sms = new \psm\Txtmsg\CMBulkSMS(); + break; } // copy login information from the config file diff --git a/src/includes/psmconfig.inc.php b/src/includes/psmconfig.inc.php index af687a6f..de474bf3 100644 --- a/src/includes/psmconfig.inc.php +++ b/src/includes/psmconfig.inc.php @@ -29,7 +29,7 @@ /** * Current PSM version */ -define('PSM_VERSION', '3.2.2'); +define('PSM_VERSION', '3.3.0'); /** * URL to check for updates. Will not be checked if turned off on config page. diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index ee5b11c2..754c9185 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Оставете празно за "без аутентикация"', 'sms_status' => 'Да се изпращат ли SMS-и', 'sms_gateway' => 'Портал за изпращане на SMS-и', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Потребител', 'sms_gateway_password' => 'Парола', 'sms_from' => 'Номер на изпращача', diff --git a/src/lang/cs_CZ.lang.php b/src/lang/cs_CZ.lang.php index fd3a8fbf..606086b8 100644 --- a/src/lang/cs_CZ.lang.php +++ b/src/lang/cs_CZ.lang.php @@ -218,19 +218,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Ponechte prázdné pro použití SMTP bez hesla', 'sms_status' => 'Povolit odesílání textových zpráv', 'sms_gateway' => 'Brána použitá pro odesílání zpráv', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_freemobilesms' => 'FreeMobileSMS', - 'sms_gateway_clicksend' => 'ClickSend', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Uživatelské jméno brány', 'sms_gateway_password' => 'Heslo brány', 'sms_from' => 'Telefonní číslo odesilatele', diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php index cfa62017..1663a852 100644 --- a/src/lang/da_DK.lang.php +++ b/src/lang/da_DK.lang.php @@ -203,16 +203,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Efterlad blank hvis det ikke er krævet', 'sms_status' => 'Tillad at sende SMS beskeder', 'sms_gateway' => 'SMS Gateway', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Gateway brugernavn/apikey', 'sms_gateway_password' => 'Gateway adgangskode', 'sms_from' => 'Afsenderens navn.', diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index b4094b07..976533ae 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -206,17 +206,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Feld leer lassen, bei fehlender Authentifizierung', 'sms_status' => 'SMS-Nachrichtenversand erlauben?', 'sms_gateway' => 'SMS Gateway', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Gateway Benutzername', 'sms_gateway_password' => 'Gateway Passwort', 'sms_from' => 'SMS-Sendernummer', diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 29c0697c..5bfbc8f8 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -239,21 +239,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Leave blank for no authentication', 'sms_status' => 'Allow sending text messages', 'sms_gateway' => 'Gateway to use for sending messages', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_freemobilesms' => 'FreeMobileSMS', - 'sms_gateway_clicksend' => 'ClickSend', - 'sms_gateway_nexmo' => 'Nexmo', - 'sms_gateway_smsgw' => 'SMSgw', - 'sms_gateway_twilio' => 'Twilio', 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', 'sms_from' => 'Sender\'s phone number', diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index aab8ac56..25af90f0 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -207,21 +207,8 @@ $sm_lang = array( 'email_smtp_noauth' => 'Deja en blanco para ninguna autenticación', 'sms_status' => '¿Habilitar envio de SMS?', 'sms_gateway' => 'Proveedor de SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', 'sms_gateway_username' => 'Usuario', 'sms_gateway_password' => 'Contraseña', - 'sms_gateway_nexmo' => 'Nexmo', - 'sms_gateway_username' => 'Gateway username', - 'sms_gateway_password' => 'Gateway password', 'sms_from' => 'Número origen del SMS', 'pushover_status' => '¿Habilitar el envío de mensajes Pushover?', 'pushover_description' => 'Pushover es un servicio que hace que sea fácil de obtener notificaciones en tiempo real. Vea su página web para más información.', diff --git a/src/lang/et_ET.lang.php b/src/lang/et_ET.lang.php index f2519f73..83e17d44 100644 --- a/src/lang/et_ET.lang.php +++ b/src/lang/et_ET.lang.php @@ -192,15 +192,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Jäta tühjaks, et jätkata ilma autentimiseta', 'sms_status' => 'Luba sõnumite saatmine', 'sms_gateway' => 'Väravad sõnumite saatmiseks', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', 'sms_gateway_username' => 'Värava kasutajanimi', 'sms_gateway_password' => 'Värava parool', 'sms_from' => 'Saatja telefoni number', diff --git a/src/lang/fa_IR.lang.php b/src/lang/fa_IR.lang.php index 70639399..f50d0ae6 100644 --- a/src/lang/fa_IR.lang.php +++ b/src/lang/fa_IR.lang.php @@ -192,15 +192,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'برای عدم احراز هویت اینجا را خالی بگذارید.', 'sms_status' => 'اجازه ارسال پیام های متنی', 'sms_gateway' => 'گیت وی برای ارسال پیام ها', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', 'sms_gateway_username' => 'نام کاربری Gateway', 'sms_gateway_password' => 'کلمه عبور Gateway', 'sms_from' => 'شماره تلفن ارسال کننده', diff --git a/src/lang/fi_FI.lang.php b/src/lang/fi_FI.lang.php index 74f4de41..ee7f5a74 100644 --- a/src/lang/fi_FI.lang.php +++ b/src/lang/fi_FI.lang.php @@ -192,15 +192,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Jätä tyhjäksi jos ei varmennusta', 'sms_status' => 'Salli tekstiviestien lähetys', 'sms_gateway' => 'Palvelu jonka kautta tekstiviestit lähetetään', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', 'sms_gateway_username' => 'Palvelun käyttäjänimi', 'sms_gateway_password' => 'Palvelun salasana', 'sms_from' => 'Lähettäjän puhelinnumero', diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index ab97767c..cdfc229a 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -206,18 +206,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Laisser vide si pas d\'authentication', 'sms_status' => 'Autoriser l\'envoi de SMS', 'sms_gateway' => 'Passerelle à utiliser pour l\'envoi de SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', - 'sms_gateway_freemobilesms' => 'FreeMobileSMS', 'sms_gateway_username' => 'Nom utilisateur de la passerelle', 'sms_gateway_password' => 'Mot de passe de la passerelle', 'sms_from' => 'SMS de l\'expéditeur', diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php index 4de13b52..387dafde 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Lasciare vuoto per nessuna autentificazione', 'sms_status' => 'Permetti invio SMS', 'sms_gateway' => 'Gateway da usare per inviare SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Nome Utente Gateway', 'sms_gateway_password' => 'Password Gateway', 'sms_from' => 'Numero di telefono del mittente', diff --git a/src/lang/ja_JP.lang.php b/src/lang/ja_JP.lang.php index 4e66fe14..f368440d 100644 --- a/src/lang/ja_JP.lang.php +++ b/src/lang/ja_JP.lang.php @@ -209,20 +209,6 @@ $sm_lang = array( 'email_smtp_noauth' => '空白で認証なしになります', 'sms_status' => 'テキストメッセージの送信を許可する', 'sms_gateway' => 'このゲートウェイは、メッセージの送信に使用されます。', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_freemobilesms' => 'FreeMobileSMS', - 'sms_gateway_clicksend' => 'ClickSend', - 'sms_gateway_nexmo' => 'Nexmo', - 'sms_gateway_smsgw' => 'SMSgw', 'sms_gateway_username' => 'ゲートウェイのユーザー名', 'sms_gateway_password' => 'ゲートウェイのパスワード', 'sms_from' => '送信者の電話番号:', diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php index 10341ef0..19adc2d5 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Leave blank for no authentication', 'sms_status' => 'SMS전송 허용', 'sms_gateway' => '메세지 전송을 위한 게이트웨이 허용', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_nexmo' => 'Nexmo', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', 'sms_from' => 'Sender\'s phone number', diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index 110e4e69..2728a91e 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Laat leeg voor geen authenticatie', 'sms_status' => 'Sta SMS berichten toe?', 'sms_gateway' => 'Gateway voor het sturen van SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Gateway gebruikersnaam', 'sms_gateway_password' => 'Gateway wachtwoord', 'sms_from' => 'Telefoonnummer afzender', diff --git a/src/lang/pl_PL.lang.php b/src/lang/pl_PL.lang.php index 853d3f3c..6fd7447c 100644 --- a/src/lang/pl_PL.lang.php +++ b/src/lang/pl_PL.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Pozostaw puste dla braku autentykacji', 'sms_status' => 'Pozwól na wysyłkę SMS', 'sms_gateway' => 'Bramka SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Login do bramki', 'sms_gateway_password' => 'Hasło do bramki', 'sms_from' => 'Numer nadawcy', diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index 26e51f85..2d4a2e51 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -203,25 +203,11 @@ $sm_lang = array( 'email_smtp_username' => 'SMTP username', 'email_smtp_password' => 'SMTP password', 'email_smtp_noauth' => 'Deixe em branco para nenhuma autenticação', - 'sms_status' => 'Habilitar o envio de mensagem de texto?', - 'sms_gateway' => 'Gateway para o uso de envio de mensagens', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', + 'sms_status' => 'Habilitar o envio de mensagem de texto?', + 'sms_gateway' => 'Gateway para o uso de envio de mensagens', 'sms_gateway_username' => 'Usuário do Gateway', 'sms_gateway_password' => 'Senha do Gateway', 'sms_from' => 'Número de telefone de envio', - 'sms_gateway_nexmo' => 'Nexmo', - 'sms_gateway_username' => 'Usuário do Gateway', - 'sms_gateway_password' => 'Senha do Gateway', - 'sms_from' => 'Número de telefone de envio', 'pushover_status' => 'Habilitar envio de mensagens Pushover', 'pushover_description' => 'Pushover é um serviço de notificações em tempo real. Veja o website para mais informações.', 'pushover_clone_app' => 'Clique aqui para criar sua app Pushover', diff --git a/src/lang/ru_RU.lang.php b/src/lang/ru_RU.lang.php index 4825e56e..bb271c68 100644 --- a/src/lang/ru_RU.lang.php +++ b/src/lang/ru_RU.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Оставить пустым, если без аутентификации', 'sms_status' => 'Разрешить отправку SMS', 'sms_gateway' => 'Шлюз для отправки SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Пользователь', 'sms_gateway_password' => 'Пароль', 'sms_from' => 'Номер отправителя', diff --git a/src/lang/sk_SK.lang.php b/src/lang/sk_SK.lang.php index 40cd4d49..59c14a65 100644 --- a/src/lang/sk_SK.lang.php +++ b/src/lang/sk_SK.lang.php @@ -204,19 +204,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Nechajte prázdne pre použitie SMTP bez hesla', 'sms_status' => 'Povoliť odosielanie textových správ', 'sms_gateway' => 'Brána použitá pro odosielanie správ', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_freemobilesms' => 'FreeMobileSMS', - 'sms_gateway_clicksend' => 'ClickSend', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Užívateľské meno brány', 'sms_gateway_password' => 'Heslo brány', 'sms_from' => 'Telefónne číslo odosielateľa', diff --git a/src/lang/sl_SI.lang.php b/src/lang/sl_SI.lang.php index 42e8266d..ec753c41 100644 --- a/src/lang/sl_SI.lang.php +++ b/src/lang/sl_SI.lang.php @@ -190,14 +190,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Če ni potrebna overovitev, pustite prazno', 'sms_status' => 'Dovolim pošiljanje SMS sporočil?', 'sms_gateway' => 'Prehod za pošiljanje SMS sporočil', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Uporabniško ime SMS prehoda', 'sms_gateway_password' => 'Geslo SMS prehoda', 'sms_from' => 'Telefonska številka pošiljatelja', diff --git a/src/lang/sv_SE.lang.php b/src/lang/sv_SE.lang.php index 9d750e48..420d4a0e 100644 --- a/src/lang/sv_SE.lang.php +++ b/src/lang/sv_SE.lang.php @@ -205,16 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Lämna blank för att inte autentisera', 'sms_status' => 'Tillåt SMS', 'sms_gateway' => 'Gateway för SMS', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Gateway användarnamn', 'sms_gateway_password' => 'Gateway lösenord', 'sms_from' => 'Avsändarens telefonnummer', diff --git a/src/lang/tr_TR.lang.php b/src/lang/tr_TR.lang.php index e5e498fd..e0e39a84 100644 --- a/src/lang/tr_TR.lang.php +++ b/src/lang/tr_TR.lang.php @@ -205,17 +205,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Doğrulama yapmamak için boş bırakın', 'sms_status' => 'SMS mesaj göndermeye izin ver', 'sms_gateway' => 'Mesaj göndermek için servisi seçin', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Servis kullanıcı adı', 'sms_gateway_password' => 'Servis şifresi', 'sms_from' => 'Gönderen numarası', diff --git a/src/lang/vi_VN.lang.php b/src/lang/vi_VN.lang.php index dea17622..004f2dd0 100644 --- a/src/lang/vi_VN.lang.php +++ b/src/lang/vi_VN.lang.php @@ -190,14 +190,6 @@ $sm_lang = array( 'email_smtp_noauth' => 'Để trống nếu không có chứng thực', 'sms_status' => 'Cho phép gửi tin nhắn văn bản', 'sms_gateway' => 'Gateway sử dụng để gửi tin nhắn', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', 'sms_from' => 'Số điện thoại của người gửi', diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 0421d8a6..b8eee2eb 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -221,17 +221,6 @@ $sm_lang = array( 'email_smtp_noauth' => '留空为无验证', 'sms_status' => '允许发送短信SMS?', 'sms_gateway' => '短信SMS发送网关', - 'sms_gateway_mosms' => 'Mosms', - 'sms_gateway_mollie' => 'Mollie', - 'sms_gateway_spryng' => 'Spryng', - 'sms_gateway_inetworx' => 'Inetworx', - 'sms_gateway_clickatell' => 'Clickatell', - 'sms_gateway_textmarketer' => 'Textmarketer', - 'sms_gateway_smsglobal' => 'SMSGlobal', - 'sms_gateway_octopush' => 'Octopush', - 'sms_gateway_smsit' => 'Smsit', - 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', - 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'SMS网关用户名', 'sms_gateway_password' => 'SMS网关密码', 'sms_from' => '发信人电话号', diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index d0d80e2c..1db33c35 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -117,8 +117,19 @@ class ConfigController extends AbstractController { ); } + // generate sms_gateway array + $sms_gateways = psm_get_sms_gateways(); + $tpl_data['sms_gateway_current'] = (isset($config['sms_gateway'])) + ? $config['sms_gateway'] + : current($sms_gateways); + $tpl_data['sms_gateways'] = array(); + foreach($sms_gateways as $sms_gateway => $label) { + $tpl_data['sms_gateways'][] = array( + 'value' => $sms_gateway, + 'label' => $label, + ); + } // @todo these selected values can easily be rewritten in the template using twig - $tpl_data['sms_selected_' . $config['sms_gateway']] = 'selected="selected"'; $tpl_data['alert_type_selected_' . $config['alert_type']] = 'selected="selected"'; $smtp_sec = isset($config['email_smtp_security']) ? $config['email_smtp_security'] : ''; $tpl_data['email_smtp_security_selected_' . $smtp_sec] = 'selected="selected"'; @@ -266,9 +277,9 @@ class ConfigController extends AbstractController { $pushover = psm_build_pushover(); $pushover->setDebug(true); $user = $this->getUser()->getUser(); - $api_token = psm_get_conf('pushover_api_token'); + $apiToken = psm_get_conf('pushover_api_token'); - if(empty($api_token)) { + if(empty($apiToken)) { $this->addMessage(psm_get_lang('config', 'pushover_error_noapp'), 'error'); } elseif(empty($user->pushover_key)) { $this->addMessage(psm_get_lang('config', 'pushover_error_nokey'), 'error'); @@ -303,9 +314,9 @@ class ConfigController extends AbstractController { protected function testTelegram() { $telegram = psm_build_telegram(); $user = $this->getUser()->getUser(); - $api_token = psm_get_conf('telegram_api_token'); + $apiToken = psm_get_conf('telegram_api_token'); - if(empty($api_token)) { + if(empty($apiToken)) { $this->addMessage(psm_get_lang('config', 'telegram_error_notoken'), 'error'); } elseif(empty($user->telegram_id)) { $this->addMessage(psm_get_lang('config', 'telegram_error_noid'), 'error'); @@ -363,21 +374,6 @@ class ConfigController extends AbstractController { 'label_email_smtp_noauth' => psm_get_lang('config', 'email_smtp_noauth'), 'label_sms_status' => psm_get_lang('config', 'sms_status'), 'label_sms_gateway' => psm_get_lang('config', 'sms_gateway'), - 'label_sms_gateway_mosms' => psm_get_lang('config', 'sms_gateway_mosms'), - 'label_sms_gateway_mollie' => psm_get_lang('config', 'sms_gateway_mollie'), - 'label_sms_gateway_spryng' => psm_get_lang('config', 'sms_gateway_spryng'), - 'label_sms_gateway_inetworx' => psm_get_lang('config', 'sms_gateway_inetworx'), - 'label_sms_gateway_clickatell' => psm_get_lang('config', 'sms_gateway_clickatell'), - 'label_sms_gateway_textmarketer' => psm_get_lang('config', 'sms_gateway_textmarketer'), - 'label_sms_gateway_smsit' => psm_get_lang('config', 'sms_gateway_smsit'), - 'label_sms_gateway_freevoipdeal' => psm_get_lang('config', 'sms_gateway_freevoipdeal'), - 'label_sms_gateway_smsglobal' => psm_get_lang('config', 'sms_gateway_smsglobal'), - 'label_sms_gateway_nexmo' => psm_get_lang('config', 'sms_gateway_nexmo'), - 'label_sms_gateway_smsgw' => psm_get_lang('config', 'sms_gateway_smsgw'), - 'label_sms_gateway_octopush' => psm_get_lang('config', 'sms_gateway_octopush'), - 'label_sms_gateway_freemobilesms' => psm_get_lang('config', 'sms_gateway_freemobilesms'), - 'label_sms_gateway_clicksend' => psm_get_lang('config', 'sms_gateway_clicksend'), - 'label_sms_gateway_twilio' => psm_get_lang('config', 'sms_gateway_twilio'), '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'), diff --git a/src/psm/Module/Server/Controller/AbstractServerController.php b/src/psm/Module/Server/Controller/AbstractServerController.php index d4bfe48c..87387374 100644 --- a/src/psm/Module/Server/Controller/AbstractServerController.php +++ b/src/psm/Module/Server/Controller/AbstractServerController.php @@ -105,12 +105,10 @@ abstract class AbstractServerController extends AbstractController { $server['rtime'] = round((float) $server['rtime'], 4); $server['last_online'] = psm_timespan($server['last_online']); $server['last_offline'] = psm_timespan($server['last_offline']); + $server['last_offline_duration'] = ""; 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/User/Controller/ProfileController.php b/src/psm/Module/User/Controller/ProfileController.php index e3b4b554..03c6cf49 100644 --- a/src/psm/Module/User/Controller/ProfileController.php +++ b/src/psm/Module/User/Controller/ProfileController.php @@ -157,9 +157,9 @@ class ProfileController extends AbstractController { */ protected function activateTelegram() { $telegram = psm_build_telegram(); - $api_token = psm_get_conf('telegram_api_token'); + $apiToken = psm_get_conf('telegram_api_token'); - if(empty($api_token)) { + if(empty($apiToken)) { $this->addMessage(psm_get_lang('config', 'telegram_error_notoken'), 'error'); } else { $result = $telegram->getBotUsername(); @@ -180,4 +180,3 @@ class ProfileController extends AbstractController { } } } - diff --git a/src/psm/Txtmsg/CMBulkSMS.php b/src/psm/Txtmsg/CMBulkSMS.php index 07a83b9e..1851af23 100644 --- a/src/psm/Txtmsg/CMBulkSMS.php +++ b/src/psm/Txtmsg/CMBulkSMS.php @@ -83,9 +83,6 @@ class CMBulkSMS extends Core { return false; } - // Set message text - $this->messageBody = $message; - // Prepare the message in CM's XML or JSON format switch($this->apiType) { case 'xml': @@ -133,7 +130,7 @@ class CMBulkSMS extends Core { 'from' => substr($this->originator, 0, 11), 'to' => $recipients, 'body' => array( - 'content' => $this->messageBody + 'content' => $message ) ) ) @@ -184,7 +181,7 @@ class CMBulkSMS extends Core { } // Add body text - $msg->addChild('BODY', $this->messageBody); + $msg->addChild('BODY', $message); return $xml->asXML(); } diff --git a/src/psm/Txtmsg/Clickatell.php b/src/psm/Txtmsg/Clickatell.php index e9b28073..201bc8e3 100644 --- a/src/psm/Txtmsg/Clickatell.php +++ b/src/psm/Txtmsg/Clickatell.php @@ -19,48 +19,50 @@ * * @package phpservermon * @author Pepijn Over - * @copyright Copyright (c) 2008-2017 Pepijn Over + * @author Tim Zandbergen + * @copyright Copyright (c) 2008-2018 Pepijn Over * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 * @version Release: @package_version@ - * @link http://www.phpservermonitor.org/ + * @link https://www.phpservermonitor.org/ **/ namespace psm\Txtmsg; class Clickatell extends Core { - // ========================================================================= - // [ Fields ] - // ========================================================================= - public $gateway = 1; - public $resultcode = null; - public $resultmessage = null; - public $success = false; - public $successcount = 0; - - // ========================================================================= - // [ Methods ] - // ========================================================================= - public function setGateway($gateway) { - $this->gateway = $gateway; - } + /** + * Send sms using the Clickatell API + * @var string $message + * @var array $this->recipients + * @var string $recipient + * @var string $this->username + * @var string $this->originator + * @var int $success + * @var string $error + * @return int or string + */ public function sendSMS($message) { - //$message MUST BE urlencode or it will send only part message (first word in most cases) - $recipients = implode(',', $this->recipients); - //example: https://api.clickatell.com/http/sendmsg?user=XXXXXX&password=PASSWORD&api_id=111111&to=11111111&text=Message - //YOU MUST MANUALLY CHANGE THE VALUE OF 'api_id' EX: '&api_id=' . '1234567' - $result = $this->_auth_https_post('api.clickatell.com', '/http/sendmsg', - '?user=' . $this->username . - '&password=' . $this->password . - '&to=' . $recipients . - '&api_id=' . 'XXXXXX' . - '&text=' . substr(urlencode($message), 0, 153) - ); - return $result; - } + $success = 1; + $error = ''; + foreach($this->recipients as $recipient) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://platform.clickatell.com/messages/http/send?apiKey=".urlencode($this->username)."&to=".urlencode($recipient)."&content=".urlencode($message)); + 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); - protected function _auth_https_post($host, $path, $data) { - $url = $host . $path . $data; - return psm_curl_get($url); + // Check on error + if (strpos($result, ",\"errorCode\":null,\"error\":null,\"errorDescription\":null") === False) { + $error = $result; + $success = 0; + } + } + if($success == 1){ + return 1; + } + return $error; } } diff --git a/src/psm/Txtmsg/Messagebird.php b/src/psm/Txtmsg/Messagebird.php new file mode 100644 index 00000000..5445d5f9 --- /dev/null +++ b/src/psm/Txtmsg/Messagebird.php @@ -0,0 +1,79 @@ +. + * + * @package phpservermon + * @author Perri Vardy-Mason + * @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 2.1 + **/ + +namespace psm\Txtmsg; + +class Messagebird extends Core { + + /** + * Send sms using the Messagebird API + * @var string $message + * @var array $this->recipients + * @var array $this->originator (Max 11 characters) + * @var array $recipients_chunk + * @var string $this->password + * @var int $success + * @var string $error + * @return int or string + */ + public function sendSMS($message) { + $success = 1; + $error = ''; + + // Maximum of 50 users a time. + $recipients_chunk = array_chunk($this->recipients, ceil(count($this->recipients) / 50)); + + foreach ($recipients_chunk as $recipients) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://rest.messagebird.com/messages"); + curl_setopt($ch, CURLOPT_POSTFIELDS, + "originator=".urlencode($this->originator == '' ? 'PSM' : $this->originator). + "&body=".urlencode($message). + "&recipients=".implode(",", $recipients)); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $headers = array(); + $headers[] = "Authorization: AccessKey ".$this->password; + $headers[] = "Content-Type: application/x-www-form-urlencoded"; + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $result = curl_exec($ch); + curl_close($ch); + + // Check on error + if (is_numeric(strpos($result, "{\"errors\":"))) { + $error = $result; + $success = 0; + } + } + if($success == 1){ + return 1; + } + return $error; + } +} diff --git a/src/psm/Txtmsg/Mollie.php b/src/psm/Txtmsg/Mollie.php deleted file mode 100644 index 08981238..00000000 --- a/src/psm/Txtmsg/Mollie.php +++ /dev/null @@ -1,100 +0,0 @@ -. - * - * @package phpservermon - * @author Pepijn Over - * @copyright Copyright (c) 2008-2017 Pepijn Over - * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 - * @version Release: @package_version@ - * @link http://www.phpservermonitor.org/ - **/ - -namespace psm\Txtmsg; - -class Mollie extends Core { - // ========================================================================= - // [ Fields ] - // ========================================================================= - public $gateway = 1; - public $success = false; - public $reference = ''; - - // ========================================================================= - // [ Methods ] - // ========================================================================= - /** - * Select the gateway to use - * - * @param unknown_type $gateway - */ - public function setGateway($gateway) { - $this->gateway = $gateway; - } - - public function setReference ($reference) { - $this->reference = $reference; - } - - /** - * Send a text message to one or more recipients - * - * @param string $subject - * @param string $body - * @return boolean - */ - public function sendSMS($message) { - $recipients = implode(',', $this->recipients); - - $result = $this->_auth_https_post('api.messagebird.com', '/xml/sms/', - 'gateway='.urlencode($this->gateway). - '&username='.urlencode($this->username). - '&password='.urlencode($this->password). - '&originator='.urlencode($this->originator). - '&recipients='.urlencode($recipients). - '&message='.urlencode($message) . - (($this->reference != '') ? '&reference='.$this->reference : '') - ); - - $this->recipients = array(); - - list($headers, $xml) = preg_split("/(\r?\n){2}/", $result, 2); - $data = simplexml_load_string($xml); - - $this->success = ($data->item->success == 'true'); - return $this->success; - } - - protected function _auth_https_post($host, $path, $data) { - $fp = @fsockopen($host,80); - $buf = ''; - if ($fp) { - @fputs($fp, "POST $path HTTP/1.0\n"); - @fputs($fp, "Host: $host\n"); - @fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); - @fputs($fp, "Content-length: " . strlen($data) . "\n"); - @fputs($fp, "Connection: close\n\n"); - @fputs($fp, $data); - while (!feof($fp)) { - $buf .= fgets($fp,128); - } - fclose($fp); - } - return $buf; - } -} diff --git a/src/psm/Txtmsg/Spryng.php b/src/psm/Txtmsg/Spryng.php index 35087277..6b929f1e 100644 --- a/src/psm/Txtmsg/Spryng.php +++ b/src/psm/Txtmsg/Spryng.php @@ -28,49 +28,32 @@ namespace psm\Txtmsg; class Spryng extends Core { - // ========================================================================= - // [ Fields ] - // ========================================================================= - public $gateway = 1; - public $resultcode = null; - public $resultmessage = null; - public $success = false; - public $successcount = 0; - // ========================================================================= - // [ Methods ] - // ========================================================================= - public function setGateway($gateway) { - $this->gateway = $gateway; - } - - public function sendSMS($message) { - $recipients = implode(',', $this->recipients); - $message = urlencode($message); - - $result = $this->_auth_https_post('http://www.spryng.nl', '/SyncTextService', - '?OPERATION=send' . - '&USERNAME=' . $this->username . - '&PASSWORD=' . $this->password . - '&DESTINATION=' . $recipients . - '&SENDER=' . $this->originator . - '&BODY=' . $message . - '&SMSTYPE=' . 'BUSINESS' - ); - return $result; - } - - protected function _auth_https_post($host, $path, $data) { + /** + * Send sms using the Spryngsms API + * @var string $message + * @var array $this->recipients + * @var string $this->username + * @var string $this->password + * @var string $this->originator + * @return int or string + */ + public function sendSMS($message) { + $recipients = implode(",", $this->recipients); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $host . $path . $data); - //curl_setopt($ch, CURLOPT_HEADER, 1); - //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_URL, "https://api.spryngsms.com/api/send.php?OPERATION=send&USERNAME=".urlencode($this->username)."&PASSWORD=".urlencode($this->password)."&DESTINATION=".urlencode($recipients)."&SENDER=".urlencode($this->originator)."&BODY=".urlencode($message)."&SMSTYPE=BUSINESS"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - - $data = curl_exec($ch); + $headers = array(); + $headers[] = "Content-Type: application/x-www-form-urlencoded"; + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $result = curl_exec($ch); curl_close($ch); - return $data; + + // Check on error + if ($result != 1) { + return "Error ".$result.": see http://www.spryng.nl/en/developers/http-api/ for the description."; + } + return 1; } } diff --git a/src/psm/Txtmsg/Textmarketer.php b/src/psm/Txtmsg/Textmarketer.php index 5292491a..d55b17e4 100644 --- a/src/psm/Txtmsg/Textmarketer.php +++ b/src/psm/Txtmsg/Textmarketer.php @@ -19,6 +19,7 @@ * * @package phpservermon * @author Perri Vardy-Mason + * @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@ @@ -29,31 +30,41 @@ namespace psm\Txtmsg; class Textmarketer extends Core { - // ========================================================================= - // [ Fields ] - // ========================================================================= - public $gateway = 1; - public $resultcode = null; - public $resultmessage = null; - public $success = false; - public $successcount = 0; + /** + * Send sms using the Textmarketer API + * @var string $message + * @var array $this->recipients + * @var string $recipient + * @var string $this->username + * @var string $this->password + * @var int $success + * @var string $error + * @return int or string + */ public function sendSMS($message) { + $success = 1; + $error = ''; + foreach( $this->recipients as $recipient ){ - $textmarketer_url = "https://api.textmarketer.co.uk/gateway/"; - $textmarketer_data = urlencode( $message ); - $textmarketer_origin = urlencode( 'SERVERALERT' ); - - - foreach( $this->recipients as $phone ){ - - $URL = $textmarketer_url."?username=" . $this->username . "&password=" . $this->password . "&to=" . $phone . "&message=" . $textmarketer_data . "&orig=" . $textmarketer_origin; - - $result = file_get_contents( $URL ); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://api.textmarketer.co.uk/gateway/?username=".$this->username."&password=".$this->password."&to=".$recipient."&message=".urlencode($message)."&orig=SERVERALERT"); + 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 on error + if (is_numeric(strpos($result, "FAILED"))) { + $error = $result; + $success = 0; + } } - - return $result; + if($success == 1){ + return 1; + } + return $error; } - } diff --git a/src/psm/Txtmsg/Twilio.php b/src/psm/Txtmsg/Twilio.php index 04d25832..4b73e39a 100644 --- a/src/psm/Txtmsg/Twilio.php +++ b/src/psm/Txtmsg/Twilio.php @@ -70,8 +70,6 @@ class Twilio extends Core { if($success == 1){ return 1; } - else{ - return $error; - } + return $error; } } diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index 0743199c..869c0676 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -144,7 +144,7 @@ class Installer { ('email_smtp_username', ''), ('email_smtp_password', ''), ('sms_status', '0'), - ('sms_gateway', 'mollie'), + ('sms_gateway', 'messagebird'), ('sms_gateway_username', 'username'), ('sms_gateway_password', 'password'), ('sms_from', '1234567890'), @@ -534,5 +534,9 @@ class Installer { $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`;"; $this->execSQL($queries); + if(psm_get_conf('sms_gateway') == 'mollie'){ + psm_update_conf('sms_gateway', 'messagebird'); + } + } } diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index d60eab4c..a262c508 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -188,21 +188,9 @@