Show
Ignore:
Timestamp:
08/03/07 20:16:51 (18 months ago)
Author:
earle
Message:

Add support for IP blacklisting modules.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides.pm

    r1105 r1117  
    177177parameter was passed.) 
    178178 
     179If you have specified the C<host_checker_module> option in your 
     180C<wiki.conf>, this method will attempt to call the <blacklisted_host> 
     181method of that module to determine whether the host requesting the node 
     182has been blacklisted. If this method returns true, then the  
     183C<blacklisted_host.tt> template will be used to display an error message. 
     184 
     185The C<blacklisted_host> method will be passed a scalar containing the host's 
     186IP address. 
     187 
    179188=cut 
    180189 
     
    191200 
    192201    my %tt_vars; 
     202 
     203    # If we can, check to see if requesting host is blacklisted. 
     204    my $host_checker = $config->host_checker_module; 
     205    my $is_blacklisted; 
     206    if ( $host_checker ) { 
     207        eval { 
     208            eval "require $host_checker"; 
     209            $is_blacklisted = $host_checker->blacklisted_host(CGI->new->remote_host); 
     210        }; 
     211    } 
     212 
     213    if ( $is_blacklisted ) { 
     214        my $output = OpenGuides::Template->output( 
     215            wiki     => $self->wiki, 
     216            config   => $config, 
     217            template => "blacklisted_host.tt", 
     218            vars     => { 
     219                          not_editable => 1, 
     220                        }, 
     221        ); 
     222        return $output if $return_output; 
     223        print $output; 
     224        return; 
     225    } 
    193226 
    194227    $tt_vars{home_name} = $self->config->home_name;