Pretty simple script, check it out in action at http://download.askthefool.com/music.
Regenerates a playlist everytime the file is called, and redirect the user to the playlist. This way I can upload a song, and it will be added to the playlist of all the music in that directory.
I know it works with winamp, the rest I’m not sure. Let me know if you use something other than winamp and it works. It shouldn’t be hard to modify to work with any other music player. If you come up with any creative uses email me@askthefool.com and let me know. Code continued..
< ?
// Written by Ashutosh Kadakia
// Feel free to use it
// Question? email me@askthefool.com
// AIM: Ask 2k3
// Copyright 2001-2003 askthefool.com
// 1) Copy this code to a folder that contains your .mp3 files
// 2) Rename it to index.php
// 3) Change the url below to the address of it (No ending slash)
// 4) Create a file called playlist.pls in the folder
// and set the permissions to 777
// Additional:
// You can change this to a diffrent directory simply by changing
// value that the call to function generate_pls to the directory name
$url = "http://download.askthefool.com/music";
// Shouldn't need to mess with the rest.
function generate_pls($file)
{
global $url;
if (is_dir($file)) {
$handle = opendir($file);
while($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
if($filename != "index.php" && $filename != ".htaccess" && $filename != "playlist.pls")
$list[] = "$filename";
}
}
closedir($handle);
$count = count($list);
$file = fopen("playlist.pls",w);
$var = "[playlist]\n";
fputs($file,$var);
$x = 1;
for($y=0; $y<$count; $y++)
{
$var = "File$x=$url/$list[$y]\n";
fputs($file,$var);
$var = "Title$x=$url/$list[$y]\n";
fputs($file,$var);
$var = "Lenght$x=-1\n";
fputs($file,$var);
$x++;
}
$var = "NumberOfEntries=$count\n";
fputs($file,$var);
$var = "Version=2\n";
fputs($file,$var);
fclose($file);
}
}
generate_pls(".");
Header("Location: $url/playlist.pls");
?>