mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
The New Desing
This commit is contained in:
parent
def9cc4ea6
commit
067a2c862a
305 changed files with 22231 additions and 7576 deletions
1343
web/file_manager/UploadHandler.php
Normal file
1343
web/file_manager/UploadHandler.php
Normal file
File diff suppressed because it is too large
Load diff
359
web/file_manager/files.php
Normal file
359
web/file_manager/files.php
Normal file
|
@ -0,0 +1,359 @@
|
|||
<?php
|
||||
|
||||
//define(MAX_FILES_TO_SORT, 5);
|
||||
//define(LISTING_TIMEOUT, 0.000001);
|
||||
define(LISTING_TIMEOUT, 5);
|
||||
|
||||
|
||||
|
||||
|
||||
//echo 'files: ';
|
||||
//$files = scandir(__DIR__);
|
||||
|
||||
|
||||
//echo '<pre>';
|
||||
//print_r($files);
|
||||
|
||||
|
||||
//$_REQUEST['sort_field'] = 'size';
|
||||
$_REQUEST['sort_field'] = 'name';
|
||||
//$_REQUEST['sort_field'] = 'atime';
|
||||
//$_REQUEST['sort_field'] = 'mtime';
|
||||
$_REQUEST['sort_desc'] = 1;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
+- copy file / dir [ recursive ]
|
||||
+- rename(move) file / dir
|
||||
+- delete file / dir [ recursive ]
|
||||
+- chmod file / dir
|
||||
+- chown file / dir
|
||||
+- create file
|
||||
+- create dir
|
||||
*/
|
||||
|
||||
switch($_REQUEST['action']){
|
||||
case 'copy': fm_copy($_REQUEST['source'], $_REQUEST['dest']); break;
|
||||
case 'rename': fm_rename($_REQUEST['source'], $_REQUEST['dest']); break;
|
||||
case 'delete': fm_delete($_REQUEST['source']); break;
|
||||
case 'chmod': fm_chmod($_REQUEST['source'], $_REQUEST['mode']); break;
|
||||
case 'chown': fm_chown($_REQUEST['source'], $_REQUEST['uid'], $_REQUEST['gid']); break;
|
||||
case 'create_file': fm_create_file($_REQUEST['source'], $_REQUEST['mode'] || FALSE); break;
|
||||
case 'create_dir': fm_create_dir($_REQUEST['source'], $_REQUEST['mode'] || FALSE); break;
|
||||
|
||||
default:
|
||||
$pwd = $_REQUEST['path'] ? $_REQUEST['path'] : __DIR__;
|
||||
$listing = dir_list($pwd, $_REQUEST['sort_field']);
|
||||
$writable = is_writable($pwd);
|
||||
|
||||
$pwd = array_merge(array('/'), explode('/', trim($pwd, '/')));
|
||||
|
||||
include('templates/filemanager.php');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//echo $_GET['sort_field'];
|
||||
|
||||
// if(in_array($_GET['sort_field'], $available_sort_fields)){
|
||||
// echo '1';
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
upload_file
|
||||
|
||||
+ list_dir
|
||||
+- copy file / dir [ recursive ]
|
||||
+- rename(move) file / dir
|
||||
+- delete file / dir [ recursive ]
|
||||
+- chmod file / dir
|
||||
+- chown file / dir
|
||||
+- create file
|
||||
+- create dir
|
||||
|
||||
view file / image
|
||||
download file / image
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function fm_create_file($filename){
|
||||
if(is_file($filename))
|
||||
return array('error' => 'file exists', 'code' => 1);
|
||||
|
||||
return !!fopen($filename, 'w');
|
||||
}
|
||||
|
||||
|
||||
function fm_create_dir($dirname){
|
||||
if(is_dir($filename))
|
||||
return array('error' => 'directory exists', 'code' => 1);
|
||||
|
||||
// TODO set parent directory mode
|
||||
return mkdir($dirname);
|
||||
}
|
||||
|
||||
|
||||
function fm_chown($filename, $recursive = 0, $uid = FALSE, $gid = FALSE){
|
||||
if(is_dir($filename) && $recursive){
|
||||
$dir_handle = opendir($dir);
|
||||
while ($item = readdir($dir_handle)){
|
||||
if (!in_array($item, array('.','..'))){
|
||||
$new_item = $filename.'/'.$item;
|
||||
|
||||
if($uid !== FALSE) chown($new_item, (int)$uid);
|
||||
if($gid !== FALSE) chgrp($new_item, (int)$gid);
|
||||
|
||||
if(is_dir($new_item)){
|
||||
fm_chown($new_item, $recursive, $uid, $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($uid !== FALSE) chown($filename, (int)$uid);
|
||||
if($gid !== FALSE) chgrp($filename, (int)$gid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fm_chmod($filename, $recursive = 0, $mode){
|
||||
if(is_dir($filename) && $recursive){
|
||||
$dir_handle = opendir($dir);
|
||||
while ($item = readdir($dir_handle)){
|
||||
if (!in_array($item, array('.','..'))){
|
||||
$new_item = $filename.'/'.$item;
|
||||
chmod($new_item, octdec($mode));
|
||||
|
||||
if(is_dir($new_item)){
|
||||
fm_chmod($new_item, $recursive, $mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
chmod($filename, octdec($mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fm_delete($filename){
|
||||
if(is_dir($filename)){
|
||||
foreach (
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($filename, RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::SELF_FIRST) as $item
|
||||
) {
|
||||
if ($item->isDir()) {
|
||||
rmdir($item);
|
||||
// mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), decoct(fileperms($item->getPerms())));
|
||||
} else {
|
||||
unlink($item);
|
||||
// copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return unlink($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fm_rename($source, $dest){
|
||||
return rename($source, $dest);
|
||||
}
|
||||
|
||||
|
||||
function fm_copy($source, $dest){
|
||||
if(is_dir($source)){
|
||||
foreach (
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::SELF_FIRST) as $item
|
||||
) {
|
||||
if ($item->isDir()) {
|
||||
// TODO set dir perms
|
||||
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), decoct(fileperms($item->getPerms())));
|
||||
} else {
|
||||
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
return copy($source, $dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function list_dir(){
|
||||
$dir_iterator = new RecursiveDirectoryIterator("/path");
|
||||
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
|
||||
// could use CHILD_FIRST if you so wish
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
echo $file, "\n";
|
||||
}
|
||||
|
||||
$size = 0;
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile()) {
|
||||
echo substr($file->getPathname(), 27) . ": " . $file->getSize() . " B; modified " . date("Y-m-d", $file->getMTime()) . "\n";
|
||||
$size += $file->getSize();
|
||||
}
|
||||
}
|
||||
|
||||
echo "\nTotal file size: ", $size, " bytes\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// fast removing directory
|
||||
function rmrf($dir) {
|
||||
|
||||
foreach (glob($dir) as $file) {
|
||||
if (is_dir($file)) {
|
||||
rmrf("$file/*");
|
||||
rmdir($file);
|
||||
} else {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function dir_list($dir, $sort = 0)
|
||||
{
|
||||
$sort_order_for_filename = SORT_ASC;
|
||||
//$available_sort_fields = array('size, type', 'mtime', 'atime', 'owner', 'group');
|
||||
$available_sort_fields = array('name', 'size', 'type', 'mtime', 'atime', 'owner', 'group');
|
||||
$sort_order = SORT_ASC;
|
||||
|
||||
if ($dir[strlen($dir)-1] != '/') $dir .= '/';
|
||||
if (!is_dir($dir)) return array();
|
||||
|
||||
$start = microtime(TRUE);
|
||||
|
||||
$listing = array('dirs' => array(), 'files' => array(), 'dir_names' => array(), 'file_names' => array() ,'count' => 0, 'timeout_exeeded' => 0, 'time' => 0);
|
||||
$dir_handle = opendir($dir);
|
||||
$dir_objects = array();
|
||||
while ($object = readdir($dir_handle)){
|
||||
if (!in_array($object, array('.','..'))){
|
||||
$filename = $dir . $object;
|
||||
$time = microtime(true) - $start;
|
||||
if($time <= LISTING_TIMEOUT){
|
||||
$stats = stat($filename);
|
||||
$mode = explain_mode($stats['mode']);
|
||||
$perms = decoct(fileperms($filename));
|
||||
$item = array(
|
||||
'name' => $object,
|
||||
'size' => $stats['size'],
|
||||
'mode' => array('owner' => $mode['owner'], 'group' => $mode['owner'], 'other' => $mode['owner']),
|
||||
'perms' => decoct($stats['mode']),
|
||||
'type' => $mode['type'],
|
||||
'mtime' => $stats['mtime'],
|
||||
'atime' => $stats['atime'],
|
||||
'mdate_human' => date("Y F d", $stats['mtime']),
|
||||
'mtime_human' => date("H:i:s", $stats['mtime']),
|
||||
'adate_human' => date("Y F d", $stats['atime']),
|
||||
'atime_human' => date("H:i:s", $stats['atime']),
|
||||
'nlink' => $stats['nlink'],
|
||||
'owner' => posix_getpwuid($stats['uid'])['name'],
|
||||
'group' => posix_getgrgid($stats['gid'])['name']
|
||||
);
|
||||
}else{
|
||||
$listing['timeout_exeeded'] = TRUE;
|
||||
if(is_dir($filename)){ $type = 'd';
|
||||
}else{ $type = '-'; }
|
||||
|
||||
$item = array(
|
||||
'name' => $object,
|
||||
'size' => FALSE,
|
||||
'mode' => array('owner' => FALSE, 'group' => FALSE, 'other' => FALSE),
|
||||
'type' => $type,
|
||||
'mtime' => FALSE,
|
||||
'atime' => FALSE,
|
||||
'mdate_human' => FALSE,
|
||||
'mtime_human' => FALSE,
|
||||
'adate_human' => FALSE,
|
||||
'atime_human' => FALSE,
|
||||
'nlink' => FALSE,
|
||||
'owner' => FALSE,
|
||||
'group' => FALSE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$listing['count']++;
|
||||
|
||||
if($item['type'] == 'd'){
|
||||
$listing['dirs'][] = $item;
|
||||
$listing['dir_names'][] = $item['name'];
|
||||
}else{
|
||||
if($sort && !$listing['timeout_exeeded']){
|
||||
$listing[$sort][] = $item[$sort];
|
||||
}
|
||||
$listing['files'][] = $item;
|
||||
$listing['file_names'][] = $item['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$listing['time'] = microtime(TRUE) - $start;
|
||||
|
||||
|
||||
if(!$listing['timeout_exeeded']){
|
||||
if(in_array($_REQUEST['sort_field'], $available_sort_fields)){
|
||||
if($_REQUEST['sort_desc']){
|
||||
$sort_order = SORT_DESC;
|
||||
}
|
||||
array_multisort($listing[$_REQUEST['sort_field']], $sort_order, $listing['file_names'], $sort_order_for_filename, $listing['files']);
|
||||
}
|
||||
array_multisort($listing['dir_names'], $sort_order_for_filename, $listing['dirs']);
|
||||
}
|
||||
|
||||
return $listing;
|
||||
}
|
||||
|
||||
|
||||
function explain_mode($mode)
|
||||
{
|
||||
$info = array();
|
||||
|
||||
if (($mode & 0xC000) == 0xC000) { $info['type'] = 's'; }
|
||||
elseif (($mode & 0xA000) == 0xA000) { $info['type'] = 'l'; }
|
||||
elseif (($mode & 0x8000) == 0x8000) { $info['type'] = '-'; }
|
||||
elseif (($mode & 0x6000) == 0x6000) { $info['type'] = 'b'; }
|
||||
elseif (($mode & 0x4000) == 0x4000) { $info['type'] = 'd'; }
|
||||
elseif (($mode & 0x2000) == 0x2000) { $info['type'] = 'c'; }
|
||||
elseif (($mode & 0x1000) == 0x1000) { $info['type'] = 'p'; }
|
||||
else { $info['type'] = 'u'; }
|
||||
|
||||
$info['owner'] = (($mode & 0x0100) ? 'r' : '-');
|
||||
$info['owner'] .= (($mode & 0x0080) ? 'w' : '-');
|
||||
$info['owner'] .= (($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) : (($mode & 0x0800) ? 'S' : '-'));
|
||||
|
||||
// group
|
||||
$info['group'] = (($mode & 0x0020) ? 'r' : '-');
|
||||
$info['group'] .= (($mode & 0x0010) ? 'w' : '-');
|
||||
$info['group'] .= (($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) : (($mode & 0x0400) ? 'S' : '-'));
|
||||
|
||||
// other
|
||||
$info['other'] = (($mode & 0x0004) ? 'r' : '-');
|
||||
$info['other'] .= (($mode & 0x0002) ? 'w' : '-');
|
||||
$info['other'] .= (($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) : (($mode & 0x0200) ? 'T' : '-'));
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
?>
|
70
web/file_manager/fm_api.php
Normal file
70
web/file_manager/fm_api.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
// Init
|
||||
//error_reporting(NULL);
|
||||
|
||||
|
||||
session_start();
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
include($_SERVER['DOCUMENT_ROOT']."/file_manager/fm_core.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);
|
||||
}
|
||||
|
||||
$fm = new FileManager($user);
|
||||
$fm->setRootDir($panel[$user]['HOME']);
|
||||
|
||||
$_REQUEST['action'] = empty($_REQUEST['action']) ? '' : $_REQUEST['action'];
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'rename_file':
|
||||
$dir = $_REQUEST['dir'];
|
||||
$item = $_REQUEST['item'];
|
||||
$target_name = $_REQUEST['target_name'];
|
||||
|
||||
print json_encode($fm->renameItem($dir, $item, $target_name));
|
||||
break;
|
||||
case 'delete_files':
|
||||
$dir = $_REQUEST['dir'];
|
||||
$item = $_REQUEST['item'];
|
||||
|
||||
print json_encode($fm->deleteItems($dir, $item));
|
||||
break;
|
||||
case 'create_file':
|
||||
$dir = $_REQUEST['dir'];
|
||||
$filename = $_REQUEST['filename'];
|
||||
print json_encode($fm->createFile($dir, $filename));
|
||||
break;
|
||||
case 'create_dir':
|
||||
$dir = $_REQUEST['dir'];
|
||||
$dirname = $_REQUEST['dirname'];
|
||||
print json_encode($fm->createDir($dir, $dirname));
|
||||
break;
|
||||
case 'cd':
|
||||
$dir = $_REQUEST['dir'];
|
||||
print json_encode($fm->ls($dir));
|
||||
break;
|
||||
case 'open_file':
|
||||
$dir = $_REQUEST['dir'];
|
||||
print json_encode($fm->open_file($dir));
|
||||
break;
|
||||
case 'copy_files':
|
||||
$dir = $_REQUEST['dir'];
|
||||
$target_dir = $_REQUEST['dir_target'];
|
||||
$filename = $_REQUEST['filename'];
|
||||
print json_encode($fm->copyFile($dir, $target_dir, $filename));
|
||||
break;
|
||||
default:
|
||||
//print json_encode($fm->init());
|
||||
break;
|
||||
}
|
201
web/file_manager/fm_core.php
Normal file
201
web/file_manager/fm_core.php
Normal file
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
|
||||
class FileManager {
|
||||
|
||||
protected $delimeter = '|';
|
||||
protected $info_positions = array(
|
||||
'TYPE' => 0,
|
||||
'PERMISSIONS' => 1,
|
||||
'DATE' => 2,
|
||||
'TIME' => 3,
|
||||
'OWNER' => 4,
|
||||
'GROUP' => 5,
|
||||
'SIZE' => 6,
|
||||
'NAME' => 7
|
||||
);
|
||||
|
||||
protected $user = null;
|
||||
public $ROOT_DIR = null;
|
||||
|
||||
public function setRootDir($root = null) {
|
||||
if (null != $root) {
|
||||
$root = realpath($root);
|
||||
}
|
||||
$this->ROOT_DIR = $root;
|
||||
}
|
||||
|
||||
public function __construct($user) {
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/*public function init() {
|
||||
$path = !empty($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
|
||||
$start_url = !empty($path) ? $this->ROOT_DIR . '/' . $path : $this->ROOT_DIR;
|
||||
$listing = $this->getDirectoryListing($path);
|
||||
|
||||
return $data = array(
|
||||
'result' => true,
|
||||
'ROOT_DIR' => $this->ROOT_DIR,
|
||||
'TAB_A_PATH' => $start_url,
|
||||
'TAB_B_PATH' => $this->ROOT_DIR, // second tab always loads home dir
|
||||
'listing' => $listing
|
||||
);
|
||||
}*/
|
||||
|
||||
public function formatFullPath($path_part = '') {
|
||||
if (substr($path_part, 0, strlen($this->ROOT_DIR)) === $this->ROOT_DIR) {
|
||||
$path = $path_part;
|
||||
}
|
||||
else {
|
||||
$path = $this->ROOT_DIR . '/' . $path_part;
|
||||
}
|
||||
//var_dump($path);die();
|
||||
return escapeshellarg($path);
|
||||
}
|
||||
|
||||
function deleteItems($dir, $item) {
|
||||
if (is_readable($item)) {
|
||||
unlink($item);
|
||||
}
|
||||
if (is_readable($item)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'message' => 'item was not deleted'
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'result' => true
|
||||
);
|
||||
}
|
||||
|
||||
function copyFile($dir, $target_dir, $filename) {
|
||||
// todo: checks
|
||||
// todo: vesta method "create file"
|
||||
if (empty($dir)) {
|
||||
$dir = $this->ROOT_DIR;
|
||||
}
|
||||
|
||||
if (empty($target_dir)) {
|
||||
$target_dir = $this->ROOT_DIR;
|
||||
}
|
||||
copy($dir . '/' . $filename, $target_dir.'/'.$filename);
|
||||
|
||||
if (!is_readable($target_dir . '/' .$filename)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'message' => 'item was not created'
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'result' => true,
|
||||
'bla' => $target_dir.'/'.$filename,
|
||||
'bla2' => $dir . '/' . $filename
|
||||
);
|
||||
}
|
||||
|
||||
function createFile($dir, $filename) {
|
||||
// todo: checks
|
||||
// todo: vesta method "create file"
|
||||
if (empty($dir)) {
|
||||
$dir = $this->ROOT_DIR;
|
||||
}
|
||||
file_put_contents($dir . '/' . $filename, '');
|
||||
|
||||
if (!is_readable($dir . '/' .$filename)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'message' => 'item was not created'
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'result' => true
|
||||
);
|
||||
}
|
||||
|
||||
function renameItem($dir, $item, $target_name) {
|
||||
if (empty($dir)) {
|
||||
$dir = $this->ROOT_DIR;
|
||||
}
|
||||
if (is_readable($dir . '/' . $item)) {
|
||||
rename($dir . '/' . $item, $dir . '/' . $target_name);
|
||||
}
|
||||
if (!is_readable($dir . '/' .$target_name)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'message' => 'item was not renamed'
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'result' => true
|
||||
);
|
||||
}
|
||||
|
||||
function createDir($dir, $dirname) {
|
||||
// todo: checks
|
||||
// todo: vesta method "create file"
|
||||
if (empty($dir)) {
|
||||
$dir = $this->ROOT_DIR;
|
||||
}
|
||||
|
||||
mkdir($dir . '/' . $dirname);
|
||||
|
||||
if (!is_readable($dir . '/' .$dirname)) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'message' => 'item was not created'
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'result' => true
|
||||
);
|
||||
}
|
||||
|
||||
function getDirectoryListing($dir = '') {
|
||||
$dir = $this->formatFullPath($dir);
|
||||
exec (VESTA_CMD . "v-list-fs-directory {$this->user} {$dir}", $output, $return_var);
|
||||
|
||||
return $this->parseListing($output);
|
||||
}
|
||||
|
||||
public function ls($dir = '') {
|
||||
$listing = $this->getDirectoryListing($dir);
|
||||
|
||||
return $data = array(
|
||||
'result' => true,
|
||||
'listing' => $listing
|
||||
);
|
||||
}
|
||||
|
||||
public function open_file($dir = '') {
|
||||
$listing = $this->getDirectoryListing($dir);
|
||||
|
||||
return $data = array(
|
||||
'result' => true,
|
||||
'listing' => $listing
|
||||
);
|
||||
}
|
||||
|
||||
public function parseListing($raw) {
|
||||
$data = array();
|
||||
foreach ($raw as $o) {
|
||||
$info = explode($this->delimeter, $o);
|
||||
$data[] = array(
|
||||
'type' => $info[$this->info_positions['TYPE']],
|
||||
'permissions' => $info[$this->info_positions['PERMISSIONS']],
|
||||
'date' => $info[$this->info_positions['DATE']],
|
||||
'time' => $info[$this->info_positions['TIME']],
|
||||
'owner' => $info[$this->info_positions['OWNER']],
|
||||
'group' => $info[$this->info_positions['GROUP']],
|
||||
'size' => $info[$this->info_positions['SIZE']],
|
||||
'name' => $info[$this->info_positions['NAME']]
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
15
web/file_manager/index.php
Normal file
15
web/file_manager/index.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/*
|
||||
* jQuery File Upload Plugin PHP Example 5.14
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
require('UploadHandler.php');
|
||||
$upload_handler = new UploadHandler();
|
25
web/file_manager/upload_file.php
Normal file
25
web/file_manager/upload_file.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
// Define a destination
|
||||
$targetFolder = '/home/admin/'; // 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.';
|
||||
// }
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue