Randomiser v - www.puremango.co.uk

"; } ?>
Played:\"".stripslashes($played_tracks[$i])."\"
$errstr ($errno)
"; return false; } else { // prepare headers to send $out = "GET $file HTTP/1.0\r\n"; $out .= "Host: $url\r\n"; $out .= "Referer: http://$url\r\n"; // ask server to return data in plain ascii $out .= "Accept-Encoding: \r\n"; // add anything else (eg cookie): $out .= $extraHeaders; $out .= "Connection: close\r\n"; // terminate headers $out .= "\r\n"; // send headers to server fputs($fsock, $out); // this is where we would receive the response - for this application, we don't want to // in fact, we MUST not. // close connection fclose($fsock); return true; } } // are we supposed to be playing a track? if(isset($_GET['play'])) { if(!empty($_GET['playtrack'])) { // actually run the media player passthru($path_to_media_player." \"".stripslashes(base64_decode($_GET['playtrack']))."\""); // PHP hangs until the media player closes, so the exit() here never gets executed - it's just to remind me that after the passthru we may as well have exited as the effect is the same. exit(); } else { // get track and call self to play track if(!isset($_GET['track'])) { // choose random track and escape path info // get dir list as an array $dir_list = `dir /b/s ${path_to_music}\\*.$filetype`; $dir_list = explode("\n",$dir_list); do { // keep choosing random tracks until we find one that is not excluded. srand((float) microtime() * 10000000); $key = array_rand($dir_list); $track = addslashes($dir_list[$key]); } while(excluded($track)); } else { // we were sent a specific track to play, from the history list. $track = base64_decode($_GET['track']); // tracks sent this way bypass the excluded list; so a user can choose to play the same track twice. } // tell me what track it is, and give link to stop playing echo "Now playing: \"".stripslashes($track)."\" (".my_filesize(stripslashes($track)).")"; echo "

stop   "; // remember track $_SESSION['played_tracks'][] = $track; // call self to run the media player // this is because running the media player causes PHP to hang and we can't output playlist and stop/play list to the user if PHP is waiting for the media player to exit before sending output. // this problem only exists within windows. http_request($hostname,"/".$filename."?play&playtrack=".base64_encode($track)); } } else if(isset($_GET['stop'])){ // doesn't actually stop it, instead, tries to play a non-existant file. http_request($hostname,"/".$filename."?play&playtrack=foo.bar"); // AFAIK, the process will actually stay alive until apache is re-started. // (it serves my purposes, that is all.) echo $media_player_name." stopped

"; } ?> play