<?php 
header('Content-type: text/xml');
include "../includes/include_fns.php";
$conn = db_connect();
?>

<rss version="1.0">
<channel>
  <title>Masters of Harmony Shows</title> 
  <link>http://www.mastersofharmony.org/see_us/</link> 
  <description>The very best in Southern California Barbershop shows!</description> 
  <copyright>Copyright <?php print $current_year = date("Y",time()); ?> Masters of Harmony, All Rights Reserved</copyright>
  <language>en-us</language> 
  <pubDate><?php print $now = date("r",time()); ?></pubDate>
  <lastBuildDate><?php print $now = date("r",time()); ?></lastBuildDate> 
  <docs>http://www.mastersofharmony.org/rss/docs.html</docs> 
  <managingEditor>editor@mastersofharmony.org</managingEditor> 
  <webMaster>webmaster@mastersofharmony.org</webMaster> 

<?php

   // ----------------------------------------------
   // Get the show notices from the database here...
   // ----------------------------------------------

   $now = time();
   $news_sql = "select * from stories where page = 'events' and event_end_date > ".$now." and published is not null order by event_start_date";
   $news_result = mysql_query($news_sql, $conn);
   $num_stories = mysql_num_rows($news_result);

   $desired_number_of_stories = 8;
   if ($desired_number_of_stories > $num_stories) $actual_number_of_stories = $num_stories;
   if ($desired_number_of_stories <= $num_stories) $actual_number_of_stories = $desired_number_of_stories;

   for ($i=1; $i <= $actual_number_of_stories; $i++) {
      $story = mysql_fetch_array($news_result);
      if ($story[event_end_date] < $now) $i--;
      if (($num_stories >= $i) and ($story[event_end_date] > $now)) {
?>

   <item>
   <title><?php print $story[headline]; ?></title>
   <link>http://www.mastersofharmony.org/view_article/index.php?id=<?php print $story[id]; ?></link>
   <description><?php print $story[headline]; ?></description>
   <pubDate><?php print date("r", $story[event_start_date]); ?></pubDate>
   <guid>http://www.mastersofharmony.org/view_article/index.php?id=<?php print $story[id]; ?></guid>
   </item>

<?php
      }
   }
?>


</channel>
</rss>
