A very simple Music Libery Builder

My friend Ray was uploading some musics of his to his private network so he can listen to them anywhere he wants without sharing them. So I build wrote this simple PHP page for him to let him build a simple music player by just clicking: (Note: XSPF is the standard for MP3 playlists Details at http://www.xspf.org/)
include 'SecurityChecking.php';
foreach($FileList as $file)
	$content.=""SOMEDIRECTORY.$file."\n"; //And other mp3 meta infos.
$fh = fopen($file, 'w+') or die("can't open file");
fwrite($fh, $content);
echo "Successful! Thanks to Edison.";
function filesInDir($tdir){
	$dirs = scandir($tdir);
        foreach($dirs as $file){
                if (($file == '.')||($file == '..')){}
                elseif (is_dir($tdir.'/'.$file))
	return $return;