Changeset 30
- Timestamp:
- 02/16/05 08:59:16
- Files:
-
- trunk/plugins/dnsbl/dnsbl.pl (modified) (11 diffs)
- trunk/plugins/dnsbl/tmpl/dnsbl.tmpl (modified) (1 diff)
- trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plugins/dnsbl/dnsbl.pl
r28 r30 44 44 caching_enabled cache_limit 45 45 headers_enabled headers_moderate headers_ignore 46 urlcount_enabled urlcount_moderate_limit urlcount_block_limit 46 47 ); 47 48 } … … 103 104 unless exists $data->{headers_ignore}; 104 105 106 $data->{urlcount_enabled} = 0 unless exists $data->{urlcount_enabled}; 107 $data->{urlcount_moderate_limit} = 5 unless exists $data->{urlcount_moderate_limit}; 108 $data->{urlcount_block_limit} = 10 unless exists $data->{urlcount_block_limit}; 109 105 110 $data->{proxycheck_enabled} = 0 unless exists $data->{proxycheck_enabled}; 106 111 $data->{proxycheck_moderate} = 1 unless exists $data->{proxycheck_moderate}; … … 114 119 sub filter { 115 120 my ($eh, $app, $obj) = @_; 116 121 117 122 # pull these from user configuration settings... 118 123 my $data = $plugin->get_config_hash(); 119 124 120 my (@urls, $blog );125 my (@urls, $blog, $nurls); 121 126 if (ref $obj eq 'MT::Comment') { 122 127 return 1 unless $data->{comment_filter}; … … 125 130 126 131 # comment 127 @urls = extract_urls($obj->text );132 @urls = extract_urls($obj->text, 0, \$nurls); 128 133 push @urls, extract_urls($obj->url) if $obj->url; 129 134 $data->{source_url} = $obj->url; … … 147 152 $data->{__type} = 'Trackback ping'; 148 153 149 if ($data->{domainbl_enabled} ) {150 @urls = extract_urls($obj->excerpt );154 if ($data->{domainbl_enabled} || $data->{urlcount_enabled}) { 155 @urls = extract_urls($obj->excerpt, 0, \$nurls); 151 156 push @urls, extract_urls($obj->source_url) if $obj->source_url; 152 157 } … … 154 159 } 155 160 $data->{__urls} = \@urls; 161 $data->{__nurls} = $nurls; 156 162 157 163 require MT::Blog; … … 177 183 push @tests, \&ipbl_check if $data->{ipbl_enabled}; 178 184 push @tests, \&domainbl_check if $data->{domainbl_enabled}; 185 push @tests, \&urlcount_check if $data->{urlcount_enabled}; 179 186 push @tests, \&proxy_check if $data->{proxycheck_enabled}; 180 187 … … 400 407 } 401 408 409 sub urlcount_check { 410 my ($eh, $app, $obj, $data) = @_; 411 412 my $type = $data->{__type}; 413 my $nurls = $data->{__nurls}; 414 if($nurls >= $data->{urlcount_block_limit}) { 415 $eh->error("Blocking $type on blog " . $obj->blog_id . 416 " because of too many (" . $nurls . 417 ") links"); 418 return BLOCK; 419 420 }elsif($nurls >= $data->{urlcount_moderate_limit}) { 421 # what should we do for trackbacks? 422 if($type eq 'comment') { 423 $eh->error("Moderating $type on blog " . $obj->blog_id . 424 " because of many (" . $nurls . 425 ") links"); 426 return MODERATE; 427 } 428 } 429 return IGNORE; 430 } 431 402 432 sub cache_check { 403 433 my ($eh, $app, $obj, $data) = @_; … … 477 507 478 508 sub extract_urls { 479 my ($str, $single ) = @_;509 my ($str, $single, $total) = @_; 480 510 481 511 # unmunge so we can see encoded urls as well … … 492 522 next unless @parts; 493 523 if (($domain =~ m/^\d+\.\d+\.\d+\.\d+$/) || ($domain =~ m/^\d+$/)) { 524 $$total++ if(defined($total)); 494 525 next if $seen{$domain}; 495 526 $seen{$domain} = 1; … … 498 529 } 499 530 return $domain if $single; 531 $$total++ if(defined($total)); 500 532 my $last = $#parts; 501 533 my $start = length($parts[$last]) < 3 ? 2 : 1; trunk/plugins/dnsbl/tmpl/dnsbl.tmpl
r26 r30 71 71 <hr /> 72 72 73 <input onclick="toggle(this, 'urlcount_prefs')" value="1" type="checkbox" name="urlcount_enabled" id="urlcount_enabled" <TMPL_IF NAME=URLCOUNT_ENABLED>checked="checked"</TMPL_IF> /><label for="urlcount_enabled">Enable link count limits. Moderation/Blocking of comments/trackbacks based on the number of links. </label><br /> 74 <div id="urlcount_prefs" class="sub-field" <TMPL_IF NAME=URLCOUNT_ENABLED>style="display: block"</TMPL_IF>> 75 <p>Moderation Limit. Comments with more links will be moderated automatically:<br /> 76 <input type="text" name="urlcount_moderate_limit" value="<TMPL_VAR NAME=URLCOUNT_MODERATE_LIMIT ESCAPE=HTML>" /> 77 </p> 78 <p>Block Limit. Comments/Trackbacks with more links will be blocked automatically:<br /> 79 <input type="text" name="urlcount_block_limit" value="<TMPL_VAR NAME=URLCOUNT_BLOCK_LIMIT ESCAPE=HTML>" /> 80 </p> 81 82 </div> 83 84 <hr /> 85 73 86 <input onclick="toggle(this, 'proxycheck_prefs')" value="1" type="checkbox" name="proxycheck_enabled" id="proxycheck_enabled" <TMPL_IF NAME=PROXYCHECK_ENABLED>checked="checked"</TMPL_IF> /><label for="proxycheck_enabled">Enable dynamic proxy checking. This involves a limited port scan for IPs that are not blacklisted. Not recommended if your web server cannot make outbound TCP/IP connections.</label><br /> 74 87 <div id="proxycheck_prefs" class="sub-field" <TMPL_IF NAME=PROXYCHECK_ENABLED>style="display: block"</TMPL_IF>> trunk/readme.txt
r29 r30 81 81 legitimate cases. 82 82 83 * Link count limitation. Moderate/Block comments and trackbacks 84 based on the number of links that appear in the message. 83 85 84 86 CREDITS
