<?
function wikiundo($params){
  global $db,$topic,$backupdir,$scripturl;
  $backupfile="$backupdir/$db/$topic";
  if(is_file($backupfile)){
    $text="<form action=\"$scripturl/$topic\" method=\"post\">\n";
    $text.="<select name=\"undochoice\" size=5>\n";
    $fpin=fopen($backupfile,"r");
    $count=1;
    while (!feof($fpin)){
      $line=fgets($fpin,4096);
      if (ereg("^___.*___\n",$line)){
        $line=chop($line);
        $line=ereg_replace("___","",$line);
        if ($count==1){
          $text.="<option selected value=\"$count\">$line\n";
        } else {
          $text.="<option value=\"$count\">$line\n";
        }
        $count++;
      }
    }
  } else {
    $text="";
    return $text;
  }
  $text.="</select><br>";
  $text.="<input type=\"submit\" value=\"Undo\">\n";
  $text.="<input type=\"hidden\" name=\"request\" value=\"undo\">\n";
  $text.="<input type=\"hidden\" name=\"topic\" value=\"$topic\">\n";
  $text.="</form>";
  return $text;
}
?>
