1 # These functions are useful for Gatekeeper product.
3 # check if the header line is to be ignored
5 my $header = pop( @_ );
6 my @delete_headers = ( "NNTP-Posting-Host", "X-Originating-IP",
7 "Received", "Recieved", "Date", "X400",
9 foreach (@delete_headers) {
10 return "yes" if( $header =~ /^$_:/i );
17 ######################################################################
18 # this function reads an article from a file and prepares it for posting.
23 my @delete_headers = ( "NNTP-Posting-Host", "X-Originating-IP",
24 "Received", "Recieved", "Date", "X400",
27 open ARTICLE, $file || return "";
29 my $headers = "", $body = "";
33 my $newsgroups_present = 0;
40 if( /^$/ || /^\S/ ) { # non-whitespace or empty line
43 if( &ignore_header( $header ) ) {
48 if( $header =~ /^Newsgroups: / ) {
49 $newsgroups_present = 1;
50 if( ! ($header =~ $newsgroup)) {
52 $header .= ",$newsgroup\n";
66 $headers .= "$newsgroup\n" if( !$newsgroups_present );
68 $body .= $_ while( <ARTICLE> );
70 print "Header:\n\n$header\nBody:\n\n$body\n" or die $!;
72 return $headers . $body;
75 # processApproved file comment
77 my $comment = pop( @_ );
80 my $article = &prepareArticle( $file );
84 =================================================================
85 == Moderator's comment: $comment\n";
88 &email_message( $article, $posting_gateway ) if( $posting_gateway );
90 if( $posting_spool_dir ) {
92 my $spoolfile = "$posting_spool_dir/$$.$time";
93 open( SPOOL, ">$posting_spool_dir/$$.$time" )
94 || &error( "Can't open $spoolfile" );
95 print SPOOL $message or die $!;
96 close( SPOOL ) or die $!;
101 # processDecision file decision+reason comment
102 sub gk_approval_decision{
103 my $comment = pop( @_ );
104 my $decision = pop( @_ );
105 my $file = pop( @_ );
107 if( $decision eq "approve" ) {
108 &processApproved( $file, $comment );
109 } elsif( $decision eq "reject" ) {
110 my ($dummy, $reason) = split( $decision );
111 &processRejected( $file, $reason, $comment );