diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-25 00:18:20 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-25 00:18:20 +0100 |
commit | 808f2a389fb96a3e86be616aaa3cb3b351933088 (patch) | |
tree | 84d317bff5d0d65a9f3865deb1e4fa1acc0062e1 | |
parent | c47d063ff2076ee38daded85fedacd02055b63a2 (diff) | |
download | istreamdev-808f2a389fb96a3e86be616aaa3cb3b351933088.tar.gz istreamdev-808f2a389fb96a3e86be616aaa3cb3b351933088.tar.bz2 |
M3u generator
-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"; + +?> |