-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
119 lines (119 loc) · 5.67 KB
/
index.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<html dir="ltr" lang="en-US">
<head>
<title>fileManger</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<?php
if (isset($_GET['dir'])) {
$dir = $_GET['dir'];
} else {
$dir = "myComputer";
}
?>
<script>
function goBack(){ window.history.back(); }
function goForward(){ window.history.forward(); }
function makeDir() {
var dirName = prompt("please enter your folder name:");
if (dirName === '') {
dirName = 'newFolder';
}
window.location = "mkdir.php?dir=<?php echo $dir; ?>&dirName=" + dirName;
}
function makefile(){
var filename = prompt("please enter your file name");
if(filename == ''){
filename = 'newfile';
}
window.location = "makefile.php?dir=<?php echo $dir; ?>&fileName=" + filename;
}
function copyfile(filename) {
var copypath = prompt("please enter your path to copy:");
if (copypath === '') {
copypath = '<?php echo $dir; ?>';
}
window.location = "copyfile.php?dir=<?php echo $dir; ?>&fileName=" + filename + "&path=" + copypath;
}
function renamefile(filename) {
var newName = prompt("please enter new name:");
if (newName === '') {
alert('please fill new file name');
} else {
window.location = "rename.php?dir=<?php echo $dir; ?>&fileName=" + filename + "&newName=" + newName;
}
}
function deletefile(filename) {
if (window.confirm("Do you want to delete file?")) {
window.location = "deletefile.php?dir=<?php echo $dir; ?>&fileName=" + filename;
}
}
function copydir(dirname) {
var copypath = prompt("please enter the copy path");
if (copypath === '') {
alert("please fill copy path");
} else {
window.location = "cpdir.php?dir=<?php echo $dir; ?>©path=" + copypath + "&dirName=" + dirname;
}
}
function deletedir(dirname) {
if (window.confirm("Do you want to delete directory")) {
window.location = "rmdir.php?dir=<?php echo $dir; ?>&dirName=" + dirname;
}
}
</script>
</head>
<body>
<a href="<?php echo (dirname($dir) !== '.') ? "?dir=" . dirname($dir) : '#'; ?>" title="parent directory">
<div class="file fa fa-reply"></div>
</a>
<a href="" onclick="goBack()" title="backWard">
<div class="file fa fa-arrow-left"></div>
</a>
<a href="" onclick="goForward()" title="forWard">
<div class="file fa fa-arrow-right"></div>
</a>
<a href="#" title="make directory" onclick="makeDir()" >
<div class="file fa fa-plus-circle"></div>
</a>
<a href="#" title="make file" onclick="makefile()" >
<div class="file fa fa-plus"></div>
</a>
<form action="uploadfile.php?dir=<?php echo $dir; ?>" method="post" enctype="multipart/form-data">
<input type="file" name="uploaded_file" >
<input type="submit" name="upload_file" value="upload">
</form>
<?php
$filelist = glob($dir . '/*');
foreach ($filelist as $file) {
$filetype = filetype($file);
if ($filetype == 'file') {
?>
<div class="container-file">
<a href="#" title="" >
<div class="file fa fa-file-text-o"></div>
<span class="fname"><?php echo basename($file); ?></span>
</a>
<a href="#" class="file-action cfile" title="copy file" onclick="copyfile('<?php echo basename($file); ?>')"><i class="fa fa-copy"></i></a>
<a href="#" class="file-action rfile" title="rename file" onclick="renamefile('<?php echo basename($file); ?>')"><i class="fa fa-pencil-square"></i></a>
<a href="#" class="file-action dfile" title="delete file" onclick="deletefile('<?php echo basename($file); ?>')"><i class="fa fa-trash"></i></a>
</div><!--.container-file-->
<?php
} elseif ($filetype == 'dir') {
?>
<div class="container-file">
<a href="?dir=<?php echo $file ?>" title="" >
<div class="file fa fa-folder-o"></div>
<span><?php echo basename($file); ?></span>
</a>
<a href="#" class="file-action cfile" title="copy directory" onclick="copydir('<?php echo basename($file); ?>')"><i class="fa fa-copy"></i></a>
<a href="#" class="file-action rfile" title="rename directory" onclick="renamefile('<?php echo basename($file); ?>')"><i class="fa fa-pencil-square"></i></a>
<a href="#" class="file-action dfile" title="delete directory" onclick="deletedir('<?php echo basename($file); ?>')"><i class="fa fa-trash"></i></a>
</div><!--.container-file-->
<?php
}
}
?>
</body>
</html>