parent
a80452d916
commit
9d30b9854c
|
@ -556,6 +556,9 @@ function psm_build_sms() {
|
|||
case 'smsgw':
|
||||
$sms = new \psm\Txtmsg\Smsgw();
|
||||
break;
|
||||
case 'twilio':
|
||||
$sms = new \psm\Txtmsg\Twilio();
|
||||
break;
|
||||
}
|
||||
|
||||
// copy login information from the config file
|
||||
|
@ -786,4 +789,3 @@ class telegram
|
|||
return $this->sendurl();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Тестовия имейл е изпратен успешно.',
|
||||
'email_error' => 'Възникна грешка при изпращането на тесовия имейл',
|
||||
'sms_sent' => 'Тестовото SMS съобщение е изпратеното успешно.',
|
||||
'sms_error' => 'Възникна грешка при изпращането на тестовия SMS',
|
||||
'sms_error' => 'Възникна грешка при изпращането на тестовия SMS. %s',
|
||||
'sms_error_nomobile' => 'Неуспешно изпращане на тестов SMS: не е намерен валиден телефонен номер във вашия профил.',
|
||||
'pushover_sent' => 'Pushover тестово известие',
|
||||
'pushover_error' => 'Възникна грешка при изпращане на тестово Pushover известие: %s',
|
||||
|
|
|
@ -267,7 +267,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'E-mail odeslán',
|
||||
'email_error' => 'Chyba při odeslání e-mailu',
|
||||
'sms_sent' => 'SMS odeslána',
|
||||
'sms_error' => 'Chyba při odeslání SMS',
|
||||
'sms_error' => 'Chyba při odeslání SMS. %s',
|
||||
'sms_error_nomobile' => 'Nebylo možné odeslat SMS: v uživatelském profilu nebylo nalezeno platné telefonní číslo.',
|
||||
'pushover_sent' => 'Pushover upozornění odesláno.',
|
||||
'pushover_error' => 'Nastala chyba při odesílání Pushover upozornění: %s',
|
||||
|
|
|
@ -251,7 +251,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'E-mail sendt',
|
||||
'email_error' => 'Fejl ved afsendelse af e-mail',
|
||||
'sms_sent' => 'Sms sendt',
|
||||
'sms_error' => 'Fejl ved afsendelse af SMS',
|
||||
'sms_error' => 'Fejl ved afsendelse af SMS. %s',
|
||||
'sms_error_nomobile' => 'Ikke muligt at sende SMS: Intet gyldigt telefonnummer blev fundet i din profil.',
|
||||
'pushover_sent' => 'Pushover notifikation blev sendt',
|
||||
'pushover_error' => 'En fejl opstod under afsendelse af Pushover notifikation: %s',
|
||||
|
|
|
@ -255,7 +255,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'E-Mail gesendet.',
|
||||
'email_error' => 'Beim Versand der E-Mail trat ein Fehler auf.',
|
||||
'sms_sent' => 'SMS-Nachricht gesendet.',
|
||||
'sms_error' => 'Beim Versand der SMS-Nachricht trat ein Fehler auf.',
|
||||
'sms_error' => 'Beim Versand der SMS-Nachricht trat ein Fehler auf. %s',
|
||||
'sms_error_nomobile' => 'Versand der SMS-Nachricht nicht möglich: Es wurde keine gültige Telefonnummer in Ihrem Profil hinterlegt.',
|
||||
'pushover_sent' => 'Pushover-Benachrichtigung versendet',
|
||||
'pushover_error' => 'Beim Versand der Pushover-Benachrichtigung trat ein Fehler auf: %s',
|
||||
|
|
|
@ -240,6 +240,7 @@ $sm_lang = array(
|
|||
'sms_gateway_clicksend' => 'ClickSend',
|
||||
'sms_gateway_nexmo' => 'Nexmo',
|
||||
'sms_gateway_smsgw' => 'SMSgw',
|
||||
'sms_gateway_twilio' => 'Twilio',
|
||||
'sms_gateway_username' => 'Gateway username',
|
||||
'sms_gateway_password' => 'Gateway password',
|
||||
'sms_from' => 'Sender\'s phone number',
|
||||
|
@ -302,7 +303,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email sent',
|
||||
'email_error' => 'Error in email sending',
|
||||
'sms_sent' => 'Sms sent',
|
||||
'sms_error' => 'Error in sms sending',
|
||||
'sms_error' => 'An error has occurred while sending the SMS: %s',
|
||||
'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.',
|
||||
'pushover_sent' => 'Pushover notification sent',
|
||||
'pushover_error' => 'An error has occurred while sending the Pushover notification: %s',
|
||||
|
@ -359,4 +360,3 @@ $sm_lang = array(
|
|||
'401_unauthorized_description' => 'You do not have the privileges to view this page.',
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email enviado',
|
||||
'email_error' => 'Error al enviar el email',
|
||||
'sms_sent' => 'SMS enviado',
|
||||
'sms_error' => 'Error al enviar el SMS',
|
||||
'sms_error' => 'Error al enviar el SMS. %s',
|
||||
'sms_error_nomobile' => 'No se puede enviar SMS de prueba: no hay ningún número de teléfono válido en su perfil.',
|
||||
'pushover_sent' => 'Notificación Pushover enviada',
|
||||
'pushover_error' => 'Error al enviar la notificación Pushover: %s',
|
||||
|
|
|
@ -252,7 +252,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email saadetud',
|
||||
'email_error' => 'Emaili saatmisel esines error',
|
||||
'sms_sent' => 'Sms saadetud',
|
||||
'sms_error' => 'Smsi saatmisel esines error',
|
||||
'sms_error' => 'Smsi saatmisel esines error. %s',
|
||||
'sms_error_nomobile' => 'Test SMSi ei saadetud: kehtivat telefoni numbrit ei leitud.',
|
||||
'pushover_sent' => 'Pushover teavitus saadetud',
|
||||
'pushover_error' => 'Pushover teavituse saatmisel esines error: %s',
|
||||
|
|
|
@ -252,7 +252,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'ایمیل ارسال شد',
|
||||
'email_error' => 'خطا در ارسال ایمیل',
|
||||
'sms_sent' => 'پیامک ارسال شد',
|
||||
'sms_error' => 'خطا در ارسال پیامک',
|
||||
'sms_error' => '%s خطا در ارسال پیامک',
|
||||
'sms_error_nomobile' => 'قادر به ارسال پیامک تستی نیستیم: شماره تلفن معتبر در پروفایل شما یافته نشد.',
|
||||
'pushover_sent' => 'اطلاعیه پوش آور ارسال شد.',
|
||||
'pushover_error' => 'یک خطا در هنگام ارسال اطلاعیه پوش آور رخ داده است: %s',
|
||||
|
|
|
@ -252,7 +252,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Sähköposti lähetetty',
|
||||
'email_error' => 'Virhe sähköpostin lähetyksessä',
|
||||
'sms_sent' => 'Tekstiviesti lähetetty',
|
||||
'sms_error' => 'Virhe tekstiviestin lähetyksessä',
|
||||
'sms_error' => 'Virhe tekstiviestin lähetyksessä. %s',
|
||||
'sms_error_nomobile' => 'Testitektiviestin lähetys epäonnistui: toimivaa numeroa ei löydetty profiilistasi.',
|
||||
'pushover_sent' => 'Pushover ilmoitus lähetetty',
|
||||
'pushover_error' => 'Virhe Pushover-ilmoitusta lähetettäessä: %s',
|
||||
|
|
|
@ -256,7 +256,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email envoyé',
|
||||
'email_error' => 'Erreur lors de l\'envoi de l\'email',
|
||||
'sms_sent' => 'Sms envoyé',
|
||||
'sms_error' => 'Erreur lors de l\'envoi du SMS',
|
||||
'sms_error' => 'Erreur lors de l\'envoi du SMS. %s',
|
||||
'sms_error_nomobile' => 'Impossible d\'envoyer un SMS de test: aucun numéro de téléphone défini dans votre profil.',
|
||||
'pushover_sent' => 'Notification Pushover envoyée',
|
||||
'pushover_error' => 'Une erreur s\'est produite lors de l\'envoi de la notification Pushover : %s',
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email inviata',
|
||||
'email_error' => 'Errore in invio Email',
|
||||
'sms_sent' => 'SMS inviato',
|
||||
'sms_error' => 'Errore in invio SMS',
|
||||
'sms_error' => 'Errore in invio SMS. %s',
|
||||
'sms_error_nomobile' => 'Impossibile inviare SMS: nessun numero di telefono valido inserito nel tuo profilo.',
|
||||
'pushover_sent' => 'Notifica Pushover inviata',
|
||||
'pushover_error' => 'Riscontrato un errore durante l\'invio della notifica Pushover: %s',
|
||||
|
|
|
@ -277,7 +277,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'メールが送信されました',
|
||||
'email_error' => 'メールを送信中にエラーが発生しました',
|
||||
'sms_sent' => 'SMSが送信されました',
|
||||
'sms_error' => 'SMSを送信中にエラーが発生しました',
|
||||
'sms_error' => 'SMSを送信中にエラーが発生しました %s',
|
||||
'sms_error_nomobile' => 'テストSMSの送信に失敗: あなたのプロフィールに有効な電話番号がありません',
|
||||
'pushover_sent' => 'プッシュオーバー通知が送信されました',
|
||||
'pushover_error' => 'プッシュオーバー通知を送信中にエラーが発生しました: %s',
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email sent',
|
||||
'email_error' => 'Error in email sending',
|
||||
'sms_sent' => 'Sms sent',
|
||||
'sms_error' => 'Error in sms sending',
|
||||
'sms_error' => 'Error in sms sending. %s',
|
||||
'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.',
|
||||
'pushover_sent' => 'Pushover notification sent',
|
||||
'pushover_error' => 'An error has occurred while sending the Pushover notification: %s',
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email verzonden',
|
||||
'email_error' => 'Er is een fout opgetreden tijdens het verzenden',
|
||||
'sms_sent' => 'SMS verzonden',
|
||||
'sms_error' => 'Er is een fout opgetreden tijdens het verzenden',
|
||||
'sms_error' => 'Er is een fout opgetreden tijdens het verzenden. %s',
|
||||
'sms_error_nomobile' => 'Kan test SMS niet verzenden: er is geen telefoonnummer ingevuld in je profiel.',
|
||||
'pushover_sent' => 'Pushover notificatie verzonden',
|
||||
'pushover_error' => 'De volgende fout is opgetreden bij het versturen van de Pushover notificatie: %s',
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email wysłany',
|
||||
'email_error' => 'Błąd podczas wysyłania emaila',
|
||||
'sms_sent' => 'Sms wysłany',
|
||||
'sms_error' => 'Błąd podczas wysyłania sms',
|
||||
'sms_error' => 'Błąd podczas wysyłania sms. %s',
|
||||
'sms_error_nomobile' => 'Nie udało się wysłać testowego SMS: brak poprawnego telefonu w Twoim profilu.',
|
||||
'pushover_sent' => 'Powiadomienie Pushover wysłane.',
|
||||
'pushover_error' => 'Błąd podczas wysyłania powiadomienia Pushover: %s',
|
||||
|
|
|
@ -257,7 +257,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email enviado',
|
||||
'email_error' => 'Erro no envio do email',
|
||||
'sms_sent' => 'Sms enviado',
|
||||
'sms_error' => 'Error no envio do SMS',
|
||||
'sms_error' => 'Error no envio do SMS. %s',
|
||||
'sms_error_nomobile' => 'Não foi possível enviar SMS de teste: nenhum número de telefone válido encontrado em seu perfil.',
|
||||
'pushover_sent' => 'Notificação Pushover enviada',
|
||||
'pushover_error' => 'Um erro foi encontrado ao enviar a notificação Pushover: %s',
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Сообщение отправлено',
|
||||
'email_error' => 'Ошибка при отправке сообщения',
|
||||
'sms_sent' => 'SMS отправлено',
|
||||
'sms_error' => 'Ошибка при отправке SMS',
|
||||
'sms_error' => 'Ошибка при отправке SMS. %s',
|
||||
'sms_error_nomobile' => 'Не удалось отправить пробный SMS: действительный телефонный номер не был найден в вашем профиле.',
|
||||
'pushover_sent' => 'Pushover уведомление отправлено',
|
||||
'pushover_error' => 'Произошла ошибка во время отправки Pushover уведомления: %s',
|
||||
|
|
|
@ -268,7 +268,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'E-mail odoslaný',
|
||||
'email_error' => 'Chyba pri odosielaní e-mailu',
|
||||
'sms_sent' => 'SMS odoslaná',
|
||||
'sms_error' => 'Chyba pri odosielaní SMS',
|
||||
'sms_error' => 'Chyba pri odosielaní SMS. %s',
|
||||
'sms_error_nomobile' => 'Nebolo možné odoslať SMS: v užívateľskom profile nebylo nájdené platné telefónne číslo.',
|
||||
'pushover_sent' => 'Pushover upozornenie odoslané.',
|
||||
'pushover_error' => 'Nastala chyba pri odosielaní Pushover upozornenia: %s',
|
||||
|
|
|
@ -249,7 +249,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'E-pošta poslana',
|
||||
'email_error' => 'Napaka pri pošiljanju e-pošte',
|
||||
'sms_sent' => 'SMS sporočilo poslano',
|
||||
'sms_error' => 'Napaka pri pošiljanju SMS sporočila',
|
||||
'sms_error' => 'Napaka pri pošiljanju SMS sporočila. %s',
|
||||
'sms_error_nomobile' => 'Ni mogoče poslati testnega SMS sporočila: v vašem profilu ni vpisana veljavna telefonska številka.',
|
||||
'pushover_sent' => 'Pushover obvestilo poslano',
|
||||
'pushover_error' => 'Napaka pri pošiljanju Pushover sporočila: %s',
|
||||
|
|
|
@ -253,7 +253,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Email skickat',
|
||||
'email_error' => 'Sändning av email misslyckades',
|
||||
'sms_sent' => 'Sms skickat',
|
||||
'sms_error' => 'Sändning av SMS misslyckades',
|
||||
'sms_error' => 'Sändning av SMS misslyckades. %s',
|
||||
'sms_error_nomobile' => 'Kan inte skicka test-SMS: det finns inget giltigt mobilnummer i din profil.',
|
||||
'pushover_sent' => 'Pushover-meddelande skickat',
|
||||
'pushover_error' => 'Ett fel uppstod vid sändning av Pushover-meddelande: %s',
|
||||
|
|
|
@ -254,7 +254,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'E-posta gönderildi',
|
||||
'email_error' => 'E-posta gönderiminde hata.',
|
||||
'sms_sent' => 'Sms gönderildi',
|
||||
'sms_error' => 'SMS gönderiminde hata',
|
||||
'sms_error' => 'SMS gönderiminde hata. %s',
|
||||
'sms_error_nomobile' => 'SMS gönderilemiyor: profilinizde geçerli bir telefon numarası yok.',
|
||||
'pushover_sent' => 'Pushover bildirimi gönderildi',
|
||||
'pushover_error' => 'Pushover bildirimi gönderilirken bir hata meydana geldi: %s',
|
||||
|
|
|
@ -249,7 +249,7 @@ $sm_lang = array(
|
|||
'email_sent' => 'Gửi email',
|
||||
'email_error' => 'Lỗi trong khi gửi mail',
|
||||
'sms_sent' => 'Gửi SMS',
|
||||
'sms_error' => 'Lỗi trong khi gửi sms',
|
||||
'sms_error' => 'Lỗi trong khi gửi sms. %s',
|
||||
'sms_error_nomobile' => 'Không thể gửi thử SMS: không có số điện thoại hợp lệ được tìm thấy trong hồ sơ của bạn.',
|
||||
'pushover_sent' => 'Gửi thông báo Pushover',
|
||||
'pushover_error' => 'Một lỗi đã xảy ra trong khi gửi thông báo Pushover: %s',
|
||||
|
|
|
@ -273,7 +273,7 @@ $sm_lang = array(
|
|||
'email_sent' => '发送邮件',
|
||||
'email_error' => '发送出错',
|
||||
'sms_sent' => '发送短信',
|
||||
'sms_error' => '短信发送出错',
|
||||
'sms_error' => '短信发送出错 %s',
|
||||
'sms_error_nomobile' => '无法发送短信: 您的账号未设置有效手机号码.',
|
||||
'pushover_sent' => '发送Pushover通知',
|
||||
'pushover_error' => 'Pushover通知发送出错: %s',
|
||||
|
|
|
@ -247,10 +247,11 @@ class ConfigController extends AbstractController {
|
|||
$this->addMessage(psm_get_lang('config', 'sms_error_nomobile'), 'error');
|
||||
} else {
|
||||
$sms->addRecipients($user->mobile);
|
||||
if($sms->sendSMS(psm_get_lang('config', 'test_message'))) {
|
||||
$result = $sms->sendSMS(psm_get_lang('config', 'test_message'));
|
||||
if($result === 1) {
|
||||
$this->addMessage(psm_get_lang('config', 'sms_sent'), 'success');
|
||||
} else {
|
||||
$this->addMessage(psm_get_lang('config', 'sms_error'), 'error');
|
||||
$this->addMessage(sprintf(psm_get_lang('config', 'sms_error'), $result), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,6 +377,7 @@ class ConfigController extends AbstractController {
|
|||
'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_twilio' => psm_get_lang('config', 'sms_gateway_twilio'),
|
||||
'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'),
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<?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 Tim Zandbergen <Tim@Xervion.nl>
|
||||
* @copyright Copyright (c) 2008-2018 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/
|
||||
**/
|
||||
|
||||
namespace psm\Txtmsg;
|
||||
|
||||
class Twilio extends Core {
|
||||
|
||||
/**
|
||||
* Send sms using the Twilio API
|
||||
* https://www.twilio.com/docs/sms/api#send-an-sms-with-the-sms-api
|
||||
* @var string $message
|
||||
* @var array $this->recipients
|
||||
* @var string $recipient
|
||||
* @var string $this->username
|
||||
* @var string $this->password
|
||||
* @var string $this->originator
|
||||
* @var int $success
|
||||
* @var string $error
|
||||
* @return int or string
|
||||
*/
|
||||
public function sendSMS($message) {
|
||||
$success = 1;
|
||||
$error = '';
|
||||
|
||||
foreach($this->recipients as $recipient) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, "https://api.twilio.com/2010-04-01/Accounts/".$this->username."/Messages.json");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "From=".urlencode($this->originator)."&Body=".urlencode($message)."&To=".urlencode($recipient));
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ":" . $this->password);
|
||||
|
||||
$headers = array();
|
||||
$headers[] = "Content-Type: application/x-www-form-urlencoded";
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// When the result string starts with {"code": there is a problem
|
||||
if (strpos($result, "{\"code\":") === 0) {
|
||||
$error = $result;
|
||||
$success = 0;
|
||||
}
|
||||
}
|
||||
if($success == 1){
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -202,6 +202,7 @@
|
|||
<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>
|
||||
<option value="twilio" {{ sms_selected_twilio|raw }}>{{ label_sms_gateway_twilio }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue