Changeset 1117

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

Add support for IP blacklisting modules.

Location:
trunk
Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/Build.PL

    r1093 r1117  
    106106   licence_name licence_url licence_info_url moderation_requires_password 
    107107   enable_node_image enable_common_categories enable_common_locales 
    108    spam_detector_module static_path static_url send_moderation_notifications 
     108   spam_detector_module host_checker_module static_path static_url 
     109   send_moderation_notifications 
    109110  ) ) { 
    110111    my $q_method = $var . "__qu"; 
     
    333334                      "backlink_results.tt", 
    334335                      "banner.tt", 
     336                      "blacklisted_host.tt", 
    335337                      "delete_confirm.tt", 
    336338                      "delete_done.tt", 
  • trunk/Changes

    r1116 r1117  
    22 
    33More detailed changelogs can be found at 
    4 http://dev.openguides.org/log/trunk 
     4<http://dev.openguides.org/log/trunk>. 
    55 
    660.62     
    77        Ensure that all modules we ship are versioned. 
     8        Added experimental support for local IP blacklisting modules; see the 
     9          display_node method in "perldoc OpenGuides" for details. 
    810 
    9110.61    4 July 2007 
  • trunk/MANIFEST

    r1096 r1117  
    3131templates/backlink_results.tt 
    3232templates/banner.tt 
     33templates/blacklisted_host.tt 
    3334templates/delete_confirm.tt 
    3435templates/delete_done.tt 
     
    143144t/77_send_email.t 
    144145t/78_about.t 
     146t/79_host_blacklist.t 
    145147t/templates/15_test.tt 
    146148wiki.cgi 
  • 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; 
  • trunk/lib/OpenGuides/Config.pm

    r1116 r1117  
    44 
    55use vars qw( $VERSION ); 
    6 $VERSION = '0.01'; 
     6$VERSION = '0.02'; 
    77 
    88use Carp qw( croak ); 
     
    2525   licence_name licence_url licence_info_url moderation_requires_password 
    2626   enable_node_image enable_common_categories enable_common_locales 
    27    spam_detector_module static_path static_url send_moderation_notifications 
     27   spam_detector_module host_checker_module static_path static_url 
     28   send_moderation_notifications 
    2829); 
    2930my @questions = map { $_ . "__qu" } @variables; 
     
    112113                     licence_info_url => "", 
    113114                     spam_detector_module => "", 
     115                     host_checker_module => "", 
    114116                     static_path => "/usr/local/share/openguides/static", 
    115117                     send_moderation_notifications => 1 
     
    195197        licence_info_url => "What is the URL to your local page about your licensing policy?", 
    196198        spam_detector_module => "What module would you like to use for spam detection? (optional)", 
     199        host_checker_module => "What module would you like to use to run an IP blacklist? (optional)", 
    197200        static_path => "What directory should we install static content (CSS, images, javascript) to?", 
    198201        static_url => "What is the URL corresponding to the static content?", 
     
    324327=item * spam_detector_module 
    325328 
     329=item * host_checker_module 
     330 
    326331=item * static_path 
    327332