Location: PHPKode > projects > Wiki Web Help > wwh/pages/sitemap.php
<?php
$sitemap='<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>';
$sitemap.='<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n"
;

require_once("../config.php");
//require_once("../wwh/class/node.class.php");


$sql = "SELECT * FROM langxref WHERE language != ''";
$result = mysql_query($sql,$con) or die(mysql_error());
$n = mysql_num_rows($result);
for($r=0;$r<$n;$r++){
	$langnode = mysql_result($result, $r, 'node_id');    
	parsenode($langnode, $node,$con);

}
$sitemap.= "</urlset>\n";

header ("Content-Type:text/xml");
echo $sitemap;

function parsenode($lid,$node,$con){
	$sql = "SELECT node.node_id,label FROM page ".
		"INNER JOIN node on page.node_id=node.node_id WHERE ".
		"node.parent_id=$lid";
	$resultp = mysql_query($sql,$con) or die(mysql_error());
	$np = mysql_num_rows($resultp);
	for($p=0;$p<$np;$p++){
		$id = mysql_result($resultp, $p, 'node.node_id');
		$label = mysql_result($resultp, $p, 'label');
        	addmap($id,$label);
        	parsenode($id, $node,$con);
	}
    
}

function addmap($id,$label){
    global $sitemap;
    $root = $_SERVER['SERVER_NAME'];
    $scriptpath = $_SERVER['REQUEST_URI'];
    $break = Explode('/', $scriptpath);
    $pfile = $break[count($break) - 1]; 

    $scriptpath = substr($scriptpath,0,strlen($scriptpath)-strlen($pfile)-strlen($relpath)-1);
    $path = "http://$root$scriptpath".substr($path,5)."/getpage.php?id=$id&amp;title=".htmlspecialchars($label);

    $mod = date("Y-m-d");
    $sitemap.="  <url>\n".
    "   <loc>$path</loc>\n".
    "   <lastmod>$mod</lastmod>\n".
    "   <priority>0.5</priority>\n".
    "   <changefreq>weekly</changefreq>\n".
    "  </url>\n"
    ;
}
?>
Return current item: Wiki Web Help