pull/545/merge
Axel Wehner 2018-03-09 21:17:33 +00:00 committed by GitHub
commit 065c12eebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 277 additions and 14 deletions

View File

@ -55,6 +55,7 @@ The following SMS gateways are currently available:
* Nexmo - <https://www.nexmo.com/>
* OctoPush - <http://www.octopush.com/>
* FreeMobile (FR) - <http://mobile.free.fr/>
* CM Telecom - <https://www.cm.com/>

View File

@ -556,6 +556,9 @@ function psm_build_sms() {
case 'smsgw':
$sms = new \psm\Txtmsg\Smsgw();
break;
case 'cmbulksms':
$sms = new \psm\Txtmsg\CMBulkSMS();
break;
}
// copy login information from the config file

View File

@ -203,6 +203,7 @@ $sm_lang = array(
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_octopush' => 'Octopush',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Потребител',
'sms_gateway_password' => 'Парола',
'sms_from' => 'Номер на изпращача',

View File

@ -218,6 +218,7 @@ $sm_lang = array(
'sms_gateway_freemobilesms' => 'FreeMobileSMS',
'sms_gateway_clicksend' => 'ClickSend',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Uživatelské jméno brány',
'sms_gateway_password' => 'Heslo brány',
'sms_from' => 'Telefonní číslo odesilatele',

View File

@ -200,6 +200,7 @@ $sm_lang = array(
'sms_gateway_octopush' => 'Octopush',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway brugernavn/apikey',
'sms_gateway_password' => 'Gateway adgangskode',
'sms_from' => 'Afsenderens navn.',

View File

@ -204,6 +204,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway Benutzername',
'sms_gateway_password' => 'Gateway Passwort',
'sms_from' => 'SMS-Sendernummer',

View File

@ -240,6 +240,7 @@ $sm_lang = array(
'sms_gateway_clicksend' => 'ClickSend',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_smsgw' => 'SMSgw',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway username',
'sms_gateway_password' => 'Gateway password',
'sms_from' => 'Sender\'s phone number',

View File

@ -207,6 +207,7 @@ $sm_lang = array(
'sms_gateway_username' => 'Usuario',
'sms_gateway_password' => 'Contraseña',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway username',
'sms_gateway_password' => 'Gateway password',
'sms_from' => 'Número origen del SMS',

View File

@ -201,6 +201,7 @@ $sm_lang = array(
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Värava kasutajanimi',
'sms_gateway_password' => 'Värava parool',
'sms_from' => 'Saatja telefoni number',

View File

@ -201,6 +201,7 @@ $sm_lang = array(
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'نام کاربری Gateway',
'sms_gateway_password' => 'کلمه عبور Gateway',
'sms_from' => 'شماره تلفن ارسال کننده',

View File

@ -201,6 +201,7 @@ $sm_lang = array(
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Palvelun käyttäjänimi',
'sms_gateway_password' => 'Palvelun salasana',
'sms_from' => 'Lähettäjän puhelinnumero',

View File

@ -205,6 +205,7 @@ $sm_lang = array(
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_freemobilesms' => 'FreeMobileSMS',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Nom utilisateur de la passerelle',
'sms_gateway_password' => 'Mot de passe de la passerelle',
'sms_from' => 'SMS de l\'expéditeur',

View File

@ -203,6 +203,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Nome Utente Gateway',
'sms_gateway_password' => 'Password Gateway',
'sms_from' => 'Numero di telefono del mittente',

View File

@ -223,6 +223,7 @@ $sm_lang = array(
'sms_gateway_clicksend' => 'ClickSend',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_smsgw' => 'SMSgw',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'ゲートウェイのユーザー名',
'sms_gateway_password' => 'ゲートウェイのパスワード',
'sms_from' => '送信者の電話番号:',

View File

@ -203,6 +203,7 @@ $sm_lang = array(
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_octopush' => 'Octopush',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway username',
'sms_gateway_password' => 'Gateway password',
'sms_from' => 'Sender\'s phone number',

View File

@ -203,6 +203,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway gebruikersnaam',
'sms_gateway_password' => 'Gateway wachtwoord',
'sms_from' => 'Telefoonnummer afzender',

View File

@ -203,6 +203,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Login do bramki',
'sms_gateway_password' => 'Hasło do bramki',
'sms_from' => 'Numer nadawcy',

View File

@ -206,6 +206,7 @@ $sm_lang = array(
'sms_gateway_password' => 'Senha do Gateway',
'sms_from' => 'Número de telefone de envio',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Usuário do Gateway',
'sms_gateway_password' => 'Senha do Gateway',
'sms_from' => 'Número de telefone de envio',

View File

@ -203,6 +203,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Пользователь',
'sms_gateway_password' => 'Пароль',
'sms_from' => 'Номер отправителя',

View File

@ -217,6 +217,7 @@ $sm_lang = array(
'sms_gateway_freemobilesms' => 'FreeMobileSMS',
'sms_gateway_clicksend' => 'ClickSend',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Užívateľské meno brány',
'sms_gateway_password' => 'Heslo brány',
'sms_from' => 'Telefónne číslo odosielateľa',

View File

@ -198,6 +198,7 @@ $sm_lang = array(
'sms_gateway_textmarketer' => 'Textmarketer',
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Uporabniško ime SMS prehoda',
'sms_gateway_password' => 'Geslo SMS prehoda',
'sms_from' => 'Telefonska številka pošiljatelja',

View File

@ -202,6 +202,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway användarnamn',
'sms_gateway_password' => 'Gateway lösenord',
'sms_from' => 'Avsändarens telefonnummer',

View File

@ -202,7 +202,8 @@ $sm_lang = array(
'sms_gateway_octopush' => 'Octopush',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Servis kullanıcı adı',
'sms_gateway_password' => 'Servis şifresi',
'sms_from' => 'Gönderen numarası',

View File

@ -198,6 +198,7 @@ $sm_lang = array(
'sms_gateway_textmarketer' => 'Textmarketer',
'sms_gateway_smsglobal' => 'SMSGlobal',
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'Gateway username',
'sms_gateway_password' => 'Gateway password',
'sms_from' => 'Số điện thoại của người gửi',

View File

@ -219,6 +219,7 @@ $sm_lang = array(
'sms_gateway_smsit' => 'Smsit',
'sms_gateway_freevoipdeal' => 'FreeVoipDeal',
'sms_gateway_nexmo' => 'Nexmo',
'sms_gateway_cmbulksms' => 'CM Telecom',
'sms_gateway_username' => 'SMS网关用户名',
'sms_gateway_password' => 'SMS网关密码',
'sms_from' => '发信人电话号',

View File

@ -367,6 +367,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_cmbulksms' => psm_get_lang('config', 'sms_gateway_cmbulksms'),
'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_freevoipdeal' => psm_get_lang('config', 'sms_gateway_freevoipdeal'),

View File

@ -0,0 +1,234 @@
<?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 Axel Wehner <mail@axelwehner.de>
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@
* @link http://www.phpservermonitor.org/
* @since phpservermon 3.2.1
**/
namespace psm\Txtmsg;
/**
* CMBulkSMS - Class for CM Telecom's Bulk SMS Gateway API
*
* Sending SMS notifications via the CM Telecom Bulk SMS Gateway
* Please use the gateway password field in your configuration for the CM API-Token
*
* Requirements: cURL v7.18.1+ and OpenSSL 0.9.8j+
*/
class CMBulkSMS extends Core {
/** @var bool|null True when cURL request succeeded */
public $result;
/** @var string|null Contains error message if cURL request failed */
public $error;
/** @var bool Set to true for debug output/logging */
protected $debug = false;
/** @var bool Set to false if your operator isn't able to handle multipart messages */
protected $multipartMessage = true;
/** @var string|null Gateway API URL uses const GATEWAY_URL_XML or GATEWAY_URL_JSON */
protected $apiUrl;
/** @var string Gateway API Type: Use 'json' (default) or 'xml' */
protected $apiType = 'json';
/** @var string|null JSON or XML message for cURL request */
protected $request;
/** @var string|null HTTP Content-Type for cURL request */
protected $contentType;
/** @var string|null Raw sms text message */
protected $messageBody;
/** @var string JSON Gateway API URL */
const GATEWAY_URL_JSON = "https://gw.cmtelecom.com/v1.0/message";
/** @var string XML Gateway API URL */
const GATEWAY_URL_XML = "https://sgw01.cm.nl/gateway.ashx";
/**
* Build the message and send cURL request to the sms gateway
*
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests
* @param string $message Your text message
* @return boolean True when cURL request was successful
*/
public function sendSMS($message) {
// Check if recipient and text message are available
if(count($this->recipients) < 1 || empty($message)) {
return false;
}
// Set message text
$this->messageBody = $message;
// Prepare the message in CM's XML or JSON format
switch($this->apiType) {
case 'xml':
$this->request = $this->buildMessageXml();
$this->contentType = 'Content-Type: application/xml';
$this->apiUrl = self::GATEWAY_URL_XML;
break;
case 'json':
default:
$this->request = $this->buildMessageJson();
$this->contentType = 'Content-Type: application/json';
$this->apiUrl = self::GATEWAY_URL_JSON;
break;
}
$request = $this->executeCurlRequest();
return $request;
}
/**
* Create a JSON batch sms message using CM's format
*
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cbatch_messages
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cmultipart
* @return string JSON message object
*/
protected function buildMessageJson() {
// Prepare recipient array for batch message
$recipients = array();
foreach($this->recipients as $recipient) {
$recipients[] = array('number' => $recipient);
}
// Build message array in CM's Bulk SMS format
$msgArray = array(
'messages' => array(
'authentication' => array(
'producttoken' => $this->password
),
'msg' => array(
array(
'from' => substr($this->originator, 0, 11),
'to' => $recipients,
'body' => array(
'content' => $this->messageBody
)
)
)
)
);
// Multipart message
if($this->multipartMessage) {
$msgArray['messages']['msg'][0]['minimumNumberOfMessageParts'] = 1;
$msgArray['messages']['msg'][0]['maximumNumberOfMessageParts'] = 8;
}
// Convert array in JSON object
return json_encode($msgArray);
}
/**
* Create a XML batch sms message in CM's format
*
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cbatch_messages
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Cmultipart
* @return string XML message
*/
protected function buildMessageXml() {
// Create XML string
$xml = new \SimpleXMLElement('<MESSAGES/>');
// API-Token
$auth = $xml->addChild('AUTHENTICATION');
$auth->addChild('PRODUCTTOKEN', $this->password);
// Message
$msg = $xml->addChild('MSG');
// From
$msg->addChild('FROM', substr($this->originator, 0, 11));
// Recipients
foreach($this->recipients as $recipient) {
$msg->addChild('TO', $recipient);
}
// Multipart message
if($this->multipartMessage) {
$msg->addChild('MINIMUMNUMBEROFMESSAGEPARTS', 1);
$msg->addChild('MAXIMUMNUMBEROFMESSAGEPARTS', 8);
}
// Add body text
$msg->addChild('BODY', $this->messageBody);
return $xml->asXML();
}
/**
* Create and execute the curl request
*
* @return boolean True if message is sent
*/
protected function executeCurlRequest() {
$cr = curl_init();
curl_setopt_array($cr, array(
CURLOPT_URL => $this->apiUrl,
CURLOPT_HTTPHEADER => array($this->contentType),
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $this->request,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FAILONERROR => true
)
);
// execute curl request and fetch the response/error
$cResponse = curl_exec($cr);
$cError = curl_error($cr);
$cErrorCode = curl_errno($cr);
curl_close($cr);
// set result and log error if needed
if($cError) {
$this->error = 'Response: CM SMS API:' . $cResponse . ' cURL Error Code: ' . $cErrorCode . '"' . $cError . '"';
error_log($this->error, E_USER_ERROR);
$this->result = false;
} else {
$this->result = true;
}
// Debug output
// Note: CM's XML gateway gives no response when message is sent successfully :/
if($this->debug || PSM_DEBUG) {
$debug = '<pre>Request: '. $this->request . '<br>Response: ' . $cResponse.'</pre>';
error_log("Request: $this->request\r\nResponse: $cResponse", E_USER_NOTICE);
echo $debug;
}
return $this->result;
}
}

View File

@ -188,21 +188,22 @@
<label class="control-label" for="sms_gateway">{{ label_sms_gateway }}</label>
<div class="controls">
<select id="sms_gateway" name="sms_gateway">
<option value="mosms" {{ sms_selected_mosms|raw }}>{{ label_sms_gateway_mosms }}</option>
<option value="mollie" {{ sms_selected_mollie|raw }}>{{ label_sms_gateway_mollie }}</option>
<option value="spryng" {{ sms_selected_spryng|raw }}>{{ label_sms_gateway_spryng }}</option>
<option value="inetworx" {{ sms_selected_inetworx|raw }}>{{ label_sms_gateway_inetworx }}</option>
<option value="clickatell" {{ sms_selected_clickatell|raw }}>{{ label_sms_gateway_clickatell }}</option>
<option value="clicksend" {{ sms_selected_clicksend|raw }}>{{ label_sms_gateway_clicksend }}</option>
<option value="cmbulksms" {{ sms_selected_cmbulksms|raw }}>{{ label_sms_gateway_cmbulksms }}</option>
<option value="freemobilesms" {{ sms_selected_freemobilesms|raw }}>{{ label_sms_gateway_freemobilesms }}</option>
<option value="freevoipdeal" {{ sms_selected_freevoipdeal|raw }}>{{ label_sms_gateway_freevoipdeal }}</option>
<option value="inetworx" {{ sms_selected_inetworx|raw }}>{{ label_sms_gateway_inetworx }}</option>
<option value="mollie" {{ sms_selected_mollie|raw }}>{{ label_sms_gateway_mollie }}</option>
<option value="mosms" {{ sms_selected_mosms|raw }}>{{ label_sms_gateway_mosms }}</option>
<option value="nexmo" {{ sms_selected_nexmo|raw }}>{{ label_sms_gateway_nexmo }}</option>
<option value="octopush" {{ sms_selected_octopush|raw }}>{{ label_sms_gateway_octopush }}</option>
<option value="smsglobal" {{ sms_selected_smsglobal|raw }}>{{ label_sms_gateway_smsglobal }}</option>
<option value="smsgw" {{ sms_selected_smsgw|raw }}>{{ label_sms_gateway_smsgw }}</option>
<option value="smsit" {{ sms_selected_smsit|raw }}>{{ label_sms_gateway_smsit }}</option>
<option value="spryng" {{ sms_selected_spryng|raw }}>{{ label_sms_gateway_spryng }}</option>
<option value="textmarketer" {{ sms_selected_textmarketer|raw }}>{{ label_sms_gateway_textmarketer }}</option>
<option value="smsglobal" {{ sms_selected_smsglobal|raw }}>{{ label_sms_gateway_smsglobal }}</option>
<option value="smsit" {{ sms_selected_smsit|raw }}>{{ label_sms_gateway_smsit }}</option>
<option value="freevoipdeal" {{ sms_selected_freevoipdeal|raw }}>{{ label_sms_gateway_freevoipdeal }}</option>
<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>
<option value="nexmo" {{ sms_selected_nexmo|raw }}>{{ label_sms_gateway_nexmo }}</option>
</select>
</select>
</div>
</div>
<div class="control-group">