From 79804697a6afb0469e668adcea6df047ceab1c08 Mon Sep 17 00:00:00 2001 From: SvenDowideit Date: Sun, 14 Dec 2008 13:09:08 +0000 Subject: [PATCH] Item461: port& clean AntiSpamPlugin git-svn-id: http://svn.foswiki.org/trunk/AntiWikiSpamPlugin@1332 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- data/TWiki/AntiWikiSpamPlugin.txt | 7 +- lib/TWiki/Plugins/AntiWikiSpamPlugin.pm | 123 ++++-------------- lib/TWiki/Plugins/AntiWikiSpamPlugin/MANIFEST | 4 +- lib/TWiki/Plugins/AntiWikiSpamPlugin/build.pl | 4 +- 4 files changed, 35 insertions(+), 103 deletions(-) diff --git a/data/TWiki/AntiWikiSpamPlugin.txt b/data/TWiki/AntiWikiSpamPlugin.txt index fae3263..6bd9669 100644 --- a/data/TWiki/AntiWikiSpamPlugin.txt +++ b/data/TWiki/AntiWikiSpamPlugin.txt @@ -11,7 +11,7 @@ list, it _only_ refuses to save it. *Major premise is not to create any unnecessary load on the server and not to use excess server resources by holding connections open.* All its processing is _only_ done on save, or on attach. -(Foswiki:Extensions/BlackListPlugin does alot of processing on _every_ twiki script, +(Foswiki:Extensions/BlackListPlugin does alot of processing on _every_ topic operation, including view) It uses a timeout on save to check if the list has changed, so if there are no @@ -61,13 +61,12 @@ __Note:__ You do not need to install anything on the browser to use this plugin. | Plugin Author: | TWiki:Main.SvenDowideit - http:///www.WikiRing.com| | Plugin Version: | 4 Sept 2007 (V1.2) | | Change History: |   | +| 14 Dev 2008: | updated for Foswiki v1.0 | | 4 Sept 2007: | updated to 4.2 | | 22 Jul 2006: | resurected it for TWiki 4.0 due to demand for a low resource AntiSpam solution | | 22 Aug 2005: | Initial version | -| TWiki Dependency: | $TWiki::Plugins::VERSION 1.024 | | CPAN Dependencies: | none | -| Other Dependencies: | none | -| Perl Version: | 5.005 | +| Other Dependencies: | internet acces to update the spam list | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Foswiki:Extensions/Benchmark: | %SYSTEMWEB%.GoodStyle nn%, %SYSTEMWEB%.FormattedSearch nn%, %TOPIC% nn% | | Plugin Home: | http://foswiki.org/Extensions/%TOPIC% | diff --git a/lib/TWiki/Plugins/AntiWikiSpamPlugin.pm b/lib/TWiki/Plugins/AntiWikiSpamPlugin.pm index b6cd178..5e74dbe 100644 --- a/lib/TWiki/Plugins/AntiWikiSpamPlugin.pm +++ b/lib/TWiki/Plugins/AntiWikiSpamPlugin.pm @@ -1,6 +1,6 @@ # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ # -# Copyright (C) 2005 Sven Dowideit SvenDowideit@wikiring.com +# Copyright (C) 2005-2008 Sven Dowideit SvenDowideit@wikiring.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -18,19 +18,19 @@ ---+ package AntiWikiSpamPlugin -This is the AntiWikiSpam TWiki plugin. it uses the shared Anti-spam regex list to +AntiWikiSpam plugin uses the shared Anti-spam regex list to check topic text when saving, refusing to save if it finds a matche. =cut -package TWiki::Plugins::AntiWikiSpamPlugin; +package Foswiki::Plugins::AntiWikiSpamPlugin; use Error qw(:try); use strict; use vars qw( $VERSION $RELEASE $pluginName $debug ); -# This should always be $Rev$ so that TWiki can determine the checked-in +# This should always be $Rev$ so that Foswiki can determine the checked-in # status of the plugin. It is used by the build automation tools, so # you should leave it alone. $VERSION = '$Rev$'; @@ -60,13 +60,13 @@ sub initPlugin { my( $topic, $web, $user, $installWeb ) = @_; # check for Plugins.pm versions - if( $TWiki::Plugins::VERSION < 1.026 ) { - TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" ); + if( $Foswiki::Plugins::VERSION < 1.026 ) { + Foswiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" ); return 0; } #forceUpdate - TWiki::Func::registerRESTHandler('forceUpdate', \&forceUpdate); + Foswiki::Func::registerRESTHandler('forceUpdate', \&forceUpdate); # Plugin correctly initialized return 1; @@ -81,7 +81,7 @@ write debug output if the debug flag is set =cut sub writeDebug { - TWiki::Func::writeDebug( "- $pluginName - ".$_[0]) if $debug; + Foswiki::Func::writeDebug( "- $pluginName - ".$_[0]) if $debug; } =pod @@ -90,7 +90,7 @@ sub writeDebug { * =$text= - text _with embedded meta-data tags_ * =$topic= - the name of the topic in the current CGI query * =$web= - the name of the web in the current CGI query - * =$meta= - the metadata of the topic being saved, represented by a TWiki::Meta object + * =$meta= - the metadata of the topic being saved, represented by a Foswiki::Meta object This handler is called just before the save action, checks @@ -122,15 +122,14 @@ sub beforeAttachmentSaveHandler { ### my ( $attachmentAttr, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead my $attachmentName = $_[0]->{"attachment"}; - my $tmpFilename = $_[0]->{"tmpFilename"} - || $_[0]->{"file"}; # workaround for TWiki 4.0.2 bug - my $text = TWiki::Func::readFile( $tmpFilename ); + my $tmpFilename = $_[0]->{"tmpFilename"}; + my $text = Foswiki::Func::readFile( $tmpFilename ); #from BlackListPlugin # check for evil eval() spam in