From ea8e767377325a25afb8b2b7c17c13f7c5af3fd9 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Sat, 5 Jul 2014 17:28:02 +1000 Subject: [PATCH 1/3] Added SMSGlobal as sms gateway --- src/includes/functions.inc.php | 3 ++ src/lang/en_US.lang.php | 1 + src/psm/Txtmsg/Smsglobal.class.php | 81 ++++++++++++++++++++++++++++ src/templates/config/config.tpl.html | 1 + 4 files changed, 86 insertions(+) mode change 100644 => 100755 src/includes/functions.inc.php mode change 100644 => 100755 src/lang/en_US.lang.php create mode 100755 src/psm/Txtmsg/Smsglobal.class.php diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php old mode 100644 new mode 100755 index 788e9d24..7caf85ae --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -444,6 +444,9 @@ function psm_build_sms() { case 'textmarketer': $sms = new \psm\Txtmsg\Textmarketer(); break; + case 'smsglobal': + $sms = new \psm\Txtmsg\Smsglobal(); + break; } // copy login information from the config file diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php old mode 100644 new mode 100755 index 919a9377..5eb63be9 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( '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', diff --git a/src/psm/Txtmsg/Smsglobal.class.php b/src/psm/Txtmsg/Smsglobal.class.php new file mode 100755 index 00000000..c5d42ad7 --- /dev/null +++ b/src/psm/Txtmsg/Smsglobal.class.php @@ -0,0 +1,81 @@ +. + * + * @package phpservermon + * @author Victor Macko + * @copyright Copyright (c) 2008-2014 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 Smsglobal extends Core { + // ========================================================================= + // [ Fields ] + // ========================================================================= + public $gateway = 1; + public $resultcode = null; + public $resultmessage = null; + public $success = false; + public $successcount = 0; + + /** + * Send the SMS message + * @param string $message + * @return boolean (true = message was sent successfully, false = there was a problem sending the message) + */ + public function sendSMS($message) { + $recipients = join(',', $this->recipients); + + if(count($recipients) == 0) { + return false; + } + + /** + * Documentation is here: http://www.smsglobal.com/http-api/ + * Recipient numbers should be in the MSIDSN format (eg. 61400111222). The '+' sign should not be included before the country code. + */ + + $from = urlencode(substr($this->originator,0 , 11)); // Max 11 Char. + + $url = 'http://www.smsglobal.com/http-api.php' . + '?action=sendsms' . + '&user=' . $this->username . + '&password=' . $this->password . + '&from=' . $from . + '&to=' . rawurlencode($recipients) . + '&clientcharset=ISO-8859-1' . + '&text=' . substr(rawurlencode($message), 0, 153); + + $returnedData = file_get_contents($url); + + $isOk = strpos($returnedData, 'OK: 0') !== false; + + $this->success = $isOk; + $this->resultmessage = $returnedData; + + if(!$isOk) { + error_log($this->resultmessage, E_USER_NOTICE); + } + + return $isOk; + } +} diff --git a/src/templates/config/config.tpl.html b/src/templates/config/config.tpl.html index 502eefb6..28daab5a 100755 --- a/src/templates/config/config.tpl.html +++ b/src/templates/config/config.tpl.html @@ -123,6 +123,7 @@ + From 2cbb2dc932351b2cea59dfd3923b8345eb1bba62 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Sat, 5 Jul 2014 17:42:57 +1000 Subject: [PATCH 2/3] Added SMSGlobal as sms gateway --- src/psm/Module/Config/Controller/ConfigController.class.php | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 src/psm/Module/Config/Controller/ConfigController.class.php diff --git a/src/psm/Module/Config/Controller/ConfigController.class.php b/src/psm/Module/Config/Controller/ConfigController.class.php old mode 100644 new mode 100755 index 4d422be1..10d8ee23 --- a/src/psm/Module/Config/Controller/ConfigController.class.php +++ b/src/psm/Module/Config/Controller/ConfigController.class.php @@ -271,6 +271,7 @@ class ConfigController extends AbstractController { '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_smsglobal' => psm_get_lang('config', 'sms_gateway_smsglobal'), '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'), From 4916b9e5d02da7c65c21b46ca14b37d3bf4317df Mon Sep 17 00:00:00 2001 From: Pepijn Over Date: Mon, 28 Jul 2014 09:36:51 +0200 Subject: [PATCH 3/3] issue #110: adding missing translations and changelog --- CHANGELOG.rst | 1 + docs/credits.rst | 4 ++++ src/includes/functions.inc.php | 0 src/lang/bg_BG.lang.php | 1 + src/lang/da_DK.lang.php | 1 + src/lang/de_DE.lang.php | 1 + src/lang/en_US.lang.php | 0 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/pt_BR.lang.php | 1 + src/lang/ru_RU.lang.php | 1 + src/lang/zh_CN.lang.php | 1 + src/psm/Module/Config/Controller/ConfigController.class.php | 0 src/psm/Txtmsg/Smsglobal.class.php | 3 +-- 17 files changed, 17 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/includes/functions.inc.php mode change 100755 => 100644 src/lang/en_US.lang.php mode change 100755 => 100644 src/psm/Module/Config/Controller/ConfigController.class.php mode change 100755 => 100644 src/psm/Txtmsg/Smsglobal.class.php diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 021c7df9..b19d80a1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,7 @@ not yet released * #105: Fixing check for websites with unverified SSL certificates. * #107: Fixing update job for Synology DSM Task Scheduler. * #111: Generated urls for non-default ports included the port twice. +* #110: Support for SMSGlobal SMS gateway . * Support for Danish SMS provider Smsit * Composer added for dependencies. diff --git a/docs/credits.rst b/docs/credits.rst index eb1d5f12..9f557578 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -46,6 +46,10 @@ The following people have contributed to the development of PHP Server Monitor: * Smsit SMS gateway +* Victor Macko + + * SMSGlobal SMS gateway + Translators +++++++++++ diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php old mode 100755 new mode 100644 diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index ef5cbbde..881c56b3 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -179,6 +179,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', 'sms_gateway_username' => 'Потребител', 'sms_gateway_password' => 'Парола', 'sms_from' => 'Номер на изпращача', diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php index e3246f5d..fdb91614 100644 --- a/src/lang/da_DK.lang.php +++ b/src/lang/da_DK.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 84e35909..90eb0d97 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 old mode 100755 new mode 100644 diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index 786433f7..29e27105 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -177,6 +177,7 @@ $sm_lang = array( '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', diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index 7c64447b..4de4f9f8 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 76f965fe..7721365f 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -177,6 +177,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 dcb19402..fd186ca8 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -179,6 +179,7 @@ $sm_lang = array( 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 2824e2fd..fccc7f73 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Gateway gebruikersnaam', 'sms_gateway_password' => 'Gateway wachtwoord', diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index 3b06652b..a8b412ad 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 e82eda7c..9fb5add1 100644 --- a/src/lang/ru_RU.lang.php +++ b/src/lang/ru_RU.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_username' => 'Пользователь', 'sms_gateway_password' => 'Пароль', diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 8f57b26e..4f312245 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -178,6 +178,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', 'sms_gateway_textmarketer' => 'Textmarketer', + 'sms_gateway_smsglobal' => 'SMSGlobal', '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 old mode 100755 new mode 100644 diff --git a/src/psm/Txtmsg/Smsglobal.class.php b/src/psm/Txtmsg/Smsglobal.class.php old mode 100755 new mode 100644 index c5d42ad7..762104e9 --- a/src/psm/Txtmsg/Smsglobal.class.php +++ b/src/psm/Txtmsg/Smsglobal.class.php @@ -23,6 +23,7 @@ * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 * @version Release: @package_version@ * @link http://www.phpservermonitor.org/ + * @since phpservermon 3.1 **/ namespace psm\Txtmsg; @@ -48,7 +49,6 @@ class Smsglobal extends Core { if(count($recipients) == 0) { return false; } - /** * Documentation is here: http://www.smsglobal.com/http-api/ * Recipient numbers should be in the MSIDSN format (eg. 61400111222). The '+' sign should not be included before the country code. @@ -66,7 +66,6 @@ class Smsglobal extends Core { '&text=' . substr(rawurlencode($message), 0, 153); $returnedData = file_get_contents($url); - $isOk = strpos($returnedData, 'OK: 0') !== false; $this->success = $isOk;