-
Notifications
You must be signed in to change notification settings - Fork 3
/
kabook-acct-engine-stop.php
51 lines (42 loc) · 1.58 KB
/
kabook-acct-engine-stop.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
#!/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');
$moduleName = "KABOOK RADIUS - ACCT - ENGINE";
//Create Logger
$logger = new LOGGER();
$logger->agi = NULL;
$logger->moduleName = $moduleName;
//Create Database Connection
$db = new DB();
$db->assignConfig(DB_TYPE_MYSQL);
$dbConn = $db->connect();
//Create RADIUS Handler
$radius = new RADIUS();
$logger->sendLog("Get list of all online calls START STAGE");
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_START;
$dbResults = $db->getCalls($dbConn, $data);
$logger->sendLog("Count of all online calls START STAGE : ".count($dbResults));
foreach($dbResults as $dbResult) {
$radius->acctSessionId = $dbResult["onlineCalls_uniqueid"];
$radius->username = $dbResult["onlineCalls_callerid"];
$radius->destination = $dbResult["onlineCalls_extension"];
$radius->h323_conf_id = $dbResult["onlineCalls_confId"];
$radius->nasPort = $dbResult["onlineCalls_nasPort"];
$accountingResponse = $radius->sendAccounting(RADIUS_STOP, $dbResult);
if($accountingResponse == RADIUS_ACCOUNTING_RESPONSE) {
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_STOP;
$data['uniqueid'] = $dbResult["onlineCalls_uniqueid"];
$updateResult = $db->updateCallStatus($dbConn, $data);
$logger->sendLog("update call status with uniqueid {$data['uniqueid']} to STOP, RAD RESP: {$accountingResponse}");
}
}
//Free up the resources
$db->close($dbConn);
$db = NULL;
$radClient = NULL;
$agi = NULL;
$logger = NULL;
exit();