<?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 members WHERE status='1' order by addtime desc limit $showmax";
	$showtitle = "$lang[585]";
	$link   = $config['baseurl']."/syndicate/videos/0/$lang[176]"; 
}
elseif ($filter =="1")
{
	$query = "SELECT * from members WHERE status='1' order by lastlogin desc limit  $showmax";
	$showtitle = "$lang[586]";
	$link   = $config['baseurl']."/syndicate/videos/1/$lang[186]";
}
elseif ($filter =="2")
{
	$query = "SELECT * from members WHERE status='1' order by profileviews desc limit  $showmax";
	$showtitle = "$lang[587]";
	$link   = $config['baseurl']."/syndicate/videos/2/$lang[189]";
}
elseif ($filter =="3")
{
	$query = "SELECT * from members WHERE status='1' order by videosyouviewed desc limit  $showmax";
	$showtitle = "$lang[588]";
	$link   = $config['baseurl']."/syndicate/videos/3/$lang[190]";
}
elseif ($filter =="4")
{
	$query = "SELECT * from members WHERE status='1' AND featured='1' order by username desc limit  $showmax";
	$showtitle = "$lang[165]";
	$link   = $config['baseurl']."/syndicate/videos/4/$lang[53]";
}
elseif ($filter =="5")
{
	$query = "SELECT * from members WHERE status='1' AND gender='1' order by username desc limit  $showmax";
	$showtitle = "$lang[589]";
	$link   = $config['baseurl']."/syndicate/videos/5/$lang[285]";
}
elseif ($filter =="6")
{
	$query = "SELECT * from members WHERE status='1' AND gender='0' order by username desc limit  $showmax";
	$showtitle = "$lang[590]";
	$link   = $config['baseurl']."/syndicate/videos/6/$lang[287]";
}


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)) 
{ 
  		$query="SELECT profilepicture FROM members WHERE USERID='".mysql_real_escape_string($results['USERID'])."' limit 1";
        $executequery=$conn->execute($query);
		$mpp = $executequery->fields[profilepicture];
		if ($mpp == "")
			$profilefpic = "noprofilepicture.gif";
		else
			$profilefpic = $mpp;
			
  $thumbnail       = $config['membersprofilepicurl']."/thumbs/".$profilefpic; 
  $video       = $config['baseurl']."/members/profile/".$results['USERID']."/".$results['username']; 
  $description = str_replace ("&amp","",htmlspecialchars(stripslashes($results['description']))); 
  $getusername = $results['username'];
		
	print "<item>\n"; 
	print "  <title>".$results['username']."</title>\n";
	print "  <link>".$video."</link>\n"; 
	print "  <description>\n"; 
	print "    <![CDATA["; 
	print "<img src=\"$thumbnail\" align=\"right\" border=\"0\" width=\"96\" height=\"72\" vspace=\"5\" hspace=\"5\"/>".$description."<br><br>$lang[672]: <a href=\"$config[baseurl]/members/profile/$results[USERID]/$getusername\">$getusername</a>"; 
	
	print "<br>$lang[203]: ".$results['profileviews']; 
	print "<br>$lang[673]: ".$results['videosyouviewed'];
	print "<br>$lang[140]: ".$results['city'];
	print "<br>$lang[139]: ".$results['country'];
	
	print "<br/><br/><br /><hr>"; 
	print "    ]]>\n"; 
	print "  </description>\n"; 
	print "  <author>".$getusername."</author>\n"; 
	print "</item>\n"; 
} 
mysql_close(); 
print "</channel>\n"; 
print "</rss>"; 
?> 