1 # Blosxom Plugin: blacklist
2 # Author: Fletcher T. Penney (http://fletcher.freeshell.org)
8 # --- Configurable variables ---
10 # Where is the blacklist file?
11 $blacklist_file = "$blosxom::plugin_state_dir/blacklist";
13 # Where is the whitelist file?
14 $whitelist_file = "$blosxom::plugin_state_dir/whitelist";
16 # Both the black and white lists consist of one IP address per line
17 # you may also use regexp's to match more than one address
18 # Be careful that you don't accidentally block out the world!
20 # 192.168.1.102 - block this ip addy
21 # 192.168.1.* - block the whole subnet
22 # 192.* - blocks a whole bunch of addresses
23 # .* - blocks the world
24 # 192.168.1 - fails to match, as this is not a complete address
27 # What should I display for a page that isn't found
28 $message = "404 Not Found\n";
30 # ------------------------------
31 my ( @blacklist, @whitelist) = ();
35 if (open (BLACK, "< $blacklist_file")) {
39 if (open (WHITE, "< $whitelist_file")) {
45 $remoteIP = $ENV{'REMOTE_ADDR'};
46 foreach (@whitelist) {
48 if (($_ !~ /^\s*$/) && ($remoteIP =~ /^$_$/)) {
50 warn "IP address $_ is whitelisted\n";
54 foreach (@blacklist) {
56 if (($_ !~ /^\s*$/) && ($remoteIP =~ /^$_$/)) {
57 #$blosxom::output = "Status: 404", exit;
58 warn "IP address $_ is blacklisted\n";
60 # You may want to disable certain plugins,
61 # such as writebacks here, as blosxom is still
62 # functioning - it just won't return any results
63 #$blosxom::plugins{'writebacks'} = 0;
68 return 0; # We're finished
74 # We only end up here if we are blacklisting someone
76 $blosxom::output = $message;
77 print "Status: 404\n";
89 Blosxom Plug-in: blacklist
93 Allows you to blacklist (or whitelist) certain IP addresses or IP ranges by using regexp's. You create two files, consisting of one term per line. The plugin compares the visitor's IP address to each term and quits when it finds a match. Whitelists supercede blacklists.
95 This plugin does not prevent blosxom from performing all of its steps. Instead, if a visitor is blacklisted, it erases all of the HTML just prior to sending it to the visitor's browser, and instead sends a 404 code, making it appear as if your web pages are no longer present.
101 =head2 VERSION HISTORY
103 0.1 - initial public release
107 Fletcher T. Penney, http://fletcher.freeshell.org
111 Blosxom Blacklist Plug-in
112 Copyright 2003, by Fletcher T. Penney
114 Permission is hereby granted, free of charge, to any person obtaining a
115 copy of this software and associated documentation files (the "Software"),
116 to deal in the Software without restriction, including without limitation
117 the rights to use, copy, modify, merge, publish, distribute, sublicense,
118 and/or sell copies of the Software, and to permit persons to whom the
119 Software is furnished to do so, subject to the following conditions:
121 The above copyright notice and this permission notice shall be included
122 in all copies or substantial portions of the Software.
124 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
127 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
128 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
129 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
130 OTHER DEALINGS IN THE SOFTWARE.