-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathstatus.php
79 lines (69 loc) · 2.55 KB
/
status.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
72
73
74
75
76
77
78
79
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// These lines are part of the original code
// removed for FreePBX compatibility
require_once('./phpagi/phpagi-asmanager.php');
$asm = new AGI_AsteriskManager();
if($asm->connect())
{
$result = $asm->Command("core show channels concise");
$ccount = $asm->Command("core show channels count");
}
$asm->disconnect();
*** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/
// FreePBX bootstrap loader
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
include_once('/etc/asterisk/freepbx.conf');
}
// These lines modifed from original to use FreePBX $astman class
if($astman->connected()) {
$result = $astman->Command("core show channels concise");
$ccount = $astman->Command("core show channels count");
}
//echo $result['data']; //debug
$data = array();
echo "<table class='table table-striped table-bordered table-condensed'>";
echo "<tr class='heading';><td>call length</td><td>from</td><td>to</td><td>Channel(s)</td></tr>";
foreach(explode("\n", $result['data']) as $line)
if (preg_match("/Up/i", $line) && preg_match("/!Dial!/i", $line))
{
{
/* summary of $pieces and $to array values
$pieces[0] = channel
$pieces[1] = context
$pieces[2] = extension (which could be 's' on FreePBX system)
$pieces[3] = priority
$pieces[4] = state
$pieces[5] = application
$pieces[6] = data
$pieces[7] = callerid number
$pieces[8] =
$pieces[9] =
$pieces[10] = peer account
$pieces[11] = duration
$pieces[12] = bridged channel
*/
$pieces = explode("!", $line);
// use regular expression to search thru concise channel data to determine the CID and trunk for the "to" end of the call
// regex works for Asterisk 11 & 1.8
$regex = "~".preg_quote($pieces[12],"~")."!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!(.*?)!~";
preg_match($regex,$result['data'],$to);
echo "<tr>";
echo "<td class='large';>" . gmdate("H:i:s", $pieces[11]) . "</td>";
echo "<td class='large';>" . $pieces[7] . "</td>";
echo "<td class='large';>" . $to[7] . "</td>";
echo "<td class='large';>" . trim(substr($pieces[12], 0, strpos($pieces[12], '-'))) . "</br>". trim(substr($to[12], 0, strpos($to[12], '-'))) ."</td>";
echo "</tr>";
}
}
echo "</table>";
// print_r($to); //debug
foreach(explode("\n", $ccount['data']) as $line)
if ((preg_match("/call/i", $line) || preg_match("/processed/i", $line)) && !preg_match("/processed/i", $line) )
{
{
$pieces = explode("!", $line);
echo $line . "<br />";
}
}
?>