Revision [12564]

This is an old revision of GoogleSitemap made by BarkerJr on 2006-01-08 21:05:57.

 

Google Sitemap Support

by BarkerJr

This script will generate output compatible with Google Sitemap. It can then be submitted to the service.

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_assoc($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>';
?>


As noted by StewartPlatt...
If you use the rewrite code inside .htaccess, you need to create an exception for this (and probably your verifier) files. Such code to add to your .htaccess would look like:

<Files sitemap.xml>
  RewriteEngine off
</Files>

<Files google09f4d14e09f8db1a.html>
  RewriteEngine off
</Files>


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