cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Captcha Widget
Date Thu, 21 Dec 2006 11:21:14 GMT
A new document has been created.

Document ID: 1294
Branch: main
Language: default
Name: Captcha Widget
Document Type: Cocoon Document
Created: 12/21/06 11:20:55 AM
Creator (owner): Helma van der Linden
State: draft


Mime type: text/xml
Size: 2101 bytes

<p>        &lt;!-- generate captcha image --&gt;<br/>
        &lt;map:match pattern="**/captcha-*.jpg"&gt;<br/>
          &lt;map:read type="captcha" src="{session-attr:captcha-{2}}"/&gt;


<p>To prevent spammers from abusing forms, more and more sites are including an
image that displays a distorted code. This is based on the CAPTCHA technique
(see also the <a href="daisy:686">CAPTCHA</a> block).</p>

<p>The Captcha widget provides a widget containing the generated image and an
input field. The validation is only true if the input in the field matches the
code displayed in the image.<br/>
The widget defines a session attribute with a name of <tt>captcha-&lt;random
id&gt;</tt> and a value containing a random code. The code is also added to a
<tt>secret</tt> attribute of the widget for the validation phase. The image has
the same name as the session attribute with a <tt>jpg</tt> extension.</p>


<p>The definition is simply:</p>

<pre>&lt;fd:captcha id="captchacheck" required="true"&gt;
   &lt;fd:datatype base="string"/&gt;

<h2>Sitemap definition</h2>

<p>In your sitemap you need a reference to the
<a href="daisy:687">captchaReader</a>. It is already provided in the standard
Cocoon root sitemap, but if you start from scratch, here it is:</p>

   &lt;map:readers ...&gt;
    &lt;map:reader logger="sitemap.reader.captcha" name="captcha" src="org.apache.cocoon.reading.CaptchaReader"/&gt;

<p>You now need to include a pipeline that can generate the CAPTCHA image:</p>

<pre>&lt;!-- generate captcha image --&gt;
&lt;map:match pattern="**/captcha-*.jpg"&gt;
   &lt;map:read type="captcha" src="{session-attr:captcha-{2}}"/&gt;


The document belongs to the following collections: documentation

View raw message