-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_file.php
More file actions
39 lines (27 loc) · 872 Bytes
/
get_file.php
File metadata and controls
39 lines (27 loc) · 872 Bytes
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
<?php
$_baseUrl = './';
require('./libs/includes/ajax.utils.inc.php');
if ($_SERVER["REQUEST_METHOD"] == "OPTIONS")
exit(0);
//$target_path = $_baseUrl . FOLDER_MODULE_UPLOAD;
if(empty($_GET['file']))
die('Aucun fichier sélectionné');
$fileName = $_GET['file'];
if(preg_match('!\.\.!', $fileName))
die('You cannot retrieve this file');
securePath();
$filePath = findFile();
$infos = new InfosFile($filePath);
$mime = $infos -> getMime();
if (!$mime)
die("Impossible to get mime type");
$fName = @parse_ini_file($filePath . '.props');
$filename = empty($fName['name']) ? $_GET['file'] : $fName['name'];
if(!empty($fName['ext']))
$filename .= "." . $fName['ext'];
$fp = fopen($filePath, 'rb');
header("Content-disposition: inline; filename=" . $filename);
header("Content-Type: $mime");
header("Content-Length: " . filesize($filePath));
fpassthru($fp);
?>