Added SMSGlobal as sms gateway

This commit is contained in:
Victor Macko 2014-07-05 17:28:02 +10:00 committed by Pepijn Over
parent eee14aea53
commit ea8e767377
4 changed files with 86 additions and 0 deletions

3
src/includes/functions.inc.php Normal file → Executable file
View File

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

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

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

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;
}
}

View File

@ -123,6 +123,7 @@
<option value="inetworx" {sms_selected_inetworx}>{label_sms_gateway_inetworx}</option>
<option value="clickatell" {sms_selected_clickatell}>{label_sms_gateway_clickatell}</option>
<option value="textmarketer" {sms_selected_textmarketer}>{label_sms_gateway_textmarketer}</option>
<option value="smsglobal" {sms_selected_smsglobal}>{label_sms_gateway_smsglobal}</option>
<option value="smsit" {sms_selected_smsit}>{label_sms_gateway_smsit}</option>
</select>
</div>