![]() |
Math CAPTCHA library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Math CAPTCHA library (/showthread.php?tid=54437) |
Math CAPTCHA library - El Forum - 09-08-2012 [eluser]Dan Murfitt[/eluser] Hi I've just released an early version of a math CAPTCHA library. It needs proper testing (which I intend to do over the next week). If anyone wants to have a go, or offer some suggestions, it would be much appreciated. The library repository and latest version can be found at: https://github.com/danmurf/CI-MathCaptcha Latest version download: https://github.com/danmurf/CI-MathCaptcha/zipball/master Here is some of the information I've posted to GitHub: A simple math based CAPTCHA library for CodeIgniter with various configurable options. Supports addition and multiplication Multi-language support Questions written in plain English (or your chosen language) in various phrases Questions can contain numbers as words, numeric or random Answers can be enforced to numeric, words or either Add your own question phrases for added randomness Copy the application/libraries/mathcaptcha_library.php file to application/libraries/ Copy the application/language/english/mathcaptcha_lang.php to application/language/english/ If you would like to use another language other than English you will need to duplicate the language file and add translations the numbers and phrases respectively Initialise the math CAPTCHA library and include it in your controller. Example below: Code: public function myform() Add a callback for the math CAPTCHA form validation if you are using CodeIgniter Form Validation library. Example below: Code: function _check_math_captcha($str) Print the $mathcaptcha_question on your form somewhere. Example below: Code: <?php echo validation_errors(); ?> There are some configuration options which you can pass to the library in an associative array when you $this->mathcaptcha->init($config): language: This should be set to the language that you want to use. It will default to the language set in the Codeigniter config.php. operation: The type of math question to use; addition or multiplication. This will default to addition if not specified. question_format: The type of number to include in the question; numeric, word, or random. This will default to word if not specified. question_max_number_size: The maximum number size to use in the question. The default is 10, which is also the maximum allowed given the limitations of the language file. answer_format: The type of answer that is allowed; word means the user must answer in a word, numeric means the user must enter the number or either for, well, either. Hope it helps ![]() Many thanks |