tagging: Allow using titles in for related stories.
[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 =head1 TODO
67
68 Figure out how to get this work with writebacks as well to hide email addresses 
69 that are submitted. 
70
71 =head1 BUGS
72
73 None known; please send bug reports and feedback to the Blosxom
74 development mailing list <blosxom-devel@lists.sourceforge.net>.
75
76 =head1 AUTHOR
77
78 Fletcher T. Penney  http://fletcher.freeshell.org
79
80 This plugin is now maintained by the Blosxom Sourceforge Team,
81 <blosxom-devel@lists.sourceforge.net>.
82
83 =head1 LICENSE
84
85 This source is submitted to the public domain.  Feel free to use and modify it.  
86 If you like, a comment in your modified source attributing credit to myself for 
87 my work would be appreciated.
88
89 THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND.  USE AT 
90 YOUR OWN RISK!