A simple, driver based spam protection package.
Check for spam messages on client requests before forwarding them to the system for further processing.
Install the latest version with
$ composer require zexbre/spam-protect
<?php use ZexBre\SpamProtect\Factory\ReCaptchaVersion2Factory; ?>
<html>
<head>
<?php
// ...
$widgetData = ReCaptchaVersion2Factory::getWidgetResponse([
'reCaptchaSiteKey' => [RECAPTCHA-SITE-KEY],
'hl' => [LANGUAGE-CODE], // optional
]);
echo $widgetData->htmlHead;
?>
</head>
<body>
<?php
// ...
echo $widgetData->htmlBody;
?>
</body>
<html>
<?php
use ZexBre\SpamProtect\Factory\ReCaptchaVersion2Factory;
// (1/3) preparation
$spamProtect = ReCaptchaVersion2Factory::getProtector([
'reCaptchaSecretKey' => [RECAPTCHA-SECRET-KEY],
'gReCaptchaResponse' => [RECAPTCHA-RESPONSE],
'acceptLanguage' => [ACCEPT-LANGUAGE-HEADER], // optional
'httpReferer' => [HTTP-REFERER-HEADER], // optional, see '$_SERVER["HTTP_REFERER"]'
'httpUserAgent' => [HTTP-USER-AGENT-HEADER], // optional, see '$_SERVER["HTTP_USER_AGENT"]'
]);
// (2/3) verification
$spamProtect->verify();
// (3/3) validation
$isHuman = $spamProtect->isHuman(); // boolean
$isRobot = $spamProtect->isRobot(); // boolean
$isValidResponse = $spamProtect->isValidResponse(); // boolean
$isInvalidResponse = $spamProtect->isInvalidResponse(); // boolean
$errors = $spamProtect->getErrors(); // array
Please see CHANGELOG-0.x for more information what has changed recently.
Please see CONTRIBUTING and CODE OF CONDUCT for details.
If you discover any security related issues, please email to niks986@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.