Support for SMSgw provider http://smsgw.net

This commit is contained in:
Daif Alotaibi 2016-11-02 00:40:05 +03:00
parent c981fe5daf
commit d712bb7100
5 changed files with 71 additions and 3 deletions

View File

@ -531,7 +531,11 @@ function psm_build_sms() {
break;
case 'octopush':
$sms = new \psm\Txtmsg\Octopush();
break; }
break;
case 'smsgw':
$sms = new \psm\Txtmsg\Smsgw();
break;
}
// copy login information from the config file
if($sms) {

View File

@ -214,6 +214,7 @@ $sm_lang = array(
'sms_gateway_freemobilesms' => 'FreeMobileSMS',
'sms_gateway_clicksend' => 'ClickSend',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_smsgw' => 'SMSgw',
'sms_gateway_username' => 'Gateway username',
'sms_gateway_password' => 'Gateway password',
'sms_from' => 'Sender\'s phone number',
@ -315,4 +316,4 @@ $sm_lang = array(
'401_unauthorized' => 'Unauthorized',
'401_unauthorized_description' => 'You do not have the privileges to view this page.',
),
);
);

View File

@ -321,6 +321,7 @@ class ConfigController extends AbstractController {
'label_sms_gateway_freevoipdeal' => psm_get_lang('config', 'sms_gateway_freevoipdeal'),
'label_sms_gateway_smsglobal' => psm_get_lang('config', 'sms_gateway_smsglobal'),
'label_sms_gateway_nexmo' => psm_get_lang('config', 'sms_gateway_nexmo'),
'label_sms_gateway_smsgw' => psm_get_lang('config', 'sms_gateway_smsgw'),
'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'),
@ -356,4 +357,4 @@ class ConfigController extends AbstractController {
'label_log_retention_days' => psm_get_lang('config', 'log_retention_days'),
);
}
}
}

61
src/psm/Txtmsg/Smsgw.php Normal file
View File

@ -0,0 +1,61 @@
<?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 Daif Alotaibi <daif@daif.net>
* @copyright Copyright (c) 2008-2015 Pepijn Over <pep@peplab.net>
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@
* @link http://www.phpservermonitor.org/
**/
namespace psm\Txtmsg;
class Smsgw extends Core {
/**
* Send a text message to one or more recipients
*
* @param string $message
* @return boolean
*/
public function sendSMS($message) {
$url = 'http://api.smsgw.net/SendBulkSMS';
$post = array(
'strUserName' => $this->username,
'strPassword' => $this->password,
'strTagName' => $this->originator,
'strRecepientNumbers' => implode(';', $this->recipients),
'strMessage' => $message,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$data = curl_exec($ch);
if($data == '1') {
$this->success = true;
}
return $this->success;
}
}

View File

@ -173,6 +173,7 @@
<option value="octopush" {{ sms_selected_octopush|raw }}>{{ label_sms_gateway_octopush }}</option>
<option value="freemobilesms" {{ sms_selected_freemobilesms|raw }}>{{ label_sms_gateway_freemobilesms }}</option>
<option value="clicksend" {{ sms_selected_clicksend|raw }}>{{ label_sms_gateway_clicksend }}</option>
<option value="smsgw" {{ sms_selected_smsgw|raw }}>{{ label_sms_gateway_smsgw }}</option>
</select>
</div>
</div>