An integration library for BotGuard Cloud.
use BotGuard\BotGuard;
use BotGuard\Profile;
// Initialize BotGuard Service instance
$botguard = BotGuard::instance([
'server' => 'xxx.botguard.net',
'backup' => 'yyy.botguard.net',
]);
// Check incoming request
$profile = $botguard->check();
// Do bot mitigation
if ($profile) {
switch ($profile->getMitigation()) {
case Profile::MITIGATION_DENY:
case Profile::MITIGATION_RETURN_FAKE:
http_response_code(403);
exit;
case Profile::MITIGATION_CHALLENGE:
http_response_code(403);
$profile->challenge();
exit;
case Profile::MITIGATION_REDIRECT:
case Profile::MITIGATION_CAPTCHA:
header('Location: ' . $profile->getMitigationURL(), true, 302);
exit;
}
}
echo 'Welcome, human';$ composer require wolfsoft/botguard-php
{
"require": {
"wolfsoft/botguard-php": "^1.1"
}
}<?php
require 'vendor/autoload.php';
use BotGuard\BotGuard;
use BotGuard\Profile;
// the rest of the codeWhy are you not using Composer? Download BotGuard.php from the repo and save the file into your project path somewhere.
<?php
require 'path/to/Profile.php';
require 'path/to/BotGuard.php';
use BotGuard\BotGuard;
use BotGuard\Profile;
// the rest of the code