-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracker-stats.php
52 lines (50 loc) · 1.62 KB
/
tracker-stats.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
<?php
require('functions.php');
$addresses = array (
'errors' => upstreamAddress('ERRORS'),
'events' => upstreamAddress('EVENTS'),
'ignore' => upstreamAddress('IGNORE')
);
$tracker_data = array();
foreach ($addresses as $addr_name => $addr_val) {
$handle = fopen($addr_val, 'r');
if ( !$handle ) {
http_response_code(500);
echo "Error";
die();
} else {
$tracker_data[$addr_name] = json_decode(stream_get_contents($handle), TRUE);
}
}
$trackers_list = array_unique([
... $tracker_data['ignore'],
...array_keys($tracker_data['errors']),
...array_keys($tracker_data['events'])
]);
?>
<!DOCTYPE html>
<html lang="en">
<?php require('head.php'); ?>
<body>
<h1>Torrent Health Tracker</h1>
<h2>Updated: <?php echo (new \DateTime())->format('Y-m-d H:i:s e'); ?></h2>
<table>
<thead>
<th>Tracker</th>
<th>Ignored</th>
<th data-sort-method="number">Errors</th>
<th data-sort-method="number">Events</th>
</thead>
<tbody>
<?php foreach($trackers_list as $t): ?>
<tr>
<td><?= $t; ?></td>
<td><?= in_array($t, $tracker_data['ignore']) ? 'True': 'False'; ?></td>
<td><?= count($tracker_data['errors'][$t] ?? []); ?></td>
<td><?= count($tracker_data['events'][$t] ?? []); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>