'; if(!isset($header_end)) $header_end = '
'; # set this to false if you don't want the site's title linked to it's url $header_linked = true; # this is for the start and end of each block of items from each feed if(!isset($block_start)) $block_start = ''; # this is for the start and end of each individual item in each feed if(!isset($item_start)) $item_start = '
  • '; if(!isset($item_end)) $item_end = '
  • '; # this is for the start and end of each item's title if(!isset($item_title_start)) $item_title_start = ''; if(!isset($item_title_end)) $item_title_end = ''; # set this to false if you don't want the each item linked to it's url $item_title_linked = true; # set to true if you don't want titles shortened (defaults to a length # of 200 chars if true, 20 chars if false) $no_short_titles = true; # set this to false if you don't want to show the author's name for each item # if this is false then 'author_start' and 'author_end' don't get used $show_author_name = true; # this is for before and after the author's name for each item # if there is no author information then these do not get used if(!isset($author_start)) $author_start = ' (By: '; if(!isset($author_end)) $author_end = ')
    '; # for atom feeds, link to the author's website if they have one? # note that for rss2 feeds email ids are not linked or displayed. $link_atom_author = true; # set to true if no descriptions should be displayed at all. $no_desc = true; # should really long item descriptions be cut short? $cut_item_desc = true; # how short should they be cut down to? $cut_item_desc_to = 374; # set this to false if you don't want a link to the end of a shortened item $link_truncated_item = true; # this is how many items to show if it is not set in _main.php if(!isset($show_me)) $show_me = 15; # set this to false if you do not want to fix invalid tags in your feeds # this will not fix ALL bad stuff in your feeds but it catches some common problems $fix_bad_tags = true; // BEYOND HERE BE DRAGONS! if ( $rss ) { echo $block_start."\n"; $ii = 1; foreach ($rss->items as $item ) { // now start cycling through items if ( $ii <= $show_me ) { // do it again if we have not reached the limit $item_title = $item[title]; $item_url = $item[link]; $item_desc = $item[description]; if ( isset($item[atom_content]) ) { // get the atom content as the description $item_desc = $item[atom_content]; } if ( $show_author_name ) { // do this if the authors name gets displayed if ( isset($item[author]) ) { // is it rss2? $item_auth = $item[author]; $have_auth = true; // remove the author's email id if present $has_email = strpos($item_auth, '@'); if ( $has_email !== false ) { // we found an email id so remove it and starve a spam-bot $item_auth = substr($item_auth, 0, strrpos($item_auth, ' ')); } } if ( isset($item[dc][creator]) ) { // is it rdf? $item_auth = $item[dc][creator]; $have_auth = true; } if ( isset($item[author_name]) ) { // is it atom? $item_auth = $item[author_name]; $have_auth = true; // link to the author's website if they have one if ( isset($item[author_url]) && $link_atom_author ) { // website present so build a good link $item_auth_url = $item[author_url]; if( !preg_match('#://#', $item_auth_url) ) { // add the http part if it's not there $item_auth_url = 'http://'.$item_auth_url; } $item_auth = "".$item_auth.""; } } } if ( $item_title == '' ) { // if the item is untitled then make one up if ( $no_short_titles ) { $item_title = substr(strip_tags($item_desc), 0, 200); } else { $item_title = substr(strip_tags($item_desc), 0, 20).'...'; } } if ( $item_url == '' ) { // if the item has no link then use the site link $item_url = $rss->channel['link']; } if ( $fix_bad_tags ) { // clean up some bad xhtml that might be in the feed - keep your page valid! $item_desc = preg_replace("(
    )", "
    ", $item_desc); $item_desc = preg_replace("(.gif>)", ".gif\" alt=\"image\" />", $item_desc); $item_desc = preg_replace("(.jpg>)", ".jpg\" alt=\"image\" />", $item_desc); $item_desc = preg_replace("(.png>)", ".png\" alt=\"image\" />", $item_desc); $item_desc = preg_replace("(src=htt)", "src=\"htt", $item_desc); } if ( $cut_item_desc ) { // do this if long descriptions are to be cut down $strip_item_desc = strip_tags($item_desc); $strip_item_desc_len = strlen($strip_item_desc); if ( $strip_item_desc_len >= $cut_item_desc_to ) { if ( $link_truncated_item ) { // do this if cut down items get linked to the article $continued_text = " (read more)"; } else { // do this if truncated items do not get linked to the article $continued_text = " (read more)"; } $item_desc = substr($strip_item_desc, 0, $cut_item_desc_to).$continued_text; } } //this is a hack to not display descriptions if ( $no_desc ) { $item_desc = " "; } $item_title_string = ""; $item_title_string .= $item_start.$item_title_start; if ( $item_title_linked ) { // do this if the item title gets linked $item_title_string .= "".$item_title.""; } else { // do this if the item title does not get linked $item_title_string .= $item_title; } $item_title_string .= $item_title_end."\n"; echo $item_title_string; if ( ( $show_author_name ) && ( $have_auth ) ) { // do this if we want to show the author and have one to show echo $author_start.$item_auth.$author_end; } echo $item_desc.$item_end; } $ii++; } echo $block_end."\n"; } if ( $show_site_name ) { // do this if the site name gets displayed // $site_title = $rss->channel['title']; $site_title = "Joe's Audioscrobbler Profile"; $site_url = $rss->channel['link']; $site_desc = $rss->channel['description']; if ( isset($rss->channel['tagline']) ) { // get the atom tagline as the description $site_desc = $rss->channel['tagline']; } $header_string = ""; $header_string .= $header_start; if ( $header_linked ) { // do this if the site name gets linked $header_string .= "".$site_title.""; } else { // do this if the site name is not linked $header_string .= $site_title; } $header_string .= $header_end."\n"; echo $header_string; } else { echo "

    Houston we have a problem

    "; } ?>