From ae4cf0e2880efff13df23e75bfb20233e0e885c1 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Sat, 5 Jul 2014 17:28:02 +1000 Subject: [PATCH 1/7] 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 @@ + From c91d3e75cfad35b610ffaf53dc0af18afb0e2d13 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Sat, 5 Jul 2014 17:42:57 +1000 Subject: [PATCH 2/7] 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 5ddbfdd1676ac06ec30b4432fb5d9d39ca6b97a2 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Tue, 8 Jul 2014 00:45:50 +1000 Subject: [PATCH 3/7] Added SMSGlobal support --- src/lang/en_US.lang.php | 1 + .../Controller/ConfigController.class.php | 1 + src/psm/Txtmsg/Smsglobal.class.php | 81 +++++++++++++++++++ src/psm/Util/Updater/StatusNotifier.class.php | 3 + src/templates/config/config.tpl.html | 1 + 5 files changed, 87 insertions(+) mode change 100644 => 100755 src/lang/en_US.lang.php mode change 100644 => 100755 src/psm/Module/Config/Controller/ConfigController.class.php create mode 100755 src/psm/Txtmsg/Smsglobal.class.php mode change 100644 => 100755 src/psm/Util/Updater/StatusNotifier.class.php diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php old mode 100644 new mode 100755 index 36ae7d25..330f234a --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -159,6 +159,7 @@ $sm_lang = array( 'sms_gateway_inetworx' => 'Inetworx', 'sms_gateway_clickatell' => 'Clickatell', '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/psm/Module/Config/Controller/ConfigController.class.php b/src/psm/Module/Config/Controller/ConfigController.class.php old mode 100644 new mode 100755 index 34544cc2..7ad8b79e --- a/src/psm/Module/Config/Controller/ConfigController.class.php +++ b/src/psm/Module/Config/Controller/ConfigController.class.php @@ -206,6 +206,7 @@ class ConfigController extends AbstractController { '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_smsglobal' => psm_get_lang('config', 'sms_gateway_smsglobal'), 'label_sms_gateway_textmarketer' => psm_get_lang('config', 'sms_gateway_textmarketer'), 'label_sms_gateway_username' => psm_get_lang('config', 'sms_gateway_username'), 'label_sms_gateway_password' => psm_get_lang('config', 'sms_gateway_password'), diff --git a/src/psm/Txtmsg/Smsglobal.class.php b/src/psm/Txtmsg/Smsglobal.class.php new file mode 100755 index 00000000..f644060f --- /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; + } +} \ No newline at end of file diff --git a/src/psm/Util/Updater/StatusNotifier.class.php b/src/psm/Util/Updater/StatusNotifier.class.php old mode 100644 new mode 100755 index 0d07ad43..462f10df --- a/src/psm/Util/Updater/StatusNotifier.class.php +++ b/src/psm/Util/Updater/StatusNotifier.class.php @@ -248,6 +248,9 @@ class StatusNotifier { 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/templates/config/config.tpl.html b/src/templates/config/config.tpl.html index ff9fcf96..86c38ec4 100755 --- a/src/templates/config/config.tpl.html +++ b/src/templates/config/config.tpl.html @@ -116,6 +116,7 @@ + From b77ffc95c3f17d870fc2f1afbe413a0a47d36832 Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Thu, 24 Mar 2016 07:35:06 +1100 Subject: [PATCH 4/7] Also use string comparison --- src/psm/Util/Updater/StatusUpdater.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Util/Updater/StatusUpdater.class.php b/src/psm/Util/Updater/StatusUpdater.class.php index dacd784a..2ba1094c 100644 --- a/src/psm/Util/Updater/StatusUpdater.class.php +++ b/src/psm/Util/Updater/StatusUpdater.class.php @@ -204,7 +204,7 @@ class StatusUpdater { } if($this->server['pattern'] != '') { // Check to see if the pattern was found. - if(!preg_match("/{$this->server['pattern']}/i", $curl_result)) { + if(!preg_match("/{$this->server['pattern']}/i", $curl_result) && strpos($curl_result, $this->server['pattern']) === false) { $this->error = 'Pattern not found.'; $result = false; } From 7cf13e5b8a25f87348bc5b25d48aec544447f04c Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Wed, 30 Mar 2016 12:25:40 +1100 Subject: [PATCH 5/7] Case insensitive check --- src/psm/Util/Updater/StatusUpdater.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Util/Updater/StatusUpdater.class.php b/src/psm/Util/Updater/StatusUpdater.class.php index 2ba1094c..5e343c80 100644 --- a/src/psm/Util/Updater/StatusUpdater.class.php +++ b/src/psm/Util/Updater/StatusUpdater.class.php @@ -204,7 +204,7 @@ class StatusUpdater { } if($this->server['pattern'] != '') { // Check to see if the pattern was found. - if(!preg_match("/{$this->server['pattern']}/i", $curl_result) && strpos($curl_result, $this->server['pattern']) === false) { + if(!preg_match("/{$this->server['pattern']}/i", $curl_result) && stripos($curl_result, $this->server['pattern']) === false) { $this->error = 'Pattern not found.'; $result = false; } From c0843ff53c353bedbee98e540bbdca2a2f29833d Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Thu, 7 Jul 2016 00:09:57 +1000 Subject: [PATCH 6/7] Added ClickSend SMS provider --- src/includes/functions.inc.php | 3 + src/lang/en_US.lang.php | 1 + .../Config/Controller/ConfigController.php | 1 + src/psm/Txtmsg/ClickSend.php | 78 +++++++++++++++++++ .../default/module/config/config.tpl.html | 1 + 5 files changed, 84 insertions(+) create mode 100644 src/psm/Txtmsg/ClickSend.php diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 5346012f..6fc7c29d 100755 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -526,6 +526,9 @@ function psm_build_sms() { case 'freemobilesms': $sms = new \psm\Txtmsg\FreeMobileSMS(); break; + case 'clicksend': + $sms = new \psm\Txtmsg\ClickSend(); + break; case 'octopush': $sms = new \psm\Txtmsg\Octopush(); break; } diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index eb2f77c0..07c1d5d1 100755 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -212,6 +212,7 @@ $sm_lang = array( 'sms_gateway_smsit' => 'Smsit', 'sms_gateway_freevoipdeal' => 'FreeVoipDeal', 'sms_gateway_freemobilesms' => 'FreeMobileSMS', + 'sms_gateway_clicksend' => 'ClickSend', 'sms_gateway_nexmo' => 'Nexmo', 'sms_gateway_username' => 'Gateway username', 'sms_gateway_password' => 'Gateway password', diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index 35d9d7e3..d058de63 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -323,6 +323,7 @@ class ConfigController extends AbstractController { 'label_sms_gateway_nexmo' => psm_get_lang('config', 'sms_gateway_nexmo'), '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_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/ClickSend.php b/src/psm/Txtmsg/ClickSend.php new file mode 100644 index 00000000..185bce81 --- /dev/null +++ b/src/psm/Txtmsg/ClickSend.php @@ -0,0 +1,78 @@ +. + * + * @package phpservermon + * @author Victor Macko + * @copyright Copyright (c) 2008-2015 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 + **/ + +namespace psm\Txtmsg; + +class ClickSend extends Core { + // ========================================================================= + // [ Fields ] + // ========================================================================= + public $gateway = 1; + public $resultcode = null; + public $resultmessage = null; + public $success = false; + public $successcount = 0; + + public function sendSMS($message) { + // Documentation: http://docs.clicksend.apiary.io/#reference/sms/send-an-sms/send-an-sms + // https://rest.clicksend.com/v3/sms/send + // Use your API KEY as the password ($this->password) + $apiurl = "https://rest.clicksend.com/v3/sms/send"; + $from = substr($this->originator,0,11); // Max 11 Char. + + $request = array('messages' => array()); + foreach($this->recipients as $phone) { + $request['messages'][] = array( + 'source' => 'phpservermon', + 'from' => $from, + 'to' => $phone, + 'body' => $message + ); + } + + $data_string = json_encode($request); + $ch = curl_init($apiurl); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($data_string)) + ); + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password); + $result = curl_exec($ch); + + $response = json_decode($result); + $this->success = $response->data->response_code == 'SUCCESS'; + $this->successcount = $response->data->total_count; + + return $response; + } + +} diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index 08fc0fc1..103c52a8 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -172,6 +172,7 @@ + From 5f1dac32c6e1305a4eaa315af7d102e2cc57abde Mon Sep 17 00:00:00 2001 From: Victor Macko Date: Thu, 7 Jul 2016 00:21:26 +1000 Subject: [PATCH 7/7] Removed duplicate file --- src/psm/Txtmsg/Smsglobal.class.php | 81 ------------------------------ 1 file changed, 81 deletions(-) delete mode 100755 src/psm/Txtmsg/Smsglobal.class.php diff --git a/src/psm/Txtmsg/Smsglobal.class.php b/src/psm/Txtmsg/Smsglobal.class.php deleted file mode 100755 index c5d42ad7..00000000 --- a/src/psm/Txtmsg/Smsglobal.class.php +++ /dev/null @@ -1,81 +0,0 @@ -. - * - * @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; - } -}