mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
Integrated new api interface.
This commit is contained in:
parent
4a9bfc94ad
commit
4306a4fb4f
116 changed files with 10371 additions and 0 deletions
33
web/api/v1/download/file/index.php
Normal file
33
web/api/v1/download/file/index.php
Normal file
|
@ -0,0 +1,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(VESTA_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');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue