mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 21:34:12 -07:00
FileManger stuff
This commit is contained in:
parent
b6dd534b60
commit
52db853acf
11 changed files with 417 additions and 131 deletions
|
@ -1,25 +1,38 @@
|
|||
<?php
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// todo: set in session?
|
||||
if (empty($panel)) {
|
||||
$command = VESTA_CMD."v-list-user '".$user."' 'json'";
|
||||
exec ($command, $output, $return_var);
|
||||
if ( $return_var > 0 ) {
|
||||
header("Location: /error/");
|
||||
exit;
|
||||
}
|
||||
$panel = json_decode(implode('', $output), true);
|
||||
}
|
||||
|
||||
|
||||
// Define a destination
|
||||
$targetFolder = '/home/admin/'; // Relative to the root
|
||||
//$targetFolder = '/home/admin/'; // Relative to the root
|
||||
$targetFolder = $panel[$user]['HOME']; // Relative to the root
|
||||
|
||||
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
|
||||
|
||||
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
|
||||
$tempFile = $_FILES['Filedata']['tmp_name'];
|
||||
$targetPath = $targetFolder;
|
||||
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
|
||||
|
||||
// Validate the file type
|
||||
//$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
|
||||
//$fileParts = pathinfo($_FILES['Filedata']['name']);
|
||||
|
||||
//if (in_array($fileParts['extension'],$fileTypes)) {
|
||||
move_uploaded_file($tempFile,$targetFile);
|
||||
echo '1';
|
||||
//} else {
|
||||
// echo 'Invalid file type.';
|
||||
// }
|
||||
$tempFile = $_FILES['Filedata']['tmp_name'];
|
||||
$targetPath = $targetFolder;
|
||||
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
|
||||
|
||||
exec (VESTA_CMD . "v-copy-fs-file {$user} {$tempFile} {$targetFile}", $output, $return_var);
|
||||
|
||||
$error = self::check_return_code($return_var, $output);
|
||||
if ($return_var != 0) {
|
||||
echo '0';
|
||||
} else {
|
||||
echo '1';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue