CodeIgniter Forums
My new work - An anti-scriping library. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forum-7.html)
+--- Forum: Addins (https://forum.codeigniter.com/forum-13.html)
+--- Thread: My new work - An anti-scriping library. (/thread-73730.html)



My new work - An anti-scriping library. - allenlee - 05-28-2019

I just have completed the document, can't wait for share with you. Any feedback, feature request are welcome. 


Git: https://github.com/terrylinooo/shieldon



Document: https://shield-on-php.github.io/


Demo: https://terryl.in (Just refresh many times at a short period time to see how it work.)


Implement this in your Codeigniter 3:

in MY_Controller


Code:
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\Ip());
    $shieldon->setComponent(new \Shieldon\Component\Robot());

 
    $shieldon->setCaptcha(new \Shieldon\Captcha\ImageCaptcha(['word_length' => 4]));
    

    // 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);
    }
}

Then


PHP Code:
$this->protection(); 

In any Controller, you want to protect the page.


RE: My new work - An anti-scriping library. - remote4me - 06-24-2019

Interesting project!

Do you exclude the "good" bots ?
Like the search engines crawler ?