summaryrefslogtreecommitdiffstats
path: root/www/index.php
blob: e37fe7f768684daf07b4c6464517f6742f13e252 (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
<?php
	require_once "vendor/autoload.php";
	use Rhilip\Bencode\TorrentFile;
	use Rhilip\Bencode\ParseException;
?>
<meta charset=UTF-8 />
<meta name=viewport content='width=device-width, initial-scale=1.0'>
<h1>število datotek: <?= shell_exec("find .. -name '*.torrent' | wc -l") ?></h1>
<h2><a href=list.php>seznam</a></h2>
<h2>iskalnik</h2>
<form>
	<input name=i value="<?= !empty($_REQUEST["i"]) ? htmlspecialchars($_REQUEST["i"]) : "" ?>" />
	<input type=submit value=išči />
</form>
<?php if (!empty($_REQUEST["i"])) { ?>
<h3>rezultati</h3>
<pre>
<?php
$q = "find .. -maxdepth 2 -name '*.torrent' | xargs grep -lie " . escapeshellarg($_REQUEST["i"]);
echo htmlspecialchars($q);
?>
</pre>
<ul>
<?php
foreach (explode(PHP_EOL, shell_exec($q)) as $f) {
	if (trim($f) == "")
		continue;
	$t = TorrentFile::load($f);
	$m = [];
	preg_match("|/([a-fA-F0-9]*).torrent|", $f, $m);
	if (count($m) < 2)
		var_dump([$f, $m]);
	echo "<li> <a href=info.php?h=" . $m[1] . ">" . htmlspecialchars($t->getName()) . "</a></li>";
}
?>
</ul>
<?php } ?>