-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
download.php
63 lines (52 loc) · 1.47 KB
/
download.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
<?php
/**
* Download Files
*
* Forces the download of file types
*
* @package GetSimple
* @subpackage Download
*/
// Setup inclusions
$load['plugin'] = true;
// Include common.php
include('inc/common.php');
login_cookie_check();
# check if all variables are set
if(isset($_GET['file'])) {
$file = removerelativepath($_GET['file']);
if(!filepath_is_safe($file,GSDATAUPLOADPATH) && !filepath_is_safe($file,GSBACKUPSPATH.DIRECTORY_SEPARATOR.'zip')) die();
$extention = pathinfo($file,PATHINFO_EXTENSION);
header("Content-disposition: attachment; filename=".$file);
# set content headers
if ($extention == 'zip') {
header("Content-type: application/octet-stream");
} elseif ($extention == 'gz') {
header("Content-type: application/x-gzip");
} elseif ($extention == 'mpg') {
header("Content-type: video/mpeg");
} elseif ($extention == 'jpg' || $extention == 'jpeg' ) {
header("Content-type: image/jpeg");
} elseif ($extention == 'txt' || $extention == 'log' ) {
header("Content-type: text/plain");
} elseif ($extention == 'xml' ) {
header("Content-type: text/xml");
} elseif ($extention == 'js' ) {
header("Content-type: text/javascript");
} elseif ($extention == 'pdf' ) {
header("Content-type: text/pdf");
} elseif ($extention == 'css' ) {
header("Content-type: text/css");
}
# plugin hook
exec_action('download-file');
# get file
if (file_exists($file)) {
readfile($file, 'r');
}
exit;
} else {
echo 'No such file found';
die;
}
exit;