summaryrefslogtreecommitdiffstats
path: root/www/info.php
blob: 7ec562a8469b75c54ae2ac421ddf55c3ed029d3a (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
require_once "vendor/autoload.php";
use Rhilip\Bencode\TorrentFile;
use Rhilip\Bencode\ParseException;
if (!preg_match("/^[a-f0-9A-F]{40}$/", $_REQUEST["h"]))
	die('!preg_match("/^[a-f0-9A-F]{40}$/", $_REQUEST["h"])');
$t = TorrentFile::load("../".$_REQUEST["h"].".torrent");
?>
<meta name=viewport content='width=device-width, initial-scale=1.0'>
<meta charset=UTF-8 />
<style>
table, td, tr, th {
	border: 1px solid gray;
}
</style>
<h1><?= htmlspecialchars($t->getName()) ?></h1>
<title><?= htmlspecialchars($t->getName()) ?></title>
<table>
	<tr>
		<th>pridobljeno</th>
		<td><?= date("d. m. Y H:i:s", $t->getCreationDate()) ?></td>
	<tr>
		<th>tip</th>
		<td><?= $t->getProtocol() ?></td>
	<tr>
		<th>datotečni način</th>
		<td><?= $t->getFileMode() ?></td>
	<?php if ($t->isPrivate()) echo "<tr colspan=2><th style=color:red>zaseben</th>"; ?>
	<tr>
		<th colspan=2><a href="<?= htmlspecialchars($t->getMagnetLink()) ?>">magnetna povezava</a></th>
	<tr>
		<th colspan=2><a href=/<?= $_REQUEST["h"] ?>.torrent>torrent datoteka</a></th>
<?php try { ?>
	<tr>
		<th>velikost</th>
		<td><?= number_format($t->getSize()/(1024*1024*1024), 6, ",", "") ?> GiB</td>
	<tr>
		<th>število datotek</th>
		<td><?= $t->getFileCount() ?></td>
<?php } catch (Exception $a) {} ?>
	<tr>
		<th>ip naslov vira</th>
		<td><?= htmlspecialchars($t->getRootData()["source"]["ip"]) ?></td>
<?php if ($t->getRootData()["source"]["v"]) { ?>
	<tr>
		<th>odjemalec vira</th>
		<td><?= htmlspecialchars($t->getRootData()["source"]["v"]) ?></td>
<?php } ?>
	<tr>
		<th>velikost koščka</th>
		<td><?= $t->getPieceLength()/1024; ?> kB</td>
<?php if (!empty($t->getSource())) { ?>
	<tr>
		<th>izvor</th>
		<td><?= htmlspecialchars($t->getSource()) ?></td>
<?php } ?>
</table>
<?php
function p ($k, $v) {
	if (preg_match("/padding.file/i", $k))
		return;
	if (is_array($v)) {
		echo "<li> " . htmlspecialchars($k) . "<ul>";
		foreach ($v as $ke => $va)
			p($ke, $va);
		echo "</ul>";
	} else {
		echo "<li> <b>" . htmlspecialchars($k) . "</b> (" . number_format($v/(1024*1024), 6, ",", "") . " MiB)";
	}
}
echo "<ul>";
foreach ($t->getFileTree() as $k => $v)
	p($k, $v);
echo "</ul>";
?>
<?php if (preg_match("/Development Server/", $_SERVER["SERVER_SOFTWARE"])) { ?>
<h1 style=color:red>interna stran, dostop prepovedan</h1>
<?php } ?>