<?
# PHP Wiki
# Copyright (C) 1999 John L. Jorgensen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

################################
# 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;
}
?>
