CaptchaPluginPlugin for visual confirmation of new user registration, to prevent automated scripts to create users and spam your wiki with their url's to get a better google ranking. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Line: 9 to 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Syntax Rules | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* The tag %CAPTCHAURL% expands to the url of the image containing the scrambled text; * The tag %CAPTCHAHASH% expands to the hash matching the image. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Examples | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Line: 20 to 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %INTERWIKIPLUGIN_SHORTDESCRIPTION%
* One line description, is shown in the TextFormattingRules topic:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Set SHORTDESCRIPTION = Plugin for visual confirmation of new user registration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* Set SHORTDESCRIPTION = Plugin for Captcha verification / visual confirmation of new user registration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Debug plugin: (See output in data/debug.txt)
* Set DEBUG = 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Line: 28 to 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Custom settings (defaults shown): * Characters to use in generated strings: * Set CHARACTERS = ABCDEFGHKLMNPRSTVWXYZabcdeghpqsuvwxy@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Truetype font to use: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* Truetype font to use (place the font in $prefix/pub/TWiki/CaptchaPlugin, good source of apparently free fonts is http://www.webpagepublicity.com/free-fonts.html):
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Set FONT = TahomaBold?.ttf
* Number of random lines to add (use none for 0):
* Set LINES = 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Line: 44 to 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Download the ZIP file from the Plugin web (see below)
* Unzip CaptchaPlugin.zip in your twiki installation directory. Content:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Apply the patch register.patch to bin/register (alternatively, patch register manual, see section below):
* cd bin
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
register.patch to lib/TWiki/UI/Register.pm (alternatively, patch Register.pm manually, see section below), be sure to make a backup so you can revert the patch if you want to disable the plugin:
* cd /path/to/twiki
* cp lib/TWiki/UI/Register.pm lib/TWiki/UI/Register.pm.dist
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * patch < ../register.patch | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deleted: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Create the directories visualconfirm and visualconfirm/db in your pub/ directory, and make sure it is readable and writable by the user that TWiki is executing as.
* mkdir -p pub/visualconfirm/db
* chown -R nobody pub/visualconfirm
* chmod -R 644 pub/visualconfirm
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
* Restrict access to the database files, for example, by including the following in your httpd.conf:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
<Directory "/path/to/twiki/pub/visualconfirm/db"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
<Directory "/path/to/twiki/pub/TWiki/CaptchaPlugin/_db"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deny from all </Directory> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Make sure the plugin has access to the preferred truetype font, by putting the .ttf file in pub/visualconfirm/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* Make sure the plugin has access to the preferred truetype font, by putting the .ttf file in pub/TWiki/CaptchaPlugin/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Test if the installation was successful: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Create a topic containing <IMG SRC="%VISUALCONFIRMURL%"> and %VISUALCONFIRMHASH%
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* Create a topic containing <IMG SRC="%CAPTCHAURL%"> and %CAPTCHAHASH%
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * When loading this topic you should see an obfuscated character string loaded as a png and a hexadecimal hash. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Check whether the hash database is properly protected by going to the url http://my.twiki.server/my/twiki/path/pub/visualconfirm/db/hashes.pag, you should see a permission denied message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* Check whether the hash database is properly protected by going to the url http://my.twiki.server/my/twiki/path/pub/TWiki/CaptchaPlugin/db/hashes.pag, you should see a permission denied message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Now edit your TWikiRegistration topic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
* Display the image %VISUALCONFIRMURL% somewhere in your form, along with a text instructing new users to copy the obfuscated text into the appropriate text input.
* Add the appropriate text input as Twk1VisualConfirm
* Add a hidden input as Twk1VisualConfirmHash
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
* Display the image %CAPTCHAURL% somewhere in your form, along with a text instructing new users to copy the obfuscated text into the appropriate text input.
* Add the appropriate text input as Twk1CaptchaString
* Add a hidden input as Twk1CaptchaHash having as value %CAPTCHAHASH%
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
* For example, add this to your TWikiRegistration:
<tr>
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
<td valign="top" align="right"><IMG SRC="%VISUALCONFIRMURL%">: <br /> (..) </td> <td><input type="hidden" name="Twk1VisualConfirmHash" value="%VISUALCONFIRMHASH%"> <input type="text" name="Twk1VisualConfirm" size="5"></td> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
<td valign="top" align="right"><IMG SRC="%CAPTCHAURL%">: <br /> (..) </td>
<td><input type="hidden" name="Twk1CaptchaHash" value="%CAPTCHAHASH%">
<input type="text" name="Twk1CaptchaString" size="5"></td> <font color="red">**</font>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
</tr>
* That's it.
Manually patching the register binary | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
Find the line in bin/register that says:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
Find these lines in lib/TWiki/UI/Register.pm:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
# everything OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
} # generate user entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
Insert the code below directly BEFORE that line: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
Insert the code below directly BEFORE the line containing the curly bracket '{': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
# check valid visual confirmation for( $x = 0; $x < $formLen; $x++ ) { $vcHash=$formDataValue[$x] unless(not($formDataName[$x] eq "Visual Confirm Hash")); $vcTxt=$formDataValue[$x] unless(not($formDataName[$x] eq "Visual Confirm")); } open(LOCKFILE,">".&TWiki::getPubDir()."/visualconfirm/db/hashes.lock"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
# check captcha my %database; my $vcHash=$data->{CaptchaHash}; my $vcTxt=$data->{CaptchaString}; open(LOCKFILE,">".&TWiki::Func::getPubDir()."/TWiki/CaptchaPlugin/_db/hashes.lock"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flock(LOCKFILE,2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
dbmopen(%database, &TWiki::getPubDir()."/visualconfirm/db/hashes" ,0644); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
dbmopen(%database, &TWiki::Func::getPubDir()."/TWiki/CaptchaPlugin/_db/hashes" ,0644); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(defined($database{$vcHash})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
$url = &TWiki::getOopsUrl( $webName, $topic, "oopsregvisualconfirm", "The visual confirmation has expired."); TWiki::redirect( $query, $url ); return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
throw TWiki::OopsException( 'captcha', web => $data->{webName}, topic => $topic, def => 'expired_vchash', params => [ "expired" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } my ($time,$txt)=split(',',$database{$vcHash}); if(not(lc($txt) eq lc($vcTxt))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
$url = &TWiki::getOopsUrl( $webName, $topic, "oopsregvisualconfirm", "The character string you entered for visual confirmation is incorrect."); TWiki::redirect( $query, $url ); return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
throw TWiki::OopsException( 'captcha', web => $data->{webName}, topic => $topic, def => 'invalid_vcstr', params => [ "wrong" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dbmclose(%database); close(LOCKFILE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Line: 133 to 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin Info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Line: 151 to 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Related Topics: TWikiPreferences, TWikiPlugins | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| < < |
-- TWiki:Main.KoenMartens - 07 Oct 2005 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
-- TWiki:Main.KoenMartens - 03 Aug 2006 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CaptchaPluginPlugin for visual confirmation of new user registration, to prevent automated scripts to create users and spam your wiki with their url's to get a better google ranking. | ||||||||
| Line: 29 to 29 | ||||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
| Changed: | ||||||||
| < < |
| |||||||
| > > |
* Set FONT = TahomaBold?.ttf | |||||||
| ||||||||
| Changed: | ||||||||
| < < |
| |||||||
| > > |
* Set NOISE = 12 | |||||||
Plugin Installation Instructions | ||||||||
CaptchaPluginPlugin for visual confirmation of new user registration, to prevent automated scripts to create users and spam your wiki with their url's to get a better google ranking. | |||||||||||
| Line: 133 to 133 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Plugin Info
| |||||||||||
| Changed: | |||||||||||
| < < |
| ||||||||||
| > > |
| ||||||||||
| |||||||||||
| Added: | |||||||||||
| > > |
| ||||||||||
| |||||||||||
| Changed: | |||||||||||
| < < |
| ||||||||||
| > > |
| ||||||||||
CaptchaPlugin | |||||||||
| Changed: | |||||||||
| < < |
Plugin for visual confirmation of new user registration. | ||||||||
| > > |
Plugin for visual confirmation of new user registration, to prevent automated scripts to create users and spam your wiki with their url's to get a better google ranking. | ||||||||
| TOC: No TOC in "TWiki.CaptchaPlugin" | |||||||||
| Line: 13 to 13 | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Examples | |||||||||
| Changed: | |||||||||
| < < |
| ||||||||
| > > |
| ||||||||
Plugin Settings | |||||||||
| Line: 25 to 25 | |||||||||
| |||||||||
| Changed: | |||||||||
| < < |
| ||||||||
| > > |
| ||||||||
Plugin Installation Instructions | |||||||||
| Line: 39 to 44 | |||||||||
| |||||||||
| Changed: | |||||||||
| < < |
| ||||||||
| > > |
| ||||||||
| |||||||||
| Added: | |||||||||
| > > |
<Directory "/path/to/twiki/pub/visualconfirm/db">
deny from all
</Directory>
| ||||||||
| |||||||||
| Changed: | |||||||||
| < < |
| ||||||||
| > > |
<tr>
<td valign="top" align="right"><IMG SRC="%VISUALCONFIRMURL%">: <br /> (..) </td>
<td><input type="hidden" name="Twk1VisualConfirmHash" value="%VISUALCONFIRMHASH%">
<input type="text" name="Twk1VisualConfirm" size="5"></td>
</tr>
Manually patching the register binaryFind the line inbin/register that says:
# everything OK
Insert the code below directly BEFORE that line:
# check valid visual confirmation
for( $x = 0; $x < $formLen; $x++ ) {
$vcHash=$formDataValue[$x]
unless(not($formDataName[$x] eq "Visual Confirm Hash"));
$vcTxt=$formDataValue[$x]
unless(not($formDataName[$x] eq "Visual Confirm"));
}
open(LOCKFILE,">".&TWiki::getPubDir()."/visualconfirm/db/hashes.lock");
flock(LOCKFILE,2);
dbmopen(%database, &TWiki::getPubDir()."/visualconfirm/db/hashes" ,0644);
if(!defined($database{$vcHash})) {
$url = &TWiki::getOopsUrl( $webName, $topic, "oopsregvisualconfirm",
"The visual confirmation has expired.");
TWiki::redirect( $query, $url );
return;
}
my ($time,$txt)=split(',',$database{$vcHash});
if(not(lc($txt) eq lc($vcTxt))) {
$url = &TWiki::getOopsUrl( $webName, $topic, "oopsregvisualconfirm",
"The character string you entered for visual confirmation is incorrect.");
TWiki::redirect( $query, $url );
return;
}
dbmclose(%database);
close(LOCKFILE);
Further Development
| ||||||||
Plugin Info | |||||||||
| Line: 64 to 149 | |||||||||
| Related Topics: TWikiPreferences, TWikiPlugins | |||||||||
| Changed: | |||||||||
| < < |
-- KoenMartens? - 07 Oct 2005 | ||||||||
| > > |
-- TWiki:Main.KoenMartens - 07 Oct 2005 | ||||||||
CaptchaPluginPlugin for visual confirmation of new user registration. | ||||||||
| Line: 26 to 26 | ||||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
| Changed: | ||||||||
| < < |
| |||||||
| > > |
| |||||||
Plugin Installation Instructions | ||||||||
| Line: 1 to 1 | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Added: | |||||||||||||||||||||||||||||||||||
| > > |
CaptchaPluginPlugin for visual confirmation of new user registration.Syntax Rules
Examples
Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>%, i.e. %INTERWIKIPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
Plugin Info
| ||||||||||||||||||||||||||||||||||