Prechádzať zdrojové kódy

SMS Broadcast and bug fix (#142)

Basic start to a working SMS broadcast; Add DIDww as Carrier; fix email sending; update readme.

Co-authored-by: blackc2004 <[email protected]>
Chris Black 5 rokov pred
rodič
commit
8bb0682083

+ 2 - 2
sms/README.md

@@ -2,7 +2,7 @@
 1. ```cd /usr/src/```
 1. ```cd /usr/src/```
 2. ```git clone https://github.com/fusionpbx/fusionpbx-apps```
 2. ```git clone https://github.com/fusionpbx/fusionpbx-apps```
 3. ```cd fusionpbx-apps/; cp -R sms /var/www/fusionpbx/app/```
 3. ```cd fusionpbx-apps/; cp -R sms /var/www/fusionpbx/app/```
-4. ```cd /var/www/fusionpbx/resources/install/scripts/app/```
+4. ```cd /var/www/fusionpbx/app/scripts/resources/scripts/app```
 5. ```ln -s /var/www/fusionpbx/app/sms/resources/install/scripts/app/sms```
 5. ```ln -s /var/www/fusionpbx/app/sms/resources/install/scripts/app/sms```
 6. Go to GUI
 6. Go to GUI
 7. Upgrades -> SCHEMA; APP DEFAULTS; MENU DEFAULTS; PERMISSION DEFAULTS
 7. Upgrades -> SCHEMA; APP DEFAULTS; MENU DEFAULTS; PERMISSION DEFAULTS
@@ -25,4 +25,4 @@
 Send and receive!
 Send and receive!
 
 
 NOTE: It is not recommended to use this app with versions of Freeswitch prior to 1.8 if you are installing in a clustered environment.  
 NOTE: It is not recommended to use this app with versions of Freeswitch prior to 1.8 if you are installing in a clustered environment.  
-There is a bug in earlier versions of Freeswitch that can cause it to crash in certain situation when using SMS.
+There is a bug in earlier versions of Freeswitch that can cause it to crash in certain situation when using SMS.

+ 63 - 0
sms/app_config.php

@@ -39,6 +39,16 @@
 		$apps[$x]['permissions'][$y]['name'] = "sms_enabled";
 		$apps[$x]['permissions'][$y]['name'] = "sms_enabled";
 		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
 		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
 		$y++;
 		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "sms_broadcast_add";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "sms_broadcast_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "sms_broadcast_edit";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+
 
 
 	//default settings
 	//default settings
 		$y = 0;
 		$y = 0;
@@ -421,4 +431,57 @@
 		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
 		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
 		$z++;
 		$z++;
 
 
+		$y=2;
+		$apps[$x]['db'][$y]['table']['name'] = "v_sms_broadcast";
+		$apps[$x]['db'][$y]['table']['parent'] = "";
+		$z=0;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_broadcast_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_broadcast_name";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "sms_broadcast_description";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "broadcast_desc";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "start_stamp";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "timestamp";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "date";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "timestamp";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_broadcast_caller_id_number";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_broadcast_phone_numbers";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "sms_broadcast_destination_data";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "response";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+
 ?>
 ?>

+ 216 - 1
sms/app_languages.php

@@ -91,6 +91,19 @@ $text['label-destination']['de-at'] = "";
 $text['label-destination']['ar-eg'] = "";
 $text['label-destination']['ar-eg'] = "";
 $text['label-destination']['he'] = "";
 $text['label-destination']['he'] = "";
 
 
+$text['label-message']['en-us'] = "Message";
+$text['label-message']['es-cl'] = "";
+$text['label-message']['pt-pt'] = "";
+$text['label-message']['fr-fr'] = "";
+$text['label-message']['pt-br'] = "";
+$text['label-message']['pl'] = " ";
+$text['label-message']['uk'] = "";
+$text['label-message']['sv-se'] = "";
+$text['label-message']['ro'] = "";
+$text['label-message']['de-at'] = "";
+$text['label-message']['ar-eg'] = "";
+$text['label-message']['he'] = "";
+
 $text['label-start']['en-us'] = "Time Stamp";
 $text['label-start']['en-us'] = "Time Stamp";
 $text['label-start']['es-cl'] = "";
 $text['label-start']['es-cl'] = "";
 $text['label-start']['pt-pt'] = "";
 $text['label-start']['pt-pt'] = "";
@@ -195,4 +208,206 @@ $text['button-mdr']['de-at'] = "";
 $text['button-mdr']['ar-eg'] = "";
 $text['button-mdr']['ar-eg'] = "";
 $text['button-mdr']['he'] = "";
 $text['button-mdr']['he'] = "";
 
 
-?>
+$text['button-broadcast']['en-us'] = "Broadcast";
+$text['button-broadcast']['es-cl'] = "";
+$text['button-broadcast']['pt-pt'] = "";
+$text['button-broadcast']['fr-fr'] = "";
+$text['button-broadcast']['pt-br'] = "";
+$text['button-broadcast']['pl'] = " ";
+$text['button-broadcast']['uk'] = "";
+$text['button-broadcast']['sv-se'] = "";
+$text['button-broadcast']['ro'] = "";
+$text['button-broadcast']['de-at'] = "";
+$text['button-broadcast']['ar-eg'] = "";
+$text['button-broadcast']['he'] = "";
+
+$text['title-call_broadcast']['en-us'] = "SMS Broadcast";
+$text['title-call_broadcast']['en-gb'] = "SMS Broadcast";
+$text['title-call_broadcast']['ar-eg'] = "";
+$text['title-call_broadcast']['de-at'] = "Rundrufe"; //copied from de-de
+$text['title-call_broadcast']['de-ch'] = "Rundrufe"; //copied from de-de
+$text['title-call_broadcast']['de-de'] = "Rundrufe";
+$text['title-call_broadcast']['es-cl'] = "Llamada Masiva (Broadcast)";
+$text['title-call_broadcast']['es-mx'] = "Llamada Masiva (Broadcast)"; //copied from es-cl
+$text['title-call_broadcast']['fr-ca'] = "Campagne d'appels"; //copied from fr-fr
+$text['title-call_broadcast']['fr-fr'] = "Campagne d'appels";
+$text['title-call_broadcast']['he-il'] = "הגדרת חשבון";
+$text['title-call_broadcast']['it-it'] = "Chiamate Multiple";
+$text['title-call_broadcast']['nl-nl'] = "Omroep";
+$text['title-call_broadcast']['pl-pl'] = "Rozsyłanie rozmów";
+$text['title-call_broadcast']['pt-br'] = "Configurações da Conta";
+$text['title-call_broadcast']['pt-pt'] = "Chamadas de Broadcast";
+$text['title-call_broadcast']['ro-ro'] = "";
+$text['title-call_broadcast']['ru-ru'] = "Массовые вызовы";
+$text['title-call_broadcast']['sv-se'] = "Samtalsdistributioner";
+$text['title-call_broadcast']['uk-ua'] = "Трансляція дзвінків";
+
+$text['title_description-call_broadcast']['en-us'] = "Manage the delivery of pre-recorded messages to mass recipients.";
+$text['title_description-call_broadcast']['en-gb'] = "Manage the delivery of pre-recorded messages to mass recipients.";
+$text['title_description-call_broadcast']['ar-eg'] = "";
+$text['title_description-call_broadcast']['de-at'] = "";
+$text['title_description-call_broadcast']['de-ch'] = "";
+$text['title_description-call_broadcast']['de-de'] = "";
+$text['title_description-call_broadcast']['es-cl'] = "";
+$text['title_description-call_broadcast']['es-mx'] = "";
+$text['title_description-call_broadcast']['fr-ca'] = "";
+$text['title_description-call_broadcast']['fr-fr'] = "";
+$text['title_description-call_broadcast']['he-il'] = "";
+$text['title_description-call_broadcast']['it-it'] = "";
+$text['title_description-call_broadcast']['nl-nl'] = "Beheer de aflevering van voor-opgenomen boodschappen naar meerdere ontvangers.";
+$text['title_description-call_broadcast']['pl-pl'] = "";
+$text['title_description-call_broadcast']['pt-br'] = "";
+$text['title_description-call_broadcast']['pt-pt'] = "";
+$text['title_description-call_broadcast']['ro-ro'] = "";
+$text['title_description-call_broadcast']['ru-ru'] = "";
+$text['title_description-call_broadcast']['sv-se'] = "";
+$text['title_description-call_broadcast']['uk-ua'] = "";
+
+$text['label-callerid-number']['en-us'] = "Caller ID Number";
+$text['label-callerid-number']['en-gb'] = "Caller ID Number";
+$text['label-callerid-number']['ar-eg'] = "";
+$text['label-callerid-number']['de-at'] = "Anruferkennung (Nummer)"; //copied from de-de
+$text['label-callerid-number']['de-ch'] = "Anruferkennung (Nummer)"; //copied from de-de
+$text['label-callerid-number']['de-de'] = "Anruferkennung (Nummer)";
+$text['label-callerid-number']['es-cl'] = "Número de Origen";
+$text['label-callerid-number']['es-mx'] = "Número de Origen"; //copied from es-cl
+$text['label-callerid-number']['fr-ca'] = "Numéro d'appelant"; //copied from fr-fr
+$text['label-callerid-number']['fr-fr'] = "Numéro d'appelant";
+$text['label-callerid-number']['he-il'] = "";
+$text['label-callerid-number']['it-it'] = "Numero Chiamante";
+$text['label-callerid-number']['nl-nl'] = "CID Nummer";
+$text['label-callerid-number']['pl-pl'] = "Prezentacja numeru dzwoniącego";
+$text['label-callerid-number']['pt-br'] = "Número do discador";
+$text['label-callerid-number']['pt-pt'] = "Número do Chamador";
+$text['label-callerid-number']['ro-ro'] = "";
+$text['label-callerid-number']['ru-ru'] = "Caller ID Номер";
+$text['label-callerid-number']['sv-se'] = "Caller ID Nummer";
+$text['label-callerid-number']['uk-ua'] = "Caller ID Номер";
+
+$text['description-caller-id-number']['en-us'] = "The number from which the SMS will be sent";
+$text['description-caller-id-number']['en-gb'] = "";
+$text['description-caller-id-number']['ar-eg'] = "";
+$text['description-caller-id-number']['de-at'] = ""; //copied from de-de
+$text['description-caller-id-number']['de-ch'] = ""; //copied from de-de
+$text['description-caller-id-number']['de-de'] = "";
+$text['description-caller-id-number']['es-cl'] = "";
+$text['description-caller-id-number']['es-mx'] = "";
+$text['description-caller-id-number']['fr-ca'] = "";
+$text['description-caller-id-number']['fr-fr'] = "";
+$text['description-caller-id-number']['he-il'] = "";
+$text['description-caller-id-number']['it-it'] = "";
+$text['description-caller-id-number']['nl-nl'] = "";
+$text['description-caller-id-number']['pl-pl'] = "";
+$text['description-caller-id-number']['pt-br'] = "";
+$text['description-caller-id-number']['pt-pt'] = "";
+$text['description-caller-id-number']['ro-ro'] = "";
+$text['description-caller-id-number']['ru-ru'] = "";
+$text['description-caller-id-number']['sv-se'] = "";
+$text['description-caller-id-number']['uk-ua'] = "";
+
+$text['label-phone']['en-us'] = "Phone Number List";
+$text['label-phone']['en-gb'] = "Phone Number List";
+$text['label-phone']['ar-eg'] = "";
+$text['label-phone']['de-at'] = "Liste der Telefonnummern"; //copied from de-de
+$text['label-phone']['de-ch'] = "Liste der Telefonnummern"; //copied from de-de
+$text['label-phone']['de-de'] = "Liste der Telefonnummern";
+$text['label-phone']['es-cl'] = "Lista de Números de Telefono";
+$text['label-phone']['es-mx'] = "Lista de Números de Telefono"; //copied from es-cl
+$text['label-phone']['fr-ca'] = "Liste de Numéros de téléphone"; //copied from fr-fr
+$text['label-phone']['fr-fr'] = "Liste de Numéros de téléphone";
+$text['label-phone']['he-il'] = "רשימת מספרי טלפון";
+$text['label-phone']['it-it'] = "Lista Numeri di Telefono";
+$text['label-phone']['nl-nl'] = "Telefoonnummer lijst";
+$text['label-phone']['pl-pl'] = "Lista numerów telefonu";
+$text['label-phone']['pt-br'] = "Lista de números de telefone";
+$text['label-phone']['pt-pt'] = "Lista de Números de Telefone";
+$text['label-phone']['ro-ro'] = "";
+$text['label-phone']['ru-ru'] = "Список телефонних номеров";
+$text['label-phone']['sv-se'] = "Lista Med Telefonnummer";
+$text['label-phone']['uk-ua'] = "Список телефонних номерів";
+
+$text['label-list_example']['en-us'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['en-gb'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['ar-eg'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['de-at'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['de-ch'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['de-de'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['es-cl'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['es-mx'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['fr-ca'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['fr-fr'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['he-il'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['it-it'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['nl-nl'] = "Nummer|Eerste,Laatste\nNummer|Eerste,Laatste\n...";
+$text['label-list_example']['pl-pl'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['pt-br'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['pt-pt'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['ro-ro'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['ru-ru'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['sv-se'] = "Number|First,Last\nNumber|First,Last\n...";
+$text['label-list_example']['uk-ua'] = "Number|First,Last\nNumber|First,Last\n...";
+
+$text['description-phone']['en-us'] = "Select a TXT/CSV file for upload, or enter Phone Numbers one per line in the format shown above.";
+$text['description-phone']['en-gb'] = "Select a TXT/CSV file for upload, or enter Phone Numbers one per line in the format shown above.";
+$text['description-phone']['ar-eg'] = "";
+$text['description-phone']['de-at'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname,Vorname"; //copied from de-de
+$text['description-phone']['de-ch'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname,Vorname"; //copied from de-de
+$text['description-phone']['de-de'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname,Vorname";
+$text['description-phone']['es-cl'] = "Opcional, definir una lista de números de telefono, uno por línea en el siguiente formato: 123-123-1234|Apellido,Nombre";
+$text['description-phone']['es-mx'] = "Opcional, definir una lista de números de telefono, uno por línea en el siguiente formato: 123-123-1234|Apellido,Nombre"; //copied from es-cl
+$text['description-phone']['fr-ca'] = "Optionnel, Insérer une liste de numéros de téléphone, un par ligne, dans le format suivant ; 0123456789|Nom,Prénom"; //copied from fr-fr
+$text['description-phone']['fr-fr'] = "Optionnel, Insérer une liste de numéros de téléphone, un par ligne, dans le format suivant ; 0123456789|Nom,Prénom";
+$text['description-phone']['he-il'] = "";
+$text['description-phone']['it-it'] = "Opzionale, inserire una lista di numeri di telefono, uno per riga, nel formato 123-123-1234|Cognome,Nome";
+$text['description-phone']['nl-nl'] = "Selecteer een TXT/CSV file om te 'uploaden' of voer Telefoonnummers in een per regel in het bovenstaande formaat.";
+$text['description-phone']['pl-pl'] = "Opcjonalne - ułóż listę numerów (jeden pod drugim) w formacie: 123-123-1234|Nazwisko,Imię";
+$text['description-phone']['pt-br'] = "Opcional, definir uma lista de números de telefone, um por linha, no seguinte formato: 210000000|Apelido,Primeiro Nome.";
+$text['description-phone']['pt-pt'] = "Opcional, definir uma lista de números de telefone, um por linha, no seguinte formato: 210000000|Apelido,Primeiro Nome";
+$text['description-phone']['ro-ro'] = "";
+$text['description-phone']['ru-ru'] = "Дополнительно, задайте список телефонных номеров, по одному в ряд, в формате: 123-123-1234|Фамилия,Имя";
+$text['description-phone']['sv-se'] = "Frivillig, fyll i en lista med nummer (ett per rad) i följande format: 123-123-1234|Efternamn,Förnamn";
+$text['description-phone']['uk-ua'] = "Додатково, задайте список телефонних номерів по одному на рядок в наступному форматі: 123-123-1234|Прізвище,ім'я";
+
+$text['description-info']['en-us'] = "Enter the description here.";
+$text['description-info']['en-gb'] = "Enter the description here.";
+$text['description-info']['ar-eg'] = "";
+$text['description-info']['de-at'] = "Geben Sie eine Beschreibung an."; //copied from de-de
+$text['description-info']['de-ch'] = "Geben Sie eine Beschreibung an."; //copied from de-de
+$text['description-info']['de-de'] = "Geben Sie eine Beschreibung an.";
+$text['description-info']['es-cl'] = "Ingrese descripción aquí.";
+$text['description-info']['es-mx'] = "Ingrese descripción aquí."; //copied from es-cl
+$text['description-info']['fr-ca'] = "Entrez la description ici";
+$text['description-info']['fr-fr'] = "Entrez la description ici";
+$text['description-info']['he-il'] = "הכנס תאור";
+$text['description-info']['it-it'] = "Inserire la descrizione qui.";
+$text['description-info']['nl-nl'] = "Voer de omschrijving hier in.";
+$text['description-info']['pl-pl'] = "Wprowadź opis";
+$text['description-info']['pt-br'] = "Inisra uma descrição";
+$text['description-info']['pt-pt'] = "Insira a descrição aqui.";
+$text['description-info']['ro-ro'] = "";
+$text['description-info']['ru-ru'] = "Введите описание";
+$text['description-info']['sv-se'] = "Ange beskrivning här.";
+$text['description-info']['uk-ua'] = "Введіть опис";
+
+$text['description-message']['en-us'] = "Enter the message here.";
+$text['description-message']['en-gb'] = "Enter the message here.";
+$text['description-message']['ar-eg'] = "";
+$text['description-message']['de-at'] = "";
+$text['description-message']['de-ch'] = "";
+$text['description-message']['de-de'] = "";
+$text['description-message']['es-cl'] = "";
+$text['description-message']['es-mx'] = "";
+$text['description-message']['fr-ca'] = "";
+$text['description-message']['fr-fr'] = "";
+$text['description-message']['he-il'] = "";
+$text['description-message']['it-it'] = "";
+$text['description-message']['nl-nl'] = "";
+$text['description-message']['pl-pl'] = "";
+$text['description-message']['pt-br'] = "";
+$text['description-message']['pt-pt'] = "";
+$text['description-message']['ro-ro'] = "";
+$text['description-message']['ru-ru'] = "";
+$text['description-message']['sv-se'] = "";
+$text['description-message']['uk-ua'] = "";
+
+?>

+ 22 - 0
sms/hook/sms_hook_didww.php

@@ -0,0 +1,22 @@
+<?php
+
+include "../root.php";
+
+require_once "resources/require.php";
+require_once "../sms_hook_common.php";
+
+error_log(print_r($_POST,true));
+
+if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
+    throw new Exception("Request method must be POST! $_SERVER[REQUEST_METHOD]");
+}
+
+
+$sms_from=$_POST['from'];
+$sms_text=base64_decode($_POST['body']);
+$sms_to_did_no=$_POST['to'];
+
+route_and_send_sms($sms_from, $sms_to_did_no, $sms_text);
+
+die("no");
+?>

+ 4 - 2
sms/resources/install/scripts/app/sms/index.lua

@@ -371,7 +371,9 @@
 		if (smstempst ~= nil) then freeswitch.consoleLog("notice", "[sms] smstempst = '" .. smstempst .. "\n") end;
 		if (smstempst ~= nil) then freeswitch.consoleLog("notice", "[sms] smstempst = '" .. smstempst .. "\n") end;
 		if (smstempend ~= nil) then freeswitch.consoleLog("notice", "[sms] smstempend = '" .. smstempend .. "\n") end;
 		if (smstempend ~= nil) then freeswitch.consoleLog("notice", "[sms] smstempend = '" .. smstempend .. "\n") end;
 		mdn = (smstempst ~= nil); --message delivery notification
 		mdn = (smstempst ~= nil); --message delivery notification
-		msgtype = message:getHeader("type");
+		if (message ~= nil) then
+			msgtype = message:getHeader("type");
+		end;
 		if (msgtype ~= nil and string.find(msgtype, "imdn") ~= nil) then mdn = true end;
 		if (msgtype ~= nil and string.find(msgtype, "imdn") ~= nil) then mdn = true end;
 		if (not mdn) then 
 		if (not mdn) then 
 			-- No XML content, continue processing
 			-- No XML content, continue processing
@@ -482,4 +484,4 @@
 			freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
 			freeswitch.consoleLog("notice", "[sms] SQL: "..sql.."; params:" .. json.encode(params) .. "\n");
 		end
 		end
 		dbh:query(sql,params);
 		dbh:query(sql,params);
-	end
+	end

+ 3 - 1
sms/sms.php

@@ -112,6 +112,8 @@ require_once "resources/paging.php";
 	if (if_group("superadmin")) {
 	if (if_group("superadmin")) {
 		echo "				<input type='button' class='btn' style='margin-right: 15px;' value='".$text['button-mdr']."' onclick=\"window.location.href='sms_mdr.php'\">\n";
 		echo "				<input type='button' class='btn' style='margin-right: 15px;' value='".$text['button-mdr']."' onclick=\"window.location.href='sms_mdr.php'\">\n";
 	}
 	}
+		echo "				<input type='button' class='btn' style='margin-right: 15px;' value='".$text['button-broadcast']."' onclick=\"window.location.href='sms_broadcast.php'\">\n";
+
 	echo "				<input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>";
 	echo "				<input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>";
 	echo "				<input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
 	echo "				<input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
 	if ($paging_controls_mini != '') {
 	if ($paging_controls_mini != '') {
@@ -227,4 +229,4 @@ require_once "resources/paging.php";
 
 
 //show the footer
 //show the footer
 	require_once "resources/footer.php";
 	require_once "resources/footer.php";
-?>
+?>

+ 194 - 0
sms/sms_broadcast.php

@@ -0,0 +1,194 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2020
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+//includes
+	require_once "root.php";
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+	require_once "resources/paging.php";
+
+//check permissions
+	if (permission_exists('call_broadcast_view')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+
+//get the http get variables and set them to php variables
+	$order_by = $_GET["order_by"];
+	$order = $_GET["order"];
+
+//add the search term
+	$search = strtolower($_GET["search"]);
+	if (strlen($search) > 0) {
+		$sql_search = " (";
+		$sql_search .= "	lower(sms_sms_broadcast_name) like :search ";
+		$sql_search .= "	or lower(sms_broadcast_description) like :search ";
+		$sql_search .= ") ";
+		$parameters['search'] = '%'.$search.'%';
+	}
+
+//get the count
+	$sql = "select count(*) from v_sms_broadcast ";
+	$sql .= "where domain_uuid = :domain_uuid ";
+	if (isset($sql_search)) {
+		$sql .= "and ".$sql_search;
+	}
+	$database = new database;
+	$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+	$num_rows = $database->select($sql, $parameters, 'column');
+
+//prepare the paging
+	$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
+	$param = "&search=".$search;
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+	list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
+	list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
+	$offset = $rows_per_page * $page;
+
+//get the call broadcast
+	$sql = str_replace('count(*)','*', $sql);
+	$sql .= order_by($order_by, $order);
+	$sql .= limit_offset($rows_per_page, $offset);
+	$database = new database;
+	$result = $database->select($sql, $parameters, 'all');
+	unset($sql, $parameters);
+
+//create token
+	$object = new token;
+	$token = $object->create($_SERVER['PHP_SELF']);
+
+//include the header
+	$document['title'] = $text['title-call_broadcast'];
+	require_once "resources/header.php";	
+
+//show the content
+	echo "<div class='action_bar' id='action_bar'>\n";
+	echo "	<div class='heading'><b>".$text['title-call_broadcast']." (".$num_rows.")</b></div>\n";
+	echo "	<div class='actions'>\n";
+	if (permission_exists('sms_broadcast_add')) {
+		echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'sms_broadcast_edit.php']);
+	}
+	if (permission_exists('sms_broadcast_add') && $result) {
+		echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','btn_copy');"]);
+	}
+	if (permission_exists('sms_broadcast_delete') && $result) {
+		echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
+	}
+	echo 		"<form id='form_search' class='inline' method='get'>\n";
+	echo 		"<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
+	echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
+	echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'sms_broadcast.php','style'=>($search == '' ? 'display: none;' : null)]);
+	if ($paging_controls_mini != '') {
+		echo 	"<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
+	}
+	echo "		</form>\n";
+	echo "	</div>\n";
+	echo "	<div style='clear: both;'></div>\n";
+	echo "</div>\n";
+
+	if (permission_exists('sms_broadcast_add') && $result) {
+		echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
+	}
+	if (permission_exists('sms_broadcast_delete') && $result) {
+		echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
+	}
+
+	echo $text['title_description-call_broadcast']."\n";
+	echo "<br /><br />\n";
+
+	echo "<form id='form_list' method='post'>\n";
+	echo "<input type='hidden' id='action' name='action' value=''>\n";
+	echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
+
+	echo "<table class='list'>\n";
+	echo "<tr class='list-header'>\n";
+	if (permission_exists('sms_broadcast_add') || permission_exists('sms_broadcast_delete')) {
+		echo "	<th class='checkbox'>\n";
+		echo "		<input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
+		echo "	</th>\n";
+	}
+	echo th_order_by('sms_broadcast_name', $text['label-name'], $order_by, $order);
+	echo th_order_by('sms_broadcast_description', $text['label-description'], $order_by, $order);
+	if (permission_exists('sms_broadcast_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
+		echo "	<td class='action-button'>&nbsp;</td>\n";
+	}
+	echo "</tr>\n";
+
+	if (is_array($result) && @sizeof($result) != 0) {
+		$x = 0;
+		foreach($result as $row) {
+			if (permission_exists('sms_broadcast_edit')) {
+				$list_row_url = "sms_broadcast_edit.php?id=".urlencode($row['sms_broadcast_uuid']);
+			}
+			echo "<tr class='list-row' href='".$list_row_url."'>\n";
+			if (permission_exists('sms_broadcast_add') || permission_exists('sms_broadcast_delete')) {
+				echo "	<td class='checkbox'>\n";
+				echo "		<input type='checkbox' name='sms_broadcast[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
+				echo "		<input type='hidden' name='sms_broadcast[$x][uuid]' value='".escape($row['sms_broadcast_uuid'])."' />\n";
+				echo "	</td>\n";
+			}
+			echo "	<td>";
+			if (permission_exists('sms_broadcast_edit')) {
+				echo "<a href='".$list_row_url."'>".escape($row['sms_broadcast_name'])."</a>";
+			}
+			else {
+				echo escape($row['sms_broadcast_name']);
+			}
+			echo "	</td>\n";
+			echo "	<td class='description overflow hide-xs'>".escape($row['sms_broadcast_description'])."</td>\n";
+			if (permission_exists('sms_broadcast_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
+				echo "	<td class='action-button'>";
+				echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
+				echo "	</td>\n";
+			}
+			echo "</tr>\n";
+			$x++;
+		}
+	}
+	unset($result);
+
+	echo "</table>\n";
+	echo "<br />\n";
+	echo "<div align='center'>".$paging_controls."</div>\n";
+
+	echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
+
+	echo "</form>\n";
+	
+	
+//include the footer
+	require_once "resources/footer.php";
+
+?>

+ 339 - 0
sms/sms_broadcast_edit.php

@@ -0,0 +1,339 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2019
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+	Luis Daniel Lucio Quiroz <[email protected]>
+*/
+
+//includes
+	include "root.php";
+	require_once "resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('sms_broadcast_edit')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//set the action with add or update
+	if (is_uuid($_REQUEST["id"])) {
+		$action = "update";
+		$sms_broadcast_uuid = $_REQUEST["id"];
+	}
+	else {
+		$action = "add";
+	}
+
+//function to Upload CSV/TXT file
+	function upload_file($sql, $sms_broadcast_phone_numbers) {
+		$upload_csv = $sql = '';
+		if (isset($_FILES['sms_broadcast_phone_numbers_file']) && !empty($_FILES['sms_broadcast_phone_numbers_file']) && $_FILES['sms_broadcast_phone_numbers_file']['size'] > 0) {
+			$filename=$_FILES["sms_broadcast_phone_numbers_file"]["tmp_name"];
+			$file_extension = array('application/octet-stream','application/vnd.ms-excel','text/plain','text/csv','text/tsv');
+			if (in_array($_FILES['sms_broadcast_phone_numbers_file']['type'],$file_extension)) {
+				$file = fopen($filename, "r");
+				$count = 0;
+				while (($getData = fgetcsv($file, 0, "\n")) !== FALSE)
+				{
+					$count++;
+					if ($count == 1) { continue; }
+					$getData = preg_split('/[ ,|]/', $getData[0], null, PREG_SPLIT_NO_EMPTY);
+					$separator = $getData[0];
+					$separator .= (isset($getData[1]) && $getData[1] != '')? '|'.$getData[1] : '';
+					$separator .= (isset($getData[2]) && $getData[2] != '')? ','.$getData[2] : '';
+					$separator .= '\n';
+					$upload_csv .= $separator;
+				}
+				 fclose($file);
+			}
+			else {
+				return array('code'=>false,'sql'=>'');
+			}
+		}
+		if (!empty($sms_broadcast_phone_numbers) && !empty($upload_csv)) {
+			$sql .= $sms_broadcast_phone_numbers.'\n'.$upload_csv;
+		}
+		elseif (empty($sms_broadcast_phone_numbers) && !empty($upload_csv)) {
+			$sql .= $upload_csv;
+		}
+		else {
+			$sql .= $sms_broadcast_phone_numbers;
+		}
+		return array('code'=>true,'sql'=> $sql);
+	}
+
+//get the http post variables and set them to php variables
+	if (count($_POST)>0) {
+		$sms_broadcast_name = $_POST["sms_broadcast_name"];
+		$sms_broadcast_caller_id_number = $_POST["sms_broadcast_caller_id_number"];
+		$sms_broadcast_phone_numbers = $_POST["sms_broadcast_phone_numbers"];
+		$sms_broadcast_destination_data = $_POST["sms_broadcast_destination_data"];
+		$sms_broadcast_description = $_POST["sms_broadcast_description"];
+	}
+
+if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+
+	//delete the call broadcast
+		if (permission_exists('sms_broadcast_delete')) {
+			if ($_POST['action'] == 'delete' && is_uuid($sms_broadcast_uuid)) {
+				//prepare
+					$sms_broadcast[0]['checked'] = 'true';
+					$sms_broadcast[0]['uuid'] = $sms_broadcast_uuid;
+				//delete
+					$obj = new sms_broadcast;
+					$obj->delete($sms_broadcast);
+				//redirect
+					header('Location: sms_broadcast.php');
+					exit;
+			}
+		}
+
+	$msg = '';
+	if ($action == "update") {
+		$sms_broadcast_uuid = $_POST["sms_broadcast_uuid"];
+	}
+
+	//validate the token
+		$token = new token;
+		if (!$token->validate($_SERVER['PHP_SELF'])) {
+			message::add($text['message-invalid_token'],'negative');
+			header('Location: sms_broadcast.php');
+			exit;
+		}
+
+	//check for all required data
+		if (strlen($sms_broadcast_name) == 0) { $msg .= "".$text['confirm-name']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//add or update the database
+	if ($_POST["persistformvar"] != "true") {
+
+		//prep insert
+			if ($action == "add" && permission_exists('sms_broadcast_add')) {
+				//begin insert array
+					$sms_broadcast_uuid = uuid();
+					$array['sms_broadcast'][0]['sms_broadcast_uuid'] = $sms_broadcast_uuid;
+
+				//set message
+					message::add($text['confirm-add']);
+
+				//set return url on error
+					$error_return_url = "sms_broadcast_edit.php";
+			}
+
+		//prep update
+			if ($action == "update" && permission_exists('sms_broadcast_edit')) {
+				//begin update array
+					$array['sms_broadcast'][0]['sms_broadcast_uuid'] = $sms_broadcast_uuid;
+
+				//set message
+					message::add($text['confirm-update']);
+
+				//set return url on error
+					$error_return_url = "sms_broadcast_edit.php?id=".urlencode($_GET['id']);
+			}
+
+		//execute
+			if (is_array($array) && @sizeof($array) != 0) {
+
+				//add file selection and download sample
+					$file_res = upload_file($sql, $sms_broadcast_phone_numbers);
+					if ($file_res['code'] != true) {
+						$_SESSION["message_mood"] = "negative";
+						$_SESSION["message"] = $text['file-error'];
+						header("Location: ".$error_return_url);
+						exit;
+					}
+					$sms_broadcast_phone_numbers = $file_res['sql'];
+
+				//common array items
+					$array['sms_broadcast'][0]['domain_uuid'] = $domain_uuid;
+					$array['sms_broadcast'][0]['sms_broadcast_name'] = $sms_broadcast_name;
+					$array['sms_broadcast'][0]['sms_broadcast_caller_id_number'] = $sms_broadcast_caller_id_number;
+					$array['sms_broadcast'][0]['sms_broadcast_phone_numbers'] = $sms_broadcast_phone_numbers;
+					$array['sms_broadcast'][0]['sms_broadcast_destination_data'] = $sms_broadcast_destination_data;
+					$array['sms_broadcast'][0]['sms_broadcast_description'] = $sms_broadcast_description;
+
+				//execute
+					$database = new database;
+					$database->app_name = 'sms';
+					$database->app_uuid = 'f1381f06-1d33-11e6-b6ba-3e1d05defe78';
+					$database->save($array);
+					//print_r($database);
+					//die();
+					unset($array);
+
+				//redirect
+					header("Location: sms_broadcast.php");
+					exit;
+
+			}
+
+	}
+}
+
+//pre-populate the form
+	if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
+		$sms_broadcast_uuid = $_GET["id"];
+		$sql = "select * from v_sms_broadcast ";
+		$sql .= "where domain_uuid = :domain_uuid ";
+		$sql .= "and sms_broadcast_uuid = :sms_broadcast_uuid ";
+		$parameters['domain_uuid'] = $domain_uuid;
+		$parameters['sms_broadcast_uuid'] = $sms_broadcast_uuid;
+		$database = new database;
+		$row = $database->select($sql, $parameters, 'row');
+		if (is_array($row) && @sizeof($row) != 0) {
+			$sms_broadcast_name = $row["sms_broadcast_name"];
+			$sms_broadcast_caller_id_number = $row["sms_broadcast_caller_id_number"];
+			$sms_broadcast_phone_numbers = $row["sms_broadcast_phone_numbers"];
+			$sms_broadcast_destination_data = $row["sms_broadcast_destination_data"];
+			$sms_broadcast_description = $row["sms_broadcast_description"];
+		}
+		unset($sql, $parameters, $row);
+	}
+
+//create token
+	$object = new token;
+	$token = $object->create($_SERVER['PHP_SELF']);
+
+//begin header
+	$document['title'] = $text['title-call_broadcast'];
+	require_once "resources/header.php";
+
+//begin content
+	echo "<form name='frm' id='frm' method='post' enctype='multipart/form-data'>\n";
+
+	echo "<div class='action_bar' id='action_bar'>\n";
+	echo "	<div class='heading'><b>".$text['title-call_broadcast']."</b></div>\n";
+	echo "	<div class='actions'>\n";
+	echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'sms_broadcast.php']);
+	if ($action == "update") {
+		//echo button::create(['type'=>'button','label'=>$text['button-start'],'icon'=>$_SESSION['theme']['button_icon_start'],'style'=>'margin-left: 15px;','link'=>'call_broadcast_send.php?id='.urlencode($sms_broadcast_uuid)]);
+		//echo button::create(['type'=>'button','label'=>$text['button-stop'],'icon'=>$_SESSION['theme']['button_icon_stop'],'link'=>'call_broadcast_stop.php?id='.urlencode($sms_broadcast_uuid)]);
+		if (permission_exists('sms_broadcast_delete')) {
+			echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
+		}
+	}
+	echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;']);
+	echo "	</div>\n";
+	echo "	<div style='clear: both;'></div>\n";
+	echo "</div>\n";
+
+	if ($action == 'update' && permission_exists('sms_broadcast_delete')) {
+		echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
+	}
+
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	".$text['label-name']."\n";
+	echo "</td>\n";
+	echo "<td width='70%' class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='sms_broadcast_name' maxlength='255' value=\"".escape($sms_broadcast_name)."\" required='required'>\n";
+	echo "<br />\n";
+	echo "".$text['description-name']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	".$text['label-callerid-number']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='number' name='sms_broadcast_caller_id_number' maxlength='255' min='0' step='1' value=\"".escape($sms_broadcast_caller_id_number)."\">\n";
+	echo "<br />\n";
+	echo "".$text['description-caller-id-number']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	".$text['label-message']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='sms_broadcast_destination_data' maxlength='255' value=\"".escape($sms_broadcast_destination_data)."\">\n";
+	echo "<br />\n";
+	echo "".$text['description-message']." <br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	".$text['label-phone']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	echo "	<textarea class='formfld' style='width: 300px; height: 200px;' type='text' name='sms_broadcast_phone_numbers' placeholder=\"".$text['label-list_example']."\">".str_replace('\n', "\n", $sms_broadcast_phone_numbers)."</textarea>";
+	echo "<br><br>";
+	echo " <input type='file' name='sms_broadcast_phone_numbers_file' accept='.csv,.txt' style=\"display:inline-block;\"><a href='sample.csv' download><i class='fas fa-cloud-download-alt' style='margin-right: 5px;'></i>".$text['label-sample_file']."</a>";
+	echo "<br /><br />";
+
+	echo "".$text['description-phone']." <br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	".$text['label-description']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='sms_broadcast_description' maxlength='255' value=\"".escape($sms_broadcast_description)."\">\n";
+	echo "<br />\n";
+	echo "".$text['description-info']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>";
+	echo "<br><br>";
+
+	if ($action == "update") {
+		echo "<input type='hidden' name='sms_broadcast_uuid' value='".escape($sms_broadcast_uuid)."'>\n";
+	}
+	echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
+
+	echo "</form>";
+
+//include the footer
+	require_once "resources/footer.php";
+
+?>

+ 58 - 0
sms/sms_broadcast_process.php

@@ -0,0 +1,58 @@
+<?php
+
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/classes/text.php";
+
+$debug = true;
+
+$sql = "select * from v_sms_broadcast";
+$database = new database;
+
+$database = new database;
+$result = $database->select($sql, $parameters, 'all');
+unset($sql, $parameters);
+
+$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
+if (!$fp) {
+	//error message
+	echo "<div align='center'><strong>Connection to Event Socket failed.</strong></div>";
+}
+
+$mailsent = false;
+
+foreach ($result as $sms_broadcast) {
+	$sms_from = $sms_broadcast['sms_broadcast_caller_id_number'];
+	$domain_uuid = $sms_broadcast['domain_uuid'];
+	
+	$sql = "select * from v_domains where domain_uuid = :domain_uuid";
+	$database = new database;
+	$parameters['domain_uuid'] = $sms_broadcast['domain_uuid'];
+	$database = new database;
+	$result_domains = $database->select($sql, $parameters, 'all');
+	$domain_name = $result_domains[0]['domain_name'];
+	
+	unset($sql, $parameters);
+	
+	$sms_body = $sms_broadcast['sms_broadcast_destination_data'];
+	$sms_broadcast_phone_numbers = explode(PHP_EOL, $sms_broadcast['sms_broadcast_phone_numbers']);
+	foreach ($sms_broadcast_phone_numbers as $individual) {
+		$number = explode("|",$individual);
+
+		print_r($number);
+
+		$switch_cmd = "api luarun app.lua sms outbound " . $number[0] . "@" . $domain_name . " " . $sms_from . " '" . $sms_body . "' " . $mailsent;
+		if ($debug) {
+			error_log(print_r($switch_cmd,true));
+		}
+		$result2 = trim(event_socket_request($fp, $switch_cmd));
+		if ($debug) {
+			error_log("RESULT: " . print_r($result2,true));
+		}
+
+	}
+}
+
+die();
+
+?>

+ 11 - 13
sms/sms_email.php

@@ -33,7 +33,7 @@ function validateEMAIL($EMAIL) {
     return (bool)preg_match($v, $EMAIL);
     return (bool)preg_match($v, $EMAIL);
 }
 }
 
 
-function send_sms_to_email($from, $to, $body, $media = "") {
+function send_sms_to_email($from, $to, $body, $media = null) {
 	global $db, $debug, $domain_uuid, $domain_name, $carrier;
 	global $db, $debug, $domain_uuid, $domain_name, $carrier;
 	if ($debug) {
 	if ($debug) {
 		error_log('Media: ' .  print_r($media, true));
 		error_log('Media: ' .  print_r($media, true));
@@ -59,7 +59,7 @@ function send_sms_to_email($from, $to, $body, $media = "") {
 	}
 	}
 
 
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement = $db->prepare(check_sql($sql));
-	$prep_statement->bindValue(':to', $to);
+	$prep_statement->bindValue(':to', "%{$to}%");
 	$prep_statement->execute();
 	$prep_statement->execute();
 	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
 	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
 
 
@@ -87,8 +87,8 @@ function send_sms_to_email($from, $to, $body, $media = "") {
 		$semi_rand = md5(time());
 		$semi_rand = md5(time());
 		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
 		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
 
 
-		if (!empty($_SESSION['email']['smtp_from']['var']) and validateEMAIL($_SESSION['email']['smtp_from']['var'])) {
-			$headers = "From: " . $_SESSION['email']['smtp_from']['var'] . "\n";
+		if (!empty($_SESSION['email']['smtp_from']['text']) and validateEMAIL($_SESSION['email']['smtp_from']['text'])) {
+			$headers = "From: " . $_SESSION['email']['smtp_from']['text'] . "\n";
 		}
 		}
 		else {
 		else {
 			$headers = "From: [email protected]\n";
 			$headers = "From: [email protected]\n";
@@ -101,17 +101,13 @@ function send_sms_to_email($from, $to, $body, $media = "") {
 		$body = preg_replace('([\n])', '<br>', $body); // fix newlines
 		$body = preg_replace('([\n])', '<br>', $body); // fix newlines
 		$email_txt = 'To: ' . $to . '<br>Msg: ' . $body;
 		$email_txt = 'To: ' . $to . '<br>Msg: ' . $body;
 
 
-		$email_message = "This is a multi-part message in MIME format.\n\n" .
-			"--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" .
-			"Content-Transfer-Encoding: 7bit\n\n" .	$email_txt . "\n\n";
+		$email_message = "" .	$email_txt . "";
 
 
 		if ($carrier == "telnyx") {
 		if ($carrier == "telnyx") {
 			if (gettype($media)=="array") {
 			if (gettype($media)=="array") {
 				$email_txt = 'To: ' . $to . '<br>Msg: ' . $body . '<br>MMS Message received, see attachment';
 				$email_txt = 'To: ' . $to . '<br>Msg: ' . $body . '<br>MMS Message received, see attachment';
 
 
-				$email_message = "This is a multi-part message in MIME format.\n\n" .
-					"--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" .
-					"Content-Transfer-Encoding: 7bit\n\n" .	$email_txt . "\n\n";
+				$email_message = "" .	$email_txt . "";
 				//process MMS attachment
 				//process MMS attachment
 				foreach ($media as $attachment) {
 				foreach ($media as $attachment) {
 					$url = $attachment->url;
 					$url = $attachment->url;
@@ -152,13 +148,15 @@ function send_sms_to_email($from, $to, $body, $media = "") {
 			}
 			}
 		}
 		}
 		else {
 		else {
-			$email_message .= "--{$mime_boundary}--\n";
+			$email_message .= "";
 		}
 		}
 		if ($debug) {
 		if ($debug) {
 			error_log("headers: " . $headers);
 			error_log("headers: " . $headers);
 		}
 		}
 		//send email
 		//send email
-		$ok = mail($email_to, $email_subject, $email_message, $headers);
+		$ok = send_email($email_to, $email_subject, $email_message);//, $headers);
+
+		if()
 
 
 		if($ok) {
 		if($ok) {
 			error_log("[sms] Email Sent Successfully.");
 			error_log("[sms] Email Sent Successfully.");
@@ -169,4 +167,4 @@ function send_sms_to_email($from, $to, $body, $media = "") {
 		}
 		}
 	}
 	}
 }
 }
-?>
+?>

+ 3 - 2
sms/sms_hook_common.php

@@ -147,10 +147,11 @@ function route_and_send_sms($from, $to, $body, $media = "") {
 				//load default and domain settings
 				//load default and domain settings
 				$_SESSION["domain_uuid"] = $domain_uuid;
 				$_SESSION["domain_uuid"] = $domain_uuid;
 				require_once "resources/classes/domains.php";
 				require_once "resources/classes/domains.php";
-				$domain = new domains;
+				$domain = new domains();
 				$domain->set();
 				$domain->set();
+				
 				if ($debug) {
 				if ($debug) {
-					error_log("email_from: " . $_SESSION['email']['smtp_from']['var']);
+					error_log("Email from: ". $_SESSION['email']['smtp_from']['text']);
 				}
 				}
 				$mailsent = send_sms_to_email($from, $to, $mailbody, $media);
 				$mailsent = send_sms_to_email($from, $to, $mailbody, $media);