forked from yanxurui/bitstorm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.php
57 lines (56 loc) · 1.57 KB
/
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
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stats of the tracker</title>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myTable').DataTable();
});
</script>
</head>
<body>
<div>
<table id="myTable" class="display">
<thead>
<tr>
<th>info_hash</th>
<th>peer_id</th>
<th>ip4</th>
<th>ip6</th>
<th>port</th>
<th>seed</th>
</tr>
</thead>
<tbody>
<?php
require 'vendor/autoload.php';
$r = new Predis\Client();
$torrents=$r->smembers('torrents');
foreach($torrents as $info_hash)
{
$peers=$r->smembers($info_hash);
foreach($peers as $peer_id)
{
$temp=$r->hmget($info_hash.':'.$peer_id,'ip4','ip6','port','seed');
if(!$temp[3])
$temp[3]='0';
echo '<tr>';
echo '<td>'.bin2hex($info_hash).'</td>',
'<td>'.bin2hex($peer_id).'</td>',
'<td>'.$temp[0].'</td>',
'<td>'.$temp[1].'</td>',
'<td>'.$temp[2].'</td>',
'<td>'.$temp[3].'</td>';
echo '</tr>';
}
}
?>
</tbody>
</table>
</div>
</body>
</html>