diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-01-30 17:27:57 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-01-30 17:27:57 +0100 |
commit | c6156989725399a83f4a33384a3c60885ed6f211 (patch) | |
tree | 842d3fb0e54e1f5c8ccaf1941dc8caf8a8863c6a /www/index.php | |
parent | fix use after free in torrent structs (diff) | |
download | travnik-c6156989725399a83f4a33384a3c60885ed6f211.tar travnik-c6156989725399a83f4a33384a3c60885ed6f211.tar.gz travnik-c6156989725399a83f4a33384a3c60885ed6f211.tar.bz2 travnik-c6156989725399a83f4a33384a3c60885ed6f211.tar.lz travnik-c6156989725399a83f4a33384a3c60885ed6f211.tar.xz travnik-c6156989725399a83f4a33384a3c60885ed6f211.tar.zst travnik-c6156989725399a83f4a33384a3c60885ed6f211.zip |
Diffstat (limited to 'www/index.php')
-rw-r--r-- | www/index.php | 108 |
1 files changed, 26 insertions, 82 deletions
diff --git a/www/index.php b/www/index.php index ac4bb50..1fd25a2 100644 --- a/www/index.php +++ b/www/index.php @@ -1,89 +1,33 @@ <?php -require_once "vendor/autoload.php"; -use Rhilip\Bencode\TorrentFile; -use Rhilip\Bencode\ParseException; -if (empty($_REQUEST["h"])) { - if ($handle = opendir("..")) { - echo "<ul>"; - while (false !== ($entry = readdir($handle))) { - if (preg_match("/torrent$/", $entry)) { - $h = htmlspecialchars(explode(".", $entry)[0]); - echo '<li> <a href="?h=' . $h . '">' . $h . '</a>'; - } - } - die(); - closedir($handle); - } else { - die("ne morem brati direktorija"); - } -} -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"); + require_once "vendor/autoload.php"; + use Rhilip\Bencode\TorrentFile; + use Rhilip\Bencode\ParseException; ?> -<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> - <tr> - <th>velikost</th> - <td><?= number_format($t->getSize()/(1024*1024*1024), 6, ",", "") ?> GiB</td> - <tr> - <th>število datotek</th> - <td><?= $t->getFileCount() ?></td> - <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> +<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 .. -name '*.torrent' | xargs grep -lie " . escapeshellarg($_REQUEST["i"]); +echo htmlspecialchars($q); +?> +</pre> +<ul> <?php -function p ($k, $v) { - 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)"; - } +foreach (explode(PHP_EOL, shell_exec($q)) as $f) { + if (trim($f) == "") + continue; + $t = TorrentFile::load($f); + echo "<li> <a href=info.php?h=" . $t->getInfoHash() . ">" . htmlspecialchars($t->getName()) . "</a></li>"; } -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> +</ul> <?php } ?> |