PHP code example of enovision / slim-captcha

1. Go to this page and download the library: Download enovision/slim-captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

enovision / slim-captcha example snippets



use Illuminate\Database\Capsule\Manager as DB;

$settings_captcha = [
    ... all the other settings ...,
    'callbackSave' => function ($captcha) {
        DB::table('captcha')->insert([
            'captcha_time' => $captcha['time'],
            'ip_address' => $captcha['ip_address'],
            'word' => $captcha['word']
        ]);
    },
    'callbackCleanUp' => function ($expiration) {
        DB::table('captcha')
          ->where('captcha_time', '<', $expiration)
          ->delete();
    },
    'callbackValidate' => function ($word, $ip_address, $expiration) {
        $count = DB::table('captcha')
          ->where('word', $word)
          ->where('ip_address', $ip_address)
          ->where('captcha_time', '>', $expiration)
          ->count();

        return $count;
    }
];

return $settings_captcha;


$captcha = new \Enovision\Slim\Captcha($this, $request, $response, [
    'settings_path' => INC_ROOT . '/alternative/location/settings.php',
]);

$captcha();

$captcha = new \Enovision\Slim\Captcha($this, $request, $response);
$captcha();

$captcha = new \Enovision\Slim\Captcha($this, $request, $response);
$captcha = $captcha(false);

$captcha = new \Enovision\Slim\Captcha($this, $request, $response);
$valid = $captcha->validateCaptcha($typed_in_word_from_a_form);

'font_path' => $_SERVER['DOCUMENT_ROOT'] . '/somewhere/in/public/fonts/00118_20thCenturyFontBold.ttf',