PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.2
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.2
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / app / Modules / Form / HoneyPot.php

HoneyPot.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.2, at app/Modules/Form/HoneyPot.php

59 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Form;
4
5 use FluentForm\Framework\Foundation\Application;
6 use FluentForm\Framework\Helpers\ArrayHelper;
7
8
9 class HoneyPot
10 {
11 private $app;
12
13 public function __construct(Application $application)
14 {
15 $this->app = $application;
16 }
17
18 public function renderHoneyPot($form)
19 {
20 if (!$this->isEnabled($form->id)) {
21 return;
22 }
23 ?>
24 <span style="display: none !important;"><input type="checkbox" name="<?php echo $this->getFieldName($form->id); ?>" value="1"
25 style="display:none !important;" tabindex="-1" autocomplete="off"></span>
26 <?php
27 }
28
29 public function verify($insertData, $requestData, $formId)
30 {
31 if (!$this->isEnabled($formId)) {
32 return;
33 }
34
35 // Now verify
36 if (ArrayHelper::get($requestData, $this->getFieldName($formId))) {
37 // It's a bot! Block him
38 wp_send_json(
39 array(
40 'errors' => 'Sorry! You can not submit this form at this moment!'
41 ), 422);
42 }
43
44 return;
45 }
46
47 public function isEnabled($formId = false)
48 {
49 $option = get_option('_fluentform_global_form_settings');
50 $status = ArrayHelper::get($option, 'misc.honeypotStatus') == 'yes';
51 return apply_filters('fluentform_honeypot_status', $status, $formId);
52 }
53
54 private function getFieldName($formId)
55 {
56 return apply_filters('fluentform_honeypot_name', 'item__' . $formId . '__fluent_checkme_', $formId);
57 }
58
59 }