Просмотр исходного кода

Remove file_manager folder from web.

Raphael Schneeberger 7 лет назад
Родитель
Сommit
5106d53ea8
4 измененных файлов с 0 добавлено и 510 удалено
  1. 0 1
      web/file_manager/files.php
  2. 0 133
      web/file_manager/fm_api.php
  3. 0 373
      web/file_manager/fm_core.php
  4. 0 3
      web/file_manager/index.php

+ 0 - 1
web/file_manager/files.php

@@ -1 +0,0 @@
-// absolete

+ 0 - 133
web/file_manager/fm_api.php

@@ -1,133 +0,0 @@
-<?php
-
-// Init
-//error_reporting(NULL);
-
-
-include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
-include($_SERVER['DOCUMENT_ROOT']."/file_manager/fm_core.php");
-
-
-// todo: set in session?
-if (empty($panel)) {
-    $command = HESTIA_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 'cd':
-        $dir = $_REQUEST['dir'];
-        print json_encode($fm->ls($dir));
-        break;
-
-    case 'check_file_type':
-        $dir = $_REQUEST['dir'];
-        print json_encode($fm->checkFileType($dir));
-        break;
-
-    case 'rename_file':
-        $dir = $_REQUEST['dir'];
-        $item = $dir . '/' . $_REQUEST['item'];
-        $target_name = $dir . '/' . $_REQUEST['target_name'];
-        print json_encode($fm->renameFile($item, $target_name));
-        break;
-
-    case 'rename_directory':
-        $dir = $_REQUEST['dir'];
-        $item = $dir.$_REQUEST['item'];
-        $target_name = $dir.$_REQUEST['target_name'];
-
-        print json_encode($fm->renameDirectory($item, $target_name));
-        break;
-
-    case 'move_file':
-        $item = $_REQUEST['item'];
-        $target_name = $_REQUEST['target_name'];
-        print json_encode($fm->renameFile($item, $target_name));
-        break;
-
-    case 'move_directory':
-        $item = $_REQUEST['item'];
-        $target_name = $_REQUEST['target_name'];
-        print json_encode($fm->renameDirectory($item, $target_name));
-        break;
-
-    case 'delete_files':
-        $dir = $_REQUEST['dir'];
-        $item = $_REQUEST['item'];
-        print json_encode($fm->deleteItem($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 'open_file':
-        $dir = $_REQUEST['dir'];
-        print json_encode($fm->open_file($dir));
-        break;
-
-    case 'copy_file':
-        $dir = $_REQUEST['dir'];
-        $target_dir = $_REQUEST['dir_target'];
-        $filename   = $_REQUEST['filename'];
-        $item       = $_REQUEST['item'];
-        print json_encode($fm->copyFile($item, $dir, $target_dir, $filename));
-        break;
-
-    case 'copy_directory':
-        $dir = $_REQUEST['dir'];
-        $target_dir = $_REQUEST['dir_target'];
-        $filename   = $_REQUEST['filename'];
-        $item       = $_REQUEST['item'];
-        print json_encode($fm->copyDirectory($item, $dir, $target_dir, $filename));
-        break;
-
-    case 'unpack_item':
-        $dir = $_REQUEST['dir'];
-        $target_dir = $_REQUEST['dir_target'];
-        $filename   = $_REQUEST['filename'];
-        $item       = $_REQUEST['item'];
-        print json_encode($fm->unpackItem($item, $dir, $target_dir, $filename));
-        break;
-
-    case 'pack_item':
-        $items      = $_REQUEST['items'];
-        $dst_item   = $_REQUEST['dst_item'];
-        print json_encode($fm->packItem($items, $dst_item));
-        break;
-
-    case 'backup':
-        $path = $_REQUEST['path'];
-        print json_encode($fm->backupItem($path));
-        break;
-
-    case 'chmod_item':
-        $dir = $_REQUEST['dir'];
-        $item = $_REQUEST['item'];
-        $permissions = $_REQUEST['permissions'];
-        print json_encode($fm->chmodItem($dir, $item, $permissions));
-        break;
-
-    default:
-        //print json_encode($fm->init());
-        break;
-}

+ 0 - 373
web/file_manager/fm_core.php

@@ -1,373 +0,0 @@
-<?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 checkFileType($dir) {
-        $dir = $this->formatFullPath($dir);
-
-        exec(HESTIA_CMD . "v-get-fs-file-type {$this->user} {$dir}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-        if (empty($error)) {
-            return array(
-                'result' => true,
-                'data'   => implode('', $output)
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    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();
-        //$path = str_replace(' ', '\ ', $path);
-        return escapeshellarg($path);
-    }
-
-    function deleteItem($dir, $item) {
-        $dir = $this->formatFullPath($item);
-        exec (HESTIA_CMD . "v-delete-fs-directory {$this->user} {$dir}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function copyFile($item, $dir, $target_dir, $filename) {
-        $src = $this->formatFullPath($item);
-        $dst = $this->formatFullPath($target_dir);
-
-        exec (HESTIA_CMD . "v-copy-fs-file {$this->user} {$src} {$dst}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function copyDirectory($item, $dir, $target_dir, $filename) {
-        $src = $this->formatFullPath($item);
-        $dst = $this->formatFullPath($target_dir);
-
-        exec (HESTIA_CMD . "v-copy-fs-directory {$this->user} {$src} {$dst}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    static function check_return_code($return_var, $output) {
-        if ($return_var != 0) {
-            $error = implode('<br>', $output);
-            return $error;
-        }
-
-        return null;
-    }
-
-    function createFile($dir, $filename) {
-        $dir = $this->formatFullPath($dir . '/' . $filename);
-
-        exec (HESTIA_CMD . "v-add-fs-file {$this->user} {$dir}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function packItem($items, $dst_item) {
-	$items_arr = explode(',', $items);
-	foreach($items_arr as $key => $item){
-	    $items_arr[$key] = $this->formatFullPath($item);
-	}
-	$items = implode(' ', $items_arr);
-
-        $dst_item = $this->formatFullPath($dst_item);
-
-        exec (HESTIA_CMD . "v-add-fs-archive {$this->user} {$dst_item} {$items}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function backupItem($item) {
-        $src_item     = $this->formatFullPath($item);
-
-        $dst_item_name = $item . '~' . date('Ymd_His');
-
-        $dst_item = $this->formatFullPath($dst_item_name);
-
-        exec (HESTIA_CMD . "v-copy-fs-file {$this->user} {$src_item} {$dst_item}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result'   => true,
-                'filename' => $dst_item_name
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function unpackItem($item, $dir, $target_dir, $filename) {
-        $item     = $this->formatFullPath($item);
-        $dst_item = $this->formatFullPath($target_dir);
-
-        exec (HESTIA_CMD . "v-extract-fs-archive {$this->user} {$item} {$dst_item}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function renameFile($item, $target_name) {
-        $item     = $this->formatFullPath($item);
-        $dst_item = $this->formatFullPath($target_name);
-
-        exec (HESTIA_CMD . "v-move-fs-file {$this->user} {$item} {$dst_item}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function renameDirectory($item, $target_name) {
-        $item     = $this->formatFullPath($item);
-        $dst_item = $this->formatFullPath($target_name);
-
-        if ($item == $dst_item) {
-            return array(
-                'result' => true
-            );
-        }
-
-        exec (HESTIA_CMD . "v-move-fs-directory {$this->user} {$item} {$dst_item}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function createDir($dir, $dirname) {
-        $dir = $this->formatFullPath($dir . '/' . $dirname);
-
-        exec (HESTIA_CMD . "v-add-fs-directory {$this->user} {$dir}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function chmodItem($dir, $item, $permissions) {
-        $item       = $this->formatFullPath($dir . $item);
-        $permissions = escapeshellarg($permissions);
-
-        exec (HESTIA_CMD . "v-change-fs-file-permission {$this->user} {$item} {$permissions}", $output, $return_var);
-
-        $error = self::check_return_code($return_var, $output);
-
-        if (empty($error)) {
-            return array(
-                'result' => true
-            );
-        }
-        else {
-            return array(
-                'result'   => false,
-                'message'  => $error
-            );
-        }
-    }
-
-    function getDirectoryListing($dir = '') {
-        $dir = $this->formatFullPath($dir);
-
-        exec (HESTIA_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'   => str_pad($info[$this->info_positions['PERMISSIONS']], 3, "0", STR_PAD_LEFT),
-                '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'          => htmlspecialchars($info[$this->info_positions['NAME']], ENT_QUOTES)
-            );
-        }
-
-        return $data;
-    }
-
-}

+ 0 - 3
web/file_manager/index.php

@@ -1,3 +0,0 @@
-<?php
-header("Location: /login/");
-exit;