<?php
$filter = ".mp3";

$directory = "modules/Mp3Player/music";

@$d = dir($directory);
if ($d) { 
	while($entry=$d->read()) {  
		$ps = strpos(strtolower($entry), $filter);
		if (!($ps === false)) {  
			$items[] = $entry; 
		} 
	}
	$d->close();
	sort($items);


}

header("content-type:text/xml;charset=utf-8");
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "	<title>Sample PHP Generated Playlist</title>\n";
echo "	<info>http://fm.tts.lt/</info>\n";
echo "	<trackList>\n";
for($i=0; $i<sizeof($items); $i++) {
	echo "		<track>\n";
	echo "			<title>".($i+1). ". ".$items[$i]."</title>\n";
	echo "			<location>".$directory.'/'.$items[$i]."</location>\n";
	echo "		</track>\n";
}
 echo "	</trackList>\n";
echo "</playlist>\n";
?>