-
Notifications
You must be signed in to change notification settings - Fork 122
/
index.php
127 lines (124 loc) · 5.56 KB
/
index.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
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
require_once("config.php");
require_once("sessions.php");
require_once("utilities.php");
if(isset($_POST['passwd']) && !empty($_POST['passwd'])) startSession($_POST['passwd']);
if(isset($_GET['logout']) && $_GET['logout'] == 1) endSession();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Youtube-dl WebUI</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 class="active"><a href="<?php echo $mainPage; ?>">Download</a></li>
<li><a href="<?php echo $listPage; ?>">List of videos</a></li>
</ul>
</div>
</div>
<div class="container">
<h1>Download</h1>
<?php
if(isset($_GET['url']) && !empty($_GET['url']) && $_SESSION['logged'] == 1)
{
$url = $_GET['url'];
$cmd = 'youtube-dl -o ' . escapeshellarg($folder.'%(title)s-%(uploader)s.%(ext)s') . ' ' . escapeshellarg($url) . ' 2>&1';
exec($cmd, $output, $ret);
if($ret == 0)
{
echo '<div class="alert alert-success">
<strong>Download succeed !</strong> <a href="'.$listPage.'" class="alert-link">Link to the video</a>.
</div>';
}
else{
echo '<div class="alert alert-dismissable alert-danger">
<strong>Oh snap!</strong> Something went wrong. Error code : <br>';
foreach($output as $out)
{
echo $out . '<br>';
}
echo '</div>';
}
}
elseif(isset($_SESSION['logged']) && $_SESSION['logged'] == 1)
{ ?>
<form class="form-horizontal" action="<?php echo $mainPage; ?>">
<fieldset>
<div class="form-group">
<div class="col-lg-10">
<input class="form-control" id="url" name="url" placeholder="Link" type="text">
</div>
<div class="col-lg-2">
<button type="submit" class="btn btn-primary">Download</button>
</div>
</div>
</fieldset>
</form>
<br>
<?php destFolderExists($folder);?>
<div class="row">
<div class="col-lg-6">
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">Info</h3></div>
<div class="panel-body">
<p>Free space : <?php if(file_exists($folder)){ echo human_filesize(disk_free_space($folder),1)."o";} else {echo "Folder not found";} ?></b></p>
<p>Download folder : <?php echo $folder ;?></p>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">Help</h3></div>
<div class="panel-body">
<p><b>How does it work ?</b></p>
<p>Simply paste your video link in the field and click "Download"</p>
<p><b>With which sites does it works ?</b></p>
<p><a href="http://rg3.github.io/youtube-dl/supportedsites.html">Here</a> is the list of the supported sites</p>
<p><b>How can I download the video on my computer ?</b></p>
<p>Go to "List of videos", choose one, right click on the link and do "Save target as ..." </p>
</div>
</div>
</div>
</div>
<?php
}
else{ ?>
<form class="form-horizontal" action="<?php echo $mainPage; ?>" method="POST" >
<fieldset>
<legend>You need to login first</legend>
<div class="form-group">
<div class="col-lg-4"></div>
<div class="col-lg-4">
<input class="form-control" id="passwd" name="passwd" placeholder="Password" type="password">
</div>
<div class="col-lg-4"></div>
</div>
</fieldset>
</form>
<?php
}
if(isset($_SESSION['logged']) && $_SESSION['logged'] == 1) echo '<p><a href="index.php?logout=1">Logout</a></p>';
?>
</div><!-- End container -->
<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>