summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-08-05 21:08:36 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-08-05 21:08:36 +0800
commit4eca0acb753df91976f54a38ccb3b79a9893a801 (patch)
tree095f0c6e46b0cfc42137f493756cbf3ce5bd876b
parent817b96d19f820eec588ae12ee61240920d9819e2 (diff)
downloadpttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.tar
pttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.tar.gz
pttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.tar.bz2
pttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.tar.lz
pttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.tar.xz
pttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.tar.zst
pttbbs-4eca0acb753df91976f54a38ccb3b79a9893a801.zip
new filtermail
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2160 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--sample/FILTERMAIL.pm23
-rw-r--r--util/filtermail.pl46
2 files changed, 46 insertions, 23 deletions
diff --git a/sample/FILTERMAIL.pm b/sample/FILTERMAIL.pm
new file mode 100644
index 00000000..2b71a917
--- /dev/null
+++ b/sample/FILTERMAIL.pm
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+# $Id$
+# 本範例僅供參考, 配合 util/filtermail.pl 使用.
+# 請依自行需要改寫後放置於 /home/bbs/bin 下.
+# checkheader() 或 checkbody() 傳回為假時表示直接丟掉該封信.
+package FILTERMAIL;
+
+sub checkheader
+{
+ return 0
+ if( $_[0] =~ /^Subject: .*行銷光碟/im ||
+ $_[0] =~ /^From: .*SpamCompany\.com/im );
+ 1;
+}
+
+sub checkbody
+{
+ return 0
+ if( $_[0] =~ /<script language=\"JavaScript\"/im );
+ 1;
+}
+
+1;
diff --git a/util/filtermail.pl b/util/filtermail.pl
index ad349b1c..1df85b4c 100644
--- a/util/filtermail.pl
+++ b/util/filtermail.pl
@@ -1,32 +1,32 @@
-#!/usr/bin/perl
+#!/usr/local/bin/pperl
# $Id$
-$SaveNoRelay = 0;
-
+use lib qw(/home/bbs/bin/);
+use FILTERMAIL;
$bbsuid = $ARGV[0];
-undef @ARGV;
-$msg = '';
-$norelay = 0;
+undef @ARGV;
+undef $header;
+undef $body;
while( <> ){
- $msg .= $_;
-
- $norelay = 1
- if( (/^Content-Type:/i &&
- ((/multipart/i && !/report/i) || /html/)) ||
- /Content-Type: audio\/x-wav; name=\".*.exe\"/ );
+ $header .= $_;
+ last if( $_ =~ /^\n/ );
+}
+while( <> ){
+ $body .= $_;
}
-if( $norelay ){
- if( $SaveNoRelay ){
- $fn = `/usr/bin/mktemp -q /tmp/norelay.XXXXXXXX`;
- open FH, ">$fn";
- print FH $msg;
- close FH;
- }
+if( FILTERMAIL::checkheader($header) && FILTERMAIL::checkbody($body) ){
+ open FH, "|/home/bbs/bin/realbbsmail $bbsuid";
+ print FH $header;
+ print FH $body;
+ close FH;
}
-else{
- open OUT, "|/home/bbs/bin/realbbsmail $bbsuid";
- print OUT $msg;
- close OUT;
+=xxx
+else {
+ $fn = `/usr/bin/mktemp -q /tmp/norelay.XXXXXXXX`;
+ open FH, ">$fn";
+ print FH $msg;
+ close FH;
}
+=cut