Smart.Framework Logo

final class \SmartCaptcha
{ } ::

Class: SmartCaptcha - Manages, Render and Check the Captcha Form.


class Methods

public static function initCaptchaPlugin ( string $y_form_name, string $y_captcha_word, string $y_mode = "cookie" ) {} :: BOOL
@return: {BOOLEAN} TRUE on success or FALSE on failure
Inits a captha plugin by setting the required values in cookie or session depend how mode is set
This should be used only with external captcha Plugins (ex: external captcha image by custom URL)
This must not be used if the drawCaptchaForm() is using internal captcha mode with no external URL
public static function drawCaptchaForm ( string $y_form_name, string $y_captcha_image_url = "", string $y_mode = "cookie", bool $y_use_absolute_url = false, bool $y_include_js_requirements = false ) {} :: STRING
@return: {STRING} The partial captcha HTML to include in a form
Draw the Captcha Form partial HTML
By default if no external URL is specified will use the internal interractive captcha
IMPORTANT: When using the interractive internal captcha the method initCaptchaPlugin() is automatically called and must not be called prior to this method !
Difficulty levels for the internal interractive captcha:
#very-easy
#easy
#moderate
#hard
#very-hard
public static function verifyCaptcha ( string $y_form_name, bool $y_clear = true, string $y_mode = "cookie" ) {} :: BOOL
@return: {BOOLEAN} TRUE on success or FALSE on failure
Verify Captcha and *OPTIONAL* Clear It
public static function clearCaptcha ( string $y_form_name, string $y_mode = "cookie", bool $y_nodelete = false ) {} :: BOOL
@return: {BOOLEAN} TRUE on success or FALSE on failure
Programatically clear the Captcha (from cookie or session)
On Verify Success the Captcha clears automatically all stored values

class Properties


class Constants


Sample code: PHP

<?php

//==
 //-- captch form needs a captcha plugin to work with (ex: image)
 // See: \SmartModExtLib\Samples\TestUnitMain::captchaImg()
 // Also See: modules/mod-samples/testunit.php # case 'testunit.captcha'
 // The method SmartCaptcha::initCaptchaPlugin() must be used to init a captcha plugin (ex: image)
 //-- captcha form (draw)
 
echo SmartCaptcha::drawCaptchaForm('form_name''?page=samples.testunit&op=testunit.captcha'); // this controller should output HTML code to render the form
 //-- captcha check (verify)
 
echo $check SmartCaptcha::verifyCaptcha('form_name'true'cookie'); // and this is the way you verify the captcha (1 = ok ; 0 = not ok)
 //-- some more info on verify()
 // captcha will reset (clear) by default upon each SmartCaptcha::verifyCaptcha()
 // to avoid this (default) behaviour, you can set the 3rd parameters of verify() to FALSE
 // but if you do so, don't forget to manually clear captcha by calling SmartCaptcha::clearCaptcha() at the end !!!
 //--
 //==

// #end php code


documentation generated on: 2023-10-19 23:15:52 +0000


Smart.Framework © 2009-2023 unix-world.org