-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsms_broadcast_process.php
62 lines (46 loc) · 1.79 KB
/
sms_broadcast_process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
//set the include path
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
set_include_path(parse_ini_file($conf[0])['document.root']);
//includes files
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();
?>