function perimeter_honeypot_reject in Drupal Perimeter Defence 2.0.x
Same name and namespace in other branches
- 8 perimeter.module \perimeter_honeypot_reject()
File
- ./
perimeter.module, line 6
Code
function perimeter_honeypot_reject($form_id, $uid, $type) {
// Honeypot might remove the uid param at some point later.
$uid = \Drupal::currentUser()
->id();
if ($uid != 1 && ($type == 'honeypot_time' && $form_id != 'user_login_form')) {
$ip = \Drupal::request()
->getClientIp();
$connection = Database::getConnection();
$banManager = new BanIpManager($connection);
$banManager
->banIp($ip);
\Drupal::logger('Perimeter')
->notice('Banned: %ip for failing %type on %form <br />Source: %source <br /> User Agent: %browser', [
'%ip' => $ip,
'%type' => $type,
'%form' => Xss::filter($form_id),
'%source' => isset($_SERVER['HTTP_REFERER']) ? Xss::filter($_SERVER['HTTP_REFERER']) : '',
'%browser' => isset($_SERVER['HTTP_USER_AGENT']) ? Xss::filter($_SERVER['HTTP_USER_AGENT']) : '',
]);
}
}