You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2006/12/21 12:21:14 UTC
[DAISY] Created: Captcha Widget
A new document has been created.
http://cocoon.zones.apache.org/daisy/documentation/1294.html
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
Parts
=====
Content
-------
Mime type: text/xml
Size: 2101 bytes
Content:
<html>
<body>
<p> <!-- generate captcha image --><br/>
<map:match pattern="**/captcha-*.jpg"><br/>
<map:read type="captcha" src="{session-attr:captcha-{2}}"/>
<br/>
</map:match></p>
<h1>Concept</h1>
<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-<random
id></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>
<h1>Definition</h1>
<p>The definition is simply:</p>
<pre><fd:captcha id="captchacheck" required="true">
<fd:label><i18n:text>captcha</i18n:text></fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:captcha/>
</fd:validation>
</fd:captcha></pre>
<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>
<pre><map:components>
...
<map:readers ...>
...
<map:reader logger="sitemap.reader.captcha" name="captcha" src="org.apache.cocoon.reading.CaptchaReader"/>
...
</map:readers>
...
</map:components>
</pre>
<p>You now need to include a pipeline that can generate the CAPTCHA image:</p>
<pre><!-- generate captcha image -->
<map:match pattern="**/captcha-*.jpg">
<map:read type="captcha" src="{session-attr:captcha-{2}}"/>
</map:match></pre>
</body>
</html>
Collections
===========
The document belongs to the following collections: documentation