PHP code example of n1ebieski / logic-captcha

1. Go to this page and download the library: Download n1ebieski/logic-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/ */

    

n1ebieski / logic-captcha example snippets


return [
    'default' => [
        'math' => false,
        'logic' => true,
        'width' => 300,
        'height' => 80,
    ],

    'logic' => [
        'questions' => [
            'Color of the sky?' => [
                'blue'
            ],
            'Highest mountain on Earth?' => [
                'Mount Everest', 'MountEverest'
            ],
            'Natural enemy of the cat?' => [
                'dog', 'human', 'lol'
            ]
        ]
    ]
];

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::any('captcha-test', function(Request $request) {
    if (request()->getMethod() == 'POST') {
        $rules = ['captcha' => 'p style="color: #00ff30;">Matched :)</p>';
        }
    }

    $form = '<p><b>Multi Captcha on one page by Base64</b></p>';

    $form .= '<form method="post" action="captcha-test">';
    $form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
    $form .= '<p><img src="' . captcha_base64(0) . '"></p>';
    $form .= '<p><input type="hidden" value="0" name="captcha_id"></p>';
    $form .= '<p><input type="text" name="captcha"></p>';
    $form .= '<p><button type="submit">Check</button>
              <button class="reload_captcha_base64" type="button"
              data-route="' . route('captcha.base64', ['default']) . '">Reload</button></p>';
    $form .= '</form>';

    $form .= '<form method="post" action="captcha-test">';
    $form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
    $form .= '<p><img src="' . captcha_base64(1) . '"></p>';
    $form .= '<p><input type="hidden" value="1" name="captcha_id"></p>';
    $form .= '<p><input type="text" name="captcha"></p>';
    $form .= '<p><button type="submit">Check</button>
              <button class="reload_captcha_base64" type="button"
              data-route="' . route('captcha.base64', ['default']) . '">Reload</button></p>';
    $form .= '</form>';

    $form .= '<p><b>Single Captcha by Async Src Controller</b></p>';

    $form .= '<form method="post" action="captcha-test">';
    $form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
    $form .= '<p>' . captcha_img() . '</p>';
    $form .= '<p><input type="text" name="captcha"></p>';
    $form .= '<p><button type="submit">Check</button>
              <button class="reload_captcha_img" type="button">Reload</button></p>';
    $form .= '</form>';

    $form .= '<script
	     src="https://code.jquery.com/jquery-3.4.1.min.js"
	     integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
	     crossorigin="anonymous"></script>';

    $form .= '<script src="' . asset('js/vendor/logic-captcha/captcha_reload.js') . '"></script>';

    return $form;
});

php artisan vendor:publish --provider="N1ebieski\LogicCaptcha\Providers\LogicCaptchaServiceProvider"