$startdir = "[Startverzeichnis]";
$files = glob_recursive("*", GLOB_NOSORT|GLOB_MARK, $startdir);
sort($files);


$prev_level = -1;
for($i=0; $i<count($files); $i++) {
	$files[$i] = str_replace($startdir,"", $files[$i]);
	$curr_level = substr_count(substr($files[$i],0,-1),"/");
	$dir = (substr($files[$i],-1)=="/");
	if($prev_level<$curr_level) {
		echo "<ol>";
	} else if ($prev_level>$curr_level) {
		echo str_repeat("</ol></li>", $prev_level-$curr_level);
	}
	echo "<li>".$files[$i];
	if(!$dir) {
		echo "</li>";
	} else {
		echo "<ol>";
		$curr_level++;
	}
	$prev_level = $curr_level;
}
echo str_repeat("</ol></li>", $prev_level);
echo "</ol>";


function glob_recursive($pattern, $flags = 0, $startdir = ''){
	$files = glob($startdir.$pattern, $flags);
	foreach (glob($startdir.'*', GLOB_ONLYDIR|GLOB_NOSORT|GLOB_MARK) as $dir){
		$files = array_merge($files, glob_recursive($pattern, $flags, $dir));
	}
	return $files;
}