<?php
/******************************************************************************
* This file is part of Yet Another Link Directory. *
* *
* Yet Another Link Directory is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* Yet Another Link Directory is distributed in the hope that it will be *
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with Yet Another Link Directory; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
******************************************************************************/
require('inc/config.php');
require('inc/functions.php');
header("Content-Type: text/xml");
mysql_connect($mysql['host'],$mysql['username'],$mysql['password']);
mysql_select_db($mysql['db']);
$settings = getSettings();
// automatically determine the URL to the YALD directory
$site_url = 'http://'.$_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/';
$query = 'SELECT * FROM '.$settings['categories_table'];
$result = mysql_query($query);
print "<?xml version='1.0' encoding='UTF-8'?>\n<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\">";
print "<url>\n<loc>".$site_url.$settings['index_file']."</loc>\n</url>\n";
while($row = mysql_fetch_array($result)){
if($row['id'] != '1'){
$caturl = rewriteUrl($row['id'],$row['name'],$row['path'],null,$site_url);
print "<url>\n<loc>{$caturl}</loc>\n</url>\n";
if($settings['use_pagination']=='true'){
$numlinks = countLinks($row['id']);
$numpages = ceil($numlinks/$settings['links_per_page']);
if($numpages > 0){
$pagerange = range(0,$numpages-1);
}
foreach($pagerange as $page){
if($page != 0){
$caturl = rewriteUrl($row['id'],$row['name'],$row['path'],$page,$site_url);
print "<url>\n<loc>{$caturl}</loc>\n</url>\n";
}
}
}
}
}
print "</urlset>";
?>