diff options
Diffstat (limited to 'genplaylist.php')
-rwxr-xr-x | genplaylist.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/genplaylist.php b/genplaylist.php new file mode 100755 index 0000000..17c083b --- /dev/null +++ b/genplaylist.php @@ -0,0 +1,56 @@ +<?php + header('Content-Type: text/xml'); + echo "<?xml version=\"1.0\"?>\n"; + echo "<status>\n"; + + $path = $_REQUEST['path']; + $name = $_REQUEST['name']; + + exec('rm playlist/*'); + exec('ln -s ' .addcslashes(quotemeta($path), " &") .'* playlist'); + + $dir_handle = @opendir($path); + if (!$dir_handle) + echo "<m3u>error</m3u>"; + else + { + $found = 0; + while ($medianame = readdir($dir_handle)) + { + if (mediagettype($path .$name) == 2) + { + if ($medianame == $name) + $found = 1; + + if ($found) + $medianame_array[] = $medianame; + } + } + + if ($medianame_array[0]) + { + + // Alphabetical sorting + sort($medianame_array); + + $plfile = fopen("playlist/playlist.m3u", 'w'); + if (!$plfile) + echo "<m3u>error</m3u>"; + else + { + $count = count($medianame_array); + for ($cnt=0; $cnt < $count; $cnt++) + fwrite($plfile, "playlist/" .$medianame_array[$cnt] ."\n"); + + fclose($plfile); + + echo "<m3u>ok</m3u>\n"; + } + } + else + echo "<m3u>error</m3u>"; + } + + echo "</status>\n"; + +?> |