<?PHP
// get Radio 1's running order, or try at least. if not return an error
$string = @file_get_contents("http://www.bbc.co.uk/radio1/chrismoyles/".$_GET['src'].".shtml") or die("Error loading Running Order. Possible 404.");

// if that didnt work, and wasnt handled by the or(), then say it again..
if (!$string) {
    print 
"Error loading Running Order. Possible 404.";
} else {

    
/*
      otherwise, search for "Golden Hour" and trim everything beforehand.
      not pretty, but it does the job 9 times out of 10
    */
    
$firstchunk strstr($string"Golden Hour");

    
/*
       now remove all the footer details. a good bet is the running order archive
       as most pages have that right after the golden hour
       (good job the golden hour is the last feature of the show!)
    */
    
$secondchunk strstr($firstchunk"runningorder_archive.shtml"true);
    
    
/*
     if neither the first chunk or second chunk contain data, the chances are
     there is no golden hour this week.
    */
    
if ((!$secondchunk) || (!$firstchunk)) {
        print 
"Looks like this week didn't have a Golden Hour...";
    }
    
    
/*
      if we got the first chunk ok but not the second chunk, then im not sure what
      signifies the end of the running order, so just return the footer anyway.
    */
    
if ((!$secondchunk) && ($firstchunk)) {
        
$secondchunk $firstchunk;
    }
    
    
// return the track listing, and remove the link to the running order archive.
    
print "<strong>".str_replace("<br />
<br />"
""str_replace("<a href=\"http://www.bbc.co.uk/radio1/chrismoyles/runningorder_archive.shtml"""$secondchunk));
}

?>