-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Captcha simple maths for HMVC 4.1.x
Category:Module Category:Module::Community Category:Module::Spam
You can use this module to prevent automated spams - especially if you do not want to generate images on your server. It is written in a way that makes it very easy to install in multiple apps.
This is a simple textual maths captcha that can be freely configured, and allows for multi-lingual operation. It reads and uses the language setting from the main applevel config.php file, included are an english and a (more advanced) hungarian message config file. You can create more language config files - if you do so, please include them here.
[h3]Download[/h3] File:kcs_captcha_module.zip
[h3]Installation:[/h3] You first need to install the [url=http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/]HMVC 4.1.x module[/url]. It is tested with CI 1.6.1 / 1.6.2 and HMVC version 4.1.11 - should work with versions above this as well (I guess it's not up to me, though :) ) After you download the file, extract the kcs_captcha_module folder from the attached zip to your app/modules folder. You are good.
[h3]Usage[/h3]
-
Make sure that it is set in your app/config/config.php [code] $config['language'] = "english"; //(or hungarian, or whatever else you made)[/code] also make sure the session library is in the autoload.php config or you loaded it before calling these.
-
In your view, (or controller, but make sure to pass the results to the view) that creates the page where you want the captcha to be printed call: [code]<?php echo modules::run('kcs_captcha_module') ?>[/code] this saves the results in a session variable, and also returns the question (equation) in the chosen language. Also create a form, with an input text box, that post to an other (or the same, you decide) controller.
-
In a controller where you want to check whether the user entered a valid value call [code]if ( modules::run('kcs_captcha_module', $this->input->post('form_element_for_results_given_by_user'), 'validate') ) { echo 'OK'; } else { echo 'NOT OK'; }[/code]
That's all :)