forked from barbodar/KABOOK-RADIUS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kabook-call-archive.php
71 lines (55 loc) · 2.24 KB
/
kabook-call-archive.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
69
70
71
#!/usr/bin/php -q
<?php
require('libs/config/defines.php');
require('libs/helper/database.php');
require('libs/helper/logger.php');
$moduleName = "KABOOK RADIUS - CALL ARCHIVE - 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();
$counter = 0;
$mainLoop = true;
while($mainLoop) {
$counter++;
$logger->sendLog("archive all call processed in STOP state");
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_STOP;
$dbResults = $db->getCalls($dbConn, $data);
foreach($dbResults as $dbResult) {
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_STOP;
$data['uniqueid'] = $dbResult["onlineCalls_uniqueid"];
$archiveResult = $db->archiveCall($dbConn, $data);
$logger->sendLog("archive call with uniqueid {$data['uniqueid']} MYSQL Result : {$archiveResult[0]}");
if($archiveResult[0] == MYSQL_SUCCESS_RESULT) {
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_ARCHIVED;
$updateResult = $db->updateCallStatus($dbConn, $data);
$logger->sendLog("update call status with uniqueid {$data['uniqueid']} to archived MYSQL Result : {$updateResult[0]}");
} else {
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_ARCHIVED;
$updateResult = $db->updateCallStatus($dbConn, $data);
$logger->sendLog("update call status with uniqueid {$data['uniqueid']} to archived MYSQL Result : {$updateResult[0]}");
}
}
usleep(SLEEP_STEP_1);
$logger->sendLog("archive all call processed in STOP state");
$data['callProcessStage'] = MYSQL_PROCESSED_CALL_ARCHIVED;
$dbResults = $db->getCalls($dbConn, $data);
foreach($dbResults as $dbResult) {
$data['uniqueid'] = $dbResult["onlineCalls_uniqueid"];
$removeResult = $db->removeOnlineCall($dbConn, $data);
$logger->sendLog("remove online call with uniqueid {$data['uniqueid']} MYSQL Result : {$removeResult[0]}");
}
usleep(SLEEP_STEP_2);
if($counter == LOOP_TIME ) { $mainLoop = false; }
}
//Free up the resources
$db->close($dbConn);
$db = NULL;
$radClient = NULL;
$agi = NULL;
$logger = NULL;
exit();