blob: e37fe7f768684daf07b4c6464517f6742f13e252 (
plain) (
tree)
|
|
<?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 } ?>
|