-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
69 lines (57 loc) · 1.41 KB
/
index.php
File metadata and controls
69 lines (57 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<script type="text/javascript" src="/jquery.js"></script>
</head>
<style>
#editor {
border: 1px solid #000;
width: 800px;
height: 400px;
}
</style>
<script>
var curfile = '';
function updateFileContents(fname, contents) {
$.post("/write.php", {fname: fname, contents: contents}, function(data) {
console.log(data);
})
}
function getFileContents(el) {
$.post("/read.php", {fname: el}, function(data) {
$('#editor').val(data);
curfile = el;
})
}
function getDirContents(el) {
$.post("/list.php", {path: el}, function(data) {
j = eval(data);
blah = ''
for (i=0; i<j.length; i++) {
if (j[i].dir) {
blah += "<a onclick=\"getDirContents('/" + el + "/" + j[i].path + "'); return false;\">"+ j[i].path + "</a><br/>";
} else {
blah += "<a onclick=\"getFileContents('/" + el + "/" + j[i].path + "'); return false;\">"+ j[i].path + "</a><br/>";
}
}
$('#fbrowser').html(blah);
})
}
</script>
<div id='fbrowser'>
<?php
$dir = "/";
$files = scandir($dir);
foreach ($files as &$value) {
$abs = $dir . '/' . $value;
if (is_dir($abs)) {
echo "<a onclick=\"getDirContents('/$abs'); return false;\">$abs</a><br/>\n";
} else {
echo "<a onclick=\"getFileContents('$abs'); return false;\">$abs</a><br/>\n";
}
}
?>
</div>
<textarea id='editor'>
</textarea>
<input type='button' value='Update' onclick='updateFileContents(curfile, $("#editor").val()); return false;'>
</html>