-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax.php
More file actions
executable file
·55 lines (50 loc) · 1.3 KB
/
ajax.php
File metadata and controls
executable file
·55 lines (50 loc) · 1.3 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
<?php
function goBack($string) {
$a = explode('/',$string);
$s = "";
for($i=0;$i<(count($a)-2);$i++) {
$s.=$a[$i];
$s.='/';
}
return $s;
}
if(isset($_POST['goto'])) {
$path = $_POST['path'];
$string = $_POST['string'];
if($string!="back") {
$path = $path.$string;
} else {
$path = goBack($path);
}
$pfiles = array('.','..','.DS_Store');
if ($files = scandir($path)) {
if($path!="../") {
echo '<a onclick="goTo(\'back\',\''.$path.'\')">'.'Back'."</a><br>\n";
}
echo "Directory: ".basename(realpath($path))."<br>\n";
echo "Total Path: ".$path."<br>\n";
//echo "Real Directory: ".$path."<br>\n";
foreach($files as $f) {
if(!in_array($f,$pfiles)) {
if(is_file($path.$f)) {
echo '<a href="" class="file" onclick="openFile(\''.$path.''.$f.'\')">'.$f."</a>\n";
} else if(is_dir($path.$f)) {
echo '<a href="" class="dir" onclick="goTo(\''.$f.'/\',\''.$path.'\')">'.$f."</a>\n";
}
}
}
}
} else if(isset($_POST['pullfile'])) {
$path = $_POST['path'];
if(strrpos($path,'/')!=(strlen($path)-1)) {
$path .= '/';
}
stripslashes(readfile($_POST['path']));
} else if(isset($_POST['savefile'])) {
$myFile = $_POST['path'];
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, stripslashes($_POST['text']));
fclose($fh);
echo "success";
}
?>