php如何生成Google Sitemap XML文件:
<?php
header('Content-type: application/xml; charset="GB2312"',true);
$timezone = "Asia/Shanghai";
date_default_timezone_set($timezone);
$website = "http://www.yipiantian.cn"; /* change this */
$page_root = "/usr/local/psa/home/vhosts/subdomains/my/httpdocs"; /* change this */
/* maybe change this: */
$changefreq = "daily"; //"always", "hourly", "daily", "weekly", "monthly", "yearly" and "never".
$priority = 0.5;
/* this sets the last modification date of all pages to the current date */
$last_modification = date("Y-m-d H:i:s");
/* list of allowed directories */
$allow_dir[] = "about";
$allow_dir[] = "help";
$allow_dir[] = "case";
$allow_dir[] = "E-Marketing";
/* list of disallowed directories */
$disallow_dir[] = "system";
$disallow_dir[] = "ads";
$disallow_dir[] = "api";
$disallow_dir[] = "ask";
$disallow_dir[] = "category";
$disallow_dir[] = "comment";
$disallow_dir[] = "corpandresize";
$disallow_dir[] = "css";
/* list of disallowed file types */
$disallow_file[] = ".inc";
$disallow_file[] = ".old";
$disallow_file[] = ".save";
$disallow_file[] = ".txt";
$disallow_file[] = ".xml";
$disallow_file[] = ".js";
$disallow_file[] = "~";
$disallow_file[] = ".LCK";
$disallow_file[] = ".zip";
$disallow_file[] = ".ZIP";
$disallow_file[] = ".CSV";
$disallow_file[] = ".csv";
$disallow_file[] = ".css";
$disallow_file[] = ".class";
$disallow_file[] = ".jar";
$disallow_file[] = ".mno";
$disallow_file[] = ".bak";
$disallow_file[] = ".lck";
$disallow_file[] = ".BAK";
$disallow_file[] = ".php";
$disallow_file[] = ".sql";
/* simple compare function: equals */
function ar_contains($key, $array) {
foreach ($array as $val) {
if ($key == $val) {
return true;
}
}
return false;
}
/* better compare function: contains */
function fl_contains($key, $array) {
foreach ($array as $val) {
$pos = strpos($key, $val);
if ($pos === FALSE) continue;
return true;
}
return false;
}
/* this function changes a substring($old_offset) of each array element to $offset */
function changeOffset($array, $old_offset, $offset) {
$res = array();
foreach ($array as $val) {
$res[] = str_replace($old_offset, $offset, $val);
}
return $res;
}
/* this walks recursivly through