604800) { $print = date("M jS", $original); if($since > 31536000) { $print .= ", " . date("Y", $original); } return $print; } if($since < 60) { $print = "just now"; return $print; } // $j saves performing the count function each time around the loop for($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; // finding the biggest chunk (if the chunk fits, break) if(($count = floor($since / $seconds)) != 0) { break; } } $print = ($count == 1) ? '1 '.$name : "$count {$name}s"; return $print . " ago"; } function c_items($feeds, $count = 10) { foreach($feeds as $feed) { $rss = fetch_rss($feed[url]); if($rss) { $link = $rss->channel[link]; $title = $rss->channel[title]; $items = array_slice($rss->items, 0, $count); foreach($items as $item) { $item[source][url] = $feed[url]; $item[source][type] = $feed[type]; $item[source][link] = $link; $item[source][title] = $title; if(isset($item[date_timestamp])) $cons_timestamp = $item[date_timestamp]; if(isset($item[published])) $cons_timestamp = strtotime(substr($item[published],0,-1)); if(isset($item[updated])) $cons_timestamp = strtotime(substr($item[updated],0,-1)); if(isset($item[dc][date])) $cons_timestamp = strtotime(substr($item[dc][date],0,19)); if(!isset($cons_timestamp)) $cons_timestamp = time(); while(isset($con[$cons_timestamp])) $cons_timestamp--; $con[$cons_timestamp] = $item; $con[$cons_timestamp]['cons_timestamp'] = $cons_timestamp; } } } krsort($con); $con = array_slice($con, 0, $count); return $con; } function print_cons_item($input) { $favicon = "http://rcboyce.com/projects/php/cons/images/small/local.png"; if(file_exists("/home/rcboyce/www/www/projects/php/cons/images/small/".$input[source][type].".png")) $favicon = "http://rcboyce.com/projects/php/cons/images/small/".$input[source][type].".png"; if($input[source][type] == "twitter") { $temp = explode(": ", $input[title], 2); $input[title] = $temp[1]; } echo '

'.$input[source][type].''.$input[title].'

'; switch($input[source][type]) { case "twitter": break; case "blog": echo $input[content][encoded]; break; default: echo "

".$input[description]."

"; break; } echo'
'.time_since($input['cons_timestamp']).' from '.$input[source][title].'
'; } function print_cons3_item($input) { $favicon = "http://rcboyce.com/projects/php/cons/images/small/local.png"; if(file_exists("/home/rcboyce/www/www/projects/php/cons/images/small/".$input[source][type].".png")) $favicon = "http://rcboyce.com/projects/php/cons/images/small/".$input[source][type].".png"; if($input[source][type] == "twitter") { $temp = explode(": ", $input[title], 2); $input[title] = $temp[1]; } switch($input[source][type]) { case "twitter": $output = ""; break; case "blog": $output = $input[content][encoded]; break; default: $output = "

".$input[description]."

"; break; } echo'
  • '.date('M', $input['cons_timestamp']).' '.date('d', $input['cons_timestamp']).'

    '.$input[title].'

    '.$output.'

      posted 13 hours ago at '.$input[source][title].'
  • '; } /* $test = array( array('url' => 'http://www.rcboyce.com/blog/feed/rss2/', 'type' => 'blog'), array('url' => 'http://rboyce.tumblr.com/rss/', 'type' => 'tumblr'), array('url' => 'http://twitter.com/statuses/user_timeline/36393.rss', 'type' => 'twitter'), array('url' => 'http://del.icio.us/rss/rboyce/', 'type' => 'delicious'), ); $items = cons_items($test, 5); echo " "; // print_r(cons_items($test, 5)); */ ?>