Viewing file: okayuser.cgi (2.77 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl
open (SPAMGATE, "/home/goodluck/public_html/mail/controls/spamgate.txt"); $gatetime = <SPAMGATE>; close (SPAMGATE);
$fromlinefound = 0; $tolinefound = 0; $subjectlinefound=0; while ($inputline = <STDIN>) { if (($fromlinefound == 0 ) && ($inputline =~ /^From:/) ) { $fromline = $inputline; $fromlinefound = 1; } if (($tolinefound == 0 ) && ($inputline =~ /^To:/) ) { $toline = $inputline; $tolinefound = 1; } if (($subjectlinefound == 0 ) && ($inputline =~ /^Subject:/) ) { $subjectline = $inputline; $subjectlinefound = 1; } @message = (@message, $inputline); } $okayuser = 0 ; $fromline =~ tr/A-Z/a-z/; $fromline =~ /[^a-z0-9\-\_\/\+\&\.]([a-z0-9\-\_\/\+\&\.]+\@[a-z0-9\-\.]+)([^a-z0-9\-\.]|\n)/; $fromline = $1; $fromline =~ /(\@.*)$/; $fromdomain = $1; $toline =~ tr/A-Z/a-z/; $toline =~ /[^a-z0-9\-\_\/\+\&\.]([a-z0-9\-\_\/\+\&\.]+\@[a-z0-9\-\.]+)([^a-z0-9\-\.]|\n)/; $toline = $1; if ($toline eq "add\@bingogamingnews.com") { $result = "Discard"; $okayuser = 1; $fromuser = ""; $fromuser = "bob" if ($fromdomain eq "\@bingogamingnews\.com"); $fromuser = "bob" if ($fromline eq "bob\@choisser\.com"); $subjectline =~ s/Subject: //; $subjectline =~ tr/A-Z/a-z/; $subjectline =~ s/\ //g; chomp($subjectline); $fromuser = "" if ($subjectline !~ /^[a-z0-9\-\_\/\&\+\.]*\@([a-z0-9\-]*\.)+[a-z]+$/); if ($fromuser ne "") { open (ADDRSLIST, ">>/home/goodluck/public_html/mail/controls/approved.txt"); print ADDRSLIST ("$subjectline\n"); close (ADDRSLIST); } } else { open (FILELIST, "/home/goodluck/public_html/mail/controls/okayuser.txt"); @filelist = <FILELIST> ; close (FILELIST) ; foreach $file (@filelist) { open (USERS, $file); @users = <USERS> ; close (USERS); foreach $user (@users) { chomp($user); next if ($user !~ /\@/); ## skips any inadvertent blank lines $okayuser=1 if ($fromline eq $user); $okayuser=1 if ($fromdomain eq $user); if ($user =~ /^\@/) { $user =~ s/\@/./; $user = "\\" . "$user"; $okayuser=1 if ($fromdomain =~ /$user/); } last if ($okayuser == 1); } last if ($okayuser == 1); } $okayuser = 1 if (time() < $gatetime); $result = 'Yes'; $result = 'Discard' if ($fromdomain eq "\@bingogamingnews.com"); $result = 'Discard' if ($fromdomain eq "\@snow.he.net"); $result = 'Discard' if ($fromline !~ /\@/); }
$result = 'No' if ($okayuser == 0); ### added if not using Spam Assassin $okayuser = 1 ; ### added if not using Spam Assassin
$userokayed = 0; foreach $line (@message) { if (($okayuser==1) && (($line =~/^X-UIDL:/)||($line !~ /[^\ \t\n]/)) && ($userokayed == 0)) { print STDOUT ("X-BGN-Okay-User: $result\n"); $userokayed = 1; } print STDOUT ("$line"); }
|