<?php
$con = mysqli_connect("localhost","thegaunt","t4ntr1c","the_gauntlet_com");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  header("Content-Type: text/xml;charset=UTF-8");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:atom=\"http://www.w3.org/2005/Atom\"
  xmlns:creativeCommons=\"http://backend.userland.com/creativeCommonsRssModule\">\n";
	echo "<channel>\n";
		echo "<title>Gauntlet TV</title>\n";
		echo "<description>Heavy metal news, music videos, interviews, and live footage</description>\n";
		echo "<link>http://www.thegauntlet.com</link>\n";
		echo "<atom:link href=\"http://thegauntlet.com/rss/gauntlettv.rss\" rel=\"self\" type=\"application/rss+xml\" />\n";
		$sqldt = mysqli_query($con, "SELECT dt FROM gauntlettv ORDER BY vidid DESC LIMIT 0,1 ");
	while($rowdt = mysqli_fetch_object($sqldt)){
		
		echo "<lastBuildDate>" . date("Y-m-d", strtotime($rowdt->dt)) . "T11:15:12+00:00</lastBuildDate>\n";
   }


$sql = mysqli_query($con, "SELECT * FROM gauntlettv ORDER BY vidid DESC LIMIT 0,10");
	while($row = mysqli_fetch_object($sql)){
echo "<item>\n";
			echo "<title>" . $row->subtitle . " - " . $row->title . "</title>\n";
  			echo "<guid>http://tv.thegauntlet.com/videos/" . $row->vidid . "</guid>\n";
  			echo "<pubDate>" . date("Y-m-d", strtotime($row->dt)) . "T11:15:12+00:00</pubDate>\n";
  			echo "<media:title>" . $row->subtitle . " - " . $row->title . "</media:title>\n";
  			echo "<media:description>" . $row->synopsis . "</media:description>\n";
  			echo "<media:category>Music Videos</media:category>\n";
  			echo "<media:thumbnail url=\"" . $row->thumbnail_url . "\" />\n";
  			echo "<media:content
   			url=\"http://tv.thegauntlet.com/videos/" . $row->filehd . "\"
   			duration=\"" . $row->secs . "\"
   			bitrate=\"2500\"
   			lang=\"en-us\" />\n";
echo "</item>\n\n";
}
echo "</channel>\n";
echo "</rss>\n";
?>