destoon根据目录下的html文件生成地图索引
因为项目需要,destoon根据目录下的html文件生成地图索引,操作方法,代码如下:
<?php
$new_array = array();
function loopDir($dir,&$new_array,$modurl)
{$handle = opendir($dir);header("Content-Type:text/xml");
$data = '<?xml version="1.0" encoding="UTF-8"?>';
$data .= '<urlset>';while(($file = readdir($handle))!== false ){$today=date('Y-m-d', time());if ($file != '.' &&$file != 'index.php' && $file != 'indexhtml.php' && $file != '..'){if (filetype($dir.'/'.$file) != 'dir'){$modurl="http://www.nongpin88.com/sitemap/";$fileurl=$modurl."html/".$file;$data .= '<url>';$data .= '<loc>'.$fileurl.'</loc>';
$data .= '<lastmod>'.$today.'</lastmod>';
$data .= '</url>'; }if (filetype($dir.'/'.$file) == 'dir'){loopDir($file,$new_array);}}}$data .= $item;$data .= '</urlset>';
$data = str_replace('><', ">\n<", $data);
echo $data;
}$dir = './';
loopDir($dir,$new_array,$modurl);?>
演示地址:模块地图 (nongpin88.com)http://www.nongpin88.com/sitemap/html/