<?php
 

session_start();
include("include/config.php");
include("include/functions/import.php");
$thebaseurl = $config['baseurl'];

$getfilter = htmlentities(strip_tags($_REQUEST[filter]));
$filter = escape($getfilter);
$showmax = $config['max_syndicate_results'];

if ($filter =="0")
{
	$query = "SELECT * from videos_series order by subscriptions desc limit $showmax";
	$showtitle = "$lang[680]";
	$link   = $config['baseurl']."/syndicate/videoseries/0/$lang[183]"; 
}
elseif ($filter =="1")
{
	$query = "SELECT * from videos_series order by SID desc limit $showmax";
	$showtitle = "$lang[681]";
	$link   = $config['baseurl']."/syndicate/videoseries/1/$lang[175]";
}
elseif ($filter =="2")
{
	$query = "SELECT * from videos_series order by rating desc limit $showmax";
	$showtitle = "$lang[682]";
	$link   = $config['baseurl']."/syndicate/videoseries/2/$lang[184]";
}
elseif ($filter =="3")
{
	$query = "SELECT * from videos_series order by last_added desc limit $showmax";
	$showtitle = "$lang[683]";
	$link   = $config['baseurl']."/syndicate/videoseries/3/$lang[185]";
}
elseif ($filter =="6")
{
	$query = "SELECT * from videos_series where featured='1' order by time_created desc limit $showmax";
	$showtitle = "$lang[231]";
	$link   = $config['baseurl']."/syndicate/videoseries/6/$lang[229]";
}


header("Content-Type: text/xml"); 
header("Expires: 0"); 
print "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; 
print "<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\">\n"; 
print "<channel>\n"; 
print "<title>".$showtitle." - ".$config['site_name']."</title>\n"; 
print "<link>$link</link>\n"; 
print "<description>".$showtitle."</description>\n"; 

$db=mysql_connect ($DBHOST,$DBUSER,$DBPASSWORD) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($DBNAME); 
  
$result = mysql_query($query) or die ('Query Error: ' . mysql_error()); 
while ($results = mysql_fetch_array($result)) 
{ 
  $thumbnail       = $config['seriesurl']."/".$results['thumbnail'];
  $series       = $config['baseurl']."/videoseries/".$results['SID']."/".seo_clean_titles_sendmail($results['name']); 
  $description = str_replace ("&amp","",htmlspecialchars(stripslashes($results['description']))); 
  
  $query="SELECT username FROM members WHERE USERID='".mysql_real_escape_string($results[USERID])."'";
  $executequery=$conn->execute($query);
  $getusername = $executequery->fields[username];
		
	print "<item>\n"; 
	print "  <title>".$results['name']."</title>\n";
	print "  <link>".$series."</link>\n"; 
	print "  <description>\n"; 
	print "    <![CDATA["; 
	print "<img src=\"$thumbnail\" align=\"right\" border=\"0\" width=\"170\" height=\"120\" vspace=\"5\" hspace=\"5\"/>".$description."<br><br>$lang[672]: <a href=\"$config[baseurl]/members/profile/$results[USERID]/$getusername\">$getusername</a>"; 
  	
	print "<br />on ";
	$query="SELECT date_created FROM videos_series WHERE SID='".mysql_real_escape_string($results['SID'])."'";
	$executequery=$conn->execute($query);
	$list=explode('-',$executequery->fields[date_created]);
	print_r($list[2]);print_r('-');
	print_r($list[1]);print_r('-');
	print_r($list[0]);
	print "<br>$lang[671]: $results[subscriptions]<br/>"; 
	print "<br/><br/><br/><br /><hr>"; 
	print "    ]]>\n"; 
	print "  </description>\n"; 
	print "  <author>".$getusername."</author>\n"; 
	print "</item>\n"; 
} 
mysql_close(); 
print "</channel>\n"; 
print "</rss>"; 
?> 