Overview

reCaptcha is a free captcha web service that shows the visitors words from old books helping digitize them. This, module provides a Lua interface to recaptcha. You will need to get your own API key from recaptcha.net to use it.

Installation

The Lua interface Recaptcha to recaptcha consists of a single file (recaptcha.lua) of less than 100 lines, plus a test script (tests/recaptcha.cgi) which is meant to be used with WSAPI. Here is a list of recent releases:

You can also install it using LuaRocks with

luarocks install recaptcha

or:

luarocks --from=http://sputnik.freewisdom.org/rocks/earth install recaptcha

Using Recaptcha

Creating the catpcha object

You will need to get your PRIVATE and PUBLIC API keys from recaptcha.net. Once you have them, create an instance or ReCaptcha like this:

captcha = recaptcha.new{PRIVATE, PUBLIC}

Generating the Widget

Include the output of captcha:get_html() into your form. For instance:

my_html = "<form action='...' method='post'...>"
          .. "..." -- add your fields
          .. captcha:get_html()
          .. "<input type='submit'/>"
          .. "</form>"

Verifying User's Input

Send your POST fields and the user's IP address to captcha:verify(). For instance, for WSAPI:

local request = wsapi.request.new(wsapi_env)
local ok, err = captcha:verify(request.POST, wsapi_env.REMOTE_ADDR)

if ok then
   ...
else
   print ("Error: "..err)
end

Contact

Please contact Yuri Takhteyev (yuri -at- freewisdom.org) with any questions.

LuaDoc

recaptcha

ReCaptcha:get_fields() Returns a table of names of fields posted by the captcha widget.
Returns: a table of field names.
ReCaptcha:get_html() Returns the html block that creates the ReCaptcha widget.
options:
a table of options.
Returns: a string containing JavaScript and HTML for inclusion in an HTML document.
ReCaptcha:verify() Verifies the captcha.
params:
the table of POST parameters submitted by the client.
remote_ip:
user's IP address.
Returns: true if the verification is successful and false otherwise.
new() Creates a new ReCaptcha object.
args:
a single argument with two fields: the private API key and the public API key.
Returns: an instance of ReCaptcha.

License

Copyright (c) 2008 Yuri Takhteyev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.