head	1.10;
access;
symbols;
locks; strict;
comment	@# @;


1.10
date	2007.08.08.15.08.53;	author KoenMartens;	state Exp;
branches;
next	1.9;

1.9
date	2007.08.08.13.30.05;	author KoenMartens;	state Exp;
branches;
next	1.8;

1.8
date	2007.08.06.20.11.03;	author MuSMoAdmin;	state Exp;
branches;
next	1.7;

1.7
date	2006.08.03.10.19.42;	author KoenMartens;	state Exp;
branches;
next	1.6;

1.6
date	2006.08.02.19.51.06;	author KoenMartens;	state Exp;
branches;
next	1.5;

1.5
date	2006.01.03.22.07.04;	author KoenMartens;	state Exp;
branches;
next	1.4;

1.4
date	2005.10.10.17.16.35;	author KoenMartens;	state Exp;
branches;
next	1.3;

1.3
date	2005.10.09.13.02.22;	author KoenMartens;	state Exp;
branches;
next	1.2;

1.2
date	2005.10.08.22.14.46;	author KoenMartens;	state Exp;
branches;
next	1.1;

1.1
date	2005.10.07.17.05.26;	author KoenMartens;	state Exp;
branches;
next	;


desc
@none
@


1.10
log
@none
@
text
@%META:TOPICINFO{author="KoenMartens" date="1186585733" format="1.1" reprev="1.10" version="1.10"}%
---+!! <nop>%TOPIC%

A visual confirmation plugin, known as Captcha, for new user registration. This plugin prevents automated scripts in creating users and spam your wiki with their url's to get a better google ranking. 

%TOC%

------

---++ Syntax Rules

   * The tag %<nop>CAPTCHAURL% expands to the url of the image containing the scrambled text;
   * The tag %<nop>CAPTCHAHASH% expands to the hash matching the image.

---++ Examples

   * N/A

---++ Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>INTERWIKIPLUGIN_SHORTDESCRIPTION%==

   * One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
      * Set SHORTDESCRIPTION = Plugin for Captcha verification / visual confirmation of new user registration.

   * Debug plugin: (See output in =data/debug.txt=)
      * Set DEBUG = 0

   * Custom settings (defaults shown):
      * Number of characters for Captcha:
         * Set LENGTH = 5
      * The characters that you want to use in Captcha:
         * Set CHARACTERS = abcdefghijklmnopqrstuvwxyz%&?@@!1234567890

Additionally, the following settings can be changed in =lib/LocalSite.cfg=, the list below shows the defaults. In time, the above options will be moved to that file too.

   * $TWiki::cfg{Plugins}{CaptchaPlugin}{Expiry}=3600;  # time in seconds after which a captcha will expire and be removed
   * $TWiki::cfg{Plugins}{CaptchaPlugin}{EnableSave}=0;  # enable captcha for topic save
   * $TWiki::cfg{Plugins}{CaptchaPlugin}{SaveForAll}=0;  # enable captcha for all users, not just Main.TWikiGuest
   * $TWiki::cfg{Plugins}{CaptchaPlugin}{DeleteAfterRegistration}=0;  # delete captcha after succesfull registration
   * $TWiki::cfg{Plugins}{CaptchaPlugin}{DeleteAfterSave}=0;  # delete captcha after succesfull topic save


---++ Plugin Installation Instructions

__Note:__ 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. 

   * Download the ZIP file from the Plugin web (see below)
   * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content:
     | *File:* | *Description:* |
     | ==data/TWiki/CaptchaPlugin.txt== | Plugin topic |
     | ==data/TWiki/CaptchaPlugin.txt,v== | Plugin topic repository |
     | ==register-4.1.2.patch== | Patch for the register module |
     | ==templates/oopscaptcha.tmpl== | Error template |
     | ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
     | ==pub/TWiki/CaptchaPlugin/fonts/== | Fonts directory |
     | ==pub/TWiki/CaptchaPlugin/fonts/*== | A collection of free fonts to get you started |
     | ==pub/TWiki/CaptchaPlugin/_db== | Hash database directory |
     | ==pub/TWiki/CaptchaPlugin/img== | Image directory |
   * Apply the patch ==register-4.1.2.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
   * Restrict access to the files, for example, by including the following in your httpd.conf:
<pre>
         &lt;Directory "/path/to/twiki/pub/TWiki/%TOPIC%/_db"&gt;
           deny from all
         &lt;/Directory&gt;
         &lt;Directory "/path/to/twiki/pub/TWiki/CaptchaPlugin/fonts"&gt;
           deny from all
         &lt;/Directory&gt;
         &lt;Directory "/path/to/twiki/pub/TWiki/CaptchaPlugin/img"&gt;
           deny from all
         &lt;/Directory&gt;
</pre>
   * Enable the plugin via the =bin/configure= script
   * Install necessary !TrueType fonts in to ==pub/TWiki/%TOPIC%/fonts/==
      * This allows the plugin to randomly choose the fonts to use
   * Test if the installation was successful:
      * Create a topic containing ==&lt;IMG SRC="%<nop>CAPTCHAURL%"&gt;== and ==%<nop>CAPTCHAHASH%==
      * When loading this topic you should see an obfuscated character string loaded as a png and a hexadecimal hash.
      * Check whether the hash database is properly protected by going to the url http://my.twiki.server/my/twiki/path/pub/TWiki/%TOPIC%/db/hashes.pag, you should see a permission denied message.
   * Now edit your TWiki.TWikiRegistration topic
      * 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 TWiki.TWikiRegistration:
<pre>
            &lt;tr&gt;
              &lt;td valign="top" align="right"&gt;&lt;IMG SRC="%<nop>CAPTCHAURL%"&gt;: &lt;br /&gt; (..) &nbsp; &lt/td&gt;
              &lt;td&gt;&lt;input type="hidden" name="Twk1CaptchaHash" value="%<nop>CAPTCHAHASH%"&gt;
                  &lt;input type="text" name="Twk1CaptchaString" size="5"&gt;&lt;/td&gt;  =&lt;font color="red"&gt;**&lt;/font&gt;=
            &lt;/tr&gt;
</pre>
   * That's it.

---+++ Captcha on topic edit

If you want to protect edits by Main.TWikiGuest with a captcha, add the following line to your =lib/LocalSite.cfg=:

<pre>$TWiki::cfg{Plugins}{CaptchaPlugin}{EnableSave} = 1;</pre>

Of course, you will need the !Twk1CaptchaHash and !Twk1CaptchaString input fields somewhere in your edit template.

For example, if you are using the default pattern skin, change =templates/edit.pattern.tmpl=. Find:

<pre>
%<nop>TMPL:DEF{"textarea"}%&lt;textarea class="twikiEditboxStyleProportional" id="topic" name="text" rows="%<nop>EDITBOXHEIGHT%" cols="%<nop>EDITBOXWIDTH%" style='%<nop>EDITBOXSTYLE%' onkeydown='handleKeyDown(event)'&gt;%<nop>TEXT%&lt;/textarea&gt;&lt;script type="text/javascript"&gt;initTextAreaHeight();&lt;/script&gt;
%<nop>TMPL:END%
</pre>


and add before TMPL:END:

<pre>
%<nop>TMPL:DEF{"textarea"}%&lt;textarea class="twikiEditboxStyleProportional" id="topic" name="text" rows="%<nop>EDITBOXHEIGHT%" cols="%<nop>EDITBOXWIDTH%" style='%<nop>EDITBOXSTYLE%' onkeydown='handleKeyDown(event)'&gt;%<nop>TEXT%&lt;/textarea&gt;&lt;script type="text/javascript"&gt;initTextAreaHeight();&lt;/script&gt;
              &lt;IMG SRC="%CAPTCHAURL%"/&gt;
              &lt;input type="hidden" name="Twk1CaptchaHash" value="%CAPTCHAHASH%"/&gt;
              &lt;input type="text" name="Twk1CaptchaString" size="5"/&gt;
%<nop>TMPL:END%
</pre>

You might want to hide the captcha for logged in users (context authenticated), see TWiki.VarIF for more information on conditional rendering.

---+++ Manually patching the register binary

Refer to the patch file.

---++++ Guide for TWiki 4.0.5
Find these lines in ==lib/TWiki/UI/Register.pm==:
<pre>
 }
 
 # generate user entry
</pre>

Insert the code below directly *BEFORE* the line containing the curly bracket '{':

<pre>
    # verify captcha
    eval { use TWiki::Plugins::CaptchaPlugin; };

    my %database;
    my $vcHash = $data->{CaptchaHash};
    my $vcTxt = $data->{CaptchaString};

    open(LOCKFILE,">".&TWiki::Func::getPubDir()."/TWiki/CaptchaPlugin/_db/hashes.lock");
    flock(LOCKFILE,2);

    dbmopen(%database, &TWiki::Func::getPubDir()."/TWiki/CaptchaPlugin/_db/hashes",0644);

    my ($time,$txt) = split(',',$database{$vcHash});

    if ( not(lc($txt) eq lc($vcTxt)) || ($txt eq '') ) {
                dbmclose(%database);
                close(LOCKFILE);
                throw TWiki::OopsException( 'captcha',
                                           web => $data->{webName},
                                       topic => $topic,
                                       def => 'invalid_vcstr',
                                       params => [ "wrong" ] );
    }

    dbmclose(%database);

    close(LOCKFILE);

    if($TWiki::cfg{Plugins}{CaptchaPlugin}{DeleteAfterRegistration}) {
        TWiki::Plugins::CaptchaPlugin::expire($vcHash);
    }

</pre>

Now find:

<pre>
             # 'WikiName' omitted because they can't
             # change it, and 'Confirm' is a duplicate
             push( @@{$data->{form}}, $form )
              unless ($name eq 'WikiName' || $name eq 'Confirm');
</pre>

and change the last line to:

<pre>
             # 'WikiName' omitted because they can't
             # change it, and 'Confirm' is a duplicate
             push( @@{$data->{form}}, $form )
              unless ($name eq 'WikiName' || $name eq 'Confirm' || $name eq 'CaptchaHash' || $name eq 'CaptchaString');
</pre>
---++ Further Development

   * Refactor to comply with TWiki's convention
   * Remove created .png files -&gt; is already done on expiry, right?
   * Adjustable font size range
   * Adjustable height and width
   * Option of Black and White only

---++ Plugin Info

|  Plugin Author: | TWiki:Main.KoenMartens, TWiki:Main.KwangErnLiew |
|  Plugin Version: | 06 Aug 2007 1.5-pre2 |
|  Change History: | &nbsp; |
|  08 Aug 2007: | Added support for captcha on topic save (thanks TWiki:Main.KwangErnLiew), fixed some minor bugs, added some free fonts |
|  06 Aug 2007: | Colourised fonts; Randomised font type, font size, background colour, and font positioning; Fixed hash display on user pages; Modified oopscaptcha.tmpl |
|  03 Aug 2006: | Renamed to %TOPIC%, adapted to Dakar (TWiki 4.0.x). |
|  03 Jan 2006: | Fixed some problems with expiry, also optimised according to TWiki:TWiki.TWikiPlugins#FastPluginHints. |
|  10 Oct 2005: | Strip hash and text from arguments to register binary, or they will end up in the newly created user topic. |
|  07 Oct 2005: | Initial version |
|  TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
|  CPAN Dependencies: | GD, Digest::MD5 |
|  Other Dependencies: | none |
|  Perl Version: | 5.005 |
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
|  TWiki:Plugins/Benchmark: | %TWIKIWEB%.GoodStyle 98%, %TWIKIWEB%.FormattedSearch 98%, TWiki.TWikiRegistration (patched) 85% |
|  Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins
@


1.9
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1186579805" format="1.1" reprev="1.9" version="1.9"}%
d35 1
a35 1
Additionally, the following settings can be added to =lib/LocalSite.cfg=. In time, the above options will be moved to that file too.
d38 5
a42 1
   * $TWiki::cfg{Plugins}{CaptchaPlugin}{EnableSave}=1;  # enable captcha for topic save
d141 2
d167 5
d202 1
a202 1
|  Plugin Version: | 06 Aug 2007 1.5-pre1 |
@


1.8
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="MuSMoAdmin" date="1186431063" format="1.1" reprev="1.8" version="1.8"}%
d35 5
d52 2
a53 1
     | ==pub/TWiki/CaptchaPlugin/Fonts/== | Fonts directory |
d55 1
a55 1
     | ==pub/TWiki/CaptchaPlugin/_img== | Image directory |
d60 1
a60 1
   * Restrict access to the database files, for example, by including the following in your httpd.conf:
d65 6
d72 2
a73 1
   * Install necessary !TrueType fonts in to ==pub/TWiki/%TOPIC%/Fonts/==
d93 28
d122 1
d136 1
a136 1
    # check captcha
d138 3
a140 2
    my $vcHash=$data->{CaptchaHash};
    my $vcTxt=$data->{CaptchaString};
d144 1
a144 9
    dbmopen(%database, &TWiki::Func::getPubDir()."/TWiki/CaptchaPlugin/_db/hashes" ,0644);

    if(!defined($database{$vcHash})) {
        throw TWiki::OopsException( 'captcha',
                                    web => $data->{webName},
                                    topic => $topic,
                                    def => 'expired_vchash',
                                    params => [ "expired" ] );
    }
d146 1
a146 1
    my ($time,$txt)=split(',',$database{$vcHash});
d148 8
a155 6
    if(not(lc($txt) eq lc($vcTxt))) {
        throw TWiki::OopsException( 'captcha',
                                    web => $data->{webName},
                                    topic => $topic,
                                    def => 'invalid_vcstr',
                                    params => [ "wrong" ] );
d163 17
a181 1
   * Fix timer (expiry)
d183 1
a183 1
   * Remove created .png files
d193 1
a209 3


-- TWiki:Main.KoenMartens - 03 Aug 2006
@


1.7
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1154600382" format="1.1" reprev="1.7" version="1.7"}%
d4 1
a4 1
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. 
d27 1
a27 1
      * Set DEBUG = 1
d30 4
a33 10
      * Characters to use in generated strings:
         * Set CHARACTERS = ABCDEFGHKLMNPRSTVWXYZabcdeghpqsuvwxy@@
      * Truetype font to use (place the font in <code>$prefix/pub/TWiki/CaptchaPlugin</code>, 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
      * Number of random circles to add (use ==none== for 0):
         * Set CIRCLES = 10
      * Noise, percentage of pixels to flip randomly after generating graphics (use ==none== for 0%):
         * Set NOISE = 12
d44 1
a44 1
     | ==register.patch== | Patch for the register module |
d47 1
a47 1
     | ==pub/TWiki/CaptchaPlugin/TahomaBold.ttf== | Default font |
d50 1
a50 1
   * Apply the patch ==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:
d60 2
a61 1
   * Make sure the plugin has access to the preferred truetype font, by putting the ==.ttf== file in ==pub/TWiki/%TOPIC%/==
d81 1
d83 1
d128 6
a133 3
   * Make number of characters configurable
   * Make font size configurable
   * Find out how to safely delete images from the register binary
d137 7
a143 3
|  Plugin Author: | TWiki:Main.KoenMartens |
|  Plugin Version: | 03 Aug 2006 (V1.2) |
|  Change History: | <!-- versions below in reverse order -->&nbsp; |
a144 3
|  10 Oct 2005: | Strip hash and text from arguments to register binary, or they will end up in the newly created user topic. |
|  03 Jan 2006: | Fixed some problems with expiry, also optimised according to TWiki:TWiki.TWikiPlugins#FastPluginHints. |
|  03 Aug 2006: | Renamed to %TOPIC%, adapted to Dakar (TWiki 4.0.x). |
a158 19

%META:FILEATTACHMENT{name="luxisbi.ttf" attr="" autoattached="1" comment="" date="1154546219" path="luxisbi.ttf" size="65568" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="TahomaBold.ttf" attr="" autoattached="1" comment="" date="1154548091" path="TahomaBold.ttf" size="195956" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="f8d9367a6d41cf92619b89188aa7befa.png" attr="" autoattached="1" comment="" date="1154596686" path="f8d9367a6d41cf92619b89188aa7befa.png" size="1303" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="05c156f95c6ef8ae9591caad2b6c6581.png" attr="" autoattached="1" comment="" date="1154548358" path="05c156f95c6ef8ae9591caad2b6c6581.png" size="1261" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="fce0a41ec99a29ccbc48b89b699c3f16.png" attr="" autoattached="1" comment="" date="1154548349" path="fce0a41ec99a29ccbc48b89b699c3f16.png" size="1312" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="cf15d69a13f0408cf48769ae28a9e81b.png" attr="" autoattached="1" comment="" date="1154548271" path="cf15d69a13f0408cf48769ae28a9e81b.png" size="1294" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="b811fee8f0ca2c9e1916050e0673a4ed.png" attr="" autoattached="1" comment="" date="1154548371" path="b811fee8f0ca2c9e1916050e0673a4ed.png" size="1263" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="54c87dd0ccd02046324ef17f55f9bf1c.png" attr="" autoattached="1" comment="" date="1154545942" path="54c87dd0ccd02046324ef17f55f9bf1c.png" size="773" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="9d349e919dbe95f575b36e985d98f875.png" attr="" autoattached="1" comment="" date="1154548337" path="9d349e919dbe95f575b36e985d98f875.png" size="1277" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="7d467cdaabfbc12019d16dd429d2be9e.png" attr="" autoattached="1" comment="" date="1154546224" path="7d467cdaabfbc12019d16dd429d2be9e.png" size="1227" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="957688f290596a7f4aa4c09613ad0177.png" attr="" autoattached="1" comment="" date="1154598500" path="957688f290596a7f4aa4c09613ad0177.png" size="1282" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="c8b94fc4649a3f7fbe811acc29257c3c.png" attr="" autoattached="1" comment="" date="1154548344" path="c8b94fc4649a3f7fbe811acc29257c3c.png" size="1214" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="3426709e3fa5b47e46c096f42bd949a4.png" attr="" autoattached="1" comment="" date="1154548353" path="3426709e3fa5b47e46c096f42bd949a4.png" size="1225" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="088f7acb964be1f25e5d01c5d23d3660.png" attr="" autoattached="1" comment="" date="1154539997" path="088f7acb964be1f25e5d01c5d23d3660.png" size="779" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="87cf5aaa6b29f32476e11947e2b5531c.png" attr="" autoattached="1" comment="" date="1154548219" path="87cf5aaa6b29f32476e11947e2b5531c.png" size="1318" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="f3ce477fa4d448916f97e514e47f3c16.png" attr="" autoattached="1" comment="" date="1154597978" path="f3ce477fa4d448916f97e514e47f3c16.png" size="1315" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="b3afa94a6ebc0970fb701f57b802113a.png" attr="" autoattached="1" comment="" date="1154548363" path="b3afa94a6ebc0970fb701f57b802113a.png" size="1236" user="UnknownUser" version=""}%
%META:FILEATTACHMENT{name="0d5a4bd5b05cdc627f42673908d04970.png" attr="" autoattached="1" comment="" date="1154548210" path="0d5a4bd5b05cdc627f42673908d04970.png" size="1304" user="UnknownUser" version=""}%
@


1.6
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1154548266" format="1.1" reprev="1.6" version="1.6"}%
d12 2
a13 1
   * None
d24 1
a24 1
      * Set SHORTDESCRIPTION = Plugin for visual confirmation of new user registration.
d32 1
a32 1
      * Truetype font to use:
d48 4
a51 4
     | ==data/TWiki/VisualConfirmPlugin.txt== | Plugin topic |
     | ==data/TWiki/VisualConfirmPlugin.txt,v== | Plugin topic repository |
     | ==register.patch== | Patch for the register binary |
     | ==templates/oopsregvisualconfirm.tmpl== | Error template |
d53 6
a58 2
   * Apply the patch ==register.patch== to ==bin/register== (alternatively, patch register manual, see section below):
      * cd bin
a59 4
   * 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
d62 1
a62 1
         &lt;Directory "/path/to/twiki/pub/visualconfirm/db"&gt;
d66 1
a66 1
   * Make sure the plugin has access to the preferred truetype font, by putting the ==.ttf== file in ==pub/visualconfirm/==
d68 1
a68 1
      * Create a topic containing ==&lt;IMG SRC="%<nop>VISUALCONFIRMURL%"&gt;== and ==%<nop>VISUALCONFIRMHASH%==
d70 1
a70 1
      * 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.
d72 3
a74 3
      * 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==
d78 3
a80 3
              &lt;td valign="top" align="right"&gt;&lt;IMG SRC="%<nop>VISUALCONFIRMURL%"&gt;: &lt;br /&gt; (..) &nbsp; &lt/td&gt;
              &lt;td&gt;&lt;input type="hidden" name="Twk1VisualConfirmHash" value="%<nop>VISUALCONFIRMHASH%"&gt;
                  &lt;input type="text" name="Twk1VisualConfirm" size="5"&gt;&lt;/td&gt;
d87 1
a87 1
Find the line in ==bin/register== that says:
d89 3
a91 1
    # everything OK
d94 1
a94 1
Insert the code below directly *BEFORE* that line:
d97 5
a101 9
    # 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");
d104 1
a104 1
    dbmopen(%database, &TWiki::getPubDir()."/visualconfirm/db/hashes" ,0644);
d107 5
a111 4
      $url = &TWiki::getOopsUrl( $webName, $topic, "oopsregvisualconfirm",
        "The visual confirmation has expired.");
      TWiki::redirect( $query, $url );
      return;
d117 5
a121 4
      $url = &TWiki::getOopsUrl( $webName, $topic, "oopsregvisualconfirm",
        "The character string you entered for visual confirmation is incorrect.");
      TWiki::redirect( $query, $url );
      return;
d123 1
d138 1
a138 1
|  Plugin Version: | 03 Jan 2006 (V1.001) |
d143 2
a144 1
|  TWiki Dependency: | $TWiki::Plugins::VERSION 1.024 |
d157 1
a157 1
-- TWiki:Main.KoenMartens - 07 Oct 2005
d159 18
@


1.5
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1136326024" format="1.0" version="1.5"}%
d12 1
a12 1
	* None
d16 1
a16 1
	* N/A
d22 2
a23 2
	* One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
		* Set SHORTDESCRIPTION = Plugin for visual confirmation of new user registration.
d25 2
a26 2
	* Debug plugin: (See output in =data/debug.txt=)
		* Set DEBUG = 1
d28 11
a38 11
	* Custom settings (defaults shown):
		* Characters to use in generated strings:
			* Set CHARACTERS = ABCDEFGHKLMNPRSTVWXYZabcdeghpqsuvwxy@@
		* Truetype font to use:
			* Set FONT = luxisbi.ttf
		* Number of random lines to add (use ==none== for 0):
			* Set LINES = 10
		* Number of random circles to add (use ==none== for 0):
			* Set CIRCLES = 10
		* Noise, percentage of pixels to flip randomly after generating graphics (use ==none== for 0%):
			* Set NOISE = 15
d44 16
a59 16
	* Download the ZIP file from the Plugin web (see below)
	* Unzip ==%TOPIC%.zip== in your twiki installation directory. Content:
	  | *File:* | *Description:* |
	  | ==data/TWiki/VisualConfirmPlugin.txt== | Plugin topic |
	  | ==data/TWiki/VisualConfirmPlugin.txt,v== | Plugin topic repository |
	  | ==register.patch== | Patch for the register binary |
	  | ==templates/oopsregvisualconfirm.tmpl== | Error template |
	  | ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
	* Apply the patch ==register.patch== to ==bin/register== (alternatively, patch register manual, see section below):
		* cd bin
		* patch < ../register.patch
	* 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:
d61 3
a63 3
			&lt;Directory "/path/to/twiki/pub/visualconfirm/db"&gt;
			  deny from all
			&lt;/Directory&gt;
d65 10
a74 10
	* Make sure the plugin has access to the preferred truetype font, by putting the ==.ttf== file in ==pub/visualconfirm/==
	* Test if the installation was successful:
		* Create a topic containing ==&lt;IMG SRC="%<nop>VISUALCONFIRMURL%"&gt;== and ==%<nop>VISUALCONFIRMHASH%==
		* When loading this topic you should see an obfuscated character string loaded as a png and a hexadecimal hash.
		* 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.
	* Now edit your TWiki.TWikiRegistration topic
		* 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==
		* For example, add this to your TWiki.TWikiRegistration:
d76 5
a80 5
				&lt;tr&gt;
				  &lt;td valign="top" align="right"&gt;&lt;IMG SRC="%<nop>VISUALCONFIRMURL%"&gt;: &lt;br /&gt; (..) &nbsp; &lt/td&gt;
				  &lt;td&gt;&lt;input type="hidden" name="Twk1VisualConfirmHash" value="%<nop>VISUALCONFIRMHASH%"&gt;
						&lt;input type="text" name="Twk1VisualConfirm" size="5"&gt;&lt;/td&gt;
				&lt;/tr&gt;
d82 1
a82 1
	* That's it.
d88 1
a88 1
	 # everything OK
d94 29
a122 29
	 # 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);
d124 1
a124 1
	 close(LOCKFILE);
d129 3
a131 3
	* Make number of characters configurable
	* Make font size configurable
	* Find out how to safely delete images from the register binary
@


1.4
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1128964595" format="1.0" version="1.4"}%
d136 1
a136 1
|  Plugin Version: | 07 Oct 2005 (V1.000) |
d140 1
d146 1
a146 1
|  TWiki:Plugins/Benchmark: | %TWIKIWEB%.GoodStyle nn%, %TWIKIWEB%.FormattedSearch nn%, %TOPIC% nn% |
@


1.3
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1128862942" format="1.0" version="1.3"}%
d139 1
@


1.2
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1128809686" format="1.0" version="1.2"}%
d4 1
a4 1
Plugin for visual confirmation of new user registration.
d16 1
a16 1
	* None yet
d28 11
a38 6
	* My own setting:
		* Set CHARACTERS = ABC
		* Set FONT = luximb.ttf
		* Set NOISE = kjfksd
		* Set LINES = 3
		* Set CIRCLES = 20
d47 4
a50 2
	  | ==data/TWiki/%TOPIC%.txt== | Plugin topic |
	  | ==data/TWiki/%TOPIC%.txt,v== | Plugin topic repository |
d52 14
d67 65
a131 1
		* _enter samples here_
d152 1
a152 1
-- Main.KoenMartens - 07 Oct 2005
@


1.1
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KoenMartens" date="1128704726" format="1.0" version="1.1"}%
d29 5
a33 1
		* Set HOWTO = got it!
@
