background image

* $f 含相对路径的文件名称
* $dt 日期时间型
*/
function addToXML($f, $dt){
$s = "<url><loc>".$GLOBALS["WebRoot"].$f."</loc><lastmod>".$dt."</lastmod></url>\n";
$GLOBALS["XMLText"] .= $s;
}
/**
* 遍历指定的目录以及子目录,将符合条件的文件加入 XML
* $p 指定的目录
*/
function DealFP($p){
$FilterDir = $GLOBALS["FilterDir"];
$IndexFileExt = $GLOBALS["IndexFileExt"];
$handle=opendir($p);
if ($p==".") $path = "";
else $path = $p."/";
while ($file = readdir($handle))
{ // www.jbxue.com
    $d = filetype($path.$file);
    if ((($d=='file')||($d=='dir'))&&($file!='.')&&($file!='..'))
    {
        $pf = $path.$file;
        //echo "[".$d."]".$pf."<br>";
        if ($d=='dir')
        {
          if (!(strpos($FilterDir, "|".$pf."|")))
          {
            DealFP($pf);
          }
        }else{
          $ext = "|".strtolower()(substr($file, strrpos($file, ".")+1))."|";
         
          if (strpos($IndexFileExt, $ext))
          {
            $d = filemtime($pf);
            $dt = date("Y-m-d",$d)."T".date("H:i:s",$d)."+00:00";
            addToXML($pf, $dt);
          }
        }
    }
}
closedir($handle);
}