CSS improvement for file listing (#1077)

This commit is contained in:
Cønstantine Kovalensky 2023-11-11 18:50:01 +04:00 committed by GitHub
commit 481e5469d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,23 +35,26 @@ if (empty($row) || empty($row['physical_filename'])) {
}
if (empty($row['info_hash_v2'])) {
http_response_code(404);
http_response_code(410);
die($lang['BT_V2_FILE_LIST_ONLY']);
}
$file_path = get_attachments_dir() . '/' . $row['physical_filename'];
if (!is_file($file_path)) {
http_response_code(410);
die($lang['TOR_NOT_FOUND']);
}
$file_contents = file_get_contents($file_path);
if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) {
http_response_code(410);
die($lang['TORFILE_INVALID']);
}
if (isset($tor['info']['private']) && IS_GUEST) {
http_response_code(403);
die($lang['BT_PRIVATE_TORRENT']);
}
@ -68,6 +71,7 @@ $data = [
];
echo <<<EOF
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
@ -77,52 +81,99 @@ echo <<<EOF
<title>{$data['name']} ({$data['size']}) | {$data['hash']} | {$bb_cfg['sitename']}</title>
</head>
<body style="background-color: #1f1f1f; color: #ffffff;">
<body>
<style>
table {
table-layout: auto;
border-collapse: collapse;
width: auto;
margin: 20px auto;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
background-color: #2c2c2c;
color: #ffffff;
}
body {
background-color: #1f1f1f; color: #ffffff;
}
th, td {
border: 2px solid #00ff00;
border-color: #646464;
padding: 8px;
text-align: left;
color: #acacac;
}
table {
table-layout: auto;
border: collapse;
width: auto;
margin: 20px auto;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
background-color: #2c2c2c;
}
th {
background-color: #1f1f1f;
}
th, td {
padding: 8px;
text-align: left;
color: #acacac;
width: auto;
}
p {
color: #b3b3b3;
}
td {
border: 2px solid #353535;
}
a {
color: #187700;
}
th {
background-color: #1f1f1f;
width: auto;
}
p {
color: #b3b3b3;
}
a {
color: #187700;
}
.tooltip {
position: relative;
}
.tooltip .tooltiptext {
visibility: hidden;
position: absolute;
z-index: 1;
top: 0;
opacity: 0;
transition: opacity 0.7s;
width: 400px;
background-color: #111;
color: #c6c4c4;
text-align: left;
border-radius: 5px;
padding: 5px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
<center>
<h2 style="color: #b3b3b3; font-family: Monospace;">Name: {$data['name']} | Age: ({$data['date']}) | Size: {$data['size']}
</h2>
<p><i>Created by: {$data['client']}</i></p>
<h2 style="color: #b3b3b3; font-family: Monospace;">Name: {$data['name']} | Age: ({$data['date']}) | Size: {$data['size']}</h2>
<p>
<i>Created by: {$data['client']}</i>
</p>
<hr>
<table><tr><th>Path</th><th>Size</th><th title="BitTorrent Merkle Root — The hash of a file, which is embedded in torrents with BitTorrent v2 support, tracker users can extract, calculate them, also deduplicate torrents using desktop tools such as Torrent Merkle Root Reader.">BTMR hash <sup>?</sup></th></tr>
<table>
<tr>
<th>Path</th>
<th>Size</th>
<th class="tooltip" style="width: auto;">
BTMR hash
<sup>?
<span class="tooltiptext">
BitTorrent Merkle Root is a hash of a file that is embedded in torrents with BitTorrent v2 support, tracker users can extract, calculate them, and download deduplicated torrents using desktop tools such as
<a href="https://github.com/kovalensky/tmrr" target="_blank">Torrent Merkle Root Reader.</a>
</span>
</sup>
</th>
</tr>
EOF;
echo $files['list'];
echo '</center>
echo '
</table>
<p><i style = "color: gray">Generated by</i> <a href = "https://github.com/torrentpier/torrentpier" target="_blank">TorrentPier</a></p>
<p>
<i style = "color: gray">Generated by</i> <a href = "https://github.com/torrentpier/torrentpier" target="_blank">TorrentPier</a>
</p>
</center>
</body>
</html>';