Changeset 2646847
- Timestamp:
- 12/20/2021 03:10:48 PM (3 years ago)
- Location:
- bs-spam-protector/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
bs-spam-protector/trunk/README.txt
r2638554 r2646847 5 5 Requires at least: 5.7.2 6 6 Tested up to: 5.8.2 7 Stable tag: 1. 3.47 Stable tag: 1.6.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 17 17 18 18 == Changelog == 19 20 = 1.6.0 = 21 * SPAM Protector information is now stored in the Flamingo 'meta' column. 22 23 = 1.5.0 = 24 * More accurate calculation of the filling time for the textarea field. 25 26 = 1.4.0 = 27 * Setting for the time interval for filling out the form. 19 28 20 29 = 1.3.4 = -
bs-spam-protector/trunk/admin/class-bs-spam-protector-admin.php
r2576368 r2646847 131 131 ); 132 132 133 register_setting( 134 'bs_spam_protector_general', 135 'bs_spam_protector_expiration_interval' 136 ); 137 133 138 add_settings_section( 134 139 'bs_spam_protector_general', … … 153 158 'bs_spam_protector_general' 154 159 ); 160 161 add_settings_field( 162 'bs_spam_protector_expiration_interval', 163 'Expiration interval', 164 array( $this, 'show_expiration_interval_field' ), 165 $this->plugin_name, 166 'bs_spam_protector_general' 167 ); 155 168 } 156 169 … … 170 183 } 171 184 185 function show_expiration_interval_field() { 186 $expiration_interval = get_option( 'bs_spam_protector_expiration_interval' ); 187 echo "<input type='number' class='regular-text bs_spam_protector_expiration_interval' name='bs_spam_protector_expiration_interval' placeholder='12' value='" . (esc_attr( $expiration_interval ) ?? '') . "'>"; 188 echo "<p>The allowed time interval <strong>in hours</strong> between opening and submitting a form.</p>"; 189 } 190 172 191 } -
bs-spam-protector/trunk/bs-spam-protector.php
r2638554 r2646847 16 16 * Plugin Name: BS SPAM Protector 17 17 * Description: This plugin protects Contact Form 7 from spam. 18 * Version: 1. 3.418 * Version: 1.6.0 19 19 * Author: Oleg Sokolov 20 20 * Author URI: https://neuropassenger.ru … … 35 35 * Rename this for your plugin and update it as you release new versions. 36 36 */ 37 define( 'BS_SPAM_PROTECTOR_VERSION', '1. 3.4' );37 define( 'BS_SPAM_PROTECTOR_VERSION', '1.6.0' ); 38 38 39 39 /** -
bs-spam-protector/trunk/includes/class-bs-spam-protector-activator.php
r2549718 r2646847 35 35 $secret_key = hash_hmac( 'sha256', $time, date( 'F', $time ) ); 36 36 update_option( 'bs_spam_protector_secret_key', $secret_key ); 37 update_option( 'bs_spam_protector_expiration_interval', 12 ); 37 38 } 38 39 -
bs-spam-protector/trunk/includes/class-bs-spam-protector.php
r2576506 r2646847 186 186 $this->loader->add_filter( 'wpcf7_spam', $plugin_public, 'is_spam_submission' ); 187 187 188 //$this->loader->add_action( 'load-flamingo_page_flamingo_inbound', $plugin_public, 'add_spam_protector_flamingo_meta_box' ); 189 $this->loader->add_filter( 'flamingo_add_inbound', $plugin_public, 'prepare_data_for_flamingo_inbound' ); 190 188 191 } 189 192 -
bs-spam-protector/trunk/public/class-bs-spam-protector-public.php
r2638554 r2646847 98 98 99 99 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/bs-spam-protector-public.js', array( 'jquery' ), false ); 100 $expiration_interval = get_option( 'bs_spam_protector_expiration_interval' ); 100 101 wp_localize_script( $this->plugin_name, 'bs_vars', array( 101 102 'nonce' => wp_create_nonce( 'cf7_bs_spam_protector' ), 102 'expiration' => time() + 60 * 120,103 'expiration' => time() + 60 * 60 * $expiration_interval, 103 104 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 104 105 ) ); … … 116 117 // Before sanitizing 117 118 Bs_Spam_Protector_Functions::logit(array( 118 'nonce' 119 'nonce' => $_POST['nonce'], 119 120 'form_id' => $_POST['form_id'], 120 121 'expiration' => $_POST['expiration'], … … 161 162 162 163 public function ajax_get_validation_meta() { 163 $expiration = time() + 60 * 120; 164 $expiration_interval = get_option( 'bs_spam_protector_expiration_interval' ); 165 $expiration = time() + 60 * 60 * $expiration_interval; 164 166 $nonce = wp_create_nonce( 'cf7_bs_spam_protector' ); 165 167 … … 178 180 $secret_key = get_option( 'bs_spam_protector_secret_key' ); 179 181 $submission = WPCF7_Submission::get_instance(); 180 $container_post_id = $submission->get_meta( 'container_post_id');182 $container_post_id = $submission->get_meta( 'container_post_id' ); 181 183 $log_flag = get_option( 'bs_spam_protector_log_checkbox', false ); 182 184 … … 254 256 255 257 // Form filled out too quickly 256 // TODO: interval settings257 258 } elseif ( $filling_form_time < $expected_filling_form_time ) { 258 259 $submission->add_spam_log(array( 259 260 'agent' => 'bs_spam_protector', 260 'reason' => "Form filled out too quickly (In " . $filling_form_time . " second(s), " . $expected_filling_form_time . " second(s) expected .)",261 'reason' => "Form filled out too quickly (In " . $filling_form_time . " second(s), " . $expected_filling_form_time . " second(s) expected).", 261 262 )); 262 263 … … 299 300 function get_filling_form_time() { 300 301 $expiration = intval( $_POST['bs_hf_expiration'] ); 301 $start_filling_form_timestamp = $expiration - 60 * 120; // TODO: make only one setting value, search: '60 * 120* in the code 302 $expiration_interval = get_option( 'bs_spam_protector_expiration_interval' ); 303 $start_filling_form_timestamp = $expiration - 60 * 60 * $expiration_interval; 302 304 $finish_filling_form_timestamp = time() - 2; // 2 - time for network delays 303 305 … … 327 329 $posted_data = WPCF7_Submission::get_instance()->get_posted_data(); 328 330 // Let's remove tech fields 329 unset($posted_data['bs_hf_nonce']); 330 unset($posted_data['bs_hf_expiration']); 331 unset($posted_data['bs_hf_validation_key']); 332 unset($posted_data['bs_hf_form_id']); 333 334 $container_post_id = WPCF7_Submission::get_instance()->get_meta('container_post_id'); 331 unset( $posted_data['bs_hf_nonce'] ); 332 unset( $posted_data['bs_hf_expiration'] ); 333 unset( $posted_data['bs_hf_validation_key'] ); 334 unset( $posted_data['bs_hf_form_id'] ); 335 335 336 336 foreach ( $posted_data as $field_name => $field_value ) { … … 349 349 // Separate time computation for files, because a user can pass an empty file field 350 350 case 'file': 351 $expected_filling_field_time = $this->get_expected_filling_time_for_file_field_type( $field_name, $container_post_id ); 351 $expected_filling_field_time = $this->get_expected_filling_time_for_file_field_type( $field_name ); 352 break; 353 case 'textarea': 354 $expected_filling_field_time = $this->get_expected_filling_time_for_textarea_field_type( $field_name ); 352 355 break; 353 356 default: … … 380 383 } 381 384 382 function get_expected_filling_time_for_file_field_type( $field_name , $container_post_id) {385 function get_expected_filling_time_for_file_field_type( $field_name ) { 383 386 if ( ! isset( $_FILES[$field_name] ) ) { 384 387 return 0; … … 393 396 } 394 397 398 function get_expected_filling_time_for_textarea_field_type( $field_name ) { 399 $textarea_content = $_POST[$field_name]; 400 $content_size = mb_strlen( $textarea_content ); 401 $expected_time = round( $content_size / 10 ); 402 403 return $expected_time; 404 } 405 406 function prepare_data_for_flamingo_inbound( $args ) { 407 // Let's save SPAM Protector fields to the meta section 408 $args['meta']['bs_hf_nonce'] = $args['fields']['bs_hf_nonce']; 409 $args['meta']['bs_hf_expiration'] = $args['fields']['bs_hf_expiration']; 410 $args['meta']['bs_hf_validation_key'] = $args['fields']['bs_hf_validation_key']; 411 $args['meta']['bs_hf_form_id'] = $args['fields']['bs_hf_form_id']; 412 413 $filling_form_time = $this->get_filling_form_time(); 414 $expected_filling_form_time = $this->get_min_expected_filling_form_time(); 415 $args['meta']['filling_time'] = $filling_form_time; 416 $args['meta']['expected_filling_time'] = $expected_filling_form_time; 417 418 unset( $args['fields']['bs_hf_nonce'] ); 419 unset( $args['fields']['bs_hf_expiration'] ); 420 unset( $args['fields']['bs_hf_validation_key'] ); 421 unset( $args['fields']['bs_hf_form_id'] ); 422 423 return $args; 424 } 425 395 426 }
Note: See TracChangeset
for help on using the changeset viewer.