Okay this update utilizes the config.php to pull database information, so you don't have to enter it.
Code:
<?php
require_once('./includes/config.php');
///////////////////////Configure this/////////////////////////////////////////////////////
$sitename="SITENAME WITHOUT THE HTTP!!"; // sitename including www
$maxkey = "8"; // max key words as you specified in tfseo control panel
$home_freq = "daily"; //always, hourly, daily, weekly, monthly, yearly, never
$home_priority = "1"; // google priority for home (www.yoursite.com)
$forum_freq = "daily"; //always, hourly, daily, weekly, monthly, yearly, never
$forum_priority = "0.8"; // google priority for forums (www.yoursite.com/f4)
$thread_freq = "daily"; //always, hourly, daily, weekly, monthly, yearly, never
$thread_priority = "0.4"; // google priority for threads (www.yoursite.com/f4/your-thread)
function remove_accents($string){ ////this strings must be the same you are using as character replacements, these are the "wide range"
return strtr($string,
"???????????????????????????????????????????????????????????????@?",
"YuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyyEan");
}
////////////////////////////DONT NEED TO TOUCH ANYTHING BELOW//////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
$username=$config['MasterServer']['username']; //your db user name
$password=$config['MasterServer']['password']; // the pass for the db
$database=$config['Database']['dbname']; // name of db
$server=$config['MasterServer']['servername']; // server
$prefix = $config['Database']['tableprefix'];
function unhtmlspecialchars($text)
{
$text = preg_replace('/&#([0-9]+);/esiU', "convert_int_to_utf8('\\1')", $text);
return str_replace(array('<', '>', '"', '&'), array('<', '>', '"', '&'), $text);
}
//connect to the database
$link = mysql_connect($server,$username,$password);
mysql_select_db($database,$link) or die( "Unable to select database");
$result = mysql_query("select * from " . $prefix . "thread WHERE visible = 1",$link);
$num_rows = mysql_num_rows($result);
$query = "select * from " . $prefix . "thread WHERE visible = 1 ORDER BY dateline desc" ;
$result = mysql_query($query) or die("Query failed");
$num_rows2 = mysql_num_rows(mysql_query("select * from " . $prefix . "forum"));
$query2 = "select * from " . $prefix . "forum ORDER BY forumid desc" ;
$result2 = mysql_query($query2) or die("Query failed");
//this is the normal header applied to any Google sitemap.xml file
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';
//HOME RESULTS
$url_product ="http://" . $sitename;
$realdate = date("Y-m-d");
$year = substr($realdate,0,4); //work out the month
$mon = substr($realdate,5,2); //work out the month
$day = substr($realdate,8,2); //work out the day
$displaydate = ''.$year.'-'.$mon.'-'.$day.'';
echo
'
<url>
<loc>'.$url_product.'</loc>
<lastmod>'.$displaydate.'</lastmod>
<changefreq>'.$home_freq.'</changefreq>
<priority>'.$home_priority.'</priority>
</url>
';
//FORUM RESULTS
$i=0;
for($i=0;$i<$num_rows2; $i++)
{
$url_product ="http://" . $sitename . "/f" .mysql_result($result2,$i,"forumid");
/*you need to assign a date to the entity. if you don't
store a timestamp in the Database then you need slapping*/
$realdate = date("Y-m-d");
$year = substr($realdate,0,4); //work out the month
$mon = substr($realdate,5,2); //work out the month
$day = substr($realdate,8,2); //work out the day
$displaydate = ''.$year.'-'.$mon.'-'.$day.'';
echo
'
<url>
<loc>'.$url_product.'</loc>
<lastmod>'.$displaydate.'</lastmod>
<changefreq>'.$forum_freq.'</changefreq>
<priority>'.$forum_priority.'</priority>
</url>
';
}
//THREAD RESULTS
for($i=0;$i<$num_rows; $i++)
{
//cleanurl
$title = mysql_result($result,$i,"title");
$a = strtolower($title);
$a = remove_accents($a);
$a = unhtmlspecialchars($a);
$a = str_replace("'", '', $a);
$a = preg_split("#[^a-z0-9]#", $a, -1, PREG_SPLIT_NO_EMPTY);
$a = array_slice($a, 0, $maxkey);
$a = implode("-",$a);
if (empty($a))
{
$a = 'thread';
}
//your url-product as we worked out in #4
$url_product ="http://" . $sitename . "/f" .mysql_result($result,$i,"forumid") . "/" . $a . '-t' .mysql_result($result,$i,"threadid");
/*you need to assign a date to the entity. if you don't
store a timestamp in the Database then you need slapping*/
$date = mysql_result($result,$i,"dateline"); //the date stored
$realdate = date('Y-m-d H:i:s', $date);
$year = substr($realdate,0,4); //work out the month
$mon = substr($realdate,5,2); //work out the month
$day = substr($realdate,8,2); //work out the day
/*display the date in the format Google expects:
2006-01-29 for example*/
$displaydate = ''.$year.'-'.$mon.'-'.$day.'';
//you can assign whatever changefreq and priority you like
echo
'
<url>
<loc>'.$url_product.'</loc>
<lastmod>'.$displaydate.'</lastmod>
<changefreq>'.$thread_freq.'</changefreq>
<priority>'.$thread_priority.'</priority>
</url>
';
}
mysql_close(); //close connection
//close the XML attribute that we opened in #3
echo
'</urlset>';
?>
It translates to XML using IE7 - Just tried and I'm awaiting another re-submission with Google Webmaster Tools.