[hns-users:57] Re: board.cgi に spam (コメントスパム)

Back to archive index

藤原 誠/ Makoto Fujiwara makot****@ki*****
2006年 5月 26日 (金) 11:01:49 JST


>                                           千葉市中央区長洲
>                                                    藤原 誠
~/diary/spam_list 
の一行々々に忌避語を書けるようにして見ました。名前は spam-list の
方が良かったでしょうか。? spam が大文字になっているのはご勘弁。

乞添削

--- board-spam.cgi	2005-12-20 18:42:26.000000000 +0900
+++ board.cgi	2006-05-26 10:55:33.000000000 +0900
@@ -399,6 +399,23 @@
     die 'invalid diary' if ($diary && (!($diary =~ /^[0-9]+$/) || length($diary) > 30));
     die 'invalid refid' if ($refid && (!($refid =~ /^[0-9]+$/) || length($refid) > 10));
 
+    my @dirty_words = '';
+    my $spam_list = $HNS::System::DiaryDir . '/spam_list';
+    my @spam_found = ();
+    if ( -f $spam_list & -r $spam_list ) {
+	open(SPAM, $spam_list) || die 'file not found:$!' ;
+	@dirty_words = <SPAM>;
+	print @dirty_words;
+	close(SPAM);
+    };
+    foreach my $word (@dirty_words) {
+	chomp($word);
+	push(@spam_found, grep (/$word/, $body)) ;
+	push(@spam_found, grep (/$word/, $subject)) ;
+	push(@spam_found, grep (/$word/, $site)) ;
+    }
+    die 'prohibited' if (@spam_found);
+
     foreach ($name, $email, $site) {
 	die 'included invalid characters' if /\|/;
     }

---
(藤原)



H14m-hns-users メーリングリストの案内
Back to archive index