diff --git a/web/download/file/index.php b/web/download/file/index.php index 6065d0fc..97afa8f7 100644 --- a/web/download/file/index.php +++ b/web/download/file/index.php @@ -1,11 +1,18 @@ 0 ) { - header("Location: /error/"); - exit; - } - $panel = json_decode(implode('', $output), true); -} -*/ - - - -/* -// Check user session -if ((!isset($_SESSION['user'])) && (!defined('NO_AUTH_REQUIRED'))) { - $_SESSION['request_uri'] = $_SERVER['REQUEST_URI']; - header("Location: /login/"); - exit; -} -*/ // Check module activation if (!$_SESSION['FILEMANAGER_KEY']) { @@ -34,6 +10,11 @@ if (!$_SESSION['FILEMANAGER_KEY']) { exit; } +// Check login_as feature +if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) { + $user=$_SESSION['look']; +} + ?> @@ -55,66 +36,46 @@ if (!$_SESSION['FILEMANAGER_KEY']) { if (!empty($_REQUEST['path'])) { $content = ''; $path = $_REQUEST['path']; - if (is_readable($path)) { - $image = getimagesize($path) ? true : false; - - if ($image) { - header('Location: /view/file/?path='.$path); - exit; - } - - if (!empty($_POST['save'])) { - $fn = tempnam ('/tmp', 'vst-save-file-'); - if ($fn) { - $f = fopen ($fn, 'w+'); - fwrite($f, $_POST['contents']); - fclose($f); - - chmod($fn, 0644); - - if ($f) { - //copy($fn, $path); - exec (VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}", $output, $return_var); + if (!empty($_POST['save'])) { + $fn = tempnam ('/tmp', 'vst-save-file-'); + if ($fn) { + $contents = $_POST['contents']; + $contents = preg_replace("/\r/", "", $contents); + $f = fopen ($fn, 'w+'); + fwrite($f, $contents); + fclose($f); + chmod($fn, 0644); - $error = check_return_code($return_var, $output); - if ($return_var != 0) { - /*var_dump(VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}"); - var_dump($path); - var_dump($output);*/ - die('

Error while saving file

');//echo '0'; - } + if ($f) { + exec (VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}", $output, $return_var); + $error = check_return_code($return_var, $output); + if ($return_var != 0) { + print('

Error while saving file

'); + exit; } - unlink($fn); } + unlink($fn); } - - // $content = file_get_contents($path); - // v-open-fs-file - - - //print file_get_contents($path); - exec (VESTA_CMD . "v-check-fs-permission {$user} {$path}", $content, $return_var); - - if ($return_var != 0) { - print 'Error while opening file'; // todo: handle this more styled - exit; - } - - - /*exec (VESTA_CMD . "v-open-fs-file {$user} {$path}", $content, $return_var); - if ($return_var != 0) { - print 'Error while opening file'; // todo: handle this more styled - exit; - } - - $content = implode("\n", $content);*/ - $content = file_get_contents($path); } - } - else { + + exec (VESTA_CMD . "v-check-fs-permission {$user} '{$path}'", $content, $return_var); + if ($return_var != 0) { + var_dump($return_var); + var_dump($content); + exit; + print 'Error while opening file'; // todo: handle this more styled + exit; + } + + exec (VESTA_CMD . "v-open-fs-file {$user} {$path}", $content, $return_var); + if ($return_var != 0) { + print 'Error while opening file'; // todo: handle this more styled + exit; + } + $content = implode("\n", $content)."\n"; + } else { $content = ''; } - ?>
@@ -131,9 +92,11 @@ if (!$_SESSION['FILEMANAGER_KEY']) { $('.editor').ace({ theme: 'twilight', lang: 'ruby' }); var dcrt = $('#editor').data('ace'); - var editor = dcrt.editor.ace; - editor.gotoLine(0); - editor.focus(); + dcrt.editor.ace.getSession().setNewLineMode('unix'); + var aceInstance = dcrt.editor.ace; + aceInstance.gotoLine(0); + aceInstance.focus(); + var makeBackup = function() { diff --git a/web/file_manager/fm_core.php b/web/file_manager/fm_core.php index 1b3c09f9..9cf70e28 100644 --- a/web/file_manager/fm_core.php +++ b/web/file_manager/fm_core.php @@ -44,9 +44,7 @@ class FileManager { public function checkFileType($dir) { $dir = $this->formatFullPath($dir); - exec(VESTA_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( @@ -76,12 +74,13 @@ class FileManager { function deleteItem($dir, $item) { $dir = $this->formatFullPath($item); - if (is_dir($item)) { + //if (is_dir($item)) { + //var_dump(VESTA_CMD . "v-delete-fs-directory {$this->user} {$dir}");die(); exec (VESTA_CMD . "v-delete-fs-directory {$this->user} {$dir}", $output, $return_var); - } - else { - exec (VESTA_CMD . "v-delete-fs-file {$this->user} {$dir}", $output, $return_var); - } + //} + //else { + // exec (VESTA_CMD . "v-delete-fs-file {$this->user} {$dir}", $output, $return_var); + //} $error = self::check_return_code($return_var, $output); @@ -189,8 +188,12 @@ class FileManager { function packItem($item, $dir, $target_dir, $filename) { $item = $this->formatFullPath($item); $dst_item = $this->formatFullPath($target_dir); -//print VESTA_CMD . "v-add-fs-archive {$this->user} {$item} {$dst_item}";die(); - exec (VESTA_CMD . "v-add-fs-archive {$this->user} {$item} {$dst_item}", $output, $return_var); + + $dst_item = str_replace('.tar.gz', '', $dst_item); + + //$item = str_replace($dir . '/', '', $item); +//var_dump(VESTA_CMD . "v-add-fs-archive {$this->user} {$dst_item} {$item}");die(); + exec (VESTA_CMD . "v-add-fs-archive {$this->user} {$dst_item} {$item}", $output, $return_var); $error = self::check_return_code($return_var, $output); diff --git a/web/js/file_manager.js b/web/js/file_manager.js index cff3d041..c428851e 100644 --- a/web/js/file_manager.js +++ b/web/js/file_manager.js @@ -99,6 +99,10 @@ FM.showError = function(type, message) { return; } + + if (ref.find('.results').length > 0) { + ref.find('.results').html(message); + } } else { FM.popupClose(); @@ -750,7 +754,7 @@ FM.bulkOperation = function(ref) { } FM.checkBulkStatus = function(bulkStatuses, acc) { - var status = false; + var status = true; var msg = ''; if (bulkStatuses.length == acc.length) { $.each(bulkStatuses, function(i, o) { @@ -759,18 +763,24 @@ FM.checkBulkStatus = function(bulkStatuses, acc) { } }); - if (msg == '') { - status = true; + if (msg != '') { + status = false; } } if (status == true) { - $('#popup .results').html(App.Constants.FM_DONE); - $('.controls').html('

'+App.Constants.FM_DONE+'

'); + //$('#popup .results').html(App.Constants.FM_DONE); + //$('.controls').html('

'+App.Constants.FM_DONE+'

'); + FM.popupClose(); + + var box = FM['TAB_' + tab]; + var tab = FM.getTabLetter(FM.CURRENT_TAB); + FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box); } else { - $('#popup .results').html(msg); - $('.controls').html('

'+App.Constants.FM_DONE+'

'); + $('#popup .results').show().html(msg); + //$('.controls').html('

'+App.Constants.FM_DONE+'

'); + $('#popup .ok').hide(); } } @@ -1249,7 +1259,7 @@ FM.unpackItem = function() { var tpl = Tpl.get('popup_unpack', 'FM'); tpl.set(':FILENAME', src.name); - tpl.set(':DST_DIRNAME', (dst + '/' + src.name).replace('//', '/')); + tpl.set(':DST_DIRNAME', (dst).replace('//', '/')); FM.popupOpen(tpl.finalize()); } diff --git a/web/js/templates.js b/web/js/templates.js index 1a4b09cb..4ccc13de 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -46,6 +46,7 @@ App.Templates.html = { '], popup_bulk_remove: ['