chiark / gitweb /
Merge remote branch 'origin/master'
[modbot-mtm.git] / webstump / scripts / webstump.lib.pl
index 8397f8694cc8816fc4c94c81f5a5f68525b34280..9b7fc794acb9242edb238313533b9c1fc5b319e7 100644 (file)
@@ -185,8 +185,9 @@ sub init_webstump {
 
       next if ! -r $file;
 
-      open( FILE, $file );
+      open( FILE, $file ) or die $!;
       $addr = <FILE>;
+      defined $addr or die $!;
       chop $addr;
       close( FILE );
 
@@ -197,8 +198,9 @@ sub init_webstump {
     }
   close( NEWSGROUPS );
 
-  open( LOG, ">>$webstump_home/log/webstump.log" );
-  print LOG "Call from $ENV{'REMOTE_ADDR'}, QUERY_STRING=$ENV{'QUERY_STRING'}\n";
+  open( LOG, ">>$webstump_home/log/webstump.log" ) or die $!;
+  LOG->autoflush(1);
+  print LOG "Call from $ENV{'REMOTE_ADDR'}, QUERY_STRING=$ENV{'QUERY_STRING'}\n" or die $!;
 }
 
 # gets the directory name for the newsgroup
@@ -511,9 +513,10 @@ sub email_message {
   my $sendmail_command = "$sendmail $recipient";
   $sendmail_command =~ /(^.*$)/; 
   $sendmail_command = $1; # untaint
-  open_pipe_for_writing( SENDMAIL, "$sendmail_command > /dev/null " );
-  print SENDMAIL $message;
-  close( SENDMAIL );
+  open_pipe_for_writing( SENDMAIL, "$sendmail_command > /dev/null " )
+                        or die $!;
+  print SENDMAIL $message or die $!;
+  close( SENDMAIL ) or die "$? $!";
                 
 }
 
@@ -582,8 +585,8 @@ sub approval_decision {
       $decision = "reject thread" if $thread_decision eq "ban";
       $decision = "approve" if $thread_decision eq "preapprove";
 
-      $decision = "reject abuse" if $poster_decision eq "ban";
-      $decision = "approve" if $poster_decision eq "preapprove";
+      #$decision = "reject blocklist" if $poster_decision eq "ban";
+      die if $decision ne "approve" and $poster_decision eq "preapprove";
 
       if( -r $fullpath && open( MESSAGE, "$fullpath" ) ) {
         my $RealSubject = "", $From = "", $Subject = "";
@@ -625,7 +628,7 @@ sub approval_decision {
                if $thread_decision eq "watch";
 
 # Subject, newsgroup, ShortDirectoryName, decision, comment
-        &process_approval_decision( $Subject, $newsgroup, $file, $decision, $comment );
+        &process_approval_decision( $Subject, $newsgroup, $file, $decision, $comment, "moderator \U$request{'moderator'}" );
 
       }
     }
@@ -709,6 +712,9 @@ sub processWebRequest {
   } elsif( $action eq "change_password" ) {
     &authenticate( $newsgroup, $moderator, $password );
     &html_change_password;
+  } elsif( $action eq "search_logs" ) {
+    &authenticate( $newsgroup, $moderator, $password );
+    &html_search_logs;
   } elsif( $action eq "validate_change_password" ) {
     &authenticate( $newsgroup, $moderator, $password );
     &validate_change_password;