-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
119 lines (94 loc) · 3.92 KB
/
index.php
File metadata and controls
119 lines (94 loc) · 3.92 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
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>
<title>Mijn filebrowser</title>
<link rel="stylesheet" type="text/css" href="filebrowser.css">
<div id="kader4">
<?php
echo '<div id="bestandinfo"><h2>Inhoud</h2>';
//Controleren welk bestand is aangeklikt.
$bestand = getcwd();
if (isset($_GET['bestand'])) {
$bestand = $_GET['bestand'];
//echo $bestand;
echo "Bestand: " . $bestand . '<br />';
} else {
echo 'Bestand: ' . "Er is nog geen bestand aangeklikt." . '<br />';
}
//Checkt hoe groot het bestand is.
if (isset($_GET['bestand'])) {
$bestandsnaam = $_GET['map'] . $_GET['bestand'];
echo 'Grootte: ' . human_filesize(filesize($bestandsnaam)) . '<br />';
} else {
echo 'Grootte: ' . 'Kan de grootte nog niet berekenen.' . '<br>';
}
function human_filesize($bytes, $decimals = 2) {
$size = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
//kijkt of het $bestand schrijfbaar is.
if (is_writable($bestand)) {
echo ("Schrijfbaar: Ja" . '<br />');
} else {
echo ("Schrijfbaar: Nee" . '<br />');
}
// echoed laatst aangepast.
setlocale(LC_ALL, 'nl_NL');
echo "Laatst aangepast: " . date("d F Y - H:i:s.", getlastmod());
echo '</div>';
?>
</div>
<div id="kader1">
<?php
$map = getcwd();
//echo $map;
//print_r($_GET);
if (isset($_GET['map'])) {
$map = $_GET['map'];
$map = realpath($map) . "/";
} else {
$map = getcwd() . "/";
}
//Om puntjes uit de URL te filteren:
$objecten = realpath($map);
$objecten = scandir($map);
echo "<pre>";
echo "</pre>";
echo '<h1><a href="index.php">Mappen/Bestanden</a></h1>';
foreach ($objecten as $object) {
if (is_file($map . $object)) {
echo 'D: <a href="index.php?map=' . $map . '&bestand=' . $object . '">' . $object . "</a><br />";
}
//punt verwijderen uit bestandsinhoud:
elseif ($object == "." || $object == ".." && $map == 'C:\xampp\htdocs\Filebrowser/') {
} else {
echo 'F: <a href="index.php?map=' . $map . $object . '/">' . $object . "</a><br />";
}
}
?></div>
<div id="kader2">
<?php
if (isset($_GET['bestand'])) {
$bestandsnaam = $_GET['map'] . $_GET['bestand'];
$opslaan = $_GET['bestand'];
//C: schijf/xampp/htdocs... verwijderen.
$bestandsnaam = str_replace(getcwd() . "\\", "", $bestandsnaam);
$bestandext = pathinfo($bestandsnaam . "", PATHINFO_EXTENSION);
if ($bestandext == "jpg" || $bestandext == "png" || $bestandext == "gif") {
echo '<img src="' . $bestandsnaam . '" width="200" height="200" >';
}
if ($bestandext == "php" || $bestandext == "css" || $bestandext == "txt") {
if (isset($_POST ["ash"])) {
file_put_contents($bestandsnaam, ($_POST['ash']));
}
$inhoudbestand = file_get_contents($bestandsnaam);
echo '<form method="post" action="index.php?map=' . $_GET['map'] . '&bestand=' . $opslaan . '">';
echo "<input id='Save' type='submit' value='Save'>";
echo "<textarea name='ash' rows='20' cols='119'>";
echo htmlentities($inhoudbestand);
echo "</textarea>";
echo '</form>';
}
}
?></div>
<div id="kader3"><h1><a href="index.php">Home ></a></h1></div>
</html>