<?
include "mysqlcon.php";
include "functions.php";
$admin_info = mysql_fetch_assoc(mysql_query("SELECT url FROM bhost_admin"));

// FOR BACKWARDS COMPATIBILITY:
if(isset($_GET['u'])) { $_GET['w'] = $_GET['u']; }
if(isset($_GET['w'])) { $w = $_GET['w']; } else { exit(); }

$getweblog = mysql_query("SELECT * FROM bhost_weblogs WHERE weblog='$w'");
if(mysql_num_rows($getweblog) == 0) { exit(); }
$weblog = mysql_fetch_assoc($getweblog);
$owner = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_users WHERE u_id='$weblog[u_id]'"));

// CHECK IF ADMIN HAS TURNED PODCASTING OFF
$owner_group = mysql_fetch_assoc(mysql_query("SELECT allow_podcast FROM bhost_groups WHERE g_id='$owner[g_id]'"));
if($owner_group[allow_podcast] != "1") { exit(); }

// CHECK IF USER HAS TURNED PODCASTING OFF
if($weblog[podcast_on] != 1) { exit(); }

$basepath1 = url("index", "$weblog[weblog]");

header("Content-Type: text/xml");
header("Pragma: no-cache");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<rss version=\"2.0\">
<channel>
<title>$weblog[title]</title>
<description>$weblog[description]</description>
<link>$basepath1</link>
<language>en-us</language>
<lastBuildDate>".date("r", time())."</lastBuildDate>
<generator>Webligo BlogHoster</generator>
";

$entries = mysql_query("SELECT * FROM bhost_entries WHERE w_id='$weblog[w_id]' AND privacy='3' AND draft='0' AND podcast<>'' AND podcast_size<>'' AND podcast_type<>''  ORDER BY e_id DESC LIMIT $weblog[podcast_entries]");
while($entry = mysql_fetch_assoc($entries)) {
$content = htmlspecialchars(strip_tags(str_replace("&#39;", "'", $entry['contents'])));
$title = htmlspecialchars(strip_tags(str_replace("&#39;", "'", $entry['title'])));
echo "
<item>
<title>$title</title>
<link>$entry[podcast]</link>
<description>$content</description>
<pubDate>".date("r", $entry[date])."</pubDate>
<enclosure url=\"$entry[podcast]\" length=\"$entry[podcast_size]\" type=\"$entry[podcast_type]\" />
</item>
";
}

echo "
</channel>
</rss>";

?>