<?
################################
# This is an example of how to make a new wiki tag.

# The function name must start with wiki and end with the desired command name.
function wikifreshmeat($params){
  $page="";
# Go scoop freshmeat's front page
  $fp=fopen ("http://freshmeat.net", "r");
  if (!fp){
    $page="";
  } else {
    while (!feof($fp)){
      $page.=fgets($fp,100000);
    }
    fclose ($fp);
  }
# Hack out the links and application names
  $text="<table border=1 width=\"90%\"><tr><td bgcolor=\"aaaaaa\"><a href=\"http://freshmeat.net\">Freshmeat</a></td></tr><tr><td>";
  preg_match_all("|<B><FONT SIZE=\"\+2\">(.*)</FONT></B><BR>|U", $page, $headers);
  preg_match_all("|\[ <A HREF=\"/news/(.*)\.html\">comments|U",$page,$links);
  for($i=0;$i<count($headers[1]);$i++){
    $thisheader=$headers[1][$i];
    $thislink="http://freshmeat.net/news/".$links[1][$i].".html";
    $text.="<a href=\"$thislink\">$thisheader</a><br>\n";
  }
  $text.="</td></tr></table>";
# and return the string to the main script
  return $text;
}
?>
