mirror of
https://github.com/timendum/Youtube-dl-WebUI.git
synced 2024-11-10 08:52:36 +08:00
"list of" is now generic
This commit is contained in:
parent
0da5123423
commit
26b05f2324
3 changed files with 12 additions and 54 deletions
|
@ -11,46 +11,25 @@ class FileHandler
|
|||
$this->config = require dirname(__DIR__).'/config/config.php';
|
||||
}
|
||||
|
||||
public function listVideos()
|
||||
public function listFiles()
|
||||
{
|
||||
$videos = [];
|
||||
$files = [];
|
||||
|
||||
if(!$this->outuput_folder_exists())
|
||||
return;
|
||||
|
||||
$folder = dirname(__DIR__).'/'.$this->config["outputFolder"].'/';
|
||||
|
||||
foreach(glob($folder.'*'.$this->videos_ext, GLOB_BRACE) as $file)
|
||||
foreach(glob($folder.'*.*', GLOB_BRACE) as $file)
|
||||
{
|
||||
$video = [];
|
||||
$video["name"] = str_replace($folder, "", $file);
|
||||
$video["size"] = $this->to_human_filesize(filesize($file));
|
||||
$content = [];
|
||||
$content["name"] = str_replace($folder, "", $file);
|
||||
$content["size"] = $this->to_human_filesize(filesize($file));
|
||||
|
||||
$videos[] = $video;
|
||||
$files[] = $content;
|
||||
}
|
||||
|
||||
return $videos;
|
||||
}
|
||||
|
||||
public function listMusics()
|
||||
{
|
||||
$musics = [];
|
||||
|
||||
if(!$this->outuput_folder_exists())
|
||||
return;
|
||||
|
||||
$folder = dirname(__DIR__).'/'.$this->config["outputFolder"].'/';
|
||||
|
||||
foreach(glob($folder.'*'.$this->musics_ext, GLOB_BRACE) as $file)
|
||||
{
|
||||
$music = [];
|
||||
$music["name"] = str_replace($folder, "", $file);
|
||||
$music["size"] = $this->to_human_filesize(filesize($file));
|
||||
|
||||
$musics[] = $music;
|
||||
}
|
||||
|
||||
return $musics;
|
||||
return $files;
|
||||
}
|
||||
|
||||
public function delete($id, $type)
|
||||
|
|
26
list.php
26
list.php
|
@ -11,20 +11,7 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
$files = $file->listFiles();
|
||||
|
||||
if($session->is_logged_in() && isset($_GET["delete"]))
|
||||
{
|
||||
|
@ -39,7 +26,7 @@
|
|||
if(!empty($files))
|
||||
{
|
||||
?>
|
||||
<h2>List of available <?php echo $type ?> :</h2>
|
||||
<h2>List of available files:</h2>
|
||||
<table class="table table-striped table-hover ">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -71,14 +58,7 @@
|
|||
}
|
||||
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>";
|
||||
}
|
||||
echo "<br><div class=\"alert alert-warning\" role=\"alert\">No files!</div>";
|
||||
}
|
||||
?>
|
||||
<br/>
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="./">Download</a></li>
|
||||
<li><a href="./list.php?type=v">List of videos</a></li>
|
||||
<li><a href="./list.php?type=m">List of songs</a></li>
|
||||
<li><a href="./list.php">List of files</a></li>
|
||||
<?php
|
||||
if($session->is_logged_in())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue