A work-around for random mp3 playlist
Posted: 07 Dec 2006, 15:10
You need to follow these steps to get it working:
1. drop rename.php in your gallery folder
2. add this line in your index.php:
Contents of rename.php:
Karl or anyone else: If you think this will introduce bugs or have better solutions, please advise.
Thanks!
1. drop rename.php in your gallery folder
2. add this line in your index.php:
Code
require_once('rename.php');Code
<?php
// Rename files with random names
$musicdir = @opendir("mp3");
$cc = 0;
while($filename = readdir($musicdir)) {
if (ereg("\.mp3|\.MP3", $filename))
{
$namearray[$cc] = "mp3/". $filename; $cc++;
}
}
for ($i=0; $i<count($namearray); $i++) {
$extension = strstr($namearray[$i], ".");
$rndnm = "mp3/". rand(10,1000) . $extension;
@rename($namearray[$i], $rndnm);
}
?>
Thanks!