Youtube-dl-WebUI/list.php

110 lines
2.4 KiB
PHP
Raw Normal View History

<?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");
}
if($session->is_logged_in() && isset($_GET["delete"]))
{
2016-01-21 05:08:07 +08:00
$file->delete($_GET["delete"]);
2016-01-21 00:49:11 +08:00
header("Location: list.php");
}
2017-09-29 16:42:38 +08:00
$files = $file->listFiles();
$parts = $file->listParts();
require 'views/header.php';
?>
<div class="container">
<?php
if(!empty($files))
{
?>
2016-01-21 00:36:34 +08:00
<h2>List of available files:</h2>
<table class="table table-striped table-hover ">
<thead>
<tr>
2016-06-21 16:07:41 +08:00
<th>Title</th>
<th>Size</th>
2016-11-28 22:55:53 +08:00
<th><span class="pull-right">Delete link</span></th>
</tr>
</thead>
<tbody>
<?php
foreach($files as $f)
{
echo "<tr>";
2016-08-23 16:47:44 +08:00
if ($file->get_relative_downloads_folder())
{
echo "<td><a href=\"".rawurlencode($file->get_relative_downloads_folder()).'/'.rawurlencode($f["name"])."\" download>".$f["name"]."</a></td>";
}
else
{
echo "<td>".$f["name"]."</td>";
}
echo "<td>".$f["size"]."</td>";
2016-11-28 22:55:53 +08:00
echo "<td><a href=\"./list.php?delete=".sha1($f["name"])."\" class=\"btn btn-danger btn-sm pull-right\">Delete</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
<?php
}
else
{
2016-01-21 00:36:34 +08:00
echo "<br><div class=\"alert alert-warning\" role=\"alert\">No files!</div>";
}
?>
<br/>
<?php
if(!empty($parts))
{
?>
2016-11-26 18:09:45 +08:00
<h2>List of part files:</h2>
<table class="table table-striped table-hover ">
<thead>
<tr>
<th>Title</th>
<th>Size</th>
2016-11-28 22:55:53 +08:00
<th><span class="pull-right">Delete link</span></th>
</tr>
</thead>
<tbody>
<?php
foreach($parts as $f)
{
echo "<tr>";
if ($file->get_relative_downloads_folder())
{
echo "<td><a href=\"".rawurlencode($file->get_relative_downloads_folder()).'/'.rawurlencode($f["name"])."\" download>".$f["name"]."</a></td>";
}
else
{
echo "<td>".$f["name"]."</td>";
}
echo "<td>".$f["size"]."</td>";
2016-11-28 22:55:53 +08:00
echo "<td><a href=\"./list.php?delete=".sha1($f["name"])."\" class=\"btn btn-danger btn-sm pull-right\">Delete</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
<br/>
<br/>
<?php
}
?>
<br/>
</div><!-- End container -->
2014-03-21 09:01:44 +08:00
<?php
require 'views/footer.php';
2016-11-28 22:55:53 +08:00
?>