<?php include('header.php');?>

<div class="container">
<div class="box">
<div class="title">Recent Searches</div>
<div id="music-button">
<ul>
<?php
if($MusicSql = $mysqli->query("SELECT term FROM search ORDER BY datetime DESC LIMIT 30")){

while ($MusicRow = mysqli_fetch_array($MusicSql)){ 
$MusicName = $MusicRow['term'];
$MusicLink = preg_replace("![^a-z0-9]+!i", "+", $MusicName);

?>
<li><a href="music-search-<?php echo $MusicLink;?>.html"><?php echo stripslashes($MusicRow['term']);?></a></li>
<?php     
	}
$MusicSql->close();
}else{
     printf("Error: %s\n", $mysqli->error);
}
?>
</ul>
</div><!--music-button-->
</div><!--end box-->
<?php if(!empty($Ad1)){?>
<div class="middle-box"><?php echo $Ad1;?></div>
<?php }?>
<div class="box">
<div class="title">Top of the Charts</div>
<div class="inner-box">
<?php
 	$i=1;
    $rss = new DOMDocument();
    $rss->load('http://www.uktop40.co.uk/official_top_40.rss');
    $feed = array();
    foreach ($rss->getElementsByTagName('item') as $node) {
        $item = array ( 
            'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
            'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
            );
        array_push($feed, $item);
    }
    $limit = 25;
    for($x=1;$x<$limit;$x++) {
        $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
		$SongTitle = substr($title, 3);
		$SongTerm =  stristr($SongTitle, '-');
		$SongTerm = substr($SongTerm, 2);
        $description = $feed[$x]['desc'];
		$AlbumArt = stristr($description, 'img src="');
		$AlbumArt = substr($AlbumArt, 9);
		$AlbumArt = explode(" ", $AlbumArt);
		$AlbumArt  = $AlbumArt[0];
		$SongTerm = preg_replace("![^a-z0-9]+!i", "+", $SongTerm);
		       
        echo '<div class="Music-Tumbs"><a href="music-search-'.$SongTerm.'.html" title="#'.$i++.'. '.$SongTitle.'"><img src="'.$AlbumArt.' alt="'.$SongTitle.'" width="92" height="92"></a></div>';
		
    }
?>
</div><!--end inner-box-->
</div><!--end box-->

<?php if(!empty($Ad2)){?>
<div class="middle-box"><?php echo $Ad2;?></div>
<?php }?>

<div class="dc"><?php echo $settings['disclaimer'];?></div>

</div><!--container-->
<?php include('footer.php');?>


