Skip to content

Commit d207b7a

Browse files
committed
FM changes
1 parent f064c09 commit d207b7a

File tree

9 files changed

+116
-135
lines changed

9 files changed

+116
-135
lines changed

web/download/file/index.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?php
2+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
3+
4+
$user = $_SESSION['user'];
5+
if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
6+
$user=$_SESSION['look'];
7+
}
8+
29
if (!empty($_REQUEST['path'])) {
310
$path = $_REQUEST['path'];
4-
if (is_readable($path)) {
5-
header("Content-disposition: attachment;filename=".basename($path));
6-
readfile($path);
7-
exit;
8-
}
11+
header("Content-type: application/octet-stream");
12+
header("Content-Transfer-Encoding: binary");
13+
header("Content-disposition: attachment;filename=".basename($path));
14+
passthru (VESTA_CMD . "v-open-fs-file " . $user . " " . escapeshellarg($path));
15+
exit;
916
}
1017
else {
1118
die('File not found');

web/edit/file/index.php

Lines changed: 42 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
<?php
2-
session_start();
32

43
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
5-
64
$user = $_SESSION['user'];
7-
/*
8-
if (empty($panel)) {
9-
$command = VESTA_CMD."v-list-user '".$user."' 'json'";
10-
exec ($command, $output, $return_var);
11-
if ( $return_var > 0 ) {
12-
header("Location: /error/");
13-
exit;
14-
}
15-
$panel = json_decode(implode('', $output), true);
16-
}
17-
*/
18-
19-
20-
21-
/*
22-
// Check user session
23-
if ((!isset($_SESSION['user'])) && (!defined('NO_AUTH_REQUIRED'))) {
24-
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
25-
header("Location: /login/");
26-
exit;
27-
}
28-
*/
295

306
// Check module activation
317
if (!$_SESSION['FILEMANAGER_KEY']) {
@@ -34,6 +10,11 @@
3410
exit;
3511
}
3612

13+
// Check login_as feature
14+
if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
15+
$user=$_SESSION['look'];
16+
}
17+
3718

3819
?>
3920

@@ -55,66 +36,46 @@
5536
if (!empty($_REQUEST['path'])) {
5637
$content = '';
5738
$path = $_REQUEST['path'];
58-
if (is_readable($path)) {
59-
$image = getimagesize($path) ? true : false;
60-
61-
if ($image) {
62-
header('Location: /view/file/?path='.$path);
63-
exit;
64-
}
65-
66-
if (!empty($_POST['save'])) {
67-
$fn = tempnam ('/tmp', 'vst-save-file-');
68-
if ($fn) {
69-
$f = fopen ($fn, 'w+');
70-
fwrite($f, $_POST['contents']);
71-
fclose($f);
72-
73-
chmod($fn, 0644);
74-
75-
if ($f) {
76-
//copy($fn, $path);
77-
exec (VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}", $output, $return_var);
78-
79-
$error = check_return_code($return_var, $output);
80-
if ($return_var != 0) {
81-
/*var_dump(VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}");
82-
var_dump($path);
83-
var_dump($output);*/
84-
die('<p style="color: white">Error while saving file</p>');//echo '0';
85-
}
39+
if (!empty($_POST['save'])) {
40+
$fn = tempnam ('/tmp', 'vst-save-file-');
41+
if ($fn) {
42+
$contents = $_POST['contents'];
43+
$contents = preg_replace("/\r/", "", $contents);
44+
$f = fopen ($fn, 'w+');
45+
fwrite($f, $contents);
46+
fclose($f);
47+
chmod($fn, 0644);
48+
49+
if ($f) {
50+
exec (VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}", $output, $return_var);
51+
$error = check_return_code($return_var, $output);
52+
if ($return_var != 0) {
53+
print('<p style="color: white">Error while saving file</p>');
54+
exit;
8655
}
87-
unlink($fn);
8856
}
57+
unlink($fn);
8958
}
90-
91-
// $content = file_get_contents($path);
92-
// v-open-fs-file
93-
94-
95-
//print file_get_contents($path);
96-
exec (VESTA_CMD . "v-check-fs-permission {$user} {$path}", $content, $return_var);
59+
}
9760

98-
if ($return_var != 0) {
99-
print 'Error while opening file'; // todo: handle this more styled
100-
exit;
101-
}
61+
exec (VESTA_CMD . "v-check-fs-permission {$user} '{$path}'", $content, $return_var);
62+
if ($return_var != 0) {
63+
var_dump($return_var);
64+
var_dump($content);
65+
exit;
66+
print 'Error while opening file'; // todo: handle this more styled
67+
exit;
68+
}
10269

103-
104-
/*exec (VESTA_CMD . "v-open-fs-file {$user} {$path}", $content, $return_var);
105-
if ($return_var != 0) {
106-
print 'Error while opening file'; // todo: handle this more styled
107-
exit;
108-
}
109-
110-
$content = implode("\n", $content);*/
111-
$content = file_get_contents($path);
70+
exec (VESTA_CMD . "v-open-fs-file {$user} {$path}", $content, $return_var);
71+
if ($return_var != 0) {
72+
print 'Error while opening file'; // todo: handle this more styled
73+
exit;
11274
}
113-
}
114-
else {
75+
$content = implode("\n", $content)."\n";
76+
} else {
11577
$content = '';
11678
}
117-
11879
?>
11980

12081
<form id="edit-file-form" method="post">
@@ -131,9 +92,11 @@
13192
$('.editor').ace({ theme: 'twilight', lang: 'ruby' });
13293

13394
var dcrt = $('#editor').data('ace');
134-
var editor = dcrt.editor.ace;
135-
editor.gotoLine(0);
136-
editor.focus();
95+
dcrt.editor.ace.getSession().setNewLineMode('unix');
96+
var aceInstance = dcrt.editor.ace;
97+
aceInstance.gotoLine(0);
98+
aceInstance.focus();
99+
137100

138101

139102
var makeBackup = function() {

web/file_manager/fm_core.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public function __construct($user) {
4444

4545
public function checkFileType($dir) {
4646
$dir = $this->formatFullPath($dir);
47-
4847
exec(VESTA_CMD . "v-get-fs-file-type {$this->user} {$dir}", $output, $return_var);
49-
5048
$error = self::check_return_code($return_var, $output);
5149
if (empty($error)) {
5250
return array(
@@ -76,12 +74,13 @@ public function formatFullPath($path_part = '') {
7674

7775
function deleteItem($dir, $item) {
7876
$dir = $this->formatFullPath($item);
79-
if (is_dir($item)) {
77+
//if (is_dir($item)) {
78+
//var_dump(VESTA_CMD . "v-delete-fs-directory {$this->user} {$dir}");die();
8079
exec (VESTA_CMD . "v-delete-fs-directory {$this->user} {$dir}", $output, $return_var);
81-
}
82-
else {
83-
exec (VESTA_CMD . "v-delete-fs-file {$this->user} {$dir}", $output, $return_var);
84-
}
80+
//}
81+
//else {
82+
// exec (VESTA_CMD . "v-delete-fs-file {$this->user} {$dir}", $output, $return_var);
83+
//}
8584

8685
$error = self::check_return_code($return_var, $output);
8786

@@ -189,8 +188,12 @@ function createFile($dir, $filename) {
189188
function packItem($item, $dir, $target_dir, $filename) {
190189
$item = $this->formatFullPath($item);
191190
$dst_item = $this->formatFullPath($target_dir);
192-
//print VESTA_CMD . "v-add-fs-archive {$this->user} {$item} {$dst_item}";die();
193-
exec (VESTA_CMD . "v-add-fs-archive {$this->user} {$item} {$dst_item}", $output, $return_var);
191+
192+
$dst_item = str_replace('.tar.gz', '', $dst_item);
193+
194+
//$item = str_replace($dir . '/', '', $item);
195+
//var_dump(VESTA_CMD . "v-add-fs-archive {$this->user} {$dst_item} {$item}");die();
196+
exec (VESTA_CMD . "v-add-fs-archive {$this->user} {$dst_item} {$item}", $output, $return_var);
194197

195198
$error = self::check_return_code($return_var, $output);
196199

web/js/file_manager.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ FM.showError = function(type, message) {
9999

100100
return;
101101
}
102+
103+
if (ref.find('.results').length > 0) {
104+
ref.find('.results').html(message);
105+
}
102106
}
103107
else {
104108
FM.popupClose();
@@ -750,7 +754,7 @@ FM.bulkOperation = function(ref) {
750754
}
751755

752756
FM.checkBulkStatus = function(bulkStatuses, acc) {
753-
var status = false;
757+
var status = true;
754758
var msg = '';
755759
if (bulkStatuses.length == acc.length) {
756760
$.each(bulkStatuses, function(i, o) {
@@ -759,18 +763,24 @@ FM.checkBulkStatus = function(bulkStatuses, acc) {
759763
}
760764
});
761765

762-
if (msg == '') {
763-
status = true;
766+
if (msg != '') {
767+
status = false;
764768
}
765769
}
766770

767771
if (status == true) {
768-
$('#popup .results').html(App.Constants.FM_DONE);
769-
$('.controls').html('<p class="ok" onClick="FM.bulkPopupClose();">'+App.Constants.FM_DONE+'</p>');
772+
//$('#popup .results').html(App.Constants.FM_DONE);
773+
//$('.controls').html('<p class="ok" onClick="FM.bulkPopupClose();">'+App.Constants.FM_DONE+'</p>');
774+
FM.popupClose();
775+
776+
var box = FM['TAB_' + tab];
777+
var tab = FM.getTabLetter(FM.CURRENT_TAB);
778+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
770779
}
771780
else {
772-
$('#popup .results').html(msg);
773-
$('.controls').html('<p class="ok" onClick="FM.bulkPopupClose();">'+App.Constants.FM_DONE+'</p>');
781+
$('#popup .results').show().html(msg);
782+
//$('.controls').html('<p class="ok" onClick="FM.bulkPopupClose();">'+App.Constants.FM_DONE+'</p>');
783+
$('#popup .ok').hide();
774784
}
775785
}
776786

@@ -1249,7 +1259,7 @@ FM.unpackItem = function() {
12491259

12501260
var tpl = Tpl.get('popup_unpack', 'FM');
12511261
tpl.set(':FILENAME', src.name);
1252-
tpl.set(':DST_DIRNAME', (dst + '/' + src.name).replace('//', '/'));
1262+
tpl.set(':DST_DIRNAME', (dst).replace('//', '/'));
12531263
FM.popupOpen(tpl.finalize());
12541264
}
12551265

web/js/templates.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ App.Templates.html = {
4646
</div>'],
4747
popup_bulk_remove: ['<div class="confirm-box delete popup-box">\
4848
<div class="message">'+App.Constants.FM_CONFIRM_DELETE_BULK+' (~!:NUMBER_OF_ITEMS~!)?</div>\
49+
<div class="results"></div>\
4950
<div class="controls">\
5051
<p class="cancel" onClick="FM.popupClose();">'+App.Constants.FM_CANCEL+'</p>\
5152
<p class="ok" onClick="FM.bulkRemoveDo();">'+App.Constants.FM_DELETE+'</p>\
@@ -73,6 +74,7 @@ App.Templates.html = {
7374
</div>'],*/
7475
popup_delete: ['<div class="confirm-box delete popup-box">\
7576
<div class="message">'+App.Constants.FM_CONFIRM_DELETE+' <span class="title">"~!:FILENAME~!"</span>?</div>\
77+
<div class="warning warning-message"></div>\
7678
<div class="controls">\
7779
<p class="cancel" onClick="FM.popupClose();">'+App.Constants.FM_CANCEL+'</p>\
7880
<p class="ok" onClick="FM.confirmDelete();">'+App.Constants.FM_DELETE+'</p>\
@@ -84,6 +86,7 @@ App.Templates.html = {
8486
<input type="text" id="copy_dest" value="~!:DST_FILENAME~!" class="new-title">\
8587
</div>\
8688
<div class="message">'+App.Constants.FM_EXISTING_FILES_WILL_BE_REPLACED+'</div>\
89+
<div class="warning warning-message"></div>\
8790
<div class="controls">\
8891
<p class="cancel" onClick="FM.popupClose();">'+App.Constants.FM_CANCEL+'</p>\
8992
<p class="ok" onClick="FM.confirmCopyItems();">'+App.Constants.FM_COPY+'</p>\

web/list/directory/index.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
include($_SERVER['DOCUMENT_ROOT'] . "/inc/main.php");
44

55

6-
7-
86
if ((!isset($_SESSION['FILEMANAGER_KEY'])) || (empty($_SESSION['FILEMANAGER_KEY']))) {
97
header("Location: /filemanager-not-purchased/");
108
exit;
119
}
1210

13-
11+
// Check login_as feature
12+
if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
13+
$user=$_SESSION['look'];
14+
}
1415

1516
if (empty($panel)) {
1617
$command = VESTA_CMD."v-list-user '".$user."' 'json'";

web/templates/file_manager/main.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
<div class="menu menu-left menu-A">
2626
<?php $pre_tab = 'A';include($_SERVER['DOCUMENT_ROOT'].'/templates/file_manager/tab_menu.php'); ?>
2727
</div>
28-
<ul class="listing listing-left"></ul>
28+
<ul class="listing listing-left" onClick="FM.setTabActive('.listing-left');"></ul>
2929
</div>
3030

3131
<div class="window">
3232
<div class="pwd pwd-tab-B"></div>
3333
<div class="menu menu-right menu-B">
3434
<?php $pre_tab = 'B';include($_SERVER['DOCUMENT_ROOT'].'/templates/file_manager/tab_menu.php'); ?>
3535
</div>
36-
<ul class="listing listing-right"></ul>
36+
<ul class="listing listing-right" onClick="FM.setTabActive('.listing-right');"></ul>
3737
</div>
3838
</div>
3939

@@ -420,4 +420,4 @@
420420
});
421421
</script>
422422
</body>
423-
</html>
423+
</html>

0 commit comments

Comments
 (0)