-
Notifications
You must be signed in to change notification settings - Fork 0
/
sender.php
52 lines (39 loc) · 1.1 KB
/
sender.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
<?php
include 'functions.php';
$smsURI = getSMSURI();
// File to read from (relative path)
$fileName = "tmp_sms/test_messages.csv";
$smsFile = fopen($fileName, "r");
if($smsFile !== false){
// Output one line until end-of-file
while(!feof($smsFile)) {
$line = fgets($smsFile);
$words = explode("|", $line);
$number = $message = "";
foreach($words as $key => $word){
switch($key){
case 0:
case 1:
case 2:
if(is_numeric($word)){
$number = $word;
}
break;
case 3: $message = $word; break;
}
}
if(is_numeric($number)){
$status = sendSMS($smsURI, $number, $message);
$success = 0;
if(strpos($status, "<status>Success</status>") !== false) $success = 1;
$sendingAttempts = 1;
$now = new DateTime("now", new DateTimeZone('Africa/Nairobi'));
$timeSent = $now->format('Y-m-d G:i');
dbLog("INSERT INTO sms (phone, message, status, sent_at, sending_attempts) VALUES ('$number', '$message', $success, '$timeSent', $sendingAttempts)");
log2File($status);
}
}
fclose($smsFile);
unlink($fileName);
}
?>