<?php

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = ['','../','../../','../../../','../../../../']; // add if needed: 'C:/websites/masonichip/htdocs/'
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  
  
  list($events, $eventsMetaData) = getRecords(array(
    'tableName'   => 'events',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

 list($news, $newsMetaData) = getRecords(array(
    'tableName'   => 'news',
    'allowSearch' => false,
    'where' => "faq  = '0'",
  ));


?><?php header('Content-type: text/xml'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
     <loc>https://www.masonichip.ca/</loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-01"); ?></lastmod>
  </url>
  <url>
     <loc>https://www.masonichip.ca/event-list.php</loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-01"); ?></lastmod>
  </url>
  <url>
     <loc>https://www.masonichip.ca/search.php</loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-01"); ?></lastmod>
  </url>
  <url>
     <loc>https://www.masonichip.ca/newsList.php</loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-01"); ?></lastmod>
  </url>
  <url>
     <loc>https://www.masonichip.ca/contacts.php</loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-01"); ?></lastmod>
  </url>
<?php foreach($events as $record): ?>
  <url>
     <loc>https://www.masonichip.ca<?php echo $record['_link']; ?></loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-d", strtotime($record['updatedDate'])); ?></lastmod>
  </url>
<?php endforeach; ?>
<?php foreach($news as $record): ?>
  <url>
     <loc>https://www.masonichip.ca/<?php echo $record['_link']; ?></loc>
     <priority>1.0</priority>
     <lastmod><?php echo date("Y-m-d", strtotime($record['updatedDate'])); ?></lastmod>
  </url>
<?php endforeach; ?>
</urlset> 