Twitch stream updates

here is the entire streams.php

<?php
if( isset( $_GET['streamID'] ) ) $streamID = $_GET['streamID'];
else $streamID = '';

if($streamID) {
	
	$stream=safe_query("SELECT * FROM ".PREFIX."streams WHERE streamID='".$streamID."'");
	while($ds=mysql_fetch_array($stream)) {
		
		$streamID = $ds['streamID'];
		$channel = $ds['channel'];
		$title = $ds['title'];
		$type = $ds['type'];
		$status = $ds['status'];
		$viewers = $ds['viewers'];
		$thumb = $ds['thumb'];
		$chat = $ds['chat'];
				
		if($type == 1) $chatz = '<div style="float:left;"><iframe width="650" height="400" frameborder="0" scrolling="no" id="chat_embed" src="http://twitch.tv/chat/embed?channel='.$chat.'&amp;popout_chat=true"></iframe></div>';
				
		// Advertising
		$allbanner = safe_query("SELECT * FROM ".PREFIX."bannerrotation WHERE displayed='1' AND bannertype='1' ORDER BY RAND() LIMIT 0,1");
		$total = mysql_num_rows($allbanner);
		if($total) {
			$banner = mysql_fetch_array($allbanner);
			$pub = '<div style="width:650px; height:80px; margin:10px 0px 10px 10px; float:left;"><a href="ads/out/'.$banner['bannerID'].'/" target="_blank"><img style="width:650px;" src="./images/bannerrotation/'.$banner['banner'].'" border="0" alt="'.htmlspecialchars($banner['bannername']).'" /></a></div>';
		}
		else $pub = '';
		
		
		eval("\$title_stream = \"".gettemplate("stream_header")."\";");
		echo $title_stream;
		 
		if($type == 1) echo '<object type="application/x-shockwave-flash" height="360" width="670" id="live_embed_player_flash" data="http://en.twitch.tv/widgets/live_embed_player.swf?channel='.$channel.'" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://en.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=en.twitch.tv&channel='.$channel.'&auto_play=true&start_volume=25" /></object>'.$pub.'';
		elseif($type == 2) echo '<iframe frameborder="0" scrolling="no" src="http://www.own3d.tv/liveembed/'.$channel.'?autoPlay=true" height="360" width="670"></iframe>'.$pub.'';
		
		eval("\$title_stream = \"".gettemplate("stream_bottom")."\";");
		echo $title_stream;
		
	}
	
}

else {
	
	$featured=safe_query("SELECT * FROM ".PREFIX."streams WHERE displayed='1' AND status='1' AND featured='1' ORDER BY viewers DESC");
	if(mysql_num_rows($featured)) {
		
		eval("\$title_streams = \"".gettemplate("streams_featured_header")."\";");
		echo $title_streams;
		
		while($ds=mysql_fetch_array($featured)) {

			$streamID = $ds['streamID'];
			$title = $ds['title'];
			$info = $ds['info'];
			$type = $ds['type'];
			$channel = $ds['channel'];
			$status = $ds['status'];
			$viewers = $ds['viewers'];
			$thumb = $ds['thumb'];
		
			$game = mysql_fetch_array(safe_query("SELECT tag FROM ".PREFIX."games WHERE gameID = '".$ds['gameID']."' LIMIT 0,1"));
			$game = $game['tag'];
		
			$country = mysql_fetch_array(safe_query("SELECT short FROM ".PREFIX."countries WHERE countryID = '".$ds['countryID']."' LIMIT 0,1"));
			$country = '<img src="images/flags/'.$country['short'].'.gif" width="18" height="12" style="margin: 3px 5px 0px 0px; float:left;" />';
		
			if($type == 1) $type_img = '<img src="gfx/streams/twitch.png" class="type" />';
			elseif($type == 2) $type_img = '<img src="gfx/streams/own3d.png" class="type" />';
		
			echo '<div class="sm_gallery" style="background:url('.$thumb.') #12181C; background-size: 249px 142px; width:216px;">
    <div class="gallery_overlay"><img src="images/games/'.$game.'.gif" alt="" />
    <small>'.$viewers.' VIEWERS</small><br/>
	<a href="stream/'.$streamID.'/">'.$title.'</a>
    </div>
</div>';
				
		}
		
		eval("\$title_streams = \"".gettemplate("streams_featured_bottom")."\";");
		echo $title_streams;
		
	}
	
	
	eval("\$title_streams = \"".gettemplate("streams_header")."\";");
	echo $title_streams;
	$streams=safe_query("SELECT * FROM ".PREFIX."streams WHERE displayed='1' AND status='1' AND featured='0' ORDER BY viewers DESC");
	if(mysql_num_rows($streams)) {
		
		while($ds=mysql_fetch_array($streams)) {

			$streamID = $ds['streamID'];
			$title = $ds['title'];
			$info = $ds['info'];
			$type = $ds['type'];
			$channel = $ds['channel'];
			$status = $ds['status'];
			$viewers = $ds['viewers'];
			$thumb = $ds['thumb'];
		
			$game = mysql_fetch_array(safe_query("SELECT tag FROM ".PREFIX."games WHERE gameID = '".$ds['gameID']."' LIMIT 0,1"));
			$game = $game['tag'];
		
			$country = mysql_fetch_array(safe_query("SELECT short FROM ".PREFIX."countries WHERE countryID = '".$ds['countryID']."' LIMIT 0,1"));
			$country = '<img src="images/flags/'.$country['short'].'.gif" width="18" height="12" style="margin: 3px 5px 0px 0px; float:left;" />';
		
			if($type == 1) $type_img = '<img src="gfx/streams/twitch.png" class="type" />';
			elseif($type == 2) $type_img = '<img src="gfx/streams/own3d.png" class="type" />';
		
			echo '<div class="sm_gallery" style="background:url('.$thumb.') #12181C; background-size: 249px 142px; width:216px;">
       <div class="gallery_overlay"><img src="images/games/'.$game.'.gif" alt="" />
    <small>'.$viewers.' VIEWERS</small><br/>
	<a href="stream/'.$streamID.'/">'.$title.'</a>
    </div>
</div>';
				
		}
	
	} else echo '<div style="margin: 7px 0px 0px 0px;float: left;">No Streams Available.</div>';
	eval("\$title_streams = \"".gettemplate("streams_bottom")."\";");
	echo $title_streams;
}
?>