note 37100 deleted from function.readdir by sp
| From: | sp@php.net | Date: | Mon, 03 Nov 2003 11:03:50 +0000 |
| Subject: | note 37100 deleted from function.readdir by sp | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59680@lists.php.net to get a copy of this message | ||
Note Submitter: sieber@netzlabor.ch
----
Simple script to read mp3-files in Apples iTunes-Directories. Just put it as index.php in every
directory.
<?php
function getFiles() {
$handle=opendir('.');
$host=getenv("HTTP_HOST");
echo "<a href='http://$host'>$host</a>";
$pfad = str_replace("%20"," ",getenv("REQUEST_URI"));
list($x,$interpret,$album) = explode("/",$pfad);
if ($interpret) { echo "/<a href='http://$host/$interpret'>$interpret</a>/";
}
if ($album) { echo "<a href='http://$host/$interpret/$album'>$album</a>";
}
echo "<br><br>";
while (false !== ($file = readdir ($handle))) {
if ($file != "index.php" AND $file != "." AND $file != ".." AND $file
!= ".htaccess") {
if (strstr($file,".") == ".mp3") { echo "- <a href='$file'
target='_blank'>$file</a><br>"; }
else{ echo "<a href='$file'>$file</a><br>"; }
}
}
closedir($handle);
}
getFiles();
?>