Ajax software
Free javascripts
↑
Main Page
header(‘Content-type: text/plain’);
foreach ($this->_items as $i)
{
echo $i[‘loc’] . “\n”;
}
return ob_get_clean();
}
// escape string characters for inclusion in XML structure
function _escapeXML($str)
{
$translation = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
foreach ($translation as $key => $value)
{
$translation[$key] = ‘&#‘ . ord($key) . ‘;’;
}
$translation[chr(38)] = ‘&‘;
return preg_replace(“/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/“,”&” ,
strtr($str, $translation));
}
}
?>
2.
You need to add the following two rewrite rules to the
.htaccess
file in
/seophp
. If you have
other entries in the file from previous exercises, just add the new rules; otherwise, create the file
from scratch. (If you haven’t already, see Chapter 3 for details on mod_rewrite.)
RewriteEngine On
# Rewrite requests for sitemap.xml
RewriteRule ^sitemap.xml$ /sitemap.php?target=google [L]
# Rewrite requests for urllist.txt
RewriteRule ^urllist.txt$ /sitemap.php?target=yahoo [L]
3.
You need to have
url_factory.inc.php
and
config.inc.php
, which you created in Chapter 3,
in your
seophp/include
folder. Feel free to take them from the code download, if needed.
4.
In the
seophp
folder, create a file named
sitemap.php
and type this code in it:
<?php
// redirect requests to dynamic to their keyword rich versions
require_once ‘include/sitemap.inc.php’;
// load configuration
require_once ‘include/config.inc.php’;
// load URL factory
require_once ‘include/url_factory.inc.php’;
// create the Sitemap object
$s = new Sitemap();
// add sitemap items
$s->addItem(SITE_DOMAIN . ‘/catalog.html’, ‘2006/10/27’, ‘weekly’);
$s->addItem(make_category_product_url(
“Carpenter’s Tools”, 12, “Belt Sander”, 45), ‘2006/10/27’, ‘weekly’);
205
Chapter 9: Sitemaps
c09.qxd:c09 10:43 205
Ajax software
Free javascripts
→