-
Notifications
You must be signed in to change notification settings - Fork 3
/
kabook-acct.php
58 lines (43 loc) · 1.55 KB
/
kabook-acct.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
#!/usr/bin/php -q
<?php
require('libs/config/defines.php');
require('libs/helper/radius.php');
require('libs/helper/database.php');
require('libs/helper/logger.php');
require('libs/phpagi/phpagi.php');
$moduleName = "KABOOK RADIUS - ACCT";
//Create a new AGI Class
$agi = new AGI();
//Create Logger
$logger = new LOGGER();
$logger->agi = $agi;
$logger->moduleName = $moduleName;
//Create Database Connection
$db = new DB();
$db->assignConfig(DB_TYPE_MYSQL);
$dbConn = $db->connect();
//User Details Catcher
$data['uniqueid'] = $agi->request['agi_uniqueid'];
$data['callerid'] = $agi->request['agi_callerid'];
$data['extension'] = $agi->request['agi_extension'];
$data['carrierAddress'] = $agi->get_variable("NEXTHOP")["data"];
$data['hangupCause'] = $agi->get_variable("HANGUPCAUSE")["data"];
$data['totalDuration'] = $agi->get_variable("CDR(duration)")["data"];
$data['billedDuration'] = $agi->get_variable("CDR(billsec)")["data"];
$data['disposition'] = $agi->get_variable("CDR(disposition)")["data"];
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_NOTPROCESSED;
$userURI = $agi->get_variable("SIPURI", true);
$sipusername = $agi->get_variable("SIP_HEADER(From)", true);
$dbResult = $db->updateCall($dbConn, $data);
if( $dbResult[0] === MYSQL_SUCCESS_RESULT ) {
$logger->sendLog("Call updated successfully, UniqueId : {$data['uniqueid']}");
} else {
$logger->sendLog("##### Call NOT updated please check UniqueId : {$data['uniqueid']} #####");
}
//Free up the resources
$db->close($dbConn);
$db = NULL;
$radClient = NULL;
$agi = NULL;
$logger = NULL;
exit();