" . $GLOBALS['titletext'] . "
"; $GLOBALS['title'] = false; $GLOBALS['titletext'] = ""; break; case 'LINK': $GLOBALS['linkcount']=""; $GLOBALS['link'] = false; $GLOBALS['linktext'] = ""; break; case 'DESCRIPTION': $GLOBALS['count']=$GLOBALS['count']+1; //echo $GLOBALS['count']; if ($GLOBALS['count']<5) { if ($GLOBALS['count']==1) {} else { // cut out the unnecessary details from the flickr rss feed preg_match("//Ui",$GLOBALS['desctext'], $matches); preg_match("/height=\".*\"/Ui",$matches[0], $matches1); preg_match("/\".*\"/Ui",$matches1[0], $matches11); preg_match("/[0-9][0-9][0-9]/Ui",$matches11[0], $matches2); // check to see whether we need to resize any of the images if ($matches2[0] <= $GLOBALS['desiredheight']) { $fixed = $matches[0]; } else { $fixed = preg_replace("/height=\".*\"/Ui", 'height=\"'.$GLOBALS['desiredheight'].'\"', $matches[0]); } $fixed2 = preg_replace("/width=\".*\"/Ui", "", $fixed); // echo the image echo ''.$GLOBALS['linkcount'].'' . $fixed2 . ' '; }; } else {}; $GLOBALS['description'] = false; $GLOBALS['desctext'] = ""; break; } } // function: charElement // Deals with the character elements (text) function charElement( $parser, $text ) { // Verify the tag that text belongs to. // I set the global tag name to true // when I am in that tag. if( $GLOBALS['title'] == true ) { $GLOBALS['titletext'] .= htmlspecialchars( trim($text) ); } else if( $GLOBALS['link'] == true ) { $GLOBALS['linktext'] .= trim( $text ); } else if( $GLOBALS['description'] == true ) { $GLOBALS['desctext'] .= $text; } } function flickrrelated($thepostid) { global $wpdb, $tablepostmeta; $q = "SELECT meta_value FROM $tablepostmeta WHERE post_id=".$thepostid." AND meta_key='technorati_tags'"; $row = $wpdb->get_row($q); $tags = explode(' ', $row->meta_value); foreach($tags as $i=>$tag) { if( !empty($tag) ) { if ($GLOBALS['out']=="") { $GLOBALS['out'] = trim($tag); }; } } echo '

Related Images

Courtesy of Flickr

'; // Create an xml parser $xmlParser = xml_parser_create(); // Set up element handler xml_set_element_handler( $xmlParser, "startElement", "endElement" ); // Set up character handler xml_set_character_data_handler( $xmlParser, "charElement" ); // Open connection to RSS XML file for parsing. $feed="http://flickr.com/services/feeds/photos_public.gne?tags=".$GLOBALS['out']."&format=rss_200"; $fp = fopen($feed, "r" ) or die( "Cannot read RSS data file." ); // Parse XML data from RSS file. while( $data = fread( $fp, 4096 ) ) { xml_parse( $xmlParser, $data, feof( $fp ) ); } // Close file open handler fclose( $fp ); // Free xml parser from memory xml_parser_free( $xmlParser ); echo '


'; $GLOBALS['count']=0; $GLOBALS['linkcount']=0; $GLOBALS['out']=""; } ?>