如何为未链接且没有索引文件的HTML或PHP生成站点地图?

Say I have a directory with 100 files in it. Some of the files are PHP and the others are HTML. None of them are linked together. It's just a directory with the files and none of the files are linked, and there is no index file. It's a shared hosting cPanel environment. My question: Is there a way via PHP or otherwise to automatically detect these files and generate a sitemap in HTML, XML or other format? Thanks very much for your help on this one.

Untested but here are a couple scripts which I think may solve your issue:

http://apptools.com/phptools/dynamicsitemap.php http://yoast.com/xml-sitemap-php-script/

If you want a proper sitemap (how the files link to one another) then there are some libraries available for that mentioned by others. If you just want to list them, then just use the opendir and readdir functions:

$directory = 'your directory';
$array_items = array();
if ($handle = opendir($directory)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
             if (is_dir($directory.'/'.$file)){
                continue;   
             }
             $array_items[] = $file;
        }
    }
    closedir($handle);
}

You can then loop through the $array_items and output xml or html. You can also make this recursive by making this a function and handling the

if (is_dir($directory.'/'.$file)){
     continue;  
}

section