[Spamscan-cvs] spamscan/bin spamscan,1.4,1.5
Brought to you by:
destari
|
From: <de...@us...> - 2003-07-23 02:23:09
|
Update of /cvsroot/spamscan/spamscan/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv32083
Modified Files:
spamscan
Log Message:
Added additional code to check in db for words on incoming spam.
This needs to be configurable in the users' spamscan.conf file.
Index: spamscan
===================================================================
RCS file: /cvsroot/spamscan/spamscan/bin/spamscan,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** spamscan 22 Jul 2003 20:52:25 -0000 1.4
--- spamscan 23 Jul 2003 02:23:05 -0000 1.5
***************
*** 148,151 ****
--- 148,152 ----
&to_filter;
&body_filter;
+ &db_filter;
if ($spampassword eq $passcode) {
***************
*** 295,299 ****
sub spam_algorithm {
# super lame right now
! $spam_weight = $from_value + $to_value + $body_value;
if ($spam_weight >= $spam_threshold) {
$itsspam = 1;
--- 296,300 ----
sub spam_algorithm {
# super lame right now
! $spam_weight = $from_value + $to_value + $body_value + $dbcount;
if ($spam_weight >= $spam_threshold) {
$itsspam = 1;
***************
*** 317,321 ****
$itsspam = 0;
}
! $spamreason_msg = "X-Spam-Scanned: Weight Totals: TOTAL: $spam_weight - From: $from_value\, To: $to_value\, Body: $body_value\n";
foreach $reason (@spamreasons) {
$spamreason_msg = $spamreason_msg . "X-Spam-Scanned: $reason\n";
--- 318,322 ----
$itsspam = 0;
}
! $spamreason_msg = "X-Spam-Scanned: Weight Totals: TOTAL: $spam_weight - From: $from_value\, To: $to_value\, Body: $body_value\, DB: $dbcount\n";
foreach $reason (@spamreasons) {
$spamreason_msg = $spamreason_msg . "X-Spam-Scanned: $reason\n";
***************
*** 500,501 ****
--- 501,536 ----
@completemailmsg = @newcompletemailmsg;
}
+
+ sub db_filter {
+ $dbfile = $filterdir . "spamscan";
+ dbmopen(%phrasedb, "$dbfile", 0644) or die "dbmopen: $! ($dbfile)";
+ # first, check the from address. If it exists in the db, then it's a non-spam address.
+ if ($phrasedb{$fromemail}) {
+ $dbcount = $dbcount - 20;
+ }
+ # now look through phrases, and total up count.
+ @words = split/\s+/,$learntext;
+
+ $maxdepth = 4;
+ $maxsize = ($#words + 1);
+
+ # this loop does all the 1,2, or 3 word combos etc
+ for ($i=0; $i < $maxdepth; $i++) {
+ # this is the "starting element" loop
+ for ($j=0; $j < $maxsize; $j++) {
+ $end = $j + $i;
+ # this would be the printing loop
+ for ($k=$j; $k <= $end; $k++) {
+ $wordling = "$wordling " . "$words[$k]";
+ }
+ $wordling =~ s/\s+$//;
+ $wordcksum = unpack ("%32C*", $wordling) % 32767;
+ # $phrasedb{$wordcksum}--;
+ $dbcount = $dbcount + $phrasedb{$wordling};
+ $wordling = "";
+ }
+ }
+
+ }
+
+
|