forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
33 lines (30 loc) · 909 Bytes
/
Copy pathindex.php
File metadata and controls
33 lines (30 loc) · 909 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
<?php
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
if ((!isset($_SESSION['FILEMANAGER_KEY'])) || (empty($_SESSION['FILEMANAGER_KEY']))) {
header("Location: /login/");
exit;
}
$user = $_SESSION['user'];
if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
$user = $_SESSION['look'];
}
$path = $_REQUEST['path'];
if (!empty($path)) {
set_time_limit(0);
if (ob_get_level()) {
ob_end_clean();
}
header("Content-type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Content-disposition: attachment;filename=".basename($path));
$output = '';
exec(HESTIA_CMD . "v-check-fs-permission " . $user . " " . escapeshellarg($path), $output, $return_var);
if ($return_var != 0) {
print 'Error while opening file'; // todo: handle this more styled
exit;
}
readfile($path);
exit;
} else {
die('File not found');
}