summaryrefslogblamecommitdiffstats
path: root/www/index.php
blob: 96f0f8fc6b6df92c98850b94906c5c2a12d62340 (plain) (tree)
1
2
3
4
5
6
7
8
9
     


                                           

                      
                                                                    
                                                                                 
                                    
                                      








                                                                                                      
                                                                                                 



                          
     



                                                  




                                                                                                      
 
  
     
          
<?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'>
<h2>število datotek: <?= shell_exec("find .. -name '*.torrent' | wc -l") ?></h2>
<h2><a href=list.php>seznam</a></h2>
<h2><a href=stanje.php>stanje</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 } ?>