forked from MTco/Youtube-dl-WebUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.php
88 lines (82 loc) · 1.8 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
<?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(isset($_GET['type']) && !empty($_GET['type']))
{
$t = $_GET['type'];
if($t === 'v')
{
$type = "videos";
$files = $file->listVideos();
}
elseif($t === 'm')
{
$type = "musics";
$files = $file->listMusics();
}
}
if($session->is_logged_in() && isset($_GET["delete"]))
{
$file->delete($_GET["delete"], $t);
header("Location: list.php?type=".$t);
}
require 'views/header.php';
?>
<div class="container">
<?php
if(!empty($files))
{
?>
<h2>List of available <?php echo $type ?> :</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
$i = 0;
$totalSize = 0;
foreach($files as $f)
{
echo "<tr>";
echo "<td><a href=\"".$file->get_downloads_folder().'/'.$f["name"]."\" download>".$f["name"]."</a></td>";
echo "<td>".$f["size"]."</td>";
echo "<td><a href=\"./list.php?delete=$i&type=$t\" class=\"btn btn-danger btn-sm\">Delete</a></td>";
echo "</tr>";
$i++;
}
?>
</tbody>
</table>
<br/>
<br/>
<?php
}
else
{
if(isset($t) && ($t === 'v' || $t === 'm'))
{
echo "<br><div class=\"alert alert-warning\" role=\"alert\">No $type !</div>";
}
else
{
echo "<br><div class=\"alert alert-warning\" role=\"alert\">No such type !</div>";
}
}
?>
<br/>
</div><!-- End container -->
<?php
require 'views/footer.php';
?>