PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.4
JetFormBuilder — Dynamic Blocks Form Builder v3.6.4
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
jetformbuilder / modules / security / module.php
module.php
95 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Security;
5
6 use JFB_Modules\Logger;
7 use JFB_Components\Module\Base_Module_After_Install_It;
8 use JFB_Components\Module\Base_Module_Dir_It;
9 use JFB_Components\Module\Base_Module_Dir_Trait;
10 use JFB_Components\Module\Base_Module_Handle_It;
11 use JFB_Components\Module\Base_Module_Handle_Trait;
12 use JFB_Components\Module\Base_Module_It;
13 use JFB_Components\Module\Base_Module_Url_It;
14 use JFB_Components\Module\Base_Module_Url_Trait;
15 use JFB_Modules\Security\Exceptions\Spam_Exception;
16 use JFB_Modules\Security\Csrf;
17 use JFB_Modules\Security\Honeypot;
18 use JFB_Modules\Security\Wp_Nonce;
19
20 // If this file is called directly, abort.
21 if ( ! defined( 'WPINC' ) ) {
22 die;
23 }
24
25 class Module implements
26 Base_Module_It,
27 Base_Module_Url_It,
28 Base_Module_Dir_It,
29 Base_Module_After_Install_It,
30 Base_Module_Handle_It {
31
32 use Base_Module_Handle_Trait;
33 use Base_Module_Url_Trait;
34 use Base_Module_Dir_Trait;
35
36 private $spam_statuses = array();
37
38 public function rep_item_id() {
39 return 'security';
40 }
41
42 public function on_install() {
43 jet_form_builder()->get_modules()->install( new Csrf\Module() );
44 jet_form_builder()->get_modules()->install( new Honeypot\Module() );
45 jet_form_builder()->get_modules()->install( new Wp_Nonce\Module() );
46
47 $this->spam_statuses = apply_filters(
48 'jet-form-builder/security/spam-statuses',
49 array()
50 );
51 }
52
53 public function on_uninstall() {
54 jet_form_builder()->get_modules()->uninstall( new Csrf\Module() );
55 jet_form_builder()->get_modules()->uninstall( new Honeypot\Module() );
56 jet_form_builder()->get_modules()->uninstall( new Wp_Nonce\Module() );
57
58 $this->spam_statuses = array();
59 }
60
61 public function condition(): bool {
62 return true;
63 }
64
65 public function init_hooks() {
66 }
67
68 public function remove_hooks() {
69 }
70
71 public function has_spam(): bool {
72 $status = jet_fb_handler()->response_args['status'] ?? '';
73
74 return (
75 in_array( $status, $this->spam_statuses, true ) ||
76 Logger\Module::instance()->has_log( Spam_Exception::class )
77 );
78 }
79
80 public static function get_hasher(): \PasswordHash {
81 global $wp_hasher;
82
83 if ( ! empty( $wp_hasher ) ) {
84 return $wp_hasher;
85 }
86
87 require_once ABSPATH . WPINC . '/class-phpass.php';
88 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
89 $wp_hasher = new \PasswordHash( 8, true );
90
91 return $wp_hasher;
92 }
93
94 }
95