© Copyright RTVE 2006
//Set these to sensible values for your site
// Maximum number of mp3s to offeron the page
$maxFeed = 30;
//Title of page Used by iPodder for download subdirectory name
$titleTAG="RNE - Boletín informativo";
//iPodder 1.0 seems to ignore everything below
//URL of site feed applies too
$linkTAG="";
//Description
$descriptionTAG="Boletin informativo";
//Copyright for feed
$copyrightTAG="Copyright RTVE 2006";
//Your email address
$webMasterTAG="";
?>
///////////////
/////////////
// Main Code
///////////
$rootMP3URL = "http://" . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];
$rootMP3URL = substr($rootMP3URL, 0, strrpos ($rootMP3URL, "/")); // Trim off script name itself
// print" © $copyrightTAG
\n";
print"
\n";
$dirArray = getDir("."); // Lista de mp3 en directorio actual
while (list($filename, $filedate) = each($dirArray)AND $maxFeed > 0) :
$mp3file = new CMP3File;
$mp3file->getid3 ($filename);
$mifichero = "http://www.rtve.es/rne/si/boletin/".htmlentities(str_replace(" ", "%20", $filename)) ;
$nombre = (str_replace(".mp3", "", $filename)) ;
$nombre = (str_replace("_", " ", $nombre)) ;
?>
Boletín informativo =$nombre?>
\n";
print "\n";
// }
// Functions and Classes
function stripJunk ($text) {
// Strip non-text characters
for ($c=0; $c= 32 AND ord($text[$c]) <= 122)
$outText.=$text[$c];
}
return $outText;
}
class CMP3File {
//properties
var $title;
var $artist;
var $album;
var $year;
var $comment;
var $genre;
function getid3 ($file)
{ // read the ID3 or ID3v2 tag from an MP3 file
if (file_exists($file))
{ //after verifying the file exists,
$id_start = filesize($file) - 128;
$fp = fopen($file, "r");
fseek($fp, $id_start);
$tag = fread($fp,3);
if ($tag == "TAG")
{
$this->title = stripJunk(trim(fread($fp, 30)));
$this->artist = stripJunk(trim(fread($fp, 30)));
$this->album = stripJunk(trim(fread($fp, 30)));
$this->year = stripJunk(trim(fread($fp, 4)));
$this->comment = stripJunk(trim(fread($fp, 30)));
$this->genre = stripJunk(trim(fread($fp, 1)));
fclose($fp);
return true;
}
else
{ // No ID3 tag
fclose($fp);
return false;
}
} else //the file doesn't exist
return false;
}
}
function getDir($mp3Dir) {
// Returns directory as array[file]=date in newest to oldest order
$dirArray = array();
$diskdir = "./$mp3Dir/";
if (is_dir($diskdir)) {
$dh = opendir($diskdir);
while (($file = readdir($dh)) != false ) {
if (filetype($diskdir . $file) == "file" && $file[0] != ".") {
if (strrchr(strtolower($file), ".") == ".mp3") {
$ftime = filemtime($mp3Dir."/".$file);
$dirArray[$file] = $ftime;
}
}
}
closedir($dh);
}
asort($dirArray);
$dirArray = array_reverse($dirArray);
return $dirArray;
}
?>