From 57a01d27c58cc5d0c5efa2884c5bcff3ce536829 Mon Sep 17 00:00:00 2001 From: "Alexis U (portable)" Date: Tue, 15 Mar 2016 13:00:07 +0100 Subject: [PATCH 1/2] add support for Octopush sms provider --- src/includes/functions.inc.php | 3 + src/lang/bg_BG.lang.php | 1 + src/lang/cs_CZ.lang.php | 1 + src/lang/da_DK.lang.php | 1 + src/lang/de_DE.lang.php | 1 + src/lang/en_US.lang.php | 1 + src/lang/es_ES.lang.php | 1 + src/lang/fr_FR.lang.php | 1 + src/lang/it_IT.lang.php | 1 + src/lang/ko_KR.lang.php | 1 + src/lang/nl_NL.lang.php | 1 + src/lang/pl_PL.lang.php | 1 + src/lang/pt_BR.lang.php | 1 + src/lang/ru_RU.lang.php | 1 + src/lang/tr_TR.lang.php | 1 + src/lang/zh_CN.lang.php | 1 + .../Controller/ConfigController.class.php | 1 + src/psm/Txtmsg/Octopush.class.php | 72 +++++++++++++++++++ .../default/module/config/config.tpl.html | 1 + 19 files changed, 92 insertions(+) create mode 100644 src/psm/Txtmsg/Octopush.class.php diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 8a81dc2c..466004b0 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -466,6 +466,9 @@ function psm_build_sms() { case 'smsglobal': $sms = new \psm\Txtmsg\Smsglobal(); break; + case 'octopush': + $sms = new \psm\Txtmsg\Octopush(); + break; } // copy login information from the config file diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index 17ad0edd..f19b8176 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -195,6 +195,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', '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 ec32ea92..794285ee 100644 --- a/src/lang/cs_CZ.lang.php +++ b/src/lang/cs_CZ.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Uživatelské jméno brány', 'sms_gateway_password' => 'Heslo brány', diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php index aa5e5b03..8cc21a8d 100644 --- a/src/lang/da_DK.lang.php +++ b/src/lang/da_DK.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway brugernavn/apikey', 'sms_gateway_password' => 'Gateway adgangskode', diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index ad1cb964..edab0e04 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway Benutzername', 'sms_gateway_password' => 'Gateway Passwort', diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 295f6e23..b1a0b4c5 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index cd2bd0ce..c18dbe8b 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -195,6 +195,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index c663b3c4..a07d5710 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -195,6 +195,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Nom utilisateur de la passerelle', 'sms_gateway_password' => 'Mot de passe de la passerelle', diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php index f6160955..eb75c25b 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Nome Utente Gateway', 'sms_gateway_password' => 'Password Gateway', diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php index 99f4ad3b..fd1dc344 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -195,6 +195,7 @@ $sm_lang = array( 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + '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 41b181fd..63929694 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway gebruikersnaam', 'sms_gateway_password' => 'Gateway wachtwoord', diff --git a/src/lang/pl_PL.lang.php b/src/lang/pl_PL.lang.php index 4a871048..16660447 100644 --- a/src/lang/pl_PL.lang.php +++ b/src/lang/pl_PL.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Login do bramki', 'sms_gateway_password' => 'Hasło do bramki', diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index 8942ed06..48e343f8 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Usuário do Gateway', 'sms_gateway_password' => 'Senha do Gateway', diff --git a/src/lang/ru_RU.lang.php b/src/lang/ru_RU.lang.php index 48ecc14b..68c5ad86 100644 --- a/src/lang/ru_RU.lang.php +++ b/src/lang/ru_RU.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Пользователь', 'sms_gateway_password' => 'Пароль', diff --git a/src/lang/tr_TR.lang.php b/src/lang/tr_TR.lang.php index caa5a6f0..a5ce9a6f 100644 --- a/src/lang/tr_TR.lang.php +++ b/src/lang/tr_TR.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Servis kullanıcı adı', 'sms_gateway_password' => 'Servis şifresi', diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 05cbeee5..69a2fea2 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -194,6 +194,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', 'sms_gateway_smsglobal' => 'SMSGlobal', + 'sms_gateway_octopush' => 'Octopush', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'SMS网关用户名', 'sms_gateway_password' => 'SMS网关密码', diff --git a/src/psm/Module/Config/Controller/ConfigController.class.php b/src/psm/Module/Config/Controller/ConfigController.class.php index c8216840..119f17ef 100644 --- a/src/psm/Module/Config/Controller/ConfigController.class.php +++ b/src/psm/Module/Config/Controller/ConfigController.class.php @@ -314,6 +314,7 @@ class ConfigController extends AbstractController { '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_smsglobal' => psm_get_lang('config', 'sms_gateway_smsglobal'), + 'label_sms_gateway_octopush' => psm_get_lang('config', 'sms_gateway_octopush'), '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/Txtmsg/Octopush.class.php b/src/psm/Txtmsg/Octopush.class.php new file mode 100644 index 00000000..790faff7 --- /dev/null +++ b/src/psm/Txtmsg/Octopush.class.php @@ -0,0 +1,72 @@ +. + * + * @package phpservermon + * @author Alexis Urien + * @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 2.1 + **/ + +namespace psm\Txtmsg; + +class Octopush extends Core { + // ========================================================================= + // [ Fields ] + // ========================================================================= + public $gateway = 1; + public $resultcode = null; + public $resultmessage = null; + public $success = false; + public $successcount = 0; + + public function sendSMS($message) { + // Octopush exemple url + // french documentation can be found here: http://www.octopush-dm.com/public/docs/envoyer-des-sms-avec-octopush.pdf (need to be logged in) + //'http://www.octopush-dm.com/api/sms/?user_login=*****%40******.com&api_key=****************&sms_text=un+exemple+de+texte&sms_recipients=0033601010101&sms_type=FR&sms_sender=UnSender' + if(count($this->recipients) == 0) + return false; + + $testMode = false; + + $recipients = urlencode(implode(',', $this->recipients)); + $octopush_url = "https://www.octopush-dm.com/api/sms/"; + $octopush_data = urlencode( $message ); + + $URL = $octopush_url. "?" . + "user_login=" . $this->username . + "&api_key=" . $this->password . + "&sms_recipients=" . $recipients . + "&sms_type=XXX" . + ($testMode ? '&request_mode=simu' : '') . + "&sms_text=" . $octopush_data; + + $result = file_get_contents( $URL ); + $xmlResults = simplexml_load_string($result); + if ($xmlResults === false) + return false; + + if ($xmlResults->error_code == '000') + return true; + return false; + } + +} diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index 6ef7adad..7ed1245f 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -158,6 +158,7 @@ + From 87a576642cd05405d11828fc8d409964f75d7d3a Mon Sep 17 00:00:00 2001 From: "Alexis U (portable)" Date: Tue, 15 Mar 2016 15:11:52 +0100 Subject: [PATCH 2/2] ajout mode premium --- src/psm/Txtmsg/Octopush.class.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/psm/Txtmsg/Octopush.class.php b/src/psm/Txtmsg/Octopush.class.php index 790faff7..dd644dda 100644 --- a/src/psm/Txtmsg/Octopush.class.php +++ b/src/psm/Txtmsg/Octopush.class.php @@ -46,17 +46,30 @@ class Octopush extends Core { return false; $testMode = false; + $highPriority = true; + + if ($highPriority) { + $sms_type = 'FR'; + $sms_sender = 'phpServerMon'; + $sms_more = ' STOP au XXXXX'; + } + else { + $sms_type = 'XXX'; + $sms_more = ''; + } + $recipients = urlencode(implode(',', $this->recipients)); $octopush_url = "https://www.octopush-dm.com/api/sms/"; - $octopush_data = urlencode( $message ); + $octopush_data = urlencode( $message . $sms_more ); $URL = $octopush_url. "?" . "user_login=" . $this->username . "&api_key=" . $this->password . "&sms_recipients=" . $recipients . - "&sms_type=XXX" . + "&sms_type=" . $sms_type . ($testMode ? '&request_mode=simu' : '') . + (isset($sms_sender) ? '&sms_sender='.$sms_sender : '') . "&sms_text=" . $octopush_data; $result = file_get_contents( $URL );