-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats-filtered.php
44 lines (34 loc) · 924 Bytes
/
stats-filtered.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
<?php
require('functions.php');
use Exceptions\FilterException as FilterException;
$address = upstreamAddress();
$handle = FALSE;
$handle = fopen($address, 'r');
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json; charset=utf-8');
if ( !$handle ) {
http_response_code(500);
echo json_encode(
array(
'status' => 'error',
'reason' => 'Invalid upstream handle'
)
);
die();
}
try {
echo json_encode(
getFiltered(
handleGetFormatted($handle),
buildFilters()
)
);
} catch (FilterException $e) {
http_response_code(400);
echo json_encode(
array(
'status' => 'error',
'reason' => $e->getMessage()
)
);
}