Added SMSGlobal support

This commit is contained in:
Victor Macko 2014-07-08 00:45:50 +10:00
parent 5123137bf0
commit 5ddbfdd167
5 changed files with 87 additions and 0 deletions

1
src/lang/en_US.lang.php Normal file → Executable file
View File

@ -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',

View File

@ -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'),

View File

@ -0,0 +1,81 @@
<?php
/**
* PHP Server Monitor
* Monitor your servers and websites.
*
* This file is part of PHP Server Monitor.
* PHP Server Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PHP Server Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
*
* @package phpservermon
* @author Victor Macko
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
* @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;
}
}

3
src/psm/Util/Updater/StatusNotifier.class.php Normal file → Executable file
View File

@ -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

View File

@ -116,6 +116,7 @@
<option value="spryng" {sms_selected_spryng}>{label_sms_gateway_spryng}</option>
<option value="inetworx" {sms_selected_inetworx}>{label_sms_gateway_inetworx}</option>
<option value="clickatell" {sms_selected_clickatell}>{label_sms_gateway_clickatell}</option>
<option value="smsglobal" {sms_selected_smsglobal}>{label_sms_gateway_smsglobal}</option>
<option value="textmarketer" {sms_selected_textmarketer}>{label_sms_gateway_textmarketer}</option>
</select>
</div>