Youtube-dl-WebUI/list.php

64 lines
1.4 KiB
PHP

<?php
require_once 'class/Session.php';
require_once 'class/Downloader.php';
require_once 'class/FileHandler.php';
$session = Session::getInstance();
$file = new FileHandler;
if(!$session->is_logged_in())
{
header("Location: login.php");
}
$files = $file->listFiles();
if($session->is_logged_in() && isset($_GET["delete"]))
{
$file->delete($_GET["delete"]);
header("Location: list.php");
}
require 'views/header.php';
?>
<div class="container">
<?php
if(!empty($files))
{
?>
<h2>List of available files:</h2>
<table class="table table-striped table-hover ">
<thead>
<tr>
<th style="min-width:800px; height:35px">Title</th>
<th style="min-width:80px">Size</th>
<th style="min-width:110px">Delete link</th>
</tr>
</thead>
<tbody>
<?php
foreach($files as $f)
{
echo "<tr>";
echo "<td><a href=\"".rawurlencode($file->get_downloads_folder()).'/'.rawurlencode($f["name"])."\" download>".$f["name"]."</a></td>";
echo "<td>".$f["size"]."</td>";
echo "<td><a href=\"./list.php?delete=".sha1($f["name"])."\" class=\"btn btn-danger btn-sm\">Delete</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
<br/>
<br/>
<?php
}
else
{
echo "<br><div class=\"alert alert-warning\" role=\"alert\">No files!</div>";
}
?>
<br/>
</div><!-- End container -->
<?php
require 'views/footer.php';
?>