set_feed_url($ndsfeed); $ndsparsed->init(); $ndsparsed->handle_content_type(); $ndsoutput['info']['title'] = $ndsparsed->get_title(); // not really using this, but could be useful... $ndsoutput['info']['feed'] = $ndsparsed->subscribe_url(); // not really using this, but could be useful... if ($ndsparsed->data) { $items = $ndsparsed->get_items(); foreach($items as $item) { $ndsoutput['items'][] = array( "title" => $item->get_title(), "date" => $item->get_date('r'), "description" => strip_tags($item->get_content()), "link" => $item->get_permalink(), ); } } // get the current month's local RSS file $thismonth = date("My"); // date format e.g. Aug09 $thismonthfeed = strtolower($thismonth) . ".rss"; $localparsed = new SimplePie(); $localparsed->set_feed_url($thismonthfeed); $localparsed->init(); $localparsed->handle_content_type(); $localoutput['info']['title'] = $localparsed->get_title(); // not really using this, but could be useful... $localoutput['info']['feed'] = $localparsed->subscribe_url(); // not really using this, but could be useful... if ($localparsed->data) { $items = $localparsed->get_items(); foreach($items as $item) { $localoutput['items'][] = array( "title" => $item->get_title(), "date" => $item->get_date('r'), "description" => $item->get_content(), "link" => $item->get_permalink(), ); $urlcache[] = $item->get_permalink(); } } // get the full archive RSS file $archivefeed = "archive.rss"; $archiveparsed = new SimplePie(); $archiveparsed->set_feed_url($archivefeed); $archiveparsed->init(); $archiveparsed->handle_content_type(); if ($archiveparsed->data) { $items = $archiveparsed->get_items(); foreach($items as $item) { $archiveurlcache[] = $item->get_permalink(); } } // foreach NDS item, see if it's in the local file foreach((array)$ndsoutput['items'] as $n) { if (!in_array($n['link'],$urlcache)) { // if not, add it (whilst potentially cleaning it up - but we trust this feed to be OK). $extraitems .= " {$n['link']} {$n['title']} {$n['description']} {$n['date']} "; } if (!in_array($n['link'],$archiveurlcache)) { // if not, add it (whilst potentially cleaning it up - but we trust this feed to be OK). $archiveextraitems .= " {$n['link']} {$n['title']} {$n['description']} {$n['date']} "; } } // save the new local monthly file if updated if ($extraitems) { $monthrss = file_get_contents($thismonthfeed); $monthrss = str_replace("","\n\n".$extraitems,$monthrss); $saved = file_put_contents($thismonthfeed,$monthrss,LOCK_EX); } // add it to the master archive.rss too if ($archiveextraitems) { $archiverss = file_get_contents($archivefeed); $archiverss = str_replace("","\n\n".$archiveextraitems,$archiverss); $saved = file_put_contents($archivefeed,$archiverss,LOCK_EX); } ?>