Revision [11221]

This is an old revision of GoogleSitemap made by BarkerJr on 2005-09-30 04:13:09.

 

Google Sitemap Support

by BarkerJr

Here's the contents of a PHP file that generates a map for Google's Sitemap service. Just copy and paste the below into a new file and name it with the ".php" extension.

You may need to change the path to the wikka.config.php file on the second line, depending on where it's located in your webspace reletive to where you place the sitemap file.

<?php
include('wiki/wikka.config.php');

if (!mysql_pconnect($wakkaConfig['mysql_host'], $wakkaConfig['mysql_user'], $wakkaConfig['mysql_password']))
{
  header('HTTP/1.1 503 Service Unavailable');
  exit;
}

header('Content-Type: text/xml; charset=iso-8859-1');

mysql_select_db($wakkaConfig['mysql_database']);

echo '<?xml version="1.0" encoding="iso-8859-1"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
'
;
$pages = mysql_query('SELECT SQL_NO_CACHE tag, time FROM ' . $wakkaConfig['table_prefix'] . 'pages LEFT JOIN ' . $wakkaConfig['table_prefix'] . "acls ON page_tag = tag WHERE latest = 'Y' AND (read_acl = '*' OR read_acl IS NULL)");
while ($row = mysql_fetch_array($pages))
{
  echo " <url>\n";
  echo '  <loc>' . $wakkaConfig['base_url'] . $row['tag'] . "</loc>\n";
  /* PHP4 doesn't support ISO dates, so we get to play games here... */
  $date = date('Y-m-d\TH:i:sO', strtotime($row['time']));
  echo '  <lastmod>' . substr($date, 0, -2) . ':' . substr($date, -2) . "</lastmod>\n";
  echo " </url>\n";
}
echo '</urlset>';
?>



CategoryUserContributions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki