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';
$FileList=filesInDir('SOMEDIRECTORY');
$content="\n".
	 "\n".
	 "\n";
foreach($FileList as $file)
	$content.=""SOMEDIRECTORY.$file."\n"; //And other mp3 meta infos.
$content.="\n\n";
$file="default.xspf";
$fh = fopen($file, 'w+') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
echo "Successful! Thanks to Edison.";
function filesInDir($tdir){
	$dirs = scandir($tdir);
        foreach($dirs as $file){
                if (($file == '.')||($file == '..')){}
                elseif (is_dir($tdir.'/'.$file))
                        filesInDir($tdir.'/'.$file);
                else
                        $return[]=$file;
        }
	return $return;
}