<?php
$aOptions = SofaiBloggr::initOptions( false );
$flickr_title = ( strlen( $aOptions[ 'flickr_title' ] ) > 0 ) ? stripslashes( $aOptions[ 'flickr_title' ] ) : 'Flickr';
$flickr_choice = ( strlen( $aOptions[ 'flickr_choice' ] ) > 0 ) ? stripslashes( $aOptions[ 'flickr_choice' ] ) : '14897087%40N04';
$flickr_noi = $aOptions[ 'flickr_noi' ];
$flickr_tou = $aOptions[ 'flickr_tou' ];
// size; s, t, m...
$size = "s";
// width, height
$w = 75;
$h = 75; 
?>

<?php
	if( $flickr_tou == "user" ) $url = "http://www.flickr.com/badge_code_v2.gne?count=" . $flickr_noi . "&display=latest&size=" . $size . "&layout=v&source=" . $flickr_tou . "&user=" . $flickr_choice;
	else if( $flickr_tou == "all_tag" ) $url = "http://www.flickr.com/badge_code_v2.gne?count=" . $flickr_noi . "&display=latest&size=" . $size . "&layout=v&source=" . $flickr_tou . "&tag=" . $flickr_choice;
	$html = file_get_contents( $url );
	$matched = preg_match_all( '|<a.*?href=[\'"](.*?)[\'"].*?>.*?<img.*?src=[\'"](.*?)[\'"].*?><.*?a>|i', $html, $imgs );
	// [ 1 ] - link to image page
	// [ 2 ] - thumbnail link
	// any images pulled?
	if( $matched > 0 ) {
		echo '<div id="flickr" class="section">';
		echo '<h2 class="sectionheader">' . $flickr_title . '</h2>';
		$ci = 1;
		while( $ci <= $matched ) {
			echo "<a href='" . $imgs[ 1 ][ $ci - 1 ] . "' title=''>";
			echo "<img class='flickr' src='" . $imgs[ 2 ][ $ci - 1 ] . "' alt='' width='" . $w . "' height='" . $h . "' />";
			echo "</a>";
			$ci ++;
		}
		echo '</div>';
	}
?>