Could probably better organize your if-statements. You don't really need the first two echos. Maybe something like,
if(!fnmatch("*.php", $file) and !fnmatch(".*", $file)) { $indfile = '' .$file. '/index.php'; ...