-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.json.php
More file actions
53 lines (47 loc) · 1.46 KB
/
status.json.php
File metadata and controls
53 lines (47 loc) · 1.46 KB
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
<?php
/*
GNU Public License
Version: GPL 3
*/
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
$settings = json_decode(file_get_contents(__DIR__."/settings.json"), true);
$vars = array('caller_id_number', 'caller_id_name', 'description');
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if (!$fp) {
die("ERROR");
}
function uuid_getvar($uuid, $var) {
global $fp;
return trim(event_socket_request($fp, "api uuid_getvar ".$uuid." ".$var));
}
$valet_info = new SimpleXMLElement(trim(event_socket_request($fp, "api valet_info")));
$out = array("parked"=>array());
foreach($valet_info as $lot) {
foreach($lot as $spot) {
$uuid = (string)$spot['uuid'];
$spot = (int)$spot;
$call = array(
"call" => $uuid,
"spot" => $spot
);
foreach($vars as $var) {
$call[$var] = uuid_getvar($uuid, $var);
}
$out["parked"][] = $call;
}
}
$out["current_call"] = NULL;
$channels = json_decode(trim(event_socket_request($fp, "api show channels as json")), true);
if(isset($channels["rows"])) {
foreach($channels['rows'] as $channel) {
if($channel['dest'] == $settings['on_air_user'] || $channel['dest'] == $settings['on_air_user']."%".$settings['on_air_domain']) {
$out["current_call"] = $channel;
foreach($vars as $var) {
$out["current_call"][$var] = uuid_getvar($channel['uuid'], $var);
}
}
}
}
echo json_encode($out);