Ето един скрипт, който си го написах за лични нужди.
Служи за слушане на музика от рс-то на хоста, като само се определят директориите с музика
+ ето този flash file в папката на скрипта: http://www.alsacreations.fr/dewplayer
Служи за слушане на музика от рс-то на хоста, като само се определят директориите с музика
Код:
<?php
header("Content-type: text/html; charset=Windows-1251");
$file = "playlist.txt";
if(!file_exists($file)) touch($file);
if(isset($_POST['dir'])){
$dir = $_POST['dir'];
file_put_contents($file,$dir);
}
if(isset($_POST['manage'])){
echo "<form method=post>";
$content = file_get_contents("$file");
echo "<textarea input type=text name=dir cols=50 rows=10>$content</textarea>";
echo "<p><input type=submit value=Промени>";
exit;
}
if(isset($_POST['search'])) $search = $_POST['search'];
$search = strtolower($search);
echo "<center><form method=post name=manage><input type=submit value='Playlist мениджър' name=manage></form><p>";
if(isset($_POST['play'])){
if(file_exists("delete.txt")){
$fordel = file_get_contents("delete.txt");
unlink("$fordel");
unlink("delete.txt");
}
$play = $_POST['play'];
$play = urldecode($play);
$files = end(explode("/","$play"));
file_put_contents("delete.txt","$files");
if(!file_exists($files) and file_exists($play)) copy($play,$files);
echo "<object type=\"application/x-shockwave-flash\" data=\"dewplayer-multi.swf?mp3=$files&autostart=1\" width=\"200\" height=\"20\"><param name=\"movie\" value=\"dewplayer-multi.swf?mp3=$files&autostart=1\"></object></center>";
}
function index($folder, $debug = false){
if ($debug) {
}
@$d = dir($folder);
while (false !== @($entry = $d->read())) {
$isdir = is_dir($folder."/".$entry);
if (!$isdir and $entry!="." and $entry!="..") {
$file = $folder."/".$entry;
$ext = end(explode(".","$file"));
$file = urlencode($file);
if("$ext" == "mp3" or "$ext" == "MP3"){
$song = explode(".","$entry");
$song = $song[0];
$song = strtolower("$song");
if(isset($_POST['search'])){
$search = $_POST['search'];
if(eregi("$search","$song")) echo "<form method=post><input type=hidden name=play value='$file'><input type=submit value='$song'></form>";
}
else echo "<form method=post><input type=hidden name=play value='$file'><input type=submit value='$song'></form>";
}
} elseif ($isdir and $entry!="." and $entry!="..") {
index($folder."/".$entry,$debug);
}
}
$d->close();
}
echo "<div align=left style=float:right>";
echo "<form method=post><input type=text name=search><p><input type=submit value=Търси></form>";
echo "</div>";
echo "<div align=left style=float:left>";
$content = file_get_contents("$file");
$content = explode("\n","$content");
foreach($content as $dir) index("$dir",true);
echo "</div>";
?>