<?php

$min = 0;
$max = 20000;

$i = $min;

header("Content-Type: text/xml");
set_time_limit(300);
$url = $_SERVER['HTTP_HOST'];
$title = str_replace("www.",'',$url);
$description = str_replace(array('.com', '.net', '.org'),'',$title);

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
echo '   <url>';
echo '    <loc>http://' . $_SERVER['HTTP_HOST'] . '/</loc>';
echo '   <lastmod>' . date('Y-m-d') . '</lastmod>';
echo '    <changefreq>hourly</changefreq>';
echo '    <priority>1.0</priority>';
echo '   </url>';

//Stuff already in index
include('sl_settings.php');
include('sl_db_connect.php');
include('sl_variables.php');


//Build site
$sql = "SELECT * FROM `who` WHERE CHAR_LENGTH(texture)>20 AND ID<$max";
$sql = "SELECT * FROM `who` WHERE ID>$min AND CHAR_LENGTH(texture)>20 AND ID<$max";
$result = mysql_query($sql) or die(mysql_error());

while ($newArray = mysql_fetch_array($result) and $i<$max) {
	$name = $newArray['agent'];
	$atime = $newArray['access_time'];
	$btime = $newArray['access_time'];
	if (strlen($atime)>10) {
		$atime = substr($atime,0,10);
	} else {
		$atime = $btime;
	}

	//Limit the text, 350 chrs 
	//$doit = $newArray["pDescription"]; 
	//$max=100; 
	//$modstr=((strlen($doit)>$max)?substr($doit,0,$max) . "..." : $doit); 

	echo '<url>';
	echo '<loc>http://' . $_SERVER['HTTP_HOST'] . '/' . str_replace(" ","-",$name) . '.html</loc>';
	echo '<lastmod>' . $atime . '</lastmod>';
	echo '<changefreq>monthly</changefreq>';
	echo '<priority>0.6</priority>';
	echo '</url>';
	$i++;
}

echo '</urlset>';

include('sl_db_disconnect.php');

?>