This old scripts worked, but not combined into one
Posted: Sat Sep 30, 2006 10:48 pm
Ok, I had my nice little radio script using frames, and 3 different scripts. Now, for simplicity, I decided to make them into one page. But, after doing this, they do not work. Here's the list songs script combined with the play song script. It shows the song list, but does not show the play song part at all.
Code: Select all
<html><head>
</head>
<body alink="green" vlink="green" link="green">
<font face="arial">
<font color=green><big>Radio</big></font><small><font color=lightblue><i>Beta</i></font></small>
<small></small>
<br>
<select name="song" onChange="document.location.href=document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value">
<option value="#" selected> Select Song</option>
<!-- MP3s -->
<?php
//define the path as relative
$path = "/homepages/21/d155481990/htdocs/server/songs";
//using the opendir function
$dir_handle = @opendir($path) or die("Error, oh noez!");
// While loop
while ($file = readdir($dir_handle))
{
if($file!="." && $file!=".." && $file!="index.php" && $file!="about.html")
{
$newfile = str_replace(".mp3", "", $file);
$newerfile = str_replace("_", " ", $newfile);
$newerfile = ucwords($newerfile);
echo "<option value=\"?song=$newfile\" target=\"song\">$newerfile</option>";
}
}
//closing the directory
closedir($dir_handle);
// SONG
// Play Song Code
$song = $_GET['song'];
if ($song == null)
{
echo "No song selected.<br>";
}
else
{
echo "Filename: \"$song.mp3\"<br><embed SRC=\"http://randomresources.com/server/songs/$song.mp3\" AUTOSTART=\"true\" HIDDEN=\"true\" LOOP=\"0\" VOLUME=\"100\">";
}
//Reads ID3v1 from a MP3 file and displays it
$mp3 = "songs/$song.mp3"; //MP3 file to be read
$filesize = filesize($mp3);
$file = fopen($mp3, "r");
fseek($file, -128, SEEK_END);
$tag = fread($file, 3);
if($tag == "TAG")
{
$data["Song"] = trim(fread($file, 30));
$data["Artist"] = trim(fread($file, 30));
$data["Album"] = trim(fread($file, 30));
}
else
{
die("MP3 information could not be read.");
}
fclose($file);
while(list($key, $value) = each($data))
{
print("$key: $value<br>\r\n");
}
?></small></font>
</font>
</body>
</html>