Add Fletcher Penney plugins to general.
[matthijs/upstream/blosxom-plugins.git] / general / antispam
1 #Bloxsom Plugin:AntiSpam
2 #Author: Fletcher T. Penney
3 #Version: 0.1
4
5 package antispam;
6
7 # --- Configurable variables ----
8
9
10
11 # -------------------------------
12
13 $ignore = 0;
14 $email = '[\w\.]+@\w+(\.\w+)+';
15
16 sub start {
17         1;
18 }
19
20 sub story {
21         my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
22
23         if ($$story_ref =~ m/<!-- noantispam -->/gi || $$body_ref =~ m/<!-- 
24 noantispam -->/gi) {
25                 $ignore = 1;
26         }
27
28         if ($ignore == 0) {
29                 while ($$body_ref =~ /($email)/ig) {
30                         $original=$1;
31                         $masked="";
32                         @decimal = unpack('C*', $original);
33                         foreach $i (@decimal) {
34                                 $masked.="&#".$i.";";
35                         }
36                         $$body_ref =~ s/$original/$masked/ig;
37                 }
38         }
39         1;
40 }
41
42 1;
43
44
45 __END__
46
47 =head1 NAME
48
49 Blosxom Plug-in: antispam
50
51 =head1 DESCRIPTION
52
53 This plugin converts any email addresses in your stories into ascii code.  It 
54 has no visible or functional effect, other than to change the html source code.  
55 So something like this:
56         fletcher@hidden.domain
57
58 Looks like this:
59 &#102;&#108;&#101;&#116;&#99;&#104;&#101;&#114;&#64;&#97;&#108;&#117;&#109;&#110;&#105;&#46;&#100;&#117;&#107;&#101;&#46;&#101;&#100;&#117;
60
61 But when viewed with a web browser, it is translated back into the expected 
62 human readable string.  The idea is that some of the spambots can't read this.  
63 Though as this technique becomes more popular, I am sure that the spambots will 
64 catch on.  But it can't hurt, right?
65
66
67 I would like to figure out how to get this work with Writebacks as well to hide 
68 email address that are submitted, but haven't gotten around to it.  If someone 
69 wants to modify the code and let me know, I can distribute the modified version 
70 and give you credit.
71
72 Let me know of any bugs!!
73
74 =head1 AUTHOR
75
76 Fletcher T. Penney  http://fletcher.freeshell.org
77
78
79 =head1 LICENSE
80
81 This source is submitted to the public domain.  Feel free to use and modify it.  
82 If you like, a comment in your modified source attributing credit to myself for 
83 my work would be appreciated.
84
85 THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND.  USE AT 
86 YOUR OWN RISK!