forked from MTco/Youtube-dl-WebUI
-
Notifications
You must be signed in to change notification settings - Fork 25
/
list.php
111 lines (106 loc) · 2.38 KB
/
list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?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");
exit;
}
if($session->is_logged_in() && isset($_GET["delete"]))
{
$file->delete($_GET["delete"]);
header("Location: list.php");
exit;
}
$files = $file->listFiles();
$parts = $file->listParts();
require 'views/header.php';
?>
<div class="container my-4">
<?php
if(!empty($files))
{
?>
<h2>List of available files:</h2>
<table class="table table-striped table-hover ">
<thead>
<tr>
<th>Title</th>
<th>Size</th>
<th><span class="pull-right">Delete link</span></th>
</tr>
</thead>
<tbody>
<?php
foreach($files 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>";
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
{
echo "<br><div class=\"alert alert-warning\" role=\"alert\">No files!</div>";
}
?>
<br/>
<?php
if(!empty($parts))
{
?>
<h2>List of part files:</h2>
<table class="table table-striped table-hover ">
<thead>
<tr>
<th>Title</th>
<th>Size</th>
<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>";
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 -->
<?php
require 'views/footer.php';
?>