Most people simply use MySQL to create sitemaps, doing it manually.
Exposing files is unsafe, but you can add some security.
<?php function files($dir=".") { $blacklist = array(str_replace("/","",$_SERVER['SCRIPT_NAME']), 'admin.php', 'users.txt', 'secret.txt'); $return = array(); $glob1 = glob($dir."/*"); for($i=0;$i<=count($glob1)-1;$i++) { $item = $glob1[$i]; $nodir = str_replace($dir, "", $item); if(is_dir($item)) { $file1 = explode('/', $item); $file = $file1[count($file1)-1]; $merge = array_merge($return, files($item)); if(!in_array($file, $blacklist) and !empty($nodir)) $return = $merge; } else { $file1 = explode('/', $item); $file = $file1[count($file1)-1]; if(!in_array($file, $blacklist) and !empty($nodir)) $return[] = str_replace("./","",$item); } } return $return; }
source share