-
Notifications
You must be signed in to change notification settings - Fork 121
/
list.php
114 lines (112 loc) · 4.82 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
112
113
114
<?php
require_once("config.php");
require_once("sessions.php");
require_once("utilities.php");
if(isset($_GET['logout']) && $_GET['logout'] == 1) endSession();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Youtube-dl WebUI - List of videos</title>
<link rel="stylesheet" href="css/bootstrap.css" media="screen">
<link rel="stylesheet" href="css/bootswatch.min.css">
</head>
<body >
<div class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo $mainPage; ?>">Youtube-dl WebUI</a>
</div>
<div class="navbar-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li><a href="<?php echo $mainPage; ?>">Download</a></li>
<li class="active"><a href="<?php echo $listPage; ?>">List of videos</a></li>
</ul>
</div>
</div>
<div class="container">
<?php
if(isset($_SESSION['logged']) && $_SESSION['logged'] == 1)
{
if(isset($_GET['fileToDel']))
{
$fileToDel = $_GET['fileToDel'];
if(file_exists($folder.$fileToDel))
{
if(unlink($folder.$fileToDel))
{
echo '<div class="panel panel-success">';
echo '<div class="panel-heading"><h3 class="panel-title">Fichier à supprimer : '.$fileToDel.'</h3></div>';
echo '<div class="panel-body">Le fichier '.$fileToDel.' a été supprimé !</div>';
echo '</div>';
echo '<p><a href="'.$listPage.'">Go back</a></p>';
}
else{
echo '<div class="panel panel-danger">';
echo '<div class="panel-heading"><h3 class="panel-title">Fichier à supprimer : '.$fileToDel.'</h3></div>';
echo '<div class="panel-body">Le fichier '.$fileToDel.' n\'a pas pu être supprimé !</div>';
echo '</div>';
echo '<p><a href="'.$listPage.'">Go back</a></p>';
}
}
else{
echo '<div class="panel panel-danger">';
echo '<div class="panel-heading"><h3 class="panel-title">Fichier à supprimer : '.$fileToDel.'</h3></div>';
echo '<div class="panel-body">Le fichier '.$fileToDel.' ne peut pas être supprimé car il est introuvable !</div>';
echo '</div>';
echo '<p><a href="'.$listPage.'">Go back</a></p>';
}
}
elseif(!file_exists($folder))
{
echo '<div class="alert alert-danger">
<strong>Error : </strong> Destination folder doesn\'t exist or is not found here.
</div>';
}
else { ?>
<h2>List of available videos :</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">Remove link</th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach(glob($folder."*") as $file)
{
$filename = str_replace($folder, "", $file); // Need to fix accent problem with something like this : utf8_encode
echo "<tr>"; //New line
echo "<td height=\"30px\"><a href=\"$folder$filename\">$filename</a></td>"; //1st col
echo "<td>".human_filesize(filesize($folder.$filename))."</td>"; //2nd col
echo "<td><a href=\"".$listPage."?fileToDel=$filename\" class=\"text-danger\">Delete</a></td>"; //3rd col
echo "</tr>"; //End line
}
}
}
else {
echo '<div class="alert alert-danger"><strong>Access denied :</strong> You must sign in before !</div>';
} ?>
</tr>
</tbody>
</table>
<br/>
<?php if(!isset($_GET['fileToDel'])) echo "<a href=".$mainPage.">Back to download page</a>"; ?>
</div><!-- End container -->
<br>
<footer>
<div class="well text-center">
<p><a href="https://github.com/p1rox/Youtube-dl-WebUI" target="_blank">Fork me on Github</a></p>
<p>Created by <a href="https://twitter.com/p1rox" target="_blank">@p1rox</a> - Web Site : <a href="http://p1rox.fr" target="_blank">p1rox.fr</a></p>
</div>
</footer>
</body>
</html>