<?php 
$globaldir = '';
require_once($globaldir.'config.php'); //configuration settings
require_once($globaldir.'lib/db.ini.php'); //db settings
require_once($globaldir.'lib/cs.functions.php'); //load global functions
require_once($globaldir.'lib/sitemap.class.php'); //sitemap class
$newLine = "\n";
$xmlHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>$newLine";
header('Content-type: application/xml; charset="utf-8"',true);
print "$xmlHeader";
print "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
print "<url><loc>".$CFG->wwwroot."/</loc><lastmod>".date('Y-m-d')."</lastmod><changefreq>weekly</changefreq><priority>0.4</priority></url>";
print "<url><loc>".$CFG->wwwroot."/courses/</loc><lastmod>".date('Y-m-d')."</lastmod><changefreq>weekly</changefreq><priority>0.4</priority></url>";
$s = new SiteMap();
$content  = $s->get_content();
if($content){
while ($row = mysql_fetch_object($content)){
print "<url><loc>".$CFG->wwwroot."/".csPageLink($row->title)."_".$row->id.".html</loc><lastmod>".strftime  ('%Y-%m-%d',strtotime($row->modified))."</lastmod><changefreq>monthly</changefreq><priority>0.2</priority></url>";
}
}
$courses  = $s->get_courses();
if($courses){
while ($row = mysql_fetch_object($courses)){
print "<url><loc>".$CFG->wwwroot."/course/".csPageLink($row->title)."_".$row->id.".html</loc><lastmod>".strftime  ('%Y-%m-%d',strtotime($row->modified))."</lastmod><changefreq>monthly</changefreq><priority>0.6</priority></url>";
if($row->material != 'none'){
print "<url><loc>".$CFG->wwwroot."/material/".$row->material."</loc><lastmod>".strftime  ('%Y-%m-%d',strtotime($row->modified))."</lastmod><changefreq>monthly</changefreq><priority>0.6</priority></url>";
}
}
}
print "</urlset>";
?>