CodeIgniter framework

2.x and 3.x

Installation

If you don't use Composer.

Download from release page, unload it to third_party folder.

application\third_party

Check the autoloader.php path, it should be:

application/third_party/shieldon/src/autoload.php

Require it.

require APPPATH . 'third_party/shieldon/src/autoload.php';

Guide

Edit MY_Controller:

application/core/MY_Controller.php

Add method:

public function protection()
{
    $db = [
        'host'    => $this->db->hostname,
        'dbname'  => $this->db->database,
        'user'    => $this->db->username,
        'pass'    => $this->db->password,
        'charset' => 'utf8',
    ];

    $pdoInstance = new \PDO(
        'mysql:host=' . $db['host'] . ';dbname=' . $db['dbname'] . ';charset=' . $db['charset'],
        $db['user'],
        $db['pass']
    );

    $shieldon = new \Shieldon\Shieldon();
    $shieldon->setDriver(new \Shieldon\Driver\MysqlDriver($pdoInstance);
    $shieldon->setComponent(new \Shieldon\Component\TrustedBot());

    $shieldon->setCaptcha(new \Shieldon\Captcha\ImageCaptcha();

    // Start protecting your website!
    $result = $shieldon->run();

    if ($result !== $shieldon::RESPONSE_ALLOW) {
        if ($shieldon->captchaResponse()) {
            // Unban current session.
            $shieldon->unban();
        }
        // Output the result page with HTTP status code 200.
        $shieldon->output(200);
    }
}

Run

  • Extend your Controller to MY_Controller.
  • Put this line in any Controller you want to protect.
$this->protection();

That's it.

results matching ""

    No results matching ""