#!/usr/bin/perl
# Update Menu
$dir="/home/cnews/cannabisnews/news/10";
chdir("/home/cnews/cannabisnews/news/10");
opendir(D,"$dir");
while($file=readdir(D)) {
 if (($file =~ /old/) or ($file !~ /thread.*shtml/)) {
  next;
 }
 print "Doing $dir $file\n";
 ($num)=$file=~m/.*thread([0-9]*).*/;
 open(F,"<$dir/$file");
 @page=<F>;
 close(F);
 open(F,">$dir/$file");
 while ($line=shift(@page)) {
  if ($line =~ /form.*action.*comment/i) {
   print F "<!--#include virtual=\"/news/comment.htm?$num\" -->\n";
   until($line =~ /<\/form>/i) {
    $line=shift(@page);
   }
   next;
  }
  print F $line;
 }
 close(F);
 ++$cnt;
}
close(D);
print "\n$cnt processed\n";
exit;
