--- LOS Bestand ---
[code]
<html>
<head>
<title>Weergave plaatjes en bestanden</title>
</head>
<body>
<?php

// Benodigde variabelen
$image_types = array("jpg","gif","bmp","png","jpeg");
$mappen_reeks = "";
$plaatjes_reeks = "";
$overige_reeks = "";

if (!empty($_GET['mapnaam']))
{
	$mapnaam = $_GET['mapnaam'];
}
else
{
	$mapnaam = "/";
};

// Voorkom dat mensen 'boven' de huidige map kunnen kijken.
if ( ereg('..',$mapnaam) || ereg('//',$mapnaam) )
{
	$mapnaam = "/";
};

// Map inhoud ophalen en tonen
$map = opendir(".{$mapnaam}");
while (false!==($bestand = readdir($map))) {
	if ($bestand != "." && $bestand != "..") {
		// Wat is de extensie?
		$ext = explode('.',$bestand);
		$extl = sizeof($ext) - 1;
		$ext = strtolower($ext[$extl]);

		if ( !ereg('.',$bestand) )
		{
			// Gaat om een map
			$mappen_reeks .= "<a href=\"index.php?mapnaam={$mapnaam}{$bestand}/\">{$bestand}</a><br />";
		}
		elseif ( in_array($ext,$image_types) )
		{
			// Plaatje
			$plaatjes_reeks .= "<img src=\".{$mapnaam}{$bestand}\" alt=\"Plaatje\" /><br />\n";
		}
		else
		{
			// Overig
			$overig_reeks .= "<a href=\".{$mapnaam}/{$bestand}\">{$bestand}</a><br />";
		}
    }
}

if ( $mappen_reeks != "" )
{
	echo ("<h1>Mappen</h1>");
	echo ($mappen_reeks);
}

if ( $plaatjes_reeks != "" )
{
	echo ("<h1>Plaatjes</h1>");
	echo ($plaatjes_reeks);
}

if ( $overig_reeks != "" )
{
	echo ("<h1>Overig</h1>");
	echo ($overig_reeks);
}
closedir($map);
?>
</body>
</html>
[/code]
--- Functie ---
<?php

function inhoud_weergave($mapnaam)
{

// Benodigde variabelen
$image_types = array('jpg','gif','bmp','png','jpeg');
$namen = '';
$map_aantal = 0;
$plaatje_aantal = 0;
$overig_aantal = 0;

// Voorkom dat mensen 'boven' de huidige map kunnen kijken.
if ( empty($mapnaam) || strstr($mapnaam,'..') || strstr($mapnaam,'//') )
{
	$mapnaam = '/';
};

// Map inhoud ophalen en tonen
$map = opendir(".{$mapnaam}");
while (false!==($bestand = readdir($map))) {
	if ($bestand != "." && $bestand != "..") {
		// Wat is de extensie?
		$ext = explode('.',$bestand);
		$extl = sizeof($ext) - 1;
		$ext = strtolower($ext[$extl]);

		if ( is_dir($bestand) )
		{
			// Gaat om een map
			$namen['map'][$map_aantal] = $bestand;
			$map_aantal++;
		}
		elseif ( in_array($ext,$image_types) )
		{
			// Plaatje
			$namen['plaatje'][$plaatje_aantal] = $bestand;
			$plaatje_aantal++;
		}
		else
		{
			// Overig
			$namen['overig'][$overig_aantal] = $bestand;
			$overig_aantal++;
		}
	}
}
closedir($map);
sort($namen['map']);
sort($namen['plaatje']);
sort($namen['overig']); 
return $namen;
}
?>