-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback.php
executable file
·68 lines (56 loc) · 1.95 KB
/
callback.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
63
64
65
66
67
68
<?php
/**
* This file is part of playSMS.
* playSMS 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.
* playSMS 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 playSMS. If not, see <http://www.gnu.org/licenses/>.
*/
error_reporting(0);
if (!$called_from_hook_call) {
chdir('../../../');
$core_config['init']['ignore_csrf'] = true;
include 'init.php';
include $core_config['apps_path']['libs'] . '/function.php';
chdir('plugin/gateway/seven/');
$requests = $_REQUEST;
}
//die(var_dump($requests));
$log = '';
if (is_array($requests)) {
foreach ($requests as $k => $v) $log .= $k . ':' . $v . ' ';
_log('pushed ' . $log, 2, 'seven callback');
}
$idSeven = $requests['msg_id'];
$idLocal = $requests['foreign_id'];
$messageStatus = $requests['status'];
$isDLR = 'dlr' === $requests['webhook_event'];
if ($isDLR && $idSeven && $messageStatus && $idLocal) {
$data = sendsms_get_sms($idLocal);
$uid = $data['uid'];
$p_status = $data['p_status'];
switch ($messageStatus) {
case 'DELIVERED':
$p_status = 3; // delivered
break;
case 'ACCEPTED':
case 'BUFFERED':
case 'TRANSMITTED':
$p_status = 1; // sent
break;
default :
$p_status = 2; // failed
break;
}
_log('dlr uid:' . $uid . ' smslog_id:' . $idLocal . ' messageid:'
. $idSeven . ' status:' . $messageStatus, 2, 'seven callback');
dlr($idLocal, $uid, $p_status);
ob_end_clean();
exit('ACK/seven');
}