rendered paste body<?php if (isset($_SERVER['REMOTE_ADDR'])) { die(); } // Request delay in seconds $requestdelay = 5; $lastrequest = 0; $curstage = -1; $scrobbled = ""; function nextRequest($stage) { global $lastrequest, $requestdelay, $curstage; if (time() > ($lastrequest + $requestdelay)) { if ($curstage == $stage) { $lastrequest = time(); $curstage++; return TRUE; } } else { return FALSE; } } function getLastSong($user) { global $scrobbled; $user = trim($user); $l = file('http://ws.audioscrobbler.com/1.0/user/'.$user.'/recenttracks.txt'); if (count($l) != 0 && strlen($l[0]) > 3) { $songdata = explode(',',$l[0]); $scrobbled .= $user.",".trim($songdata[1])."\r\n"; } } function writeData() { global $curstage, $scrobbled; if ($curstage == -1) { if ($scrobbled != "") { $fh = fopen('c:\apache\htdocs\lastfm\list.txt', 'w+'); fwrite($fh, $scrobbled); fclose($fh); $scrobbled = ""; } } } while (1) { if (nextRequest(-1)) { $friends = file('http://ws.audioscrobbler.com/1.0/user/skauert/friends.txt'); } $maxstage = count($friends); for ($i=0; $i<count($friends); $i++) { if (nextRequest($i)) { getLastSong($friends[$i]); } } if ($curstage == $maxstage) { $curstage = -1; } writeData(); sleep(1); }?>