-
Notifications
You must be signed in to change notification settings - Fork 0
/
json.php
58 lines (55 loc) · 1.47 KB
/
json.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
<?php
include_once('CCAMS.php');
if (array_key_exists('debug',$_GET)) {
$CCAMS = new CCAMS(true);
$CCAMSstats = new CCAMSstats(true);
} else {
$CCAMS = new CCAMS();
$CCAMSstats = new CCAMSstats();
}
if (array_key_exists('r',$_GET)) {
if (array_key_exists('date', $_POST)) $seldate = new DateTime($_POST['date']);
switch ($_GET['r']) {
case 'get-ranges':
echo $CCAMS->get_sqwk_ranges();
break;
case 'set-ranges':
$CCAMS->set_sqwk_range($_POST['rangename'],$_POST['ranges']);
//$CCAMS->set_squawk_range($_GET['rangename'],$_GET['ranges']);
break;
case 'squawks':
echo $CCAMS->get_reserved_codes();
break;
case 'logfiles':
echo $CCAMS->get_logs();
break;
case 'stats-daily':
$CCAMSstats->readStats($seldate);
echo $CCAMSstats->createStats();
break;
case 'stats-weekly':
$date = clone $seldate;
$date->sub(new DateInterval('P'.$date->format('N').'D'));
do {
$date->add(new DateInterval('P1D'));
$CCAMSstats->readStats($date);
} while ($date->format('N') < 7);
//echo var_dump($seldate->diff($date)->days);
echo $CCAMSstats->createStats();
break;
case 'stats-monthly':
$date = clone $seldate;
$date->sub(new DateInterval('P'.$date->format('j').'D'));
while ($date->add(new DateInterval('P1D'))->format('n') == $seldate->format('n')) {
$CCAMSstats->readStats($date);
}
echo $CCAMSstats->createStats();
break;
case 'stats-yearly':
break;
default:
echo json_encode(array());
break;
}
}
?>