<?php 
require ('../../connect2.txt');
header("Content-type: text/xml \n");
header("Content-Transfer-Encoding: utf-8");
$timestamp=gmdate('U');
$time = gmdate("D, j M Y H:i:s");
$time = "$time GMT";
$year = gmdate("Y");
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?> 
<?xml-stylesheet type=\"text/css\" href=\"http://www.whenthemusicstops.com/feeds/rss.css\" ?>
<rss version=\"2.0\" 
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"
xmlns:dc=\"http://purl.org/dc/elements/1.1/\" 
xmlns:atom=\"http://www.w3.org/2005/Atom\">

<channel>
<title>Speed Dating and other Singles Events and Parties</title>
<description>A collection of the latest Speed Dating and Singles events</description>
    <copyright>Copyright 2006 - $year When the Music Stops</copyright>
    <docs>http://www.whenthemusicstops.com/feeds</docs>
    <lastBuildDate>$time</lastBuildDate>
	<link>http://www.whenthemusicstops.com</link>
  <image>
    <url>http://www.whenthemusicstops.com/feeds/wtmslogo.gif</url>
    <title>Speed Dating and other Singles Events and Parties</title>
    <link>http://www.whenthemusicstops.com</link>
    <description>Speed dating, dinner parties and information for single people</description>
  </image>";
$eventlist = @mysql_query("select `category`, `ticketcost`, `eventdate`, date_format(`eventdate`, '%D %M %Y') as `edate`, date_format(`eventdate`, '%W') as `weekday`, `town`, `start_time`, time_format(`start_time`, '%l %i %p') as `etime`, `event_id`, `type`, `extra`, `place_id`, `m_places`, `f_places` from `events` where UNIX_TIMESTAMP(`eventdate`)>($timestamp) and `type`<>'cancelled' and `town`<>'Nowhere' and `bogus`='N' order by `eventdate` ");

while ($catquery = @mysql_fetch_array($eventlist))
{$category = $catquery["category"];
$ticketcost = $catquery["ticketcost"];
$eventdate = $catquery["eventdate"];
$event_id = $catquery["event_id"];
$start_time =$catquery["start_time"];
$start = $catquery["etime"];
$edate = $catquery["edate"];
$weekday = $catquery["weekday"];
$town = $catquery["town"];
$place_id = $catquery["place_id"];
$type = $catquery["type"];
$extra = $catquery["extra"];
$m_places = $catquery["m_places"];
$f_places = $catquery["f_places"];
$town2 = $town;
$town = urldecode($town);
$place_id=preg_replace("[&]","and",$place_id);
$place_id2 = urldecode($place_id);

unset ($pre);

if ((($m_places + $f_places) > '0')&&($type<>'cancelled'))
{
switch ($type) {
case 'fd':$type2 ="Dinner Party";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'dd':$type2 ="Dinner Party";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;

case 'gsd':$type2 ="Gay Speed Dating";$linker="http://www.whenthemusicstops.com/speeddating.php?id=$event_id";break;
case 'gsd2':$type2 ="Lesbian Speed Dating";$linker="http://www.whenthemusicstops.com/speeddating.php?id=$event_id";break;

case 'ld':$type2 ="Lunch Dating";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'sdp':$type2 ="Party Night";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'spn':$type2 ="Soul Party Night";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'mmn':$type2 ="Murder Mystery";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;;
case 'mmw':$type2 ="Murder Mystery Weekend";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'te':$type2 ="Themed Event";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'oa':$type2 ="Outdoor Activities";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";break;
case 'sd':$type2 ="Speed Dating";$linker="http://www.whenthemusicstops.com/speeddating.php?id=$event_id";break;
default:$type2 ="Dating Event";$linker="http://www.whenthemusicstops.com/singles/diary.php?event_id=$event_id";
}
switch ($start)
{
case '6 30 PM': $start2 ="6.30pm"; break;
case '7 00 PM': $start2 ="7pm"; break;    
case '7 30 PM': $start2 ="7.30pm"; break;
case '8 00 PM': $start2 ="8pm"; break;
case '8 30 PM': $start2 ="8.30pm"; break;
}

$males = $m_places;
$females = $f_places;

if($extra<>"gsd2"){
if ($males<'1') { $mplaces= "This event is full for Men";}
if ($males=='1') {$mplaces= "There is only 1 place at this event available for Men";}
if ($males=='2') { $mplaces= "There are just 2 places at this event available for Men";}
if ($males>'2'){ $mplaces= "There are still places available for Men" ;}
}
elseif($extra=="gsd2"){$mplaces= "";}

if($extra<>"gsd"){
if ($females<'1') { $fplaces= " This event is full for Women";}
if ($females=='1') { $fplaces= " There is only 1 place at this event available for Women. ";}
if ($females=='2') { $fplaces= " There are just 2 places at this event available for Women. ";}
if ($females>'2'){ $fplaces= " There are still places available for Women. ";}
}
elseif($extra=="gsd"){$fplaces= "";}

if ($type2!=="Themed Event"){$type3 = $type2. " event";} else {$type3=$type2;}
#if($event_id=='2021'){$type2="New Years Eve Dinner Party";$type3="New Years Eve Dinner Party";}

if($extra=="gsd"){$pre="Gay ";}
if($extra=="gsd2"){$pre="Lesbian ";}

echo "<item>
<title>$pre$type2 in $town on $edate</title>
<description>$pre$type3 at the $place_id in $town on $weekday $edate starting at $start2. Recommended for $category. $fplaces $mplaces.</description>
<pubDate>$time</pubDate>
<guid>$linker</guid>
<category>$type2</category>
<link>$linker</link>
</item>";}
$extra="";
}
echo "<atom:link href=\"http://www.whenthemusicstops.com/feeds/rss.xml\" rel=\"self\" type=\"application/rss+xml\" /></channel></rss>";