-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebtbulk
executable file
·62 lines (53 loc) · 1.42 KB
/
ebtbulk
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
#!/usr/bin/php -q
<?php
/**
* EBTBulk is a script for sending one message to several receivers.
*
* @author Erick Birbe <[email protected]>
* @date 2015-09-06
* */
/* *********************************************************************
* VALIDATIONS... neccessary to run well
* ********************************************************************/
// Verify the arguments before continue
if (!isset($argv) or count($argv) < 3)
{
echo "Nothing to do here... I quit!\n";
return 1;
}
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
/* ********************************************************************
* MAIN PROCESS
* ********************************************************************/
require_once('ebtmessage.php');
function _send_message($to, $message)
{
echo "Creating SMS to " . $to . "... ";
$oMessage = new EBTMessage();
$oMessage->set_header('To', $to)
->set_message($message)
->write();
echo "Created!\n";
unset($oMessage);
}
function run(array $receivers, $message)
{
// Clean duplicated phone numbers
$receivers = array_unique($receivers);
// Send multiple messages
foreach ($receivers as $sRcv)
{
_send_message($sRcv, $message);
}
}
// Extract the receivers
$aReceivers = array_slice($argv, 1, -1);
// Get the message
$iLastIndex = count($argv) - 1;
$sMessage = $argv[$iLastIndex];
// Start the applicantion
run($aReceivers, $sMessage);