"); fwrite($logf, print_r(getallheaders(),true)); } fclose($logf); */ $cacheTime=10*60; // update every x mins // check for cached file $elapsed = file_exists($cacheFile) ? time() - filemtime($cacheFile) : $cacheTime; if ($elapsed >= cacheTime) { if (@copy($url, $cacheFile)) { include("feedcreator.class.php"); $rss = new UniversalFeedCreator(); $rss->title = "processing.org recent posts"; $rss->description = "the most recent posts to the Processing forum"; $rss->descriptionHtmlSyndicated = true; $rss->descriptionTruncSize = 512; $rss->link = "http://processing.org/discourse/"; $rss->syndicationURL = "http://toxi.co.uk/feeds/p5recent.php"; $html = @file($cacheFile); if ($html!=null) { $itemOpen=false; $item=null; foreach($html as $n => $line) { $line=trim($line); if (substr($line,0,13)=='(.*)<\/a>/',$line,$matches)) { if ($itemOpen) { $rss->addItem($item); } $postURL=$matches[1]; $postID=$matches[2]; $postOffset=$matches[3]; $displayURL=$postURL.';action=display;num='.$postID.';start='.$postOffset.'#'.$postOffset; $title=strip_tags($matches[4]); $item = new FeedItem(); $item->title = $title; $item->link = $displayURL; $itemOpen=true; $authorSet=false; } if ($itemOpen) { // check for date if (preg_match('/Today<\/b> at (.*) /',$line,$matches)) { $item->date = strtotime($matches[1]); } // check for author elseif (preg_match('/action=viewprofile;username=(.*)" alt="View Profile:(.*)">(.*)<\/a>/',$line,$matches)) { $item->author = (strlen($matches[3])>0 ? $matches[3] : "unknown"); $authorSet=true; } // add contents elseif ($authorSet) { if (preg_match('/(.*)<\/td>/',$line,$matches)) { //$offset=strpos($matches[2],'>'); //echo $matches[2]."


"; //$desc=substr($matches[2],$offset+1,strlen($matches[2])-$offset); // [toxi20050516] fix for missing 1st paragraph $desc=$matches[2]; $desc.='
reply to this post
'; if ($item->author!="unknown") $desc.= 'view user profile'; $item->description = $desc; $item->descriptionHtmlSyndicated = true; $authorSet=false; } } } } // add last entry if ($itemOpen) { $rss->addItem($item); } $rss->saveFeed("Atom", $cacheFile); } } } // TODO: check for IP and last sent update timestamp header('Content-Type: application/atom+xml'); //header('Content-Type: text/plain'); // debug only readfile($cacheFile); ?>