File: D:/HostingSpaces/SBogers10/spire.komma-mediadesign.nl/wwwroot/sitemap.xml.php
<?php
header("Content-type: text/xml");
$datum = date('Y-m-d');
include $_SERVER['DOCUMENT_ROOT'] . '/check_x2.php';
if ( ! X2 ){
$base = 'http://www.spire-corp.com/';
}
else
{
$base = 'http://www.x2products.com/';
}
if($_SERVER['REMOTE_ADDR'] == '212.61.130.133')
{
/*
* Error handling (comment out when live)
*/
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
}
include '/config/config_db.php';
include '/mvc/models/m_dbHandler.php';
$Dbh = new DatabaseHandler();
echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
echo("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
?>
<url>
<loc><?php echo $base; ?></loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>company</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php if ( ! X2 ){ ?>
<url>
<loc><?php echo $base; ?>company/manufacturing</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>company/mission-statement</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php } ?>
<url>
<loc><?php echo $base; ?>company/careers</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>pc-accessories</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>cpu-coolers</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php if ( ! X2 ){ ?>
<url>
<loc><?php echo $base; ?>fans</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>mobile-accessories</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php } ?>
<url>
<loc><?php echo $base; ?>computer-cases</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>power-supplies</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>system-cooling</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php if ( ! X2 ){ ?>
<url>
<loc><?php echo $base; ?>tablet-pc</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php } ?>
<?php
/* PRODUCTS */
$pages[11] = array('pcaccessories','pc-accessories');
$pages[9] = array('cpucoolers','cpu-coolers');
$pages[12] = array('mobileaccessories','mobile-accessories');
$pages[10] = array('pccases','computer-cases');
$pages[8] = array('powersupply','power-supplies');
$pages[7] = array('systemcooling','system-cooling');
$pages[16] = array('tabletpc','tablet-pc');
foreach($pages as $pageId => $pageData)
{
$tableName = $pageData[0];
$pageUrl = $pageData[1];
$Dbh = new DatabaseHandler();
$Dbh->setTableName('page_'.$tableName.'_items');
$Dbh->setData(array('title'=>'','productCode'=>''));
$Dbh->setActiveOnly(TRUE,$pageId);
$Dbh->addRule('productStatus','1');
X2 ? $Dbh->addRule('x2',1) : $Dbh->addRule('x2',1, 'AND NOT') ;
if($data = $Dbh->select())
{
foreach($data as $info)
{
// encode url
$linkTitle = trim($info['title'].'-'.$info['productCode']);
$linkTitle = str_replace(' ','-',$linkTitle);
//remove these characters
$forbidden = array("'", '"', '\\', '/', ';', ';', '|', '>', '<', '[', ']', '!','?', '@', '#', '$', '%', '^', '&', '*', '(', ')','+','=','{','}','`', '~', '.', ',');
foreach($forbidden as $key => $value){
$linkTitle = str_replace($value, '', $linkTitle);
}
$linkTitle = strtolower($linkTitle);
echo '<url>
<loc>' . $base . $pageUrl . '/' . $linkTitle . '</loc>
<lastmod>' . $datum . '</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>';
}
}
}
?>
<url>
<loc><?php echo $base; ?>media/news</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>media/awards</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>media/newsletter</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>support/product-registration</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>support/warranty</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php if ( ! X2 ){ ?>
<url>
<loc><?php echo $base; ?>support/mobile-faq</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>reseller</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<?php } ?>
<url>
<loc><?php echo $base; ?>reseller/marketing-tools</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc><?php echo $base; ?>contact</loc>
<lastmod><?php echo($datum); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>