<?php 

//
// LAST TEN DAYS of shows
// Sample
//
/* 
Instead of on http://wmxm.org/last-10-days/, having each show open in a new window on the Radioactivity site 
(for example, clicking on DJ: Park takes you to http://wmxm.radioactivity.fm/playlist.html?djoid=5386&date=05-04-2016), 
would it be possible to have this content instead open in a frame that keeps the header / footer of the current site?
*/

/*
<item>
	<title>Show # 1 </title>
	<link>http://wmxm.radioactivity.fm/</link>
	<ra:showoid>0</ra:showoid>
	<ra:showdate>04-23-2016</ra:showdate>
	<ra:showstart>04-23-2016 12:00 am</ra:showstart>
	<ra:showend>04-23-2016 12:19 am</ra:showend> 
	<ra:showspan>Sat. April 23rd, 12:00am - 12:19am</ra:showspan> 
	<ra:djname></ra:djname> 
	<ra:showname>DJ not logging under a show name</ra:showname>
</item>
*/
			
require_once __DIR__ . '/magpie/rss_fetch.inc';

//
// use the local server pls
// $rss = @fetch_rss('http://wmxm.radioactivity.fm/feeds/last10dayshows.xml');
//

$rss = @fetch_rss('http://wmxm.org/radioactivity/feeds/last10dayshows.xml');



// some running variables
$current_day = '';
$count=1;

?>

<table border=1 width=700 cellpadding=1 cellspacing=1>

<?

foreach ($rss->items as $item) {
 
  $show_djoid				= $item['ra']['djoid'];
  $show_oid					= $item['ra']['showoid'];
  $show_date 				= $item['ra']['showdate'];
  $show_start 			= $item['ra']['showstart'];
  $show_end 				= $item['ra']['showend'];
  $show_span 				= $item['ra']['showspan'];
  $show_djname 			= $item['ra']['djname'];
  $show_showname 		= $item['ra']['showname'];
  
  if ($current_day!=$show_date) {
  	$current_day = $show_date;
  	$count++;
  } 

	// coloring
	$bgcolor="#A7E5FA";
	if ($count%2) {
		$bgcolor="#ffffff";
		
	} 
  
  // linking
  //        wmxm.radioactivity.fm/playlist.html?showoid=4628&date=05-02-2016
  // http://wmxm.radioactivity.fm/playlist.html?djoid=11269&date=05-02-2016
  if ($show_oid!="0") {
  	$built_showlink="http://wmxm.radioactivity.fm/playlist.html?showoid=" . $show_oid . "&date=" . $show_date;
  	$snippet = "?rashowoid=" . $show_oid . "&rashowdate=" . $show_date;
 	} else {
 		$built_showlink="http://wmxm.radioactivity.fm/playlist.html?djoid=" . $show_djoid . "&date=" . $show_date;
 		$snippet = "?radjoid=" . $show_djoid . "&rashowdate=" . $show_date;
 	}
 	
  
  // no showname? default to dj name
  if (!$show_showname || $show_showname=="DJ not logging under a show name") {
  	$built_showname="DJ: " . $show_djname;
  } else {
  	$built_showname=$show_showname . " with " . $show_djname;
  }
  
	/*
	
	Built showlink:  SHOWOID and date
	wmxm.radioactivity.fm/playlist.html?showoid=4628&date=05-31-2016
	
	^^^ this has an RSS feed:
	http://wmxm.radioactivity.fm/feeds/playlistrss.html?showoid=4628&date=05-31-2016
	
	Built showlink:  DJOID and date
	http://wmxm.radioactivity.fm/playlist.html?djoid=11310&date=05-24-2016
	
	HTML link: http://wmxm.radioactivity.fm/playlist.html?djoid=11310&date=05-24-2016
	
	
	*/
	if (strlen($show_djname)>0) {
	  ?><tr>
	  	<td width=60%  style="background-color:<?=$bgcolor?>; text-align: left; border: 2px ">
	  		<a href="displayshow<?=$snippet?>">
	  		<?=$built_showname?></a> 
	  	</td>
	  	<td width=40%  style="background-color:<?=$bgcolor?>; text-align: left;border: 2px ">
	  		<?=$show_span?>
	  	</td>
	  <?
	}

  
}

?>
</table>
<?

?>
