From ae4cf0e2880efff13df23e75bfb20233e0e885c1 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Sat, 5 Jul 2014 17:28:02 +1000 Subject: [PATCH] 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 4f5a2b2d..5c83db2a --- 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 @@ +