-
Notifications
You must be signed in to change notification settings - Fork 4
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.
File:kcs_captcha_module_fix_for_4.1.11up.zip
You first need to install the HMVC 4.1.x module. It is tested with CI 1.6.x (tested on latest 1.6.3 as well) and HMVC version 4.1.11 (and up) - 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.
- Make sure that it is set in your app/config/config.php
$config['language'] = "english"; //(or hungarian, or whatever else you made)
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:
<?php echo modules::run('kcs_captcha_module') ?>
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
if ( modules::run('kcs_captcha_module', $this->input->post('form_element_for_results_given_by_user'), 'validate') ) {
echo 'OK';
} else {
echo 'NOT OK';
}
That's all :)