<?php
header('Content-type: application/rss+xml');
echo('<?xml version="1.0" encoding="utf-8"?>
')?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Shiurim from The Beis</title>
<link>http://www.thebeis.co.uk</link>
<language>en-gb</language>
<image><url>http://www.thebeis.co.uk/images/logobeis.jpg</url><title>Shiurim from The Beis</title><link>http://www.thebeis.co.uk</link></image>  
<copyright>Copyright 2007 The Beis. You may copy the audio for personal use only.</copyright>
<description>The Beis is one of the premier places of Jewish learning in North London. We have several regular shiurim and attract many guest speakers, and try and post as many as we can online at www.thebeis.co.uk. This podcast contains those we have posted most recently</description>
<webMaster>info@thebeis.co.uk (Beis Webmaster)</webMaster>
<lastBuildDate>Thu, 19 Apr 2007 13:10:15 +0100</lastBuildDate>
<pubDate>Thu, 19 Apr 2007 13:10:15 +0100</pubDate>
<atom:link href="http://www.thebeis.co.uk/podcast.xml" rel="self" type="application/rss+xml" />

<itunes:subtitle>Most recent shiurim given in the Beis, as featured on www.thebeis.co.uk</itunes:subtitle>
<itunes:author>The Beis</itunes:author>
<itunes:summary>The Beis is one of the premier places of Jewish learning in North London. We have several regular shiurim and attract many guest speakers, and try and post as many as we can online at www.thebeis.co.uk. This podcast contains those we have posted most recently</itunes:summary>
<itunes:owner>
<itunes:name>The Beis</itunes:name>
<itunes:email>info@thebeis.co.uk</itunes:email>
</itunes:owner>
<itunes:image href="http://www.thebeis.co.uk/logobeis.jpg" />
<itunes:category text="Religion &amp; Spirituality">
<itunes:category text="Judaism" />
</itunes:category>
<itunes:explicit>No</itunes:explicit>

<?php
$dbhost='localhost';
$dbuser='thebeis';
$dbpassword='password';

$conn=mysql_connect($dbhost,$dbuser,$dbpassword) or die ("Failed to connect to database");

$dbase='thebeisdb';
mysql_select_db($dbase);

$result=mysql_query('SELECT SHIURID, SPEAKER, TITLE, DATEGIVEN, LOCATION, FILESIZE, LENGTH, DESCRIPTION FROM SHIUR ORDER BY DATEGIVEN DESC LIMIT 20');
$num=mysql_numrows($result);

$i=0;

while($i<$num) {

$shiurid=mysql_result($result,$i,"SHIURID");
$speaker=mysql_result($result,$i,"SPEAKER");
$title=mysql_result($result,$i,"TITLE");
$dateunformatted=strtotime(mysql_result($result,$i,"DATEGIVEN"));
$dategiven=date("D, d M Y H:i:s O" ,$dateunformatted);
$location=mysql_result($result,$i,"LOCATION");
$length=mysql_result($result,$i,"LENGTH");
$description=mysql_result($result,$i,"DESCRIPTION");

if (substr($location,0,4)=='http'){
$url=$location;
$filesize=mysql_result($result,$i,"FILESIZE");
}
else{
$url="http://www.thebeis.co.uk/$location";
$filesize=filesize($location);
}

$formatdate=date("j-M-y",$dateunformatted);

echo("
<item>
<title>$speaker - $title</title>
<link>http://www.thebeis.co.uk/listen.html?shiurid=$shiurid</link>
<guid>$url</guid>
<description><![CDATA[$description]]></description>
<enclosure url=\"$url\" length=\"$filesize\" type=\"audio/mpeg\" />
<category>Podcasts</category>
<pubDate>$dategiven</pubDate>

<itunes:author>$speaker</itunes:author>
<itunes:explicit>No</itunes:explicit>
<itunes:subtitle><![CDATA[$description]]></itunes:subtitle>
<itunes:summary>Given in The Beis, Hendon on $formatdate</itunes:summary>
<itunes:duration>$length</itunes:duration>
<itunes:keywords>Jewish, shiur, shiurim, podcast, The Beis, Torah, $speaker</itunes:keywords>
</item>
");

$i++;
}

mysql_close($conn);
?>

</channel>
</rss>
