forked from MTco/Youtube-dl-WebUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.php
55 lines (46 loc) · 1.62 KB
/
get.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
<?php
require_once("config.php");
require_once("sessions.php");
require_once("utilities.php");
if(isset($_GET['logout']) && $_GET['logout'] == 1) endSession();
if(isset($_SESSION['logged']) && $_SESSION['logged'] == 1)
{
if(isset($_GET['fileToGet']))
{
$rawFile = base64_decode($_GET['fileToGet']);
$tmpFile = pathinfo($rawFile);
$fileToGet = $tmpFile['basename'];
if(file_exists($folder.$fileToGet) && substr($fileToGet, 0, 1) != '/' && substr($fileToGet, 0, 1) != '.')
{
//Get file type and set it as Content Type
$finfo = finfo_open(FILEINFO_MIME_TYPE);
header('Content-Type: ' . finfo_file($finfo, $folder.$fileToGet));
finfo_close($finfo);
//Use Content-Disposition: attachment to specify the filename
header('Content-Disposition: attachment; filename='.basename($folder.$fileToGet));
//No cache
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
//Define file size
header('Content-Length: ' . filesize($folder.$fileToGet));
ob_clean();
flush();
readfile($folder.$fileToGet);
exit;
}
else
{
header("Location: ".$listPage);
}
}
else
{
header("Location: ".$listPage);
}
}
else
{
header("Location: ".$mainPage);
}
?>