Skip to content

Commit 9db728e

Browse files
committed
filemanager stuff
1 parent 6a7b3d6 commit 9db728e

File tree

15 files changed

+1883
-486
lines changed

15 files changed

+1883
-486
lines changed

web/autoescape.gif

-14.8 KB
Binary file not shown.

web/css/file_manager.css

Lines changed: 199 additions & 36 deletions
Large diffs are not rendered by default.

web/download/file/index.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
if (!empty($_REQUEST['path'])) {
3+
$path = $_REQUEST['path'];
4+
if (is_readable($path)) {
5+
header("Content-disposition: attachment;filename=".basename($path));
6+
readfile($path);
7+
exit;
8+
}
9+
}
10+
else {
11+
die('File not found');
12+
}
13+
14+
15+
?>

web/edit/file/index.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
session_start();
3+
4+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
5+
/*
6+
// Check user session
7+
if ((!isset($_SESSION['user'])) && (!defined('NO_AUTH_REQUIRED'))) {
8+
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
9+
header("Location: /login/");
10+
exit;
11+
}
12+
*/
13+
14+
?>
15+
16+
<title>Edit file <?= htmlspecialchars($_REQUEST['path']) ?></title>
17+
<meta charset="utf-8" />
18+
19+
<link href="/css/file_manager_editor.css" type="text/css" rel="stylesheet">
20+
<script src="/js/cheef-editor/jquery/jquery-1.8.3.min.js"></script>
21+
<script src="/js/cheef-editor/ace/ace.js"></script>
22+
<script src="/js/cheef-editor/ace/theme-twilight.js"></script>
23+
<script src="/js/cheef-editor/ace/mode-ruby.js"></script>
24+
<script src="/js/cheef-editor/jquery-ace.min.js"></script>
25+
26+
<?php
27+
28+
if (!empty($_REQUEST['path'])) {
29+
$content = '';
30+
$path = $_REQUEST['path'];
31+
if (is_readable($path)) {
32+
33+
$image = getimagesize($path) ? true : false;
34+
35+
if ($image) {
36+
header('Location: /view/file/?path='.$path);
37+
exit;
38+
}
39+
40+
if (!empty($_POST['save'])) {
41+
$fn = tempnam ('/tmp', 'vst-save-file-');
42+
if ($fn) {
43+
$f = fopen ($fn, 'w+');
44+
fwrite($f, $_POST['contents']);
45+
if ($f) {
46+
copy($fn, $path);
47+
}
48+
unlink($fn);
49+
}
50+
}
51+
52+
$content = file_get_contents($path);
53+
$content = $content;
54+
}
55+
}
56+
else {
57+
$content = '';
58+
}
59+
60+
?>
61+
62+
<form method="post">
63+
<input type="submit" name="save" value="Save" class="save" />
64+
65+
66+
<textarea name="contents" class="editor" id="editor" rows="4" style="display:none;width: 100%; height: 100%;"><?php echo $content ?></textarea>
67+
68+
</form>
69+
<script>
70+
$('.editor').ace({ theme: 'twilight', lang: 'ruby' });
71+
72+
var dcrt = $('#editor').data('ace');
73+
var editor = dcrt.editor.ace;
74+
editor.gotoLine(0);
75+
editor.focus();
76+
</script>

web/file_manager/fm_api.php

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,29 @@
2727
$_REQUEST['action'] = empty($_REQUEST['action']) ? '' : $_REQUEST['action'];
2828

2929
switch ($_REQUEST['action']) {
30+
case 'cd':
31+
$dir = $_REQUEST['dir'];
32+
print json_encode($fm->ls($dir));
33+
break;
3034
case 'rename_file':
3135
$dir = $_REQUEST['dir'];
3236
$item = $_REQUEST['item'];
3337
$target_name = $_REQUEST['target_name'];
3438

35-
print json_encode($fm->renameItem($dir, $item, $target_name));
39+
print json_encode($fm->renameFile($dir, $item, $target_name));
40+
break;
41+
case 'rename_directory':
42+
$dir = $_REQUEST['dir'];
43+
$item = $_REQUEST['item'];
44+
$target_name = $_REQUEST['target_name'];
45+
46+
print json_encode($fm->renameDirectory($dir, $item, $target_name));
3647
break;
3748
case 'delete_files':
3849
$dir = $_REQUEST['dir'];
3950
$item = $_REQUEST['item'];
4051

41-
print json_encode($fm->deleteItems($dir, $item));
52+
print json_encode($fm->deleteItem($dir, $item));
4253
break;
4354
case 'create_file':
4455
$dir = $_REQUEST['dir'];
@@ -50,19 +61,38 @@
5061
$dirname = $_REQUEST['dirname'];
5162
print json_encode($fm->createDir($dir, $dirname));
5263
break;
53-
case 'cd':
54-
$dir = $_REQUEST['dir'];
55-
print json_encode($fm->ls($dir));
56-
break;
64+
5765
case 'open_file':
5866
$dir = $_REQUEST['dir'];
5967
print json_encode($fm->open_file($dir));
6068
break;
61-
case 'copy_files':
69+
case 'copy_file':
70+
$dir = $_REQUEST['dir'];
71+
$target_dir = $_REQUEST['dir_target'];
72+
$filename = $_REQUEST['filename'];
73+
$item = $_REQUEST['item'];
74+
print json_encode($fm->copyFile($item, $dir, $target_dir, $filename));
75+
break;
76+
case 'copy_directory':
77+
$dir = $_REQUEST['dir'];
78+
$target_dir = $_REQUEST['dir_target'];
79+
$filename = $_REQUEST['filename'];
80+
$item = $_REQUEST['item'];
81+
print json_encode($fm->copyDirectory($item, $dir, $target_dir, $filename));
82+
break;
83+
case 'unpack_item':
84+
$dir = $_REQUEST['dir'];
85+
$target_dir = $_REQUEST['dir_target'];
86+
$filename = $_REQUEST['filename'];
87+
$item = $_REQUEST['item'];
88+
print json_encode($fm->unpackItem($item, $dir, $target_dir, $filename));
89+
break;
90+
case 'pack_item':
6291
$dir = $_REQUEST['dir'];
6392
$target_dir = $_REQUEST['dir_target'];
6493
$filename = $_REQUEST['filename'];
65-
print json_encode($fm->copyFile($dir, $target_dir, $filename));
94+
$item = $_REQUEST['item'];
95+
print json_encode($fm->packItem($item, $dir, $target_dir, $filename));
6696
break;
6797
default:
6898
//print json_encode($fm->init());

0 commit comments

Comments
 (0)