Hoe te beginnen met een FileBrowser?
Hopelijk kunnen jullie me helpen.
Dit is mijn code zonder str_replace:
Code (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
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
function showFiles($scan) {
foreach ($scan as $files) {
if (is_dir($_GET['url'] . '\\' . $files)) {
print_r('<strong><a href="index.php?url=' . realpath($_GET['url']) . '\\' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
function showIndex($scan) {
foreach ($scan as $files) {
if (is_dir($files)) {
print_r('<strong><a href="index.php?url=' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
if (isset($_GET['url'])) {
if (is_dir($_GET['url'])) {
$scan = scandir($_GET['url']);
showFiles($scan);
} elseif (is_file($_GET['url'])) {
} else {
echo 'Dit bestand bestaat niet!';
}
} else {
$scan = scandir(getcwd());
showIndex($scan);
}
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
function showFiles($scan) {
foreach ($scan as $files) {
if (is_dir($_GET['url'] . '\\' . $files)) {
print_r('<strong><a href="index.php?url=' . realpath($_GET['url']) . '\\' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
function showIndex($scan) {
foreach ($scan as $files) {
if (is_dir($files)) {
print_r('<strong><a href="index.php?url=' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
if (isset($_GET['url'])) {
if (is_dir($_GET['url'])) {
$scan = scandir($_GET['url']);
showFiles($scan);
} elseif (is_file($_GET['url'])) {
} else {
echo 'Dit bestand bestaat niet!';
}
} else {
$scan = scandir(getcwd());
showIndex($scan);
}
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>
</body>
</html>
Dit is mijn code met str_replace: (Tussen de QQ...QQ Is wat erbij is gekomen(En dat is er niet bij gekomen in mijn code^^))
Code (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
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
function showFiles($scan) {
QQstr_replace('\\', '/', getcwd());QQ
foreach ($scan as $files) {
if (is_dir($_GET['url'] . '\\' . $files)) {
print_r('<strong><a href="index.php?url=' . realpath($_GET['url']) . '\\' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
function showIndex($scan) {
foreach ($scan as $files) {
if (is_dir($files)) {
print_r('<strong><a href="index.php?url=' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
if (isset($_GET['url'])) {
if (is_dir($_GET['url'])) {
$scan = scandir($_GET['url']);
showFiles($scan);
} elseif (is_file($_GET['url'])) {
} else {
echo 'Dit bestand bestaat niet!';
}
} else {
$scan = scandir(getcwd());
showIndex($scan);
}
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
function showFiles($scan) {
QQstr_replace('\\', '/', getcwd());QQ
foreach ($scan as $files) {
if (is_dir($_GET['url'] . '\\' . $files)) {
print_r('<strong><a href="index.php?url=' . realpath($_GET['url']) . '\\' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
function showIndex($scan) {
foreach ($scan as $files) {
if (is_dir($files)) {
print_r('<strong><a href="index.php?url=' . $files . '">' . $files . '</a></strong><br>');
} else {
print_r($files . '<br>');
}
}
}
if (isset($_GET['url'])) {
if (is_dir($_GET['url'])) {
$scan = scandir($_GET['url']);
showFiles($scan);
} elseif (is_file($_GET['url'])) {
} else {
echo 'Dit bestand bestaat niet!';
}
} else {
$scan = scandir(getcwd());
showIndex($scan);
}
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>
</body>
</html>
Toevoeging op 31/03/2014 13:19:11:
Op internet staan velschillende dingen en heb het ook wel geprobeerd maar dat werkt allemaal ook niet:(
Gewijzigd op 31/03/2014 13:05:11 door Mathieu Posthumus
Wat wil je precies dan? Mooie urls?
Snelle Jaap op 01/04/2014 11:07:09:
Wat wil je precies dan? Mooie urls?
Nou wel beter maar ze mogen maar tot een bepaald bestand bekijken want nu kunnen ze me hele schijf bekijken.
Is geen 1 april grap toch :P?
Stel je basedir gewoon goed in in php.ini.
- Aar - op 02/04/2014 15:29:29:
Stel je basedir gewoon goed in in php.ini.
Dankje Aar!