masone / captcha Goto Github PK
View Code? Open in Web Editor NEWThis project forked from zendesk/kamcaptcha
A captcha plugin for Rails
This project forked from zendesk/kamcaptcha
A captcha plugin for Rails
= Captcha This captcha generator is based on the very fine work of Eric Methot (http://blogs.ericmethot.com/) all credit and thanks should go to him. This fork allows you to specify a file type for captcha image generation (png or gif). Using Captcha is a five step process 1. Install RMagick 2. Install the plugin 3. Generate a bunch of images off-line 4. Use the helper method(s) 5. Validate user input The plugin has been tested on OS X 10.5 using ImageMagick @6.4.1-8_0+q16 (via MacPorts) and the rmagick 2.5.2 gem. == Install RMagic Follow the instructions on their site: http://rmagick.rubyforge.org/install-faq.html == Install the plugin rails plugin install https://github.com/zendesk/captcha.git or script/plugin install https://github.com/zendesk/captcha.git == Generate a bunch of images off-line The reason why you don't need to generate images on the fly is that they have been generated in advance and all you do is pick one at random. If you have not used Rails' plugin install mechanism to install the plugin, define a salt for your application (otherwise the plugin will take care of that). Do this by setting the constant CAPTCHA_SALT to a random string in e.g. your environment.rb CAPTCHA_SALT = 'Something really random here' Next, generate the images by running the following rake task, this takes a while: rake captcha:generate COUNT=250 This will create the '/public/system/captcha' directory if it doesn't already exist and put 250 randomly generated captcha images in it. You can specify the following parameters when running the rake task: COUNT - the number of images to generate, default 3 IMAGE_HEIGHT - the height of the captcha image in pixels, default 50 IMAGE_WIDTH - the width of the captcha image in pixels, default 260 CAPTCHA_LENGTH - the number of characters in the captcha, default 5 FILE_FORMAT - the file type of the captcha image (png or gif), default png FONT_SIZE - the font size in points, default 44 == Use the helper methods In your forms all you need to do is: <%= captcha_block %> And add a little bit of CSS styling to get a nice looking captcha validation text field and image. If you don't like the way it's setup then use the other helper methods (see captcha_helper.rb), which are more granular. == Validate user input In your controller, you will need to do the following: PostController < ApplicationController validates_captcha def create ... if captcha_validated? ... else ... end end end That's it. Copyright (c) 2008 Zendesk, released under the MIT license
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.