<?php
 

session_start();
include("include/config.php");
include("include/functions/import.php");
$showmax = $config['max_viewing_now'];
$query = "SELECT * FROM videos WHERE public='1' AND active='1' ORDER BY last_viewed desc LIMIT $showmax"; 

$executequery = mysql_query($query);
header("Content-Type: text/xml"); 
header("Expires: 0"); 
print "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 
print "<ut_response status=\"ok\">\n";
print "<video_list>\n";
while ($results = mysql_fetch_array($executequery)) 
{ 
	$viewnumber = $results['viewcount']; 
	$title2 = $results['title']; 
	$title2 = utf8_encode($title2);
	$duration = $results['runtime']; 
	$mins = floor($duration/60);
	$secs = round(($duration - ($mins * 60)),0);
	$duration = $mins.":".$secs;
  	$videourl = $config['baseurl']."/videos/".$results['VIDEOID']."/";
	$VIDEOID = $results['VIDEOID'];
print "<video>\n";
print "<viewers>";
print "$viewnumber";
print "</viewers>\n";
print "<title>";
print "$title2";
print "</title>\n";
print "<run_time>";
print "$duration";
print "</run_time>\n";
print "<url>";
print "$videourl";
print xml_seotitle_from_videoid($results['VIDEOID']);
print "</url>\n";
print "<thumbnail_url>";
print $config['thumburl'];
print "/";
print "$VIDEOID";
print "-1.jpg";
print "</thumbnail_url>\n";
print "</video>\n";
} 
mysql_close(); 
print "</video_list>\n";
print "</ut_response>"; 
?>