Changeset 3323842
- Timestamp:
- 07/07/2025 05:59:20 PM (8 months ago)
- Location:
- checkview
- Files:
-
- 22 added
- 28 edited
- 1 copied
-
tags/2.0.19 (copied) (copied from checkview/trunk)
-
tags/2.0.19/.idea (added)
-
tags/2.0.19/.idea/checkview.iml (added)
-
tags/2.0.19/.idea/codeStyles (added)
-
tags/2.0.19/.idea/codeStyles/Project.xml (added)
-
tags/2.0.19/.idea/codeStyles/codeStyleConfig.xml (added)
-
tags/2.0.19/.idea/dictionaries (added)
-
tags/2.0.19/.idea/dictionaries/project.xml (added)
-
tags/2.0.19/.idea/modules.xml (added)
-
tags/2.0.19/.idea/php.xml (added)
-
tags/2.0.19/.idea/phpunit.xml (added)
-
tags/2.0.19/.idea/vcs.xml (added)
-
tags/2.0.19/README.txt (modified) (3 diffs)
-
tags/2.0.19/admin/class-checkview-admin.php (modified) (13 diffs)
-
tags/2.0.19/checkview.php (modified) (2 diffs)
-
tags/2.0.19/includes/checkview-functions.php (modified) (13 diffs)
-
tags/2.0.19/includes/class-checkview.php (modified) (2 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-cf7-helper.php (modified) (9 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-fluent-forms-helper.php (modified) (9 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-formidable-helper.php (modified) (9 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-forminator-helper.php (modified) (6 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-gforms-helper.php (modified) (5 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-ninja-forms-helper.php (modified) (8 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-wpforms-helper.php (modified) (8 diffs)
-
tags/2.0.19/includes/formhelpers/class-checkview-wsf-helper.php (modified) (8 diffs)
-
tags/2.0.19/includes/woocommercehelper/class-checkview-woo-automated-testing.php (modified) (14 diffs)
-
trunk/.idea (added)
-
trunk/.idea/checkview.iml (added)
-
trunk/.idea/codeStyles (added)
-
trunk/.idea/codeStyles/Project.xml (added)
-
trunk/.idea/codeStyles/codeStyleConfig.xml (added)
-
trunk/.idea/dictionaries (added)
-
trunk/.idea/dictionaries/project.xml (added)
-
trunk/.idea/modules.xml (added)
-
trunk/.idea/php.xml (added)
-
trunk/.idea/phpunit.xml (added)
-
trunk/.idea/vcs.xml (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/admin/class-checkview-admin.php (modified) (13 diffs)
-
trunk/checkview.php (modified) (2 diffs)
-
trunk/includes/checkview-functions.php (modified) (13 diffs)
-
trunk/includes/class-checkview.php (modified) (2 diffs)
-
trunk/includes/formhelpers/class-checkview-cf7-helper.php (modified) (9 diffs)
-
trunk/includes/formhelpers/class-checkview-fluent-forms-helper.php (modified) (9 diffs)
-
trunk/includes/formhelpers/class-checkview-formidable-helper.php (modified) (9 diffs)
-
trunk/includes/formhelpers/class-checkview-forminator-helper.php (modified) (6 diffs)
-
trunk/includes/formhelpers/class-checkview-gforms-helper.php (modified) (5 diffs)
-
trunk/includes/formhelpers/class-checkview-ninja-forms-helper.php (modified) (8 diffs)
-
trunk/includes/formhelpers/class-checkview-wpforms-helper.php (modified) (8 diffs)
-
trunk/includes/formhelpers/class-checkview-wsf-helper.php (modified) (8 diffs)
-
trunk/includes/woocommercehelper/class-checkview-woo-automated-testing.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
checkview/tags/2.0.19/README.txt
r3303097 r3323842 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 Stable tag: 2.0.1 810 Stable tag: 2.0.19 11 11 12 12 [CheckView](https://checkview.io/) is the friendly WordPress automated testing platform for everyone, from developers, shop owners to agencies. … … 86 86 87 87 == Changelog == 88 = 2.0.19 = 89 * Improve logging 90 * Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests 91 * Disable test-related hooks on API requests 92 * Disable Fluent Forms token-based spam prevention for tests 93 * Remove Fluent Forms CAPTCHA/Turnstile key swap 94 * Disable Fluent Forms CAPTCHAs using newly provided hook 95 88 96 = 2.0.18 = 89 97 * Improve logging when querying for available test results. … … 360 368 361 369 == Upgrade Notice == 370 = 2.0.19 = 371 * Improve logging 372 * Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests 373 * Disable test-related hooks on API requests 374 * Disable Fluent Forms token-based spam prevention for tests 375 * Remove Fluent Forms CAPTCHA/Turnstile key swap 376 * Disable Fluent Forms CAPTCHAs using newly provided hook 377 362 378 = 2.0.18 = 363 379 * Improve logging when querying for available test results. -
checkview/tags/2.0.19/admin/class-checkview-admin.php
r3283610 r3323842 62 62 63 63 add_action( 64 'checkview_options_cleanup_cron',65 'checkview_options_cleanup'66 );67 68 add_action(69 64 'checkview_nonce_cleanup_cron', 70 65 array( $this, 'checkview_delete_expired_nonces' ) … … 122 117 if ( ! wp_next_scheduled( 'checkview_nonce_cleanup_cron' ) ) { 123 118 wp_schedule_event( time(), 'hourly', 'checkview_nonce_cleanup_cron' ); 124 }125 126 if ( ! wp_next_scheduled( 'checkview_options_cleanup_cron' ) ) {127 wp_schedule_single_event( time() + 60, 'checkview_options_cleanup_cron' );128 119 } 129 120 } … … 216 207 */ 217 208 public function checkview_init_current_test() { 218 219 209 if ( ! function_exists( 'is_plugin_active' ) ) { 220 210 include_once ABSPATH . 'wp-admin/includes/plugin.php'; 221 211 } 222 // Current Vsitor IP. 212 213 $is_helper_api_request = isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '_checkview_timestamp' ); 214 215 if ( $is_helper_api_request ) { 216 return; 217 } 218 219 // Current Visitor IP. 223 220 $visitor_ip = checkview_get_visitor_ip(); 224 221 // Check view Bot IP. … … 227 224 // Skip if visitor ip not equal to CV Bot IP. 228 225 if ( is_array( $cv_bot_ip ) && ! in_array( $visitor_ip, $cv_bot_ip ) ) { 226 if ( isset( $_REQUEST['checkview_test_id'] ) ) { 227 Checkview_Admin_Logs::add( 'ip-logs', 'Although checkview_test_id is set in the request, exiting test init due to visitor IP [' . $visitor_ip . '] failing bot IP check [' . implode(', ', $cv_bot_ip) . '].' ); 228 } 229 229 230 if ( 'true' !== get_option( 'cv_ff_keys_set_turnstile' ) ) { 230 231 return; 231 232 } 232 if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) { 233 checkview_options_cleanup(); 234 } 233 235 234 return; 236 235 } 237 236 238 // If clean talk plugin active whitelist check form API IP. 237 Checkview_Admin_Logs::add( 'ip-logs', 'Visitor IP [' . $visitor_ip . '] determined to be in bot IP list, continuing.' ); 238 239 239 if ( is_plugin_active( 'cleantalk-spam-protect/cleantalk.php' ) ) { 240 240 checkview_whitelist_api_ip(); … … 248 248 $allowlist = Allow_List::get_ips(); 249 249 $aiowps_firewall_allow_list = AIOS_Firewall_Resource::request( AIOS_Firewall_Resource::ALLOW_LIST ); 250 250 251 if ( ! empty( $allowlist ) ) { 251 252 $allowlist .= "\n" . $visitor_ip; … … 253 254 $allowlist = $visitor_ip; 254 255 } 255 $ips = sanitize_textarea_field( wp_unslash( $allowlist ) ); 256 $ips = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline( $ips ); 256 257 $ips = sanitize_textarea_field( wp_unslash( $allowlist ) ); 258 $ips = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline( $ips ); 257 259 $validated_ip_list_array = AIOWPSecurity_Utility_IP::validate_ip_list( $ips, 'firewall_allowlist' ); 260 258 261 if ( is_wp_error( $validated_ip_list_array ) ) { 259 262 $success = false; 260 263 $message = nl2br( $validated_ip_list_array->get_error_message() ); 264 261 265 Checkview_Admin_Logs::add( 'ip-logs', 'Error ' . $message ); 262 266 } else { … … 267 271 if ( is_plugin_active( 'defender-security/wp-defender.php' ) ) { 268 272 $data = array(); 269 270 273 $data['allow_list'] = (array) $visitor_ip; 271 272 $data['block_list'] = array(); 273 $data['last_update_time'] = ''; 274 $data['block_list'] = array(); 275 $data['last_update_time'] = ''; 274 276 $data['last_update_time_utc'] = ''; 275 277 276 278 $global_ip_component = wd_di()->get( Global_IP::class ); 277 $result = $global_ip_component->set_global_ip_list( $data ); 278 } 279 $result = $global_ip_component->set_global_ip_list( $data ); 280 } 281 279 282 if ( is_plugin_active( 'enhanced-cloudflare-turnstile/enhanced-cloudflare-turnstile.php' ) ) { 280 $ect_ip_address = ecft_get_option( 'ecft_ip_address' );283 $ect_ip_address = ecft_get_option( 'ecft_ip_address' ); 281 284 $ect_ip_address_array = explode( "\n", $ect_ip_address ); 285 282 286 if ( ! empty( $ect_ip_address_array ) && is_array( $ect_ip_address_array ) ) { 283 287 if ( ! in_array( $visitor_ip, $ect_ip_address_array ) ) { 284 288 $ect_ip_address .= "\n" . $visitor_ip; 285 update_option( 'ecft_ip_address', $ect_ip_address ); 289 290 cv_update_option( 'ecft_ip_address', $ect_ip_address ); 286 291 } 287 292 } else { 288 293 $ect_ip_address = $visitor_ip; 289 update_option( 'ecft_ip_address', $ect_ip_address ); 294 295 cv_update_option( 'ecft_ip_address', $ect_ip_address ); 290 296 } 291 297 } … … 304 310 305 311 // Save the updated list back to the database. 306 update_option( 'captcha_ip_range_opt', implode( ',', $captcha_ip_range ) ); 307 } 308 } 312 cv_update_option( 'captcha_ip_range_opt', implode( ',', $captcha_ip_range ) ); 313 } 314 } 315 309 316 if ( is_plugin_active( 'recaptcha-for-woocommerce/woo-recaptcha.php' ) ) { 310 $captcha_ip_range = '';317 $captcha_ip_range = ''; 311 318 $captcha_ip_range_opt = ''; 312 $captcha_ip_range = array(); 319 $captcha_ip_range = array(); 320 313 321 // Get the existing whitelist from the database. 314 322 $captcha_ip_range_opt = sanitize_text_field( wp_unslash( get_option( 'i13_recapcha_ip_to_skip_captcha' ) ) ); … … 323 331 if ( count( $captcha_ip_range ) > 1 ) { 324 332 // Save the updated list back to the database. 325 update_option( 'i13_recapcha_ip_to_skip_captcha', implode( ',', $captcha_ip_range ) );333 cv_update_option( 'i13_recapcha_ip_to_skip_captcha', implode( ',', $captcha_ip_range ) ); 326 334 } else { 327 update_option( 'i13_recapcha_ip_to_skip_captcha',$visitor_ip );335 cv_update_option( 'i13_recapcha_ip_to_skip_captcha', $visitor_ip ); 328 336 } 329 337 } 330 338 } 331 // Gather test ID. 339 332 340 $cv_test_id = isset( $_REQUEST['checkview_test_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['checkview_test_id'] ) ) : ''; 333 334 // Flag disabling of email receipts.335 341 $disable_email_receipt = isset( $_REQUEST['disable_email_receipt'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['disable_email_receipt'] ) ) : false; 336 337 342 $disable_webhooks = isset( $_REQUEST['disable_webhooks'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['disable_webhooks'] ) ) : false; 338 339 343 $referrer_url = sanitize_url( wp_get_raw_referer(), array( 'http', 'https' ) ); 340 344 … … 343 347 // Create session for later use when form submit VIA AJAX. 344 348 checkview_create_cv_session( $visitor_ip, $cv_test_id ); 345 update_option( $visitor_ip, 'checkview-saas', true ); 349 350 cv_update_option( $visitor_ip, 'checkview-saas', true); 346 351 } 347 352 … … 349 354 if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'admin-ajax.php' ) !== false ) { 350 355 $referer_url_query = wp_parse_url( $referrer_url, PHP_URL_QUERY ); 351 $qry_str = array(); 356 $qry_str = array(); 357 352 358 if ( $referer_url_query ) { 353 359 parse_str( $referer_url_query, $qry_str ); 354 360 } 361 355 362 if ( isset( $qry_str['checkview_test_id'] ) ) { 356 363 $cv_test_id = $qry_str['checkview_test_id']; 357 364 } 358 365 } 366 359 367 if ( ! empty( $cv_test_id ) && ! checkview_is_valid_uuid( $cv_test_id ) ) { 360 Checkview_Admin_Logs::add( 'ip-logs', 'Not Bypassed invalid test id. ' . $visitor_ip . '=> ' . $cv_test_id ); 368 Checkview_Admin_Logs::add( 'ip-logs', 'Test ID format failed to validate, exiting.' ); 369 361 370 return; 362 371 } 372 363 373 if ( $cv_test_id && '' !== $cv_test_id ) { 364 374 setcookie( 'checkview_test_id', $cv_test_id, time() + 6600, COOKIEPATH, COOKIE_DOMAIN ); … … 381 391 } 382 392 } 383 if ( empty( $cv_test_id ) ) { 384 Checkview_Admin_Logs::add( 'ip-logs', 'Not Bypassed missing test id. ' . $visitor_ip . '=> ' . $cv_test_id ); 385 } else { 386 Checkview_Admin_Logs::add( 'ip-logs', 'Bypassed ' . $visitor_ip . '=> ' . $cv_test_id ); 387 } 393 388 394 if ( ! empty( $cv_session ) ) { 389 390 395 $test_key = $cv_session[0]['test_key']; 391 392 396 $test_form = get_option( $test_key, '' ); 393 397 … … 402 406 if ( ! defined( 'CV_TEST_ID' ) ) { 403 407 define( 'CV_TEST_ID', $cv_test_id ); 404 } 405 } 408 409 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [CV_TEST_ID] as [ ' . CV_TEST_ID . ' ].' ); 410 } 411 } else { 412 Checkview_Admin_Logs::add( 'ip-logs', 'The CheckView session was empty, but continuing.' ); 413 } 414 406 415 if ( ! defined( 'TEST_EMAIL' ) ) { 407 416 define( 'TEST_EMAIL', $send_to ); 417 418 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [TEST_EMAIL] as [ ' . TEST_EMAIL . ' ].' ); 408 419 } 409 420 410 421 if ( ! defined( 'CV_DISABLE_EMAIL_RECEIPT' ) && $disable_email_receipt ) { 411 422 define( 'CV_DISABLE_EMAIL_RECEIPT', 'true' ); 412 update_option( 'disable_email_receipt', 'true', true ); 423 424 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [CV_DISABLE_EMAIL_RECEIPT] as [' . CV_DISABLE_EMAIL_RECEIPT . '].' ); 425 426 cv_update_option('disable_email_receipt', 'true', true); 413 427 } 414 428 415 429 if ( ! defined( 'CV_DISABLE_WEBHOOKS' ) && $disable_webhooks ) { 416 430 define( 'CV_DISABLE_WEBHOOKS', 'true' ); 417 update_option( 'disable_webhooks', 'true', true ); 431 432 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [CV_DISABLE_WEBHOOKS] as [' . CV_DISABLE_WEBHOOKS . '].' ); 433 434 cv_update_option('disable_webhooks', 'true', true); 418 435 } 419 436 420 437 delete_transient( 'checkview_forms_test_transient' ); 421 438 delete_transient( 'checkview_store_orders_transient' ); 439 422 440 if ( is_plugin_active( 'gravityforms/gravityforms.php' ) ) { 441 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Gravity Forms helper.' ); 442 423 443 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-gforms-helper.php'; 424 444 } 445 425 446 if ( is_plugin_active( 'fluentform/fluentform.php' ) ) { 447 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Fluent Forms helper.' ); 448 426 449 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-fluent-forms-helper.php'; 427 450 } 451 428 452 if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) { 453 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Ninja Forms helper.' ); 454 429 455 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-ninja-forms-helper.php'; 430 456 } 457 431 458 if ( function_exists( 'wpforms' ) && ( is_plugin_active( 'wpforms/wpforms.php' ) || is_plugin_active( 'wpforms-lite/wpforms.php' ) ) ) { 459 Checkview_Admin_Logs::add( 'ip-logs', 'Loading WP Forms helper.' ); 460 432 461 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-wpforms-helper.php'; 433 462 } 463 434 464 if ( is_plugin_active( 'formidable/formidable.php' ) ) { 465 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Formidable Forms helper.' ); 466 435 467 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-formidable-helper.php'; 436 468 } 437 469 438 470 if ( is_plugin_active( 'forminator/forminator.php' ) ) { 471 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Forminator helper.' ); 472 439 473 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-forminator-helper.php'; 440 474 } 441 475 442 476 if ( is_plugin_active( 'ws-form/ws-form.php' ) || is_plugin_active( 'ws-form-pro/ws-form.php' ) ) { 477 Checkview_Admin_Logs::add( 'ip-logs', 'Loading WS Form helper.' ); 478 443 479 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-wsf-helper.php'; 444 480 } 481 445 482 if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) { 483 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Contact Form 7 helper.' ); 484 446 485 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-cf7-helper.php'; 447 486 } -
checkview/tags/2.0.19/checkview.php
r3303097 r3323842 12 12 * Plugin URI: https://checkview.io 13 13 * Description: CheckView is the #1 fully automated solution to test your WordPress forms and detect form problems fast. Automatically test your WordPress forms to ensure you never miss a lead again. 14 * Version: 2.0.1 814 * Version: 2.0.19 15 15 * Author: CheckView 16 16 * Author URI: https://checkview.io/ … … 36 36 * @link https://semver.org 37 37 */ 38 define( 'CHECKVIEW_VERSION', '2.0.1 8' );38 define( 'CHECKVIEW_VERSION', '2.0.19' ); 39 39 40 40 if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) { -
checkview/tags/2.0.19/includes/checkview-functions.php
r3303097 r3323842 144 144 } 145 145 } 146 146 147 if ( ! function_exists( 'complete_checkview_test' ) ) { 147 148 /** … … 156 157 function complete_checkview_test( $checkview_test_id = '' ) { 157 158 global $wpdb; 158 global $CV_TEST_ID; 159 160 Checkview_Admin_Logs::add( 'ip-logs', 'Completing test...' ); 161 159 162 if ( ! defined( 'CV_TEST_ID' ) ) { 160 163 define( 'CV_TEST_ID', $checkview_test_id ); 161 164 } 165 162 166 $session_table = $wpdb->prefix . 'cv_session'; 163 $visitor_ip = checkview_get_visitor_ip();164 $cv_session = checkview_get_cv_session( $visitor_ip, CV_TEST_ID );167 $visitor_ip = checkview_get_visitor_ip(); 168 $cv_session = checkview_get_cv_session( $visitor_ip, CV_TEST_ID ); 165 169 166 170 // Stop if session not found. 167 171 if ( ! empty( $cv_session ) ) { 168 172 $test_key = $cv_session[0]['test_key']; 169 delete_option( $test_key ); 170 } 171 172 $wpdb->delete( 173 174 cv_delete_option( $test_key ); 175 } 176 177 $result = $wpdb->delete( 173 178 $session_table, 174 179 array( 175 180 'visitor_ip' => $visitor_ip, 176 'test_id' => $checkview_test_id,181 'test_id' => $checkview_test_id, 177 182 ) 178 183 ); 184 185 if ( false === $result ) { 186 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to delete rows from session table [' . $session_table . '].' ); 187 } 188 179 189 $entry_id = get_option( $checkview_test_id . '_wsf_entry_id', '' ); 180 190 $form_id = get_option( $checkview_test_id . '_wsf_frm_id', '' ); 191 181 192 if ( ! empty( $form_id ) && ! empty( $entry_id ) ) { 182 $ws_form_submit = new WS_Form_Submit();183 $ws_form_submit->id = $entry_id;193 $ws_form_submit = new WS_Form_Submit(); 194 $ws_form_submit->id = $entry_id; 184 195 $ws_form_submit->form_id = $form_id; 185 196 $ws_form_submit->db_delete( true, true, true ); 186 197 } 187 delete_option( $checkview_test_id . '_wsf_entry_id' ); 188 delete_option( $checkview_test_id . '_wsf_frm_id' ); 189 delete_option( $visitor_ip ); 198 199 cv_delete_option( $checkview_test_id . '_wsf_entry_id' ); 200 cv_delete_option( $checkview_test_id . '_wsf_frm_id' ); 201 cv_delete_option( $visitor_ip ); 202 190 203 setcookie( 'checkview_test_id', '', time() - 6600, COOKIEPATH, COOKIE_DOMAIN ); 191 204 setcookie( 'checkview_test_id' . $checkview_test_id, '', time() - 6600, COOKIEPATH, COOKIE_DOMAIN ); 192 delete_option( 'disable_email_receipt' ); 193 delete_option( 'disable_webhooks' ); 194 } 195 } 205 206 cv_delete_option( 'disable_email_receipt' ); 207 cv_delete_option( 'disable_webhooks' ); 208 209 Checkview_Admin_Logs::add( 'ip-logs', 'Test complete.' ); 210 } 211 } 212 196 213 if ( ! function_exists( 'checkview_get_publickey' ) ) { 197 214 /** … … 235 252 */ 236 253 function checkview_get_api_ip() { 237 238 254 $ip_address = get_transient( 'checkview_saas_ip_address' ) ? get_transient( 'checkview_saas_ip_address' ) : array(); 239 if ( null === $ip_address || '' === $ip_address || empty( $ip_address ) ) { 255 256 if ( empty( $ip_address ) ) { 257 Checkview_Admin_Logs::add( 'ip-logs', 'Bot IP address list transient empty, requesting new IP addresses.' ); 258 240 259 $request = wp_remote_get( 241 260 'https://verify.checkview.io/whitelist.json', … … 245 264 ) 246 265 ); 266 247 267 if ( is_wp_error( $request ) ) { 268 $code = $request->get_error_code(); 269 $message = $request->get_error_message(); 270 271 Checkview_Admin_Logs::add( 'ip-logs', 'Request for new IP addresses failed with code [' . $code . ']. Message: ' . $message ); 272 248 273 return null; 249 274 } 250 275 251 276 $body = wp_remote_retrieve_body( $request ); 252 253 277 $data = json_decode( $body, true ); 278 254 279 if ( ! empty( $data ) && ! empty( $data['ipAddresses'] ) ) { 255 280 $ip_address = $data['ipAddresses']; 281 256 282 if ( ! empty( $ip_address ) && is_array( $ip_address ) ) { 257 283 foreach ( $ip_address as $ip ) { … … 264 290 return false; 265 291 } 292 266 293 set_transient( 'checkview_saas_ip_address', $ip_address, 12 * HOUR_IN_SECONDS ); 267 } 268 } 294 295 Checkview_Admin_Logs::add( 'ip-logs', 'Set bot IP address list transient to response data [' . wp_json_encode( $ip_address ) . ']' ); 296 } else { 297 Checkview_Admin_Logs::add( 'ip-logs', 'IP addresses not found in request for new IP addresses.' ); 298 } 299 } 300 269 301 if ( ! is_array( $ip_address ) ) { 270 302 $ip_address = (array) $ip_address; 271 303 } 304 272 305 if ( is_array( $ip_address ) ) { 273 306 $ip_address[] = '::1'; … … 275 308 $ip_address[] = '2001:8a0:e5d0:a900:70a5:138a:d159:5054'; 276 309 } 310 277 311 return $ip_address; 278 312 } … … 325 359 * @since 1.0.0 326 360 * 327 * @return string |falseIP address of visitor, or `false` if determined to be328 * an invalid IP.361 * @return string IP address of visitor, or `false` if determined to be 362 * an invalid IP. 329 363 */ 330 364 function checkview_get_visitor_ip() { … … 332 366 $cv_bot_ip = checkview_get_api_ip(); 333 367 $ip_options = checkview_get_custom_header_keys_for_ip(); 334 $ip = '';368 $ip = ''; 335 369 336 370 foreach ( $ip_options as $key ) { … … 340 374 341 375 $key = checkview_get_server_value( $key ); 376 342 377 foreach ( explode( ',', $key ) as $ip ) { 343 // Just to be safe.344 378 $ip = trim( $ip ); 345 379 346 380 if ( checkview_validate_ip( $ip ) && is_array( $cv_bot_ip ) && in_array( $ip, $cv_bot_ip ) ) { 347 Checkview_Admin_Logs::add( 'ip-logs', 'Bypassed ' . $ip );348 381 return sanitize_text_field( $ip ); 349 382 } … … 808 841 */ 809 842 function checkview_schedule_delete_orders( $order_id ) { 843 Checkview_Admin_Logs::add( 'ip-logs', 'Scheduling order deletion.' ); 844 810 845 wp_schedule_single_event( time() + 1 * HOUR_IN_SECONDS, 'checkview_delete_orders_action', array( $order_id ) ); 811 846 } … … 888 923 function checkview_is_valid_uuid( $uuid ) { 889 924 if ( empty( $uuid ) || is_wp_error( $uuid ) ) { 925 Checkview_Admin_Logs::add( 'ip-logs', 'Invalid UUID [' . $uuid . '].' ); 926 890 927 return false; 891 928 } 892 return preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i', $uuid ); 929 930 $matches = preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i', $uuid ); 931 932 if ( ! $matches ) { 933 Checkview_Admin_Logs::add( 'ip-logs', 'Invalid UUID [' . $uuid . '].' ); 934 935 return false; 936 } 937 938 return true; 893 939 } 894 940 } … … 1074 1120 } 1075 1121 return $updated; 1076 }1077 }1078 if ( ! defined( 'checkview_options_cleanup' ) ) {1079 /**1080 * Cleans options for CV.1081 *1082 * @return void1083 */1084 function checkview_options_cleanup() {1085 $old_settings = array();1086 $old_settings = (array) get_option( '_fluentform_reCaptcha_details', array() );1087 if ( ! empty( $old_settings ) && null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] ) {1088 if ( '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' === $old_settings['siteKey'] ) {1089 $old_settings['siteKey'] = get_option( 'checkview_rc-site-key' );1090 $old_settings['secretKey'] = get_option( 'checkview_rc-secret-key' );1091 update_option( '_fluentform_reCaptcha_details', $old_settings );1092 }1093 }1094 $old_settings = array();1095 $old_settings = (array) get_option( '_fluentform_turnstile_details', array() );1096 if ( ! empty( $old_settings ) && null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] ) {1097 if ( '1x00000000000000000000AA' === $old_settings['siteKey'] ) {1098 $old_settings['siteKey'] = get_option( 'checkview_ff_turnstile-site-key' );1099 $old_settings['secretKey'] = get_option( 'checkview_ff_turnstile-secret-key' );1100 update_option( '_fluentform_turnstile_details', $old_settings );1101 }1102 }1103 delete_option( 'cv_ff_keys_set_turnstile' );1104 1122 } 1105 1123 } … … 1125 1143 } 1126 1144 } 1145 1146 if ( ! function_exists( 'cv_update_option' ) ) { 1147 /** 1148 * Updates an option in WordPress. 1149 * 1150 * Wrapper for update_option() that also includes logging. Suppresses logs from 1151 * failures due to option already existing with the same value. 1152 * 1153 * @see update_option() 1154 * @see get_option() 1155 * 1156 * @param $option string Name of the option to update. 1157 * @param $value mixed Option value. 1158 * @param $autoload boolean|null Optional. Whether to load the option when WordPress starts up. 1159 * 1160 * @return boolean True if the value was updated, false otherwise. 1161 */ 1162 function cv_update_option( $option, $value, $autoload = null ) { 1163 $old_option = get_option( $option ); 1164 $result = update_option( $option, $value, $autoload ); 1165 1166 if ( $result ) { 1167 Checkview_Admin_Logs::add( 'ip-logs', 'Updated option [' . $option . '] with value [' . print_r( $value, true ) . '].' ); 1168 } else { 1169 if ($old_option !== false && $old_option !== $value && maybe_serialize( $old_option ) !== maybe_serialize( $value ) ) { 1170 Checkview_Admin_Logs::add( 'ip-logs', 'Failed updating option [' . $option . '] with value [' . print_r( $value, true ) . '].' ); 1171 } 1172 } 1173 1174 return $result; 1175 } 1176 } 1177 1178 if ( ! function_exists( 'cv_delete_option' ) ) { 1179 /** 1180 * Deletes an option in WordPress. 1181 * 1182 * Wrapper for delete_option() that also includes logging. Only attempts 1183 * deletion if the option is found in the database. 1184 * 1185 * @see delete_option() 1186 * @see get_option() 1187 * 1188 * @param $option string Name of the option to delete. 1189 * 1190 * @return boolean True if the value was deleted, false otherwise. 1191 */ 1192 function cv_delete_option( $option ) { 1193 $current_option = get_option( $option ); 1194 1195 if ( false !== $current_option ) { 1196 $result = delete_option( $option ); 1197 1198 if ( $result ) { 1199 Checkview_Admin_Logs::add( 'ip-logs', 'Deleted option [' . $option . '].' ); 1200 } else { 1201 Checkview_Admin_Logs::add( 'ip-logs', 'Failed deleting option [' . $option . '].' ); 1202 } 1203 1204 return $result; 1205 } 1206 1207 return true; 1208 } 1209 } -
checkview/tags/2.0.19/includes/class-checkview.php
r3303097 r3323842 71 71 $this->version = CHECKVIEW_VERSION; 72 72 } else { 73 $this->version = '2.0.1 8';73 $this->version = '2.0.19'; 74 74 } 75 75 $this->plugin_name = 'checkview'; … … 202 202 */ 203 203 private function define_admin_hooks() { 204 205 204 $plugin_admin = new Checkview_Admin( $this->get_plugin_name(), $this->get_version() ); 206 205 $plugin_settings = new Checkview_Admin_Settings( $this->get_plugin_name(), $this->get_version() ); 207 206 $plugin_logs = new Checkview_Admin_Logs(); 207 208 208 if ( is_admin() ) { 209 209 // load backend hooks. -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-cf7-helper.php
r3216431 r3323842 125 125 */ 126 126 public function checkview_cf7_before_send_mail( $form_tag ) { 127 128 127 global $wpdb; 129 128 130 $form_id = $form_tag->id();129 $form_id = $form_tag->id(); 131 130 $wp_filesystem_direct = new WP_Filesystem_Direct( array() ); 132 133 131 $checkview_test_id = get_checkview_test_id(); 134 132 … … 137 135 } 138 136 139 $upload_dir = wp_upload_dir();137 $upload_dir = wp_upload_dir(); 140 138 $cv_cf7_dirname = $upload_dir['basedir'] . '/cv_cf7_uploads'; 141 139 … … 145 143 146 144 $time_now = time(); 147 148 145 $submission = WPCF7_Submission::get_instance(); 146 149 147 if ( $submission ) { 150 148 $contact_form = $submission->get_contact_form(); 151 149 } 150 152 151 $tags_names = array(); 153 152 154 153 if ( $submission ) { 155 156 $allowed_tags = array(); 154 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry...' ); 157 155 158 156 $tags = $contact_form->scan_form_tags(); 157 159 158 foreach ( $tags as $tag ) { 160 159 if ( ! empty( $tag->name ) ) { … … 162 161 } 163 162 } 163 164 164 $allowed_tags = $tags_names; 165 166 165 $not_allowed_tags = array( 'g-recaptcha-response' ); 167 168 $data = $submission->get_posted_data(); 169 $files = $submission->uploaded_files(); 166 $data = $submission->get_posted_data(); 167 $files = $submission->uploaded_files(); 170 168 $uploaded_files = array(); 171 169 … … 173 171 array_push( $uploaded_files, $file_key ); 174 172 } 173 175 174 foreach ( $files as $file_key => $file ) { 176 175 $file = is_array( $file ) ? reset( $file ) : $file; … … 184 183 185 184 foreach ( $data as $key => $d ) { 186 187 185 if ( ! in_array( $key, $allowed_tags ) ) { 188 186 continue; … … 190 188 191 189 if ( ! in_array( $key, $not_allowed_tags ) && ! in_array( $key, $uploaded_files ) ) { 192 193 190 $tmp_d = $d; 194 191 195 192 if ( ! is_array( $d ) ) { 196 $bl = array( '\"', "\'", '/', '\\', '"', "'" );197 $wl = array( '"', ''', '/', '\', '"', ''' );193 $bl = array( '\"', "\'", '/', '\\', '"', "'" ); 194 $wl = array( '"', ''', '/', '\', '"', ''' ); 198 195 $tmp_d = str_replace( $bl, $wl, $tmp_d ); 199 196 } 197 200 198 if ( is_array( $d ) ) { 201 199 $tmp_d = serialize( $d ); … … 204 202 $form_data[ $key ] = $tmp_d; 205 203 } 204 206 205 if ( in_array( $key, $uploaded_files ) ) { 207 $file = is_array( $files[ $key ] ) ? reset( $files[ $key ] ) : $files[ $key ];208 $file_name = empty( $file ) ? '' : $time_now . '-' . $key . '-' . basename( $file );206 $file = is_array( $files[ $key ] ) ? reset( $files[ $key ] ) : $files[ $key ]; 207 $file_name = empty( $file ) ? '' : $time_now . '-' . $key . '-' . basename( $file ); 209 208 $form_data[ $key . 'cv_cf7_file' ] = $file_name; 210 209 } … … 213 212 // insert entry. 214 213 $entry_data = array( 215 'form_id' => $form_id,216 'status' => 'publish',217 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',214 'form_id' => $form_id, 215 'status' => 'publish', 216 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 218 217 'date_created' => current_time( 'mysql' ), 219 218 'date_updated' => current_time( 'mysql' ), 220 'uid' => $checkview_test_id,221 'form_type' => 'CF7',219 'uid' => $checkview_test_id, 220 'form_type' => 'CF7', 222 221 ); 223 222 $entry_table = $wpdb->prefix . 'cv_entry'; 224 $wpdb->insert( $entry_table, $entry_data ); 223 224 $result = $wpdb->insert( $entry_table, $entry_data ); 225 226 if ( ! $result ) { 227 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 228 } else { 229 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 230 } 231 225 232 $inserted_entry_id = $wpdb->insert_id; 226 227 233 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 234 $count = 0; 228 235 229 236 foreach ( $form_data as $key => $val ) { 230 231 237 $entry_metadata = array( 232 'uid' => $checkview_test_id,233 'form_id' => $form_id,234 'entry_id' => $inserted_entry_id,235 'meta_key' => $key,238 'uid' => $checkview_test_id, 239 'form_id' => $form_id, 240 'entry_id' => $inserted_entry_id, 241 'meta_key' => $key, 236 242 'meta_value' => $val, 237 243 ); 238 $wpdb->insert( $entry_meta_table, $entry_metadata ); 244 245 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 246 247 if ( $result ) { 248 $count++; 249 } 250 } 251 252 if ( $count > 0 ) { 253 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 254 } else { 255 if ( count( $form_data ) > 0 ) { 256 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 257 } 239 258 } 240 259 -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-fluent-forms-helper.php
r3227063 r3323842 47 47 add_filter( 48 48 'fluentform/email_to', 49 array( 50 $this, 51 'checkview_remove_receipt', 52 ), 49 array( $this, 'checkview_remove_receipt' ), 53 50 99, 54 4 51 4, 55 52 ); 56 53 57 54 add_filter( 58 55 'fluentform/email_template_header', 59 array( 60 $this, 61 'checkview_remove_email_header', 62 ), 56 array( $this, 'checkview_remove_email_header' ), 63 57 99, 64 2 58 2, 65 59 ); 66 60 } … … 70 64 add_filter( 71 65 'fluentform/email_to', 72 array( 73 $this, 74 'checkview_inject_email', 75 ), 66 array( $this, 'checkview_inject_email' ), 76 67 99, 77 4 68 4, 78 69 ); 79 70 } … … 81 72 add_action( 82 73 'fluentform/submission_inserted', 83 array( 84 $this, 85 'checkview_clone_fluentform_entry', 86 ), 74 array( $this, 'checkview_clone_fluentform_entry' ), 87 75 99, 88 76 3 89 77 ); 78 90 79 add_filter( 91 80 'fluentform/has_recaptcha', 92 function ( $isSpamCheck ) { 93 return false; 94 }, 81 '__return_false', 95 82 20, 96 197 83 ); 98 84 99 85 add_filter( 100 86 'fluentform/has_hcaptcha', 101 function ( $status ) { 102 // Do your stuff here. 103 104 return false; 105 }, 106 10, 107 1 87 '__return_false', 108 88 ); 109 89 110 90 add_filter( 111 91 'fluentform/has_turnstile', 112 function ( $status ) { 113 // Do your stuff here. 114 115 return false; 116 }, 117 10, 118 1 119 ); 92 '__return_false', 93 ); 94 120 95 add_filter( 121 96 'fluentform/akismet_check_spam', 122 function ( $isSpamCheck, $form_id, $formData ) { 123 return false; 124 }, 97 '__return_false', 125 98 20, 126 3127 ); 99 ); 100 128 101 add_filter( 129 102 'cfturnstile_whitelisted', 130 103 '__return_true', 131 999 132 ); 133 134 $old_settings = (array) get_option( '_fluentform_turnstile_details', array() ); 135 if ( ! empty( $old_settings['siteKey'] ) && null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] ) { 136 if ( '1x00000000000000000000AA' !== $old_settings['siteKey'] ) { 137 update_option( 'checkview_ff_turnstile-site-key', $old_settings['siteKey'], true ); 138 update_option( 'checkview_ff_turnstile-secret-key', $old_settings['secretKey'], true ); 139 $old_settings['siteKey'] = '1x00000000000000000000AA'; 140 $old_settings['secretKey'] = '1x0000000000000000000000000000000AA'; 141 update_option( '_fluentform_turnstile_details', $old_settings ); 142 } 143 } 144 $old_settings = array(); 145 $old_settings = (array) get_option( '_fluentform_reCaptcha_details', array() ); 146 if ( null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] && strpos( $old_settings['api_version'], 'v3' ) === false ) { 147 if ( '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' !== $old_settings['siteKey'] ) { 148 update_option( 'checkview_rc-site-key', $old_settings['siteKey'], true ); 149 update_option( 'checkview_rc-secret-key', $old_settings['secretKey'], true ); 150 $old_settings['siteKey'] = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'; 151 $old_settings['secretKey'] = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'; 152 update_option( '_fluentform_reCaptcha_details', $old_settings ); 153 } 154 } 155 update_option( 'cv_ff_keys_set_turnstile', 'true' ); 104 999, 105 ); 106 156 107 add_filter( 157 108 'fluentform/recaptcha_v3_ref_score', … … 160 111 }, 161 112 99, 162 1163 113 ); 164 114 … … 173 123 ); 174 124 175 // Dis bale feeds.125 // Disable feeds. 176 126 add_filter( 177 127 'fluentform/global_notification_active_types', 178 array( 179 $this, 180 'checkview_disable_form_actions', 181 ), 128 array( $this, 'checkview_disable_form_actions' ), 182 129 99, 183 2 130 2, 184 131 ); 185 132 … … 187 134 add_filter( 188 135 'fluentform/honeypot_status', 189 function ( $status, $form_id ) { 190 return false; 191 }, 136 '__return_false', 192 137 999, 193 2 138 ); 139 140 add_filter( 141 'fluentform/token_based_spam_protection_status', 142 '__return_false', 143 999 144 ); 145 146 add_filter( 147 'fluentform/disable_captcha', 148 '__return_true', 149 999 194 150 ); 195 151 } … … 260 216 global $wpdb; 261 217 262 $form_id = $form->id; 218 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 219 220 $form_id = $form->id; 263 221 $checkview_test_id = get_checkview_test_id(); 264 222 … … 269 227 // Clone entry to check view tables. 270 228 $tablename = $wpdb->prefix . 'fluentform_entry_details'; 271 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where submission_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 229 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where submission_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 230 $count = 0; 231 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 232 272 233 foreach ( $rows as $row ) { 273 234 $meta_key = 'ff_' . $form_id . '_' . $row->field_name; 235 274 236 if ( '' !== $row->sub_field_name ) { 275 237 $meta_key .= '_' . $row->sub_field_name . '_'; 276 238 } 277 $table = $wpdb->prefix . 'cv_entry_meta'; 239 278 240 $data = array( 279 241 'uid' => $checkview_test_id, … … 283 245 'meta_value' => $row->field_value, 284 246 ); 285 $wpdb->insert( $table, $data ); 286 } 247 248 $result = $wpdb->insert( $entry_meta_table, $data ); 249 250 if ( $result ) { 251 $count++; 252 } 253 } 254 255 if ( $count > 0 ) { 256 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 257 } else { 258 if ( count( $rows ) > 0 ) { 259 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 260 } 261 } 262 287 263 $tablename = $wpdb->prefix . 'fluentform_submissions'; 288 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A );289 $ table1= $wpdb->prefix . 'cv_entry';290 $data = array(291 'uid' => $checkview_test_id,292 'form_type' => 'FluentForms',293 'form_id' => $form_id,294 'source_url' => isset( $row['source_url'] ) ? $row['source_url'] : 'n/a',295 'response' => isset( $row['response'] ) ? $row['response'] : 'n/a',296 'user_agent' => isset( $row['browser'] ) ? $row['browser'] : 'n/a',297 'ip' => isset( $row['ip'] ) ? $row['ip'] : 'n/a',298 'date_created' => isset( $row['created_at'] ) ? $row['created_at'] : 'n/a',299 'date_updated' => isset( $row['updated_at'] ) ? $row['updated_at'] : 'n/a',264 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A ); 265 $entry_table = $wpdb->prefix . 'cv_entry'; 266 $data = array( 267 'uid' => $checkview_test_id, 268 'form_type' => 'FluentForms', 269 'form_id' => $form_id, 270 'source_url' => isset( $row['source_url'] ) ? $row['source_url'] : 'n/a', 271 'response' => isset( $row['response'] ) ? $row['response'] : 'n/a', 272 'user_agent' => isset( $row['browser'] ) ? $row['browser'] : 'n/a', 273 'ip' => isset( $row['ip'] ) ? $row['ip'] : 'n/a', 274 'date_created' => isset( $row['created_at'] ) ? $row['created_at'] : 'n/a', 275 'date_updated' => isset( $row['updated_at'] ) ? $row['updated_at'] : 'n/a', 300 276 'payment_status' => isset( $row['payment_status'] ) ? $row['payment_status'] : 'n/a', 301 277 'payment_method' => isset( $row['payment_method'] ) ? $row['payment_payment'] : 'n/a', 302 278 'payment_amount' => isset( $row['payment_total'] ) ? $row['payment_total'] : 0, 303 279 ); 304 $wpdb->insert( $table1, $data ); 280 281 $result = $wpdb->insert( $entry_table, $data ); 282 283 if ( ! $result ) { 284 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 285 } else { 286 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 287 } 305 288 306 289 // remove entry from Fluent forms tables. -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-formidable-helper.php
r3247217 r3323842 41 41 public function __construct() { 42 42 $this->loader = new Checkview_Loader(); 43 43 44 if ( defined( 'TEST_EMAIL' ) ) { 44 45 // update email to our test email. … … 83 84 2 84 85 ); 86 85 87 add_filter( 86 88 'akismet_get_api_key', … … 88 90 -10 89 91 ); 92 90 93 add_filter( 91 94 'frm_fields_to_validate', … … 97 100 2 98 101 ); 102 99 103 add_filter( 100 104 'cfturnstile_whitelisted', … … 102 106 999 103 107 ); 108 104 109 add_filter( 105 110 'frm_run_honeypot', 106 111 '__return_false' 107 112 ); 113 108 114 // Disbale form action. 109 115 add_filter( … … 169 175 global $wpdb; 170 176 177 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 178 171 179 $checkview_test_id = get_checkview_test_id(); 172 180 … … 176 184 177 185 // Insert entry. 178 $entry_data = array(179 'form_id' => $form_id,180 'status' => 'publish',181 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',186 $entry_data = array( 187 'form_id' => $form_id, 188 'status' => 'publish', 189 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 182 190 'date_created' => current_time( 'mysql' ), 183 191 'date_updated' => current_time( 'mysql' ), 184 'uid' => $checkview_test_id,185 'form_type' => 'Formidable',192 'uid' => $checkview_test_id, 193 'form_type' => 'Formidable', 186 194 ); 187 195 $entry_table = $wpdb->prefix . 'cv_entry'; 188 $wpdb->insert( $entry_table, $entry_data ); 189 $inserted_entry_id = $wpdb->insert_id; 196 197 $result = $wpdb->insert( $entry_table, $entry_data ); 198 199 if ( ! $result ) { 200 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 201 } else { 202 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 203 } 190 204 191 205 // Insert entry meta. 192 206 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 193 $fields = $this->get_form_fields( $form_id ); 207 $fields = $this->get_form_fields( $form_id ); 208 194 209 if ( empty( $fields ) ) { 195 210 return; 196 211 } 197 $tablename = $wpdb->prefix . 'frm_item_metas'; 212 213 $tablename = $wpdb->prefix . 'frm_item_metas'; 198 214 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where item_id=%d', $entry_id ) ); 215 $count = 0; 216 199 217 foreach ( $form_fields as $field ) { 200 218 if ( empty( $field->field_id ) ) { 201 219 continue; 202 220 } 221 203 222 if ( 'name' === $fields[ $field->field_id ]['type'] ) { 204 205 223 $field_values = maybe_unserialize( $field->meta_value ); 206 207 224 $name_format = $fields[ $field->field_id ]['name_layout']; 225 208 226 switch ( $name_format ) { 209 227 case 'first_middle_last': 210 228 // First. 211 229 $entry_metadata = array( 212 'uid' => $checkview_test_id,213 'form_id' => $form_id,214 'entry_id' => $entry_id,215 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'],230 'uid' => $checkview_test_id, 231 'form_id' => $form_id, 232 'entry_id' => $entry_id, 233 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'], 216 234 'meta_value' => $field_values['first'], 217 235 ); 218 $wpdb->insert( $entry_meta_table, $entry_metadata ); 236 237 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 238 239 if ( $result ) { 240 $count++; 241 } 219 242 220 243 // middle. 221 244 $entry_metadata = array( 222 'uid' => $checkview_test_id,223 'form_id' => $form_id,224 'entry_id' => $entry_id,225 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'],245 'uid' => $checkview_test_id, 246 'form_id' => $form_id, 247 'entry_id' => $entry_id, 248 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'], 226 249 'meta_value' => $field_values['middle'], 227 250 ); 228 $wpdb->insert( $entry_meta_table, $entry_metadata ); 251 252 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 253 254 if ( $result ) { 255 $count++; 256 } 229 257 230 258 // last. 231 259 $entry_metadata = array( 232 'uid' => $checkview_test_id,233 'form_id' => $form_id,234 'entry_id' => $entry_id,235 'meta_key' => $fields[ $field->field_id ]['sub_fields'][2]['field_id'],260 'uid' => $checkview_test_id, 261 'form_id' => $form_id, 262 'entry_id' => $entry_id, 263 'meta_key' => $fields[ $field->field_id ]['sub_fields'][2]['field_id'], 236 264 'meta_value' => $field_values['last'], 237 265 ); 238 $wpdb->insert( $entry_meta_table, $entry_metadata ); 266 267 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 268 269 if ( $result ) { 270 $count++; 271 } 239 272 240 273 break; … … 242 275 // First. 243 276 $entry_metadata = array( 244 'uid' => $checkview_test_id,245 'form_id' => $form_id,246 'entry_id' => $entry_id,247 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'],277 'uid' => $checkview_test_id, 278 'form_id' => $form_id, 279 'entry_id' => $entry_id, 280 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'], 248 281 'meta_value' => $field_values['first'], 249 282 ); 250 $wpdb->insert( $entry_meta_table, $entry_metadata ); 283 284 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 285 286 if ( $result ) { 287 $count++; 288 } 289 251 290 // last. 252 291 $entry_metadata = array( 253 'uid' => $checkview_test_id,254 'form_id' => $form_id,255 'entry_id' => $entry_id,256 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'],292 'uid' => $checkview_test_id, 293 'form_id' => $form_id, 294 'entry_id' => $entry_id, 295 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'], 257 296 'meta_value' => $field_values['last'], 258 297 ); 259 $wpdb->insert( $entry_meta_table, $entry_metadata ); 298 299 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 300 301 if ( $result ) { 302 $count++; 303 } 304 260 305 break; 261 306 case 'last_first': 262 307 // First. 263 308 $entry_metadata = array( 264 'uid' => $checkview_test_id,265 'form_id' => $form_id,266 'entry_id' => $entry_id,267 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'],309 'uid' => $checkview_test_id, 310 'form_id' => $form_id, 311 'entry_id' => $entry_id, 312 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'], 268 313 'meta_value' => $field_values['first'], 269 314 ); 270 $wpdb->insert( $entry_meta_table, $entry_metadata ); 315 316 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 317 318 if ( $result ) { 319 $count++; 320 } 321 271 322 // last. 272 323 $entry_metadata = array( 273 'uid' => $checkview_test_id,274 'form_id' => $form_id,275 'entry_id' => $entry_id,276 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'],324 'uid' => $checkview_test_id, 325 'form_id' => $form_id, 326 'entry_id' => $entry_id, 327 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'], 277 328 'meta_value' => $field_values['last'], 278 329 ); 279 $wpdb->insert( $entry_meta_table, $entry_metadata ); 280 break; 281 330 331 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 332 333 if ( $result ) { 334 $count++; 335 } 336 337 break; 282 338 } 283 339 } else { 284 $field_value = $field->meta_value;340 $field_value = $field->meta_value; 285 341 $entry_metadata = array( 286 'uid' => $checkview_test_id,287 'form_id' => $form_id,288 'entry_id' => $entry_id,289 'meta_key' => $fields[ $field->field_id ]['field_id'],342 'uid' => $checkview_test_id, 343 'form_id' => $form_id, 344 'entry_id' => $entry_id, 345 'meta_key' => $fields[ $field->field_id ]['field_id'], 290 346 'meta_value' => $field_value, 291 347 ); 292 $wpdb->insert( $entry_meta_table, $entry_metadata ); 348 349 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 350 351 if ( $result ) { 352 $count++; 353 } 354 } 355 } 356 357 if ( $count > 0 ) { 358 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 359 } else { 360 if ( count( $form_fields ) > 0 ) { 361 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 293 362 } 294 363 } … … 296 365 // Remove test entry form Formidable. 297 366 $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $entry_id ) ); 298 $ result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $entry_id ) );367 $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $entry_id ) ); 299 368 300 369 complete_checkview_test( $checkview_test_id ); -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-forminator-helper.php
r3216431 r3323842 41 41 public function __construct() { 42 42 $this->loader = new Checkview_Loader(); 43 43 44 if ( defined( 'TEST_EMAIL' ) ) { 44 45 // update email to our test email. … … 91 92 999 92 93 ); 94 93 95 add_filter( 94 96 'forminator_invalid_captcha_message', 95 97 '__return_null' 96 98 ); 99 97 100 // Disbale form action. 98 101 add_filter( … … 151 154 * @param object $entry entry object. 152 155 * @param int $form_id Form entry ID. 153 * @param int$form_fields Form's fields.156 * @param array $form_fields Form's fields. 154 157 * @return void 155 158 */ 156 public function checkview_log_form_test_entry( 157 $entry, 158 $form_id, 159 $form_fields 160 ) { 159 public function checkview_log_form_test_entry($entry, $form_id, $form_fields) { 161 160 global $wpdb; 162 161 163 162 $checkview_test_id = get_checkview_test_id(); 164 $entry_id = $entry->entry_id; 165 $form_id = $entry->form_id; 163 $entry_id = $entry->entry_id; 164 $form_id = $entry->form_id; 165 166 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 167 166 168 if ( empty( $checkview_test_id ) ) { 167 169 $checkview_test_id = $form_id . gmdate( 'Ymd' ); … … 180 182 181 183 $entry_table = $wpdb->prefix . 'cv_entry'; 182 $wpdb->insert( $entry_table, $entry_data ); 183 $inserted_entry_id = $wpdb->insert_id; 184 185 // Insert entry meta. 184 $result = $wpdb->insert( $entry_table, $entry_data ); 185 186 if ( ! $result ) { 187 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 188 } else { 189 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 190 } 191 186 192 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 193 $count = 0; 187 194 188 195 foreach ( $form_fields as $field ) { … … 190 197 continue; 191 198 } 199 192 200 $field_value = $field['value']; 193 201 $meta_key = $field['name']; … … 199 207 'meta_value' => $field_value, 200 208 ); 201 $wpdb->insert( $entry_meta_table, $entry_metadata ); 202 } 203 204 // Remove test entry form Forminator. 209 210 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 211 212 if ( $result ) { 213 $count++; 214 } 215 } 216 217 if ( $count > 0 ) { 218 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 219 } else { 220 if ( count( $form_fields ) > 0 ) { 221 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 222 } 223 } 205 224 206 225 complete_checkview_test( $checkview_test_id ); 226 207 227 // Delete entry. 208 228 Forminator_Form_Entry_Model::delete_by_entry( $entry_id ); -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-gforms-helper.php
r3216431 r3323842 168 168 foreach ( $form['fields'] as $key => $field ) { 169 169 if ( 'captcha' === $field->type || 'hcaptcha' === $field->type || 'turnstile' === $field->type ) { 170 Checkview_Admin_Logs::add( 'ip-logs', 'Unset captcha field type [' . $field->type . '].' ); 171 170 172 unset( $fields[ $key ] ); 171 173 } … … 173 175 174 176 $form['fields'] = $fields; 177 175 178 return $form; 176 179 } … … 186 189 */ 187 190 public function checkview_clone_entry( $entry, $form ) { 188 $form_id = rgar( $form, 'id' );191 $form_id = rgar( $form, 'id' ); 189 192 $checkview_test_id = get_checkview_test_id(); 190 193 … … 192 195 $checkview_test_id = $form_id . gmdate( 'Ymd' ); 193 196 } 197 194 198 self::checkview_clone_gf_entry( $entry['id'], $form_id, $checkview_test_id ); 199 195 200 if ( isset( $entry['id'] ) ) { 196 201 GFAPI::delete_entry( $entry['id'] ); … … 285 290 global $wpdb; 286 291 292 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . '] with unique ID [' . $uid . ']...' ); 293 287 294 $tablename = $wpdb->prefix . 'gf_entry_meta'; 288 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where entry_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 295 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where entry_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 296 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 297 $count = 0; 298 289 299 foreach ( $rows as $row ) { 290 $table = $wpdb->prefix . 'cv_entry_meta';291 300 $data = array( 292 'uid' => $uid,293 'form_id' => $row->form_id,294 'entry_id' => $row->entry_id,295 'meta_key' => $row->meta_key,301 'uid' => $uid, 302 'form_id' => $row->form_id, 303 'entry_id' => $row->entry_id, 304 'meta_key' => $row->meta_key, 296 305 'meta_value' => $row->meta_value, 297 306 ); 298 $wpdb->insert( $table, $data ); 299 } 307 308 $result = $wpdb->insert( $entry_meta_table, $data ); 309 310 if ( $result ) { 311 $count++; 312 } 313 } 314 315 if ( $count > 0 ) { 316 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 317 } else { 318 if ( count( $rows ) > 0 ) { 319 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 320 } 321 } 322 300 323 $tablename = $wpdb->prefix . 'gf_entry'; 301 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A ); 324 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A ); 325 302 326 unset( $row['id'] ); 303 327 unset( $row['source_id'] ); 304 $table1 = $wpdb->prefix . 'cv_entry'; 305 $row['uid'] = $uid; 328 329 $entry_table = $wpdb->prefix . 'cv_entry'; 330 $row['uid'] = $uid; 306 331 $row['form_type'] = 'GravityForms'; 307 $wpdb->insert( $table1, $row ); 332 $result = $wpdb->insert( $entry_table, $row ); 333 334 if ( ! $result ) { 335 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 336 } else { 337 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 338 } 308 339 } 309 340 -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-ninja-forms-helper.php
r3216431 r3323842 42 42 public function __construct() { 43 43 $this->loader = new Checkview_Loader(); 44 44 45 add_action( 45 46 'ninja_forms_after_submission', … … 51 52 1 52 53 ); 54 53 55 add_filter( 54 56 'akismet_get_api_key', … … 65 67 20 66 68 ); 69 67 70 add_filter( 68 71 'ninja_forms_validate_fields', … … 79 82 999 80 83 ); 84 81 85 add_filter( 82 86 'ninja_forms_action_recaptcha__verify_response', … … 84 88 99 85 89 ); 90 86 91 if ( defined( 'TEST_EMAIL' ) ) { 87 92 add_filter( … … 154 159 $entry_id = isset( $form_data['actions']['save']['sub_id'] ) ? $form_data['actions']['save']['sub_id'] : 0; 155 160 161 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 162 156 163 $checkview_test_id = get_checkview_test_id(); 157 164 … … 162 169 // Insert Entry. 163 170 $entry_data = array( 164 'form_id' => $form_id,165 'status' => 'publish',166 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',171 'form_id' => $form_id, 172 'status' => 'publish', 173 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 167 174 'date_created' => current_time( 'mysql' ), 168 175 'date_updated' => current_time( 'mysql' ), 169 'uid' => $checkview_test_id,170 'form_type' => 'NinjaForms',176 'uid' => $checkview_test_id, 177 'form_type' => 'NinjaForms', 171 178 ); 172 179 $entry_table = $wpdb->prefix . 'cv_entry'; 173 $wpdb->insert( $entry_table, $entry_data ); 174 $inserted_entry_id = $wpdb->insert_id; 175 176 // Insert entry meta. 180 181 $result = $wpdb->insert( $entry_table, $entry_data ); 182 183 if ( ! $result ) { 184 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 185 } else { 186 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 187 } 188 177 189 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 178 190 $field_id_prefix = 'nf'; 179 $tablename = $wpdb->prefix . 'postmeta'; 180 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where post_id=%d', $entry_id ) ); 191 $tablename = $wpdb->prefix . 'postmeta'; 192 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where post_id=%d', $entry_id ) ); 193 $count = 0; 194 181 195 foreach ( $form_fields as $field ) { 182 196 if ( ! in_array( $field->meta_key, array( '_form_id', '_seq_num' ) ) ) { … … 188 202 'meta_value' => $field->meta_value, 189 203 ); 190 $wpdb->insert( $entry_meta_table, $entry_metadata ); 204 205 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 206 207 if ( $result ) { 208 $count++; 209 } 210 } 211 } 212 213 if ( $count > 0 ) { 214 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 215 } else { 216 if ( count( $form_fields ) > 0 ) { 217 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 191 218 } 192 219 } -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-wpforms-helper.php
r3247217 r3323842 42 42 public function __construct() { 43 43 $this->loader = new Checkview_Loader(); 44 44 45 if ( ! is_admin() ) { 45 46 include_once ABSPATH . 'wp-admin/includes/plugin.php'; 46 47 } 47 48 48 $old_settings = (array) get_option( 'wpforms_settings', array() ); 49 if ( ! empty( $old_settings['turnstile-site-key'] ) && null !== $old_settings['turnstile-site-key'] && null !== $old_settings['turnstile-secret-key'] ) { 50 if ( '1x00000000000000000000AA' !== $old_settings['turnstile-site-key'] ) { 51 update_option( 'checkview_wpforms_turnstile-site-key', $old_settings['turnstile-site-key'], true ); 52 update_option( 'checkview_wpforms_turnstile-secret-key', $old_settings['turnstile-secret-key'], true ); 53 $old_settings['turnstile-site-key'] = '1x00000000000000000000AA'; 54 $old_settings['turnstile-secret-key'] = '1x0000000000000000000000000000000AA'; 55 update_option( 'wpforms_settings', $old_settings ); 56 } 57 } else { 58 // Disable reCAPTCHA assets and initialisation on the frontend. 59 add_filter( 60 'wpforms_frontend_recaptcha_disable', 61 '__return_true', 62 99 63 ); 64 } 49 add_filter( 'wpforms_frontend_form_data', array( $this, 'checkview_disable_turnstile' ) ); 50 51 add_filter( 'wpforms_process_before_form_data', array( $this, 'checkview_disable_turnstile' ) ); 52 53 add_filter( 'wpforms_frontend_captcha_api', array( $this, 'checkview_disable_frontend_captcha_api' ) ); 54 55 add_filter( 'wpforms_frontend_recaptcha_disable', '__return_true', 99 ); 65 56 66 57 // Disable validation and verification on the backend. … … 150 141 151 142 /** 143 * Disable Cloudflare Turnstile. 144 * 145 * @param array $form_data Form data. 146 * 147 * @return array Modified form data. 148 * 149 * @since 2.0.19 150 */ 151 public function checkview_disable_turnstile( $form_data ) { 152 $form_data['settings']['recaptcha'] = '0'; 153 154 return $form_data; 155 } 156 157 /** 158 * Disable WP Forms frontend CAPTCHA API. 159 * 160 * @param $captcha_api string CAPTCHA API. 161 * 162 * @return string 163 * 164 * @since 2.0.19 165 */ 166 public function checkview_disable_frontend_captcha_api( $captcha_api ) { 167 $captcha_settings = wpforms_get_captcha_settings(); 168 169 if ( $captcha_settings['provider'] === 'turnstile' ) { 170 return ''; 171 } 172 173 return $captcha_api; 174 } 175 176 /** 152 177 * Injects testing email address. 153 178 * … … 182 207 public function checkview_log_wpform_test_entry( $form_fields, $entry, $form_data, $entry_id ) { 183 208 global $wpdb; 209 210 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 211 184 212 if ( ! function_exists( 'is_plugin_active' ) ) { 185 213 include_once ABSPATH . 'wp-admin/includes/plugin.php'; 186 214 } 187 215 188 $form_id = $form_data['id'];216 $form_id = $form_data['id']; 189 217 $checkview_test_id = get_checkview_test_id(); 190 218 … … 194 222 195 223 $entry_data = array( 196 'form_id' => $form_id,197 'status' => 'publish',198 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',224 'form_id' => $form_id, 225 'status' => 'publish', 226 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 199 227 'date_created' => current_time( 'mysql' ), 200 228 'date_updated' => current_time( 'mysql' ), 201 'uid' => $checkview_test_id,202 'form_type' => 'WpForms',229 'uid' => $checkview_test_id, 230 'form_type' => 'WpForms', 203 231 ); 204 232 $entry_table = $wpdb->prefix . 'cv_entry'; 205 $wpdb->insert( $entry_table, $entry_data ); 233 234 $result = $wpdb->insert( $entry_table, $entry_data ); 235 236 if ( ! $result ) { 237 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 238 } else { 239 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 240 } 241 206 242 $inserted_entry_id = $wpdb->insert_id; 207 243 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 208 244 $field_id_prefix = 'wpforms-' . $form_id . '-field_'; 245 $count = 0; 246 209 247 foreach ( $form_fields as $field ) { 210 211 248 if ( ! isset( $field['value'] ) || '' === $field['value'] ) { 212 249 continue; 213 250 } 251 214 252 $field_value = is_array( $field['value'] ) ? serialize( $field['value'] ) : $field['value']; 215 $type = isset( $field['type'] ) ? $field['type'] : ''; 253 $type = isset( $field['type'] ) ? $field['type'] : ''; 254 216 255 switch ( $type ) { 217 256 case 'name': … … 224 263 'meta_value' => $field['first'], 225 264 ); 226 $wpdb->insert( $entry_meta_table, $entry_metadata ); 227 265 266 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 267 268 if ( $result ) { 269 $count++; 270 } 228 271 } elseif ( '' === $field['middle'] ) { 229 272 $entry_metadata = array( … … 234 277 'meta_value' => $field['first'], 235 278 ); 236 $wpdb->insert( $entry_meta_table, $entry_metadata ); 237 $entry_metadata = array( 238 'uid' => $checkview_test_id, 239 'form_id' => $form_id, 240 'entry_id' => $inserted_entry_id, 241 'meta_key' => $field_id_prefix . $field['id'] . '-last', 279 280 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 281 282 if ( $result ) { 283 $count++; 284 } 285 286 $entry_metadata = array( 287 'uid' => $checkview_test_id, 288 'form_id' => $form_id, 289 'entry_id' => $inserted_entry_id, 290 'meta_key' => $field_id_prefix . $field['id'] . '-last', 242 291 'meta_value' => $field['last'], 243 292 ); 244 $wpdb->insert( $entry_meta_table, $entry_metadata ); 245 293 294 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 295 296 if ( $result ) { 297 $count++; 298 } 246 299 } else { 247 300 $entry_metadata = array( 248 'uid' => $checkview_test_id,249 'form_id' => $form_id,250 'entry_id' => $inserted_entry_id,251 'meta_key' => $field_id_prefix . $field['id'],301 'uid' => $checkview_test_id, 302 'form_id' => $form_id, 303 'entry_id' => $inserted_entry_id, 304 'meta_key' => $field_id_prefix . $field['id'], 252 305 'meta_value' => $field['first'], 253 306 ); 254 $wpdb->insert( $entry_meta_table, $entry_metadata ); 255 $entry_metadata = array( 256 'uid' => $checkview_test_id, 257 'form_id' => $form_id, 258 'entry_id' => $inserted_entry_id, 259 'meta_key' => $field_id_prefix . $field['id'] . '-middle', 307 308 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 309 310 if ( $result ) { 311 $count++; 312 } 313 314 $entry_metadata = array( 315 'uid' => $checkview_test_id, 316 'form_id' => $form_id, 317 'entry_id' => $inserted_entry_id, 318 'meta_key' => $field_id_prefix . $field['id'] . '-middle', 260 319 'meta_value' => $field['middle'], 261 320 ); 262 $wpdb->insert( $entry_meta_table, $entry_metadata ); 263 $entry_metadata = array( 264 'uid' => $checkview_test_id, 265 'form_id' => $form_id, 266 'entry_id' => $inserted_entry_id, 267 'meta_key' => $field_id_prefix . $field['id'] . '-last', 321 322 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 323 324 if ( $result ) { 325 $count++; 326 } 327 328 $entry_metadata = array( 329 'uid' => $checkview_test_id, 330 'form_id' => $form_id, 331 'entry_id' => $inserted_entry_id, 332 'meta_key' => $field_id_prefix . $field['id'] . '-last', 268 333 'meta_value' => $field['last'], 269 334 ); 270 $wpdb->insert( $entry_meta_table, $entry_metadata ); 271 335 336 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 337 338 if ( $result ) { 339 $count++; 340 } 272 341 } 273 342 break; 274 343 default: 275 344 $entry_metadata = array( 276 'uid' => $checkview_test_id,277 'form_id' => $form_id,278 'entry_id' => $inserted_entry_id,279 'meta_key' => $field_id_prefix . $field['id'],345 'uid' => $checkview_test_id, 346 'form_id' => $form_id, 347 'entry_id' => $inserted_entry_id, 348 'meta_key' => $field_id_prefix . $field['id'], 280 349 'meta_value' => $field_value, 281 350 ); 282 $wpdb->insert( $entry_meta_table, $entry_metadata ); 351 352 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 353 354 if ( $result ) { 355 $count++; 356 } 357 283 358 break; 359 } 360 } 361 362 if ( $count > 0 ) { 363 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 364 } else { 365 if ( count( $form_fields ) > 0 ) { 366 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 284 367 } 285 368 } … … 295 378 ) 296 379 ); 380 297 381 $wpdb->delete( 298 382 $wpdb->prefix . 'wpforms_entry_fields', … … 303 387 ); 304 388 } 305 $old_settings = (array) get_option( 'wpforms_settings', array() );306 if ( ! empty( $old_settings['turnstile-site-key'] ) && null !== $old_settings['turnstile-site-key'] && null !== $old_settings['turnstile-secret-key'] ) {307 if ( '1x00000000000000000000AA' === $old_settings['turnstile-site-key'] ) {308 $old_settings['turnstile-site-key'] = get_option( 'checkview_wpforms_turnstile-site-key' );309 $old_settings['turnstile-secret-key'] = get_option( 'checkview_wpforms_turnstile-secret-key' );310 update_option( 'wpforms_settings', $old_settings );311 }312 }313 389 314 390 complete_checkview_test( $checkview_test_id ); -
checkview/tags/2.0.19/includes/formhelpers/class-checkview-wsf-helper.php
r3216431 r3323842 42 42 public function __construct() { 43 43 $this->loader = new Checkview_Loader(); 44 44 45 add_action( 45 46 'wsf_submit_post_complete', … … 51 52 1 52 53 ); 54 53 55 add_filter( 54 56 'akismet_get_api_key', … … 62 64 999 63 65 ); 66 64 67 if ( defined( 'TEST_EMAIL' ) ) { 65 68 add_filter( … … 83 86 2 84 87 ); 88 85 89 add_filter( 86 90 'wsf_config_meta_keys', … … 96 100 6 97 101 ); 102 98 103 add_filter( 99 104 'wsf_action_email_headers', … … 157 162 $headers = explode( "\r\n", $headers ); 158 163 } 164 159 165 $filtered_headers = array_filter( 160 166 $headers, … … 164 170 } 165 171 ); 172 166 173 return array_values( $filtered_headers ); 167 174 } … … 179 186 $form_id = $form_data->form_id; 180 187 $entry_id = $form_data->id; 181 182 188 $checkview_test_id = get_checkview_test_id(); 189 190 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 183 191 184 192 if ( empty( $checkview_test_id ) ) { 185 193 $checkview_test_id = $form_id . gmdate( 'Ymd' ); 186 194 } 195 187 196 // Insert Entry. 188 197 $entry_data = array( 189 'form_id' => $form_id,190 'status' => 'publish',191 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',198 'form_id' => $form_id, 199 'status' => 'publish', 200 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 192 201 'date_created' => current_time( 'mysql' ), 193 202 'date_updated' => current_time( 'mysql' ), 194 'uid' => $checkview_test_id,195 'form_type' => 'WSForms',203 'uid' => $checkview_test_id, 204 'form_type' => 'WSForms', 196 205 ); 197 206 $entry_table = $wpdb->prefix . 'cv_entry'; 198 $wpdb->insert( $entry_table, $entry_data ); 199 $inserted_entry_id = $wpdb->insert_id; 200 201 // Insert entry meta. 207 208 $result = $wpdb->insert( $entry_table, $entry_data ); 209 210 if ( ! $result ) { 211 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 212 } else { 213 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 214 } 215 202 216 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 203 217 $field_id_prefix = 'wsf'; 204 $tablename = $wpdb->prefix . 'wsf_submit_meta'; 205 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where parent_id=%d', $entry_id ) ); 218 $tablename = $wpdb->prefix . 'wsf_submit_meta'; 219 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where parent_id=%d', $entry_id ) ); 220 $count = 0; 221 206 222 foreach ( $form_fields as $field ) { 207 223 if ( ! in_array( $field->meta_key, array( '_form_id', 'post_id', 'wsf_meta_key_hidden' ) ) ) { 208 224 $entry_metadata = array( 209 'uid' => $checkview_test_id,210 'form_id' => $form_id,211 'entry_id' => $entry_id,212 'meta_key' => $field_id_prefix . str_replace( '_', '-', $field->meta_key ),225 'uid' => $checkview_test_id, 226 'form_id' => $form_id, 227 'entry_id' => $entry_id, 228 'meta_key' => $field_id_prefix . str_replace( '_', '-', $field->meta_key ), 213 229 'meta_value' => $field->meta_value, 214 230 ); 215 $wpdb->insert( $entry_meta_table, $entry_metadata ); 216 } 217 } 218 update_option( $checkview_test_id . '_wsf_entry_id', $entry_id ); 219 update_option( $checkview_test_id . '_wsf_frm_id', $form_id ); 231 232 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 233 234 if ( $result ) { 235 $count++; 236 } 237 } 238 } 239 240 if ( $count > 0 ) { 241 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 242 } else { 243 if ( count( $form_fields ) > 0 ) { 244 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 245 } 246 } 247 248 cv_update_option( $checkview_test_id . '_wsf_entry_id', $entry_id ); 249 cv_update_option( $checkview_test_id . '_wsf_frm_id', $form_id ); 250 220 251 complete_checkview_test( $checkview_test_id ); 221 252 } -
checkview/tags/2.0.19/includes/woocommercehelper/class-checkview-woo-automated-testing.php
r3303097 r3323842 564 564 */ 565 565 public function checkview_test_mode() { 566 567 // Current Vsitor IP.568 566 $visitor_ip = checkview_get_visitor_ip(); 569 // Check view Bot IP.570 567 $cv_bot_ip = checkview_get_api_ip(); 568 571 569 if ( ! is_array( $cv_bot_ip ) || ! in_array( $visitor_ip, $cv_bot_ip ) ) { 572 573 570 return; 574 571 } 575 Checkview_Admin_Logs::add( 'ip-logs', wp_json_encode( $cv_bot_ip ) . 'bot IP' ); 576 Checkview_Admin_Logs::add( 'ip-logs', wp_json_encode( $visitor_ip ) . 'visitor IP' ); 572 573 Checkview_Admin_Logs::add( 'ip-logs', 'Running Woo test mode hooks, visitor IP [' . $visitor_ip . '] matched a bot IP.' ); 574 577 575 if ( ! is_admin() && class_exists( 'WooCommerce' ) ) { 578 576 // Always use Stripe test mode when on dev or staging. … … 580 578 'option_woocommerce_stripe_settings', 581 579 function ( $value ) { 580 Checkview_Admin_Logs::add( 'ip-logs', 'Setting Woo test mode to true for hook [option_woocommerce_stripe_settings].' ); 582 581 583 582 $value['testmode'] = 'yes'; … … 586 585 } 587 586 ); 587 588 588 // Turn test mode on for stripe payments. 589 589 add_filter( 590 590 'wc_stripe_mode', 591 591 function ( $mode ) { 592 Checkview_Admin_Logs::add( 'ip-logs', 'Setting Woo test mode to true for hook [wc_stripe_mode].' ); 592 593 593 594 $mode = 'test'; … … 615 616 'checkview_woocommerce_block_support', 616 617 ); 618 617 619 add_filter( 618 620 'cfturnstile_whitelisted', … … 620 622 999 621 623 ); 624 622 625 // Make the test product visible in the catalog. 623 626 add_filter( 624 627 'woocommerce_product_is_visible', 625 function ( $visible, $product_id ) {628 function ( bool $visible, $product_id ) { 626 629 $product = $this->checkview_get_test_product(); 627 630 … … 630 633 } 631 634 632 return $product_id === $product->get_id() ? true : $visible; 635 $is_visible = $product_id === $product->get_id() ? true : $visible; 636 637 if ($is_visible) { 638 Checkview_Admin_Logs::add( 'ip-logs', 'Setting Woo test product visibility to true.' ); 639 640 return true; 641 } 642 643 return false; 633 644 }, 634 645 9999, 635 646 2 636 647 ); 648 637 649 $this->loader->add_action( 638 650 'woocommerce_order_status_changed', … … 642 654 3 643 655 ); 644 } 645 } 656 } else { 657 Checkview_Admin_Logs::add( 'ip-logs', 'No Woo hooks were ran (WooCommerce was not found or client is requesting admin area).' ); 658 } 659 } 660 646 661 /** 647 662 * Returns false. … … 729 744 * Adds CheckView dummy payment gateway to Woo. 730 745 * 731 * @param string $methods Methods to add payments.732 * @return array746 * @param string[] $methods Methods to add payments. 747 * @return string[] 733 748 */ 734 749 public function checkview_add_payment_gateway( $methods ) { 735 $methods[] = 'Checkview_Payment_Gateway'; 750 $gateway = 'Checkview_Payment_Gateway'; 751 752 Checkview_Admin_Logs::add( 'ip-logs', 'Adding Woo payment gateway [' . $gateway . '].' ); 753 754 $methods[] = $gateway; 755 736 756 return $methods; 737 757 } … … 749 769 'woocommerce_blocks_payment_method_type_registration', 750 770 function ( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 771 Checkview_Admin_Logs::add( 'ip-logs', 'Added Woo Blocks payment gateway.' ); 772 751 773 $payment_method_registry->register( new Checkview_Blocks_Payment_Gateway() ); 752 774 } … … 767 789 return; 768 790 } 791 769 792 return $this->checkview_delete_orders(); 770 793 } … … 777 800 */ 778 801 public function checkview_delete_orders( $order_id = '' ) { 779 780 global $wpdb; 802 Checkview_Admin_Logs::add( 'ip-logs', 'Deleting CheckView orders from the database...' ); 803 781 804 $orders = array(); 782 // WPDBPREPARE. 783 if ( empty( $orders ) || false === $orders ) { 784 $args = array( 785 'limit' => -1, 786 'type' => 'shop_order', 787 'meta_key' => 'payment_made_by', // Postmeta key field. 788 'meta_value' => 'checkview', // Postmeta value field. 789 'meta_compare' => '=', 790 'return' => 'ids', 791 ); 792 if ( function_exists( 'wc_get_orders' ) ) { 793 $orders = wc_get_orders( $args ); 794 } 795 $orders_cv = array(); 796 $args = array( 797 'limit' => -1, 798 'type' => 'shop_order', 799 'payment_method' => 'checkview', 800 'return' => 'ids', 801 ); 802 if ( function_exists( 'wc_get_orders' ) ) { 803 $orders_cv = wc_get_orders( $args ); 804 } 805 $orders = array_unique( array_merge( $orders, $orders_cv ) ); 806 807 } 805 $args = array( 806 'limit' => -1, 807 'type' => 'shop_order', 808 'meta_key' => 'payment_made_by', // Postmeta key field. 809 'meta_value' => 'checkview', // Postmeta value field. 810 'meta_compare' => '=', 811 'return' => 'ids', 812 ); 813 814 if ( function_exists( 'wc_get_orders' ) ) { 815 $orders = wc_get_orders( $args ); 816 } 817 818 $orders_cv = array(); 819 $args = array( 820 'limit' => -1, 821 'type' => 'shop_order', 822 'payment_method' => 'checkview', 823 'return' => 'ids', 824 ); 825 826 if ( function_exists( 'wc_get_orders' ) ) { 827 $orders_cv = wc_get_orders( $args ); 828 } 829 830 $orders = array_unique( array_merge( $orders, $orders_cv ) ); 831 832 Checkview_Admin_Logs::add( 'cron-logs', 'Found ' . count( $orders ) . ' CheckView orders to delete.' ); 833 808 834 // Delete orders. 809 835 if ( ! empty( $orders ) ) { 810 836 foreach ( $orders as $order ) { 811 837 $order_object = wc_get_order( $order ); 838 839 // Delete order. 812 840 try { 813 $order_object = wc_get_order( $order );814 // Delete order.815 841 if ( $order_object && method_exists( $order_object, 'get_customer_id' ) ) { 816 842 if ( $order_object->get_meta( 'payment_made_by' ) !== 'checkview' && 'checkview' !== $order_object->get_payment_method() ) { 817 843 continue; 818 844 } 845 819 846 $customer_id = $order_object->get_customer_id(); 820 847 $order_object->delete( true ); 848 821 849 delete_transient( 'checkview_store_orders_transient' ); 822 850 823 851 $order_object = null; 824 852 $current_user = get_user_by( 'id', $customer_id ); 853 825 854 // Delete customer if available. 826 855 if ( $customer_id && isset( $current_user->roles ) && isset( $current_user->roles ) && ! in_array( 'administrator', $current_user->roles, true ) ) { … … 831 860 } 832 861 833 $res = $customer->delete( true );862 $res = $customer->delete( true ); 834 863 $customer = null; 835 864 } … … 839 868 require_once CHECKVIEW_ADMIN_DIR . '/class-checkview-admin-logs.php'; 840 869 } 841 Checkview_Admin_Logs::add( 'cron-logs', 'Crone job failed.' ); 870 871 if ($order_object) { 872 Checkview_Admin_Logs::add( 'cron-logs', 'Failed to delete CheckView order [' . $order_object->get_id() . '] from the database.' ); 873 } else { 874 Checkview_Admin_Logs::add( 'cron-logs', 'Failed to delete CheckView order from the database.' ); 875 } 876 842 877 } 843 878 } 879 844 880 return true; 845 881 } … … 858 894 $order = new WC_Order( $order_id ); 859 895 $order->update_meta_data( 'payment_made_by', 'checkview' ); 860 861 896 $order->update_meta_data( 'checkview_test_id', sanitize_text_field( wp_unslash( $_COOKIE['checkview_test_id'] ) ) ); 897 898 Checkview_Admin_Logs::add( 'ip-logs', 'Added meta data to test order.' ); 899 862 900 complete_checkview_test( sanitize_text_field( wp_unslash( $_COOKIE['checkview_test_id'] ) ) ); 863 901 864 902 $order->save(); 903 904 Checkview_Admin_Logs::add( 'ip-logs', 'Saved new order [' . $order->get_id() . '].' ); 905 865 906 unset( $_COOKIE['checkview_test_id'] ); 866 907 setcookie( 'checkview_test_id', '', time() - 6600, COOKIEPATH, COOKIE_DOMAIN ); -
checkview/trunk/README.txt
r3303097 r3323842 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 Stable tag: 2.0.1 810 Stable tag: 2.0.19 11 11 12 12 [CheckView](https://checkview.io/) is the friendly WordPress automated testing platform for everyone, from developers, shop owners to agencies. … … 86 86 87 87 == Changelog == 88 = 2.0.19 = 89 * Improve logging 90 * Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests 91 * Disable test-related hooks on API requests 92 * Disable Fluent Forms token-based spam prevention for tests 93 * Remove Fluent Forms CAPTCHA/Turnstile key swap 94 * Disable Fluent Forms CAPTCHAs using newly provided hook 95 88 96 = 2.0.18 = 89 97 * Improve logging when querying for available test results. … … 360 368 361 369 == Upgrade Notice == 370 = 2.0.19 = 371 * Improve logging 372 * Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests 373 * Disable test-related hooks on API requests 374 * Disable Fluent Forms token-based spam prevention for tests 375 * Remove Fluent Forms CAPTCHA/Turnstile key swap 376 * Disable Fluent Forms CAPTCHAs using newly provided hook 377 362 378 = 2.0.18 = 363 379 * Improve logging when querying for available test results. -
checkview/trunk/admin/class-checkview-admin.php
r3283610 r3323842 62 62 63 63 add_action( 64 'checkview_options_cleanup_cron',65 'checkview_options_cleanup'66 );67 68 add_action(69 64 'checkview_nonce_cleanup_cron', 70 65 array( $this, 'checkview_delete_expired_nonces' ) … … 122 117 if ( ! wp_next_scheduled( 'checkview_nonce_cleanup_cron' ) ) { 123 118 wp_schedule_event( time(), 'hourly', 'checkview_nonce_cleanup_cron' ); 124 }125 126 if ( ! wp_next_scheduled( 'checkview_options_cleanup_cron' ) ) {127 wp_schedule_single_event( time() + 60, 'checkview_options_cleanup_cron' );128 119 } 129 120 } … … 216 207 */ 217 208 public function checkview_init_current_test() { 218 219 209 if ( ! function_exists( 'is_plugin_active' ) ) { 220 210 include_once ABSPATH . 'wp-admin/includes/plugin.php'; 221 211 } 222 // Current Vsitor IP. 212 213 $is_helper_api_request = isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '_checkview_timestamp' ); 214 215 if ( $is_helper_api_request ) { 216 return; 217 } 218 219 // Current Visitor IP. 223 220 $visitor_ip = checkview_get_visitor_ip(); 224 221 // Check view Bot IP. … … 227 224 // Skip if visitor ip not equal to CV Bot IP. 228 225 if ( is_array( $cv_bot_ip ) && ! in_array( $visitor_ip, $cv_bot_ip ) ) { 226 if ( isset( $_REQUEST['checkview_test_id'] ) ) { 227 Checkview_Admin_Logs::add( 'ip-logs', 'Although checkview_test_id is set in the request, exiting test init due to visitor IP [' . $visitor_ip . '] failing bot IP check [' . implode(', ', $cv_bot_ip) . '].' ); 228 } 229 229 230 if ( 'true' !== get_option( 'cv_ff_keys_set_turnstile' ) ) { 230 231 return; 231 232 } 232 if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) { 233 checkview_options_cleanup(); 234 } 233 235 234 return; 236 235 } 237 236 238 // If clean talk plugin active whitelist check form API IP. 237 Checkview_Admin_Logs::add( 'ip-logs', 'Visitor IP [' . $visitor_ip . '] determined to be in bot IP list, continuing.' ); 238 239 239 if ( is_plugin_active( 'cleantalk-spam-protect/cleantalk.php' ) ) { 240 240 checkview_whitelist_api_ip(); … … 248 248 $allowlist = Allow_List::get_ips(); 249 249 $aiowps_firewall_allow_list = AIOS_Firewall_Resource::request( AIOS_Firewall_Resource::ALLOW_LIST ); 250 250 251 if ( ! empty( $allowlist ) ) { 251 252 $allowlist .= "\n" . $visitor_ip; … … 253 254 $allowlist = $visitor_ip; 254 255 } 255 $ips = sanitize_textarea_field( wp_unslash( $allowlist ) ); 256 $ips = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline( $ips ); 256 257 $ips = sanitize_textarea_field( wp_unslash( $allowlist ) ); 258 $ips = AIOWPSecurity_Utility_IP::create_ip_list_array_from_string_with_newline( $ips ); 257 259 $validated_ip_list_array = AIOWPSecurity_Utility_IP::validate_ip_list( $ips, 'firewall_allowlist' ); 260 258 261 if ( is_wp_error( $validated_ip_list_array ) ) { 259 262 $success = false; 260 263 $message = nl2br( $validated_ip_list_array->get_error_message() ); 264 261 265 Checkview_Admin_Logs::add( 'ip-logs', 'Error ' . $message ); 262 266 } else { … … 267 271 if ( is_plugin_active( 'defender-security/wp-defender.php' ) ) { 268 272 $data = array(); 269 270 273 $data['allow_list'] = (array) $visitor_ip; 271 272 $data['block_list'] = array(); 273 $data['last_update_time'] = ''; 274 $data['block_list'] = array(); 275 $data['last_update_time'] = ''; 274 276 $data['last_update_time_utc'] = ''; 275 277 276 278 $global_ip_component = wd_di()->get( Global_IP::class ); 277 $result = $global_ip_component->set_global_ip_list( $data ); 278 } 279 $result = $global_ip_component->set_global_ip_list( $data ); 280 } 281 279 282 if ( is_plugin_active( 'enhanced-cloudflare-turnstile/enhanced-cloudflare-turnstile.php' ) ) { 280 $ect_ip_address = ecft_get_option( 'ecft_ip_address' );283 $ect_ip_address = ecft_get_option( 'ecft_ip_address' ); 281 284 $ect_ip_address_array = explode( "\n", $ect_ip_address ); 285 282 286 if ( ! empty( $ect_ip_address_array ) && is_array( $ect_ip_address_array ) ) { 283 287 if ( ! in_array( $visitor_ip, $ect_ip_address_array ) ) { 284 288 $ect_ip_address .= "\n" . $visitor_ip; 285 update_option( 'ecft_ip_address', $ect_ip_address ); 289 290 cv_update_option( 'ecft_ip_address', $ect_ip_address ); 286 291 } 287 292 } else { 288 293 $ect_ip_address = $visitor_ip; 289 update_option( 'ecft_ip_address', $ect_ip_address ); 294 295 cv_update_option( 'ecft_ip_address', $ect_ip_address ); 290 296 } 291 297 } … … 304 310 305 311 // Save the updated list back to the database. 306 update_option( 'captcha_ip_range_opt', implode( ',', $captcha_ip_range ) ); 307 } 308 } 312 cv_update_option( 'captcha_ip_range_opt', implode( ',', $captcha_ip_range ) ); 313 } 314 } 315 309 316 if ( is_plugin_active( 'recaptcha-for-woocommerce/woo-recaptcha.php' ) ) { 310 $captcha_ip_range = '';317 $captcha_ip_range = ''; 311 318 $captcha_ip_range_opt = ''; 312 $captcha_ip_range = array(); 319 $captcha_ip_range = array(); 320 313 321 // Get the existing whitelist from the database. 314 322 $captcha_ip_range_opt = sanitize_text_field( wp_unslash( get_option( 'i13_recapcha_ip_to_skip_captcha' ) ) ); … … 323 331 if ( count( $captcha_ip_range ) > 1 ) { 324 332 // Save the updated list back to the database. 325 update_option( 'i13_recapcha_ip_to_skip_captcha', implode( ',', $captcha_ip_range ) );333 cv_update_option( 'i13_recapcha_ip_to_skip_captcha', implode( ',', $captcha_ip_range ) ); 326 334 } else { 327 update_option( 'i13_recapcha_ip_to_skip_captcha',$visitor_ip );335 cv_update_option( 'i13_recapcha_ip_to_skip_captcha', $visitor_ip ); 328 336 } 329 337 } 330 338 } 331 // Gather test ID. 339 332 340 $cv_test_id = isset( $_REQUEST['checkview_test_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['checkview_test_id'] ) ) : ''; 333 334 // Flag disabling of email receipts.335 341 $disable_email_receipt = isset( $_REQUEST['disable_email_receipt'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['disable_email_receipt'] ) ) : false; 336 337 342 $disable_webhooks = isset( $_REQUEST['disable_webhooks'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['disable_webhooks'] ) ) : false; 338 339 343 $referrer_url = sanitize_url( wp_get_raw_referer(), array( 'http', 'https' ) ); 340 344 … … 343 347 // Create session for later use when form submit VIA AJAX. 344 348 checkview_create_cv_session( $visitor_ip, $cv_test_id ); 345 update_option( $visitor_ip, 'checkview-saas', true ); 349 350 cv_update_option( $visitor_ip, 'checkview-saas', true); 346 351 } 347 352 … … 349 354 if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'admin-ajax.php' ) !== false ) { 350 355 $referer_url_query = wp_parse_url( $referrer_url, PHP_URL_QUERY ); 351 $qry_str = array(); 356 $qry_str = array(); 357 352 358 if ( $referer_url_query ) { 353 359 parse_str( $referer_url_query, $qry_str ); 354 360 } 361 355 362 if ( isset( $qry_str['checkview_test_id'] ) ) { 356 363 $cv_test_id = $qry_str['checkview_test_id']; 357 364 } 358 365 } 366 359 367 if ( ! empty( $cv_test_id ) && ! checkview_is_valid_uuid( $cv_test_id ) ) { 360 Checkview_Admin_Logs::add( 'ip-logs', 'Not Bypassed invalid test id. ' . $visitor_ip . '=> ' . $cv_test_id ); 368 Checkview_Admin_Logs::add( 'ip-logs', 'Test ID format failed to validate, exiting.' ); 369 361 370 return; 362 371 } 372 363 373 if ( $cv_test_id && '' !== $cv_test_id ) { 364 374 setcookie( 'checkview_test_id', $cv_test_id, time() + 6600, COOKIEPATH, COOKIE_DOMAIN ); … … 381 391 } 382 392 } 383 if ( empty( $cv_test_id ) ) { 384 Checkview_Admin_Logs::add( 'ip-logs', 'Not Bypassed missing test id. ' . $visitor_ip . '=> ' . $cv_test_id ); 385 } else { 386 Checkview_Admin_Logs::add( 'ip-logs', 'Bypassed ' . $visitor_ip . '=> ' . $cv_test_id ); 387 } 393 388 394 if ( ! empty( $cv_session ) ) { 389 390 395 $test_key = $cv_session[0]['test_key']; 391 392 396 $test_form = get_option( $test_key, '' ); 393 397 … … 402 406 if ( ! defined( 'CV_TEST_ID' ) ) { 403 407 define( 'CV_TEST_ID', $cv_test_id ); 404 } 405 } 408 409 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [CV_TEST_ID] as [ ' . CV_TEST_ID . ' ].' ); 410 } 411 } else { 412 Checkview_Admin_Logs::add( 'ip-logs', 'The CheckView session was empty, but continuing.' ); 413 } 414 406 415 if ( ! defined( 'TEST_EMAIL' ) ) { 407 416 define( 'TEST_EMAIL', $send_to ); 417 418 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [TEST_EMAIL] as [ ' . TEST_EMAIL . ' ].' ); 408 419 } 409 420 410 421 if ( ! defined( 'CV_DISABLE_EMAIL_RECEIPT' ) && $disable_email_receipt ) { 411 422 define( 'CV_DISABLE_EMAIL_RECEIPT', 'true' ); 412 update_option( 'disable_email_receipt', 'true', true ); 423 424 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [CV_DISABLE_EMAIL_RECEIPT] as [' . CV_DISABLE_EMAIL_RECEIPT . '].' ); 425 426 cv_update_option('disable_email_receipt', 'true', true); 413 427 } 414 428 415 429 if ( ! defined( 'CV_DISABLE_WEBHOOKS' ) && $disable_webhooks ) { 416 430 define( 'CV_DISABLE_WEBHOOKS', 'true' ); 417 update_option( 'disable_webhooks', 'true', true ); 431 432 Checkview_Admin_Logs::add( 'ip-logs', 'Defined constant [CV_DISABLE_WEBHOOKS] as [' . CV_DISABLE_WEBHOOKS . '].' ); 433 434 cv_update_option('disable_webhooks', 'true', true); 418 435 } 419 436 420 437 delete_transient( 'checkview_forms_test_transient' ); 421 438 delete_transient( 'checkview_store_orders_transient' ); 439 422 440 if ( is_plugin_active( 'gravityforms/gravityforms.php' ) ) { 441 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Gravity Forms helper.' ); 442 423 443 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-gforms-helper.php'; 424 444 } 445 425 446 if ( is_plugin_active( 'fluentform/fluentform.php' ) ) { 447 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Fluent Forms helper.' ); 448 426 449 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-fluent-forms-helper.php'; 427 450 } 451 428 452 if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) { 453 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Ninja Forms helper.' ); 454 429 455 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-ninja-forms-helper.php'; 430 456 } 457 431 458 if ( function_exists( 'wpforms' ) && ( is_plugin_active( 'wpforms/wpforms.php' ) || is_plugin_active( 'wpforms-lite/wpforms.php' ) ) ) { 459 Checkview_Admin_Logs::add( 'ip-logs', 'Loading WP Forms helper.' ); 460 432 461 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-wpforms-helper.php'; 433 462 } 463 434 464 if ( is_plugin_active( 'formidable/formidable.php' ) ) { 465 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Formidable Forms helper.' ); 466 435 467 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-formidable-helper.php'; 436 468 } 437 469 438 470 if ( is_plugin_active( 'forminator/forminator.php' ) ) { 471 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Forminator helper.' ); 472 439 473 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-forminator-helper.php'; 440 474 } 441 475 442 476 if ( is_plugin_active( 'ws-form/ws-form.php' ) || is_plugin_active( 'ws-form-pro/ws-form.php' ) ) { 477 Checkview_Admin_Logs::add( 'ip-logs', 'Loading WS Form helper.' ); 478 443 479 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-wsf-helper.php'; 444 480 } 481 445 482 if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) { 483 Checkview_Admin_Logs::add( 'ip-logs', 'Loading Contact Form 7 helper.' ); 484 446 485 require_once CHECKVIEW_INC_DIR . 'formhelpers/class-checkview-cf7-helper.php'; 447 486 } -
checkview/trunk/checkview.php
r3303097 r3323842 12 12 * Plugin URI: https://checkview.io 13 13 * Description: CheckView is the #1 fully automated solution to test your WordPress forms and detect form problems fast. Automatically test your WordPress forms to ensure you never miss a lead again. 14 * Version: 2.0.1 814 * Version: 2.0.19 15 15 * Author: CheckView 16 16 * Author URI: https://checkview.io/ … … 36 36 * @link https://semver.org 37 37 */ 38 define( 'CHECKVIEW_VERSION', '2.0.1 8' );38 define( 'CHECKVIEW_VERSION', '2.0.19' ); 39 39 40 40 if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) { -
checkview/trunk/includes/checkview-functions.php
r3303097 r3323842 144 144 } 145 145 } 146 146 147 if ( ! function_exists( 'complete_checkview_test' ) ) { 147 148 /** … … 156 157 function complete_checkview_test( $checkview_test_id = '' ) { 157 158 global $wpdb; 158 global $CV_TEST_ID; 159 160 Checkview_Admin_Logs::add( 'ip-logs', 'Completing test...' ); 161 159 162 if ( ! defined( 'CV_TEST_ID' ) ) { 160 163 define( 'CV_TEST_ID', $checkview_test_id ); 161 164 } 165 162 166 $session_table = $wpdb->prefix . 'cv_session'; 163 $visitor_ip = checkview_get_visitor_ip();164 $cv_session = checkview_get_cv_session( $visitor_ip, CV_TEST_ID );167 $visitor_ip = checkview_get_visitor_ip(); 168 $cv_session = checkview_get_cv_session( $visitor_ip, CV_TEST_ID ); 165 169 166 170 // Stop if session not found. 167 171 if ( ! empty( $cv_session ) ) { 168 172 $test_key = $cv_session[0]['test_key']; 169 delete_option( $test_key ); 170 } 171 172 $wpdb->delete( 173 174 cv_delete_option( $test_key ); 175 } 176 177 $result = $wpdb->delete( 173 178 $session_table, 174 179 array( 175 180 'visitor_ip' => $visitor_ip, 176 'test_id' => $checkview_test_id,181 'test_id' => $checkview_test_id, 177 182 ) 178 183 ); 184 185 if ( false === $result ) { 186 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to delete rows from session table [' . $session_table . '].' ); 187 } 188 179 189 $entry_id = get_option( $checkview_test_id . '_wsf_entry_id', '' ); 180 190 $form_id = get_option( $checkview_test_id . '_wsf_frm_id', '' ); 191 181 192 if ( ! empty( $form_id ) && ! empty( $entry_id ) ) { 182 $ws_form_submit = new WS_Form_Submit();183 $ws_form_submit->id = $entry_id;193 $ws_form_submit = new WS_Form_Submit(); 194 $ws_form_submit->id = $entry_id; 184 195 $ws_form_submit->form_id = $form_id; 185 196 $ws_form_submit->db_delete( true, true, true ); 186 197 } 187 delete_option( $checkview_test_id . '_wsf_entry_id' ); 188 delete_option( $checkview_test_id . '_wsf_frm_id' ); 189 delete_option( $visitor_ip ); 198 199 cv_delete_option( $checkview_test_id . '_wsf_entry_id' ); 200 cv_delete_option( $checkview_test_id . '_wsf_frm_id' ); 201 cv_delete_option( $visitor_ip ); 202 190 203 setcookie( 'checkview_test_id', '', time() - 6600, COOKIEPATH, COOKIE_DOMAIN ); 191 204 setcookie( 'checkview_test_id' . $checkview_test_id, '', time() - 6600, COOKIEPATH, COOKIE_DOMAIN ); 192 delete_option( 'disable_email_receipt' ); 193 delete_option( 'disable_webhooks' ); 194 } 195 } 205 206 cv_delete_option( 'disable_email_receipt' ); 207 cv_delete_option( 'disable_webhooks' ); 208 209 Checkview_Admin_Logs::add( 'ip-logs', 'Test complete.' ); 210 } 211 } 212 196 213 if ( ! function_exists( 'checkview_get_publickey' ) ) { 197 214 /** … … 235 252 */ 236 253 function checkview_get_api_ip() { 237 238 254 $ip_address = get_transient( 'checkview_saas_ip_address' ) ? get_transient( 'checkview_saas_ip_address' ) : array(); 239 if ( null === $ip_address || '' === $ip_address || empty( $ip_address ) ) { 255 256 if ( empty( $ip_address ) ) { 257 Checkview_Admin_Logs::add( 'ip-logs', 'Bot IP address list transient empty, requesting new IP addresses.' ); 258 240 259 $request = wp_remote_get( 241 260 'https://verify.checkview.io/whitelist.json', … … 245 264 ) 246 265 ); 266 247 267 if ( is_wp_error( $request ) ) { 268 $code = $request->get_error_code(); 269 $message = $request->get_error_message(); 270 271 Checkview_Admin_Logs::add( 'ip-logs', 'Request for new IP addresses failed with code [' . $code . ']. Message: ' . $message ); 272 248 273 return null; 249 274 } 250 275 251 276 $body = wp_remote_retrieve_body( $request ); 252 253 277 $data = json_decode( $body, true ); 278 254 279 if ( ! empty( $data ) && ! empty( $data['ipAddresses'] ) ) { 255 280 $ip_address = $data['ipAddresses']; 281 256 282 if ( ! empty( $ip_address ) && is_array( $ip_address ) ) { 257 283 foreach ( $ip_address as $ip ) { … … 264 290 return false; 265 291 } 292 266 293 set_transient( 'checkview_saas_ip_address', $ip_address, 12 * HOUR_IN_SECONDS ); 267 } 268 } 294 295 Checkview_Admin_Logs::add( 'ip-logs', 'Set bot IP address list transient to response data [' . wp_json_encode( $ip_address ) . ']' ); 296 } else { 297 Checkview_Admin_Logs::add( 'ip-logs', 'IP addresses not found in request for new IP addresses.' ); 298 } 299 } 300 269 301 if ( ! is_array( $ip_address ) ) { 270 302 $ip_address = (array) $ip_address; 271 303 } 304 272 305 if ( is_array( $ip_address ) ) { 273 306 $ip_address[] = '::1'; … … 275 308 $ip_address[] = '2001:8a0:e5d0:a900:70a5:138a:d159:5054'; 276 309 } 310 277 311 return $ip_address; 278 312 } … … 325 359 * @since 1.0.0 326 360 * 327 * @return string |falseIP address of visitor, or `false` if determined to be328 * an invalid IP.361 * @return string IP address of visitor, or `false` if determined to be 362 * an invalid IP. 329 363 */ 330 364 function checkview_get_visitor_ip() { … … 332 366 $cv_bot_ip = checkview_get_api_ip(); 333 367 $ip_options = checkview_get_custom_header_keys_for_ip(); 334 $ip = '';368 $ip = ''; 335 369 336 370 foreach ( $ip_options as $key ) { … … 340 374 341 375 $key = checkview_get_server_value( $key ); 376 342 377 foreach ( explode( ',', $key ) as $ip ) { 343 // Just to be safe.344 378 $ip = trim( $ip ); 345 379 346 380 if ( checkview_validate_ip( $ip ) && is_array( $cv_bot_ip ) && in_array( $ip, $cv_bot_ip ) ) { 347 Checkview_Admin_Logs::add( 'ip-logs', 'Bypassed ' . $ip );348 381 return sanitize_text_field( $ip ); 349 382 } … … 808 841 */ 809 842 function checkview_schedule_delete_orders( $order_id ) { 843 Checkview_Admin_Logs::add( 'ip-logs', 'Scheduling order deletion.' ); 844 810 845 wp_schedule_single_event( time() + 1 * HOUR_IN_SECONDS, 'checkview_delete_orders_action', array( $order_id ) ); 811 846 } … … 888 923 function checkview_is_valid_uuid( $uuid ) { 889 924 if ( empty( $uuid ) || is_wp_error( $uuid ) ) { 925 Checkview_Admin_Logs::add( 'ip-logs', 'Invalid UUID [' . $uuid . '].' ); 926 890 927 return false; 891 928 } 892 return preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i', $uuid ); 929 930 $matches = preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i', $uuid ); 931 932 if ( ! $matches ) { 933 Checkview_Admin_Logs::add( 'ip-logs', 'Invalid UUID [' . $uuid . '].' ); 934 935 return false; 936 } 937 938 return true; 893 939 } 894 940 } … … 1074 1120 } 1075 1121 return $updated; 1076 }1077 }1078 if ( ! defined( 'checkview_options_cleanup' ) ) {1079 /**1080 * Cleans options for CV.1081 *1082 * @return void1083 */1084 function checkview_options_cleanup() {1085 $old_settings = array();1086 $old_settings = (array) get_option( '_fluentform_reCaptcha_details', array() );1087 if ( ! empty( $old_settings ) && null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] ) {1088 if ( '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' === $old_settings['siteKey'] ) {1089 $old_settings['siteKey'] = get_option( 'checkview_rc-site-key' );1090 $old_settings['secretKey'] = get_option( 'checkview_rc-secret-key' );1091 update_option( '_fluentform_reCaptcha_details', $old_settings );1092 }1093 }1094 $old_settings = array();1095 $old_settings = (array) get_option( '_fluentform_turnstile_details', array() );1096 if ( ! empty( $old_settings ) && null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] ) {1097 if ( '1x00000000000000000000AA' === $old_settings['siteKey'] ) {1098 $old_settings['siteKey'] = get_option( 'checkview_ff_turnstile-site-key' );1099 $old_settings['secretKey'] = get_option( 'checkview_ff_turnstile-secret-key' );1100 update_option( '_fluentform_turnstile_details', $old_settings );1101 }1102 }1103 delete_option( 'cv_ff_keys_set_turnstile' );1104 1122 } 1105 1123 } … … 1125 1143 } 1126 1144 } 1145 1146 if ( ! function_exists( 'cv_update_option' ) ) { 1147 /** 1148 * Updates an option in WordPress. 1149 * 1150 * Wrapper for update_option() that also includes logging. Suppresses logs from 1151 * failures due to option already existing with the same value. 1152 * 1153 * @see update_option() 1154 * @see get_option() 1155 * 1156 * @param $option string Name of the option to update. 1157 * @param $value mixed Option value. 1158 * @param $autoload boolean|null Optional. Whether to load the option when WordPress starts up. 1159 * 1160 * @return boolean True if the value was updated, false otherwise. 1161 */ 1162 function cv_update_option( $option, $value, $autoload = null ) { 1163 $old_option = get_option( $option ); 1164 $result = update_option( $option, $value, $autoload ); 1165 1166 if ( $result ) { 1167 Checkview_Admin_Logs::add( 'ip-logs', 'Updated option [' . $option . '] with value [' . print_r( $value, true ) . '].' ); 1168 } else { 1169 if ($old_option !== false && $old_option !== $value && maybe_serialize( $old_option ) !== maybe_serialize( $value ) ) { 1170 Checkview_Admin_Logs::add( 'ip-logs', 'Failed updating option [' . $option . '] with value [' . print_r( $value, true ) . '].' ); 1171 } 1172 } 1173 1174 return $result; 1175 } 1176 } 1177 1178 if ( ! function_exists( 'cv_delete_option' ) ) { 1179 /** 1180 * Deletes an option in WordPress. 1181 * 1182 * Wrapper for delete_option() that also includes logging. Only attempts 1183 * deletion if the option is found in the database. 1184 * 1185 * @see delete_option() 1186 * @see get_option() 1187 * 1188 * @param $option string Name of the option to delete. 1189 * 1190 * @return boolean True if the value was deleted, false otherwise. 1191 */ 1192 function cv_delete_option( $option ) { 1193 $current_option = get_option( $option ); 1194 1195 if ( false !== $current_option ) { 1196 $result = delete_option( $option ); 1197 1198 if ( $result ) { 1199 Checkview_Admin_Logs::add( 'ip-logs', 'Deleted option [' . $option . '].' ); 1200 } else { 1201 Checkview_Admin_Logs::add( 'ip-logs', 'Failed deleting option [' . $option . '].' ); 1202 } 1203 1204 return $result; 1205 } 1206 1207 return true; 1208 } 1209 } -
checkview/trunk/includes/class-checkview.php
r3303097 r3323842 71 71 $this->version = CHECKVIEW_VERSION; 72 72 } else { 73 $this->version = '2.0.1 8';73 $this->version = '2.0.19'; 74 74 } 75 75 $this->plugin_name = 'checkview'; … … 202 202 */ 203 203 private function define_admin_hooks() { 204 205 204 $plugin_admin = new Checkview_Admin( $this->get_plugin_name(), $this->get_version() ); 206 205 $plugin_settings = new Checkview_Admin_Settings( $this->get_plugin_name(), $this->get_version() ); 207 206 $plugin_logs = new Checkview_Admin_Logs(); 207 208 208 if ( is_admin() ) { 209 209 // load backend hooks. -
checkview/trunk/includes/formhelpers/class-checkview-cf7-helper.php
r3216431 r3323842 125 125 */ 126 126 public function checkview_cf7_before_send_mail( $form_tag ) { 127 128 127 global $wpdb; 129 128 130 $form_id = $form_tag->id();129 $form_id = $form_tag->id(); 131 130 $wp_filesystem_direct = new WP_Filesystem_Direct( array() ); 132 133 131 $checkview_test_id = get_checkview_test_id(); 134 132 … … 137 135 } 138 136 139 $upload_dir = wp_upload_dir();137 $upload_dir = wp_upload_dir(); 140 138 $cv_cf7_dirname = $upload_dir['basedir'] . '/cv_cf7_uploads'; 141 139 … … 145 143 146 144 $time_now = time(); 147 148 145 $submission = WPCF7_Submission::get_instance(); 146 149 147 if ( $submission ) { 150 148 $contact_form = $submission->get_contact_form(); 151 149 } 150 152 151 $tags_names = array(); 153 152 154 153 if ( $submission ) { 155 156 $allowed_tags = array(); 154 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry...' ); 157 155 158 156 $tags = $contact_form->scan_form_tags(); 157 159 158 foreach ( $tags as $tag ) { 160 159 if ( ! empty( $tag->name ) ) { … … 162 161 } 163 162 } 163 164 164 $allowed_tags = $tags_names; 165 166 165 $not_allowed_tags = array( 'g-recaptcha-response' ); 167 168 $data = $submission->get_posted_data(); 169 $files = $submission->uploaded_files(); 166 $data = $submission->get_posted_data(); 167 $files = $submission->uploaded_files(); 170 168 $uploaded_files = array(); 171 169 … … 173 171 array_push( $uploaded_files, $file_key ); 174 172 } 173 175 174 foreach ( $files as $file_key => $file ) { 176 175 $file = is_array( $file ) ? reset( $file ) : $file; … … 184 183 185 184 foreach ( $data as $key => $d ) { 186 187 185 if ( ! in_array( $key, $allowed_tags ) ) { 188 186 continue; … … 190 188 191 189 if ( ! in_array( $key, $not_allowed_tags ) && ! in_array( $key, $uploaded_files ) ) { 192 193 190 $tmp_d = $d; 194 191 195 192 if ( ! is_array( $d ) ) { 196 $bl = array( '\"', "\'", '/', '\\', '"', "'" );197 $wl = array( '"', ''', '/', '\', '"', ''' );193 $bl = array( '\"', "\'", '/', '\\', '"', "'" ); 194 $wl = array( '"', ''', '/', '\', '"', ''' ); 198 195 $tmp_d = str_replace( $bl, $wl, $tmp_d ); 199 196 } 197 200 198 if ( is_array( $d ) ) { 201 199 $tmp_d = serialize( $d ); … … 204 202 $form_data[ $key ] = $tmp_d; 205 203 } 204 206 205 if ( in_array( $key, $uploaded_files ) ) { 207 $file = is_array( $files[ $key ] ) ? reset( $files[ $key ] ) : $files[ $key ];208 $file_name = empty( $file ) ? '' : $time_now . '-' . $key . '-' . basename( $file );206 $file = is_array( $files[ $key ] ) ? reset( $files[ $key ] ) : $files[ $key ]; 207 $file_name = empty( $file ) ? '' : $time_now . '-' . $key . '-' . basename( $file ); 209 208 $form_data[ $key . 'cv_cf7_file' ] = $file_name; 210 209 } … … 213 212 // insert entry. 214 213 $entry_data = array( 215 'form_id' => $form_id,216 'status' => 'publish',217 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',214 'form_id' => $form_id, 215 'status' => 'publish', 216 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 218 217 'date_created' => current_time( 'mysql' ), 219 218 'date_updated' => current_time( 'mysql' ), 220 'uid' => $checkview_test_id,221 'form_type' => 'CF7',219 'uid' => $checkview_test_id, 220 'form_type' => 'CF7', 222 221 ); 223 222 $entry_table = $wpdb->prefix . 'cv_entry'; 224 $wpdb->insert( $entry_table, $entry_data ); 223 224 $result = $wpdb->insert( $entry_table, $entry_data ); 225 226 if ( ! $result ) { 227 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 228 } else { 229 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 230 } 231 225 232 $inserted_entry_id = $wpdb->insert_id; 226 227 233 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 234 $count = 0; 228 235 229 236 foreach ( $form_data as $key => $val ) { 230 231 237 $entry_metadata = array( 232 'uid' => $checkview_test_id,233 'form_id' => $form_id,234 'entry_id' => $inserted_entry_id,235 'meta_key' => $key,238 'uid' => $checkview_test_id, 239 'form_id' => $form_id, 240 'entry_id' => $inserted_entry_id, 241 'meta_key' => $key, 236 242 'meta_value' => $val, 237 243 ); 238 $wpdb->insert( $entry_meta_table, $entry_metadata ); 244 245 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 246 247 if ( $result ) { 248 $count++; 249 } 250 } 251 252 if ( $count > 0 ) { 253 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 254 } else { 255 if ( count( $form_data ) > 0 ) { 256 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 257 } 239 258 } 240 259 -
checkview/trunk/includes/formhelpers/class-checkview-fluent-forms-helper.php
r3227063 r3323842 47 47 add_filter( 48 48 'fluentform/email_to', 49 array( 50 $this, 51 'checkview_remove_receipt', 52 ), 49 array( $this, 'checkview_remove_receipt' ), 53 50 99, 54 4 51 4, 55 52 ); 56 53 57 54 add_filter( 58 55 'fluentform/email_template_header', 59 array( 60 $this, 61 'checkview_remove_email_header', 62 ), 56 array( $this, 'checkview_remove_email_header' ), 63 57 99, 64 2 58 2, 65 59 ); 66 60 } … … 70 64 add_filter( 71 65 'fluentform/email_to', 72 array( 73 $this, 74 'checkview_inject_email', 75 ), 66 array( $this, 'checkview_inject_email' ), 76 67 99, 77 4 68 4, 78 69 ); 79 70 } … … 81 72 add_action( 82 73 'fluentform/submission_inserted', 83 array( 84 $this, 85 'checkview_clone_fluentform_entry', 86 ), 74 array( $this, 'checkview_clone_fluentform_entry' ), 87 75 99, 88 76 3 89 77 ); 78 90 79 add_filter( 91 80 'fluentform/has_recaptcha', 92 function ( $isSpamCheck ) { 93 return false; 94 }, 81 '__return_false', 95 82 20, 96 197 83 ); 98 84 99 85 add_filter( 100 86 'fluentform/has_hcaptcha', 101 function ( $status ) { 102 // Do your stuff here. 103 104 return false; 105 }, 106 10, 107 1 87 '__return_false', 108 88 ); 109 89 110 90 add_filter( 111 91 'fluentform/has_turnstile', 112 function ( $status ) { 113 // Do your stuff here. 114 115 return false; 116 }, 117 10, 118 1 119 ); 92 '__return_false', 93 ); 94 120 95 add_filter( 121 96 'fluentform/akismet_check_spam', 122 function ( $isSpamCheck, $form_id, $formData ) { 123 return false; 124 }, 97 '__return_false', 125 98 20, 126 3127 ); 99 ); 100 128 101 add_filter( 129 102 'cfturnstile_whitelisted', 130 103 '__return_true', 131 999 132 ); 133 134 $old_settings = (array) get_option( '_fluentform_turnstile_details', array() ); 135 if ( ! empty( $old_settings['siteKey'] ) && null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] ) { 136 if ( '1x00000000000000000000AA' !== $old_settings['siteKey'] ) { 137 update_option( 'checkview_ff_turnstile-site-key', $old_settings['siteKey'], true ); 138 update_option( 'checkview_ff_turnstile-secret-key', $old_settings['secretKey'], true ); 139 $old_settings['siteKey'] = '1x00000000000000000000AA'; 140 $old_settings['secretKey'] = '1x0000000000000000000000000000000AA'; 141 update_option( '_fluentform_turnstile_details', $old_settings ); 142 } 143 } 144 $old_settings = array(); 145 $old_settings = (array) get_option( '_fluentform_reCaptcha_details', array() ); 146 if ( null !== $old_settings['siteKey'] && null !== $old_settings['secretKey'] && strpos( $old_settings['api_version'], 'v3' ) === false ) { 147 if ( '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' !== $old_settings['siteKey'] ) { 148 update_option( 'checkview_rc-site-key', $old_settings['siteKey'], true ); 149 update_option( 'checkview_rc-secret-key', $old_settings['secretKey'], true ); 150 $old_settings['siteKey'] = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'; 151 $old_settings['secretKey'] = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'; 152 update_option( '_fluentform_reCaptcha_details', $old_settings ); 153 } 154 } 155 update_option( 'cv_ff_keys_set_turnstile', 'true' ); 104 999, 105 ); 106 156 107 add_filter( 157 108 'fluentform/recaptcha_v3_ref_score', … … 160 111 }, 161 112 99, 162 1163 113 ); 164 114 … … 173 123 ); 174 124 175 // Dis bale feeds.125 // Disable feeds. 176 126 add_filter( 177 127 'fluentform/global_notification_active_types', 178 array( 179 $this, 180 'checkview_disable_form_actions', 181 ), 128 array( $this, 'checkview_disable_form_actions' ), 182 129 99, 183 2 130 2, 184 131 ); 185 132 … … 187 134 add_filter( 188 135 'fluentform/honeypot_status', 189 function ( $status, $form_id ) { 190 return false; 191 }, 136 '__return_false', 192 137 999, 193 2 138 ); 139 140 add_filter( 141 'fluentform/token_based_spam_protection_status', 142 '__return_false', 143 999 144 ); 145 146 add_filter( 147 'fluentform/disable_captcha', 148 '__return_true', 149 999 194 150 ); 195 151 } … … 260 216 global $wpdb; 261 217 262 $form_id = $form->id; 218 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 219 220 $form_id = $form->id; 263 221 $checkview_test_id = get_checkview_test_id(); 264 222 … … 269 227 // Clone entry to check view tables. 270 228 $tablename = $wpdb->prefix . 'fluentform_entry_details'; 271 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where submission_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 229 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where submission_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 230 $count = 0; 231 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 232 272 233 foreach ( $rows as $row ) { 273 234 $meta_key = 'ff_' . $form_id . '_' . $row->field_name; 235 274 236 if ( '' !== $row->sub_field_name ) { 275 237 $meta_key .= '_' . $row->sub_field_name . '_'; 276 238 } 277 $table = $wpdb->prefix . 'cv_entry_meta'; 239 278 240 $data = array( 279 241 'uid' => $checkview_test_id, … … 283 245 'meta_value' => $row->field_value, 284 246 ); 285 $wpdb->insert( $table, $data ); 286 } 247 248 $result = $wpdb->insert( $entry_meta_table, $data ); 249 250 if ( $result ) { 251 $count++; 252 } 253 } 254 255 if ( $count > 0 ) { 256 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 257 } else { 258 if ( count( $rows ) > 0 ) { 259 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 260 } 261 } 262 287 263 $tablename = $wpdb->prefix . 'fluentform_submissions'; 288 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A );289 $ table1= $wpdb->prefix . 'cv_entry';290 $data = array(291 'uid' => $checkview_test_id,292 'form_type' => 'FluentForms',293 'form_id' => $form_id,294 'source_url' => isset( $row['source_url'] ) ? $row['source_url'] : 'n/a',295 'response' => isset( $row['response'] ) ? $row['response'] : 'n/a',296 'user_agent' => isset( $row['browser'] ) ? $row['browser'] : 'n/a',297 'ip' => isset( $row['ip'] ) ? $row['ip'] : 'n/a',298 'date_created' => isset( $row['created_at'] ) ? $row['created_at'] : 'n/a',299 'date_updated' => isset( $row['updated_at'] ) ? $row['updated_at'] : 'n/a',264 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A ); 265 $entry_table = $wpdb->prefix . 'cv_entry'; 266 $data = array( 267 'uid' => $checkview_test_id, 268 'form_type' => 'FluentForms', 269 'form_id' => $form_id, 270 'source_url' => isset( $row['source_url'] ) ? $row['source_url'] : 'n/a', 271 'response' => isset( $row['response'] ) ? $row['response'] : 'n/a', 272 'user_agent' => isset( $row['browser'] ) ? $row['browser'] : 'n/a', 273 'ip' => isset( $row['ip'] ) ? $row['ip'] : 'n/a', 274 'date_created' => isset( $row['created_at'] ) ? $row['created_at'] : 'n/a', 275 'date_updated' => isset( $row['updated_at'] ) ? $row['updated_at'] : 'n/a', 300 276 'payment_status' => isset( $row['payment_status'] ) ? $row['payment_status'] : 'n/a', 301 277 'payment_method' => isset( $row['payment_method'] ) ? $row['payment_payment'] : 'n/a', 302 278 'payment_amount' => isset( $row['payment_total'] ) ? $row['payment_total'] : 0, 303 279 ); 304 $wpdb->insert( $table1, $data ); 280 281 $result = $wpdb->insert( $entry_table, $data ); 282 283 if ( ! $result ) { 284 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 285 } else { 286 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 287 } 305 288 306 289 // remove entry from Fluent forms tables. -
checkview/trunk/includes/formhelpers/class-checkview-formidable-helper.php
r3247217 r3323842 41 41 public function __construct() { 42 42 $this->loader = new Checkview_Loader(); 43 43 44 if ( defined( 'TEST_EMAIL' ) ) { 44 45 // update email to our test email. … … 83 84 2 84 85 ); 86 85 87 add_filter( 86 88 'akismet_get_api_key', … … 88 90 -10 89 91 ); 92 90 93 add_filter( 91 94 'frm_fields_to_validate', … … 97 100 2 98 101 ); 102 99 103 add_filter( 100 104 'cfturnstile_whitelisted', … … 102 106 999 103 107 ); 108 104 109 add_filter( 105 110 'frm_run_honeypot', 106 111 '__return_false' 107 112 ); 113 108 114 // Disbale form action. 109 115 add_filter( … … 169 175 global $wpdb; 170 176 177 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 178 171 179 $checkview_test_id = get_checkview_test_id(); 172 180 … … 176 184 177 185 // Insert entry. 178 $entry_data = array(179 'form_id' => $form_id,180 'status' => 'publish',181 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',186 $entry_data = array( 187 'form_id' => $form_id, 188 'status' => 'publish', 189 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 182 190 'date_created' => current_time( 'mysql' ), 183 191 'date_updated' => current_time( 'mysql' ), 184 'uid' => $checkview_test_id,185 'form_type' => 'Formidable',192 'uid' => $checkview_test_id, 193 'form_type' => 'Formidable', 186 194 ); 187 195 $entry_table = $wpdb->prefix . 'cv_entry'; 188 $wpdb->insert( $entry_table, $entry_data ); 189 $inserted_entry_id = $wpdb->insert_id; 196 197 $result = $wpdb->insert( $entry_table, $entry_data ); 198 199 if ( ! $result ) { 200 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 201 } else { 202 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 203 } 190 204 191 205 // Insert entry meta. 192 206 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 193 $fields = $this->get_form_fields( $form_id ); 207 $fields = $this->get_form_fields( $form_id ); 208 194 209 if ( empty( $fields ) ) { 195 210 return; 196 211 } 197 $tablename = $wpdb->prefix . 'frm_item_metas'; 212 213 $tablename = $wpdb->prefix . 'frm_item_metas'; 198 214 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where item_id=%d', $entry_id ) ); 215 $count = 0; 216 199 217 foreach ( $form_fields as $field ) { 200 218 if ( empty( $field->field_id ) ) { 201 219 continue; 202 220 } 221 203 222 if ( 'name' === $fields[ $field->field_id ]['type'] ) { 204 205 223 $field_values = maybe_unserialize( $field->meta_value ); 206 207 224 $name_format = $fields[ $field->field_id ]['name_layout']; 225 208 226 switch ( $name_format ) { 209 227 case 'first_middle_last': 210 228 // First. 211 229 $entry_metadata = array( 212 'uid' => $checkview_test_id,213 'form_id' => $form_id,214 'entry_id' => $entry_id,215 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'],230 'uid' => $checkview_test_id, 231 'form_id' => $form_id, 232 'entry_id' => $entry_id, 233 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'], 216 234 'meta_value' => $field_values['first'], 217 235 ); 218 $wpdb->insert( $entry_meta_table, $entry_metadata ); 236 237 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 238 239 if ( $result ) { 240 $count++; 241 } 219 242 220 243 // middle. 221 244 $entry_metadata = array( 222 'uid' => $checkview_test_id,223 'form_id' => $form_id,224 'entry_id' => $entry_id,225 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'],245 'uid' => $checkview_test_id, 246 'form_id' => $form_id, 247 'entry_id' => $entry_id, 248 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'], 226 249 'meta_value' => $field_values['middle'], 227 250 ); 228 $wpdb->insert( $entry_meta_table, $entry_metadata ); 251 252 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 253 254 if ( $result ) { 255 $count++; 256 } 229 257 230 258 // last. 231 259 $entry_metadata = array( 232 'uid' => $checkview_test_id,233 'form_id' => $form_id,234 'entry_id' => $entry_id,235 'meta_key' => $fields[ $field->field_id ]['sub_fields'][2]['field_id'],260 'uid' => $checkview_test_id, 261 'form_id' => $form_id, 262 'entry_id' => $entry_id, 263 'meta_key' => $fields[ $field->field_id ]['sub_fields'][2]['field_id'], 236 264 'meta_value' => $field_values['last'], 237 265 ); 238 $wpdb->insert( $entry_meta_table, $entry_metadata ); 266 267 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 268 269 if ( $result ) { 270 $count++; 271 } 239 272 240 273 break; … … 242 275 // First. 243 276 $entry_metadata = array( 244 'uid' => $checkview_test_id,245 'form_id' => $form_id,246 'entry_id' => $entry_id,247 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'],277 'uid' => $checkview_test_id, 278 'form_id' => $form_id, 279 'entry_id' => $entry_id, 280 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'], 248 281 'meta_value' => $field_values['first'], 249 282 ); 250 $wpdb->insert( $entry_meta_table, $entry_metadata ); 283 284 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 285 286 if ( $result ) { 287 $count++; 288 } 289 251 290 // last. 252 291 $entry_metadata = array( 253 'uid' => $checkview_test_id,254 'form_id' => $form_id,255 'entry_id' => $entry_id,256 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'],292 'uid' => $checkview_test_id, 293 'form_id' => $form_id, 294 'entry_id' => $entry_id, 295 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'], 257 296 'meta_value' => $field_values['last'], 258 297 ); 259 $wpdb->insert( $entry_meta_table, $entry_metadata ); 298 299 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 300 301 if ( $result ) { 302 $count++; 303 } 304 260 305 break; 261 306 case 'last_first': 262 307 // First. 263 308 $entry_metadata = array( 264 'uid' => $checkview_test_id,265 'form_id' => $form_id,266 'entry_id' => $entry_id,267 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'],309 'uid' => $checkview_test_id, 310 'form_id' => $form_id, 311 'entry_id' => $entry_id, 312 'meta_key' => $fields[ $field->field_id ]['sub_fields'][1]['field_id'], 268 313 'meta_value' => $field_values['first'], 269 314 ); 270 $wpdb->insert( $entry_meta_table, $entry_metadata ); 315 316 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 317 318 if ( $result ) { 319 $count++; 320 } 321 271 322 // last. 272 323 $entry_metadata = array( 273 'uid' => $checkview_test_id,274 'form_id' => $form_id,275 'entry_id' => $entry_id,276 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'],324 'uid' => $checkview_test_id, 325 'form_id' => $form_id, 326 'entry_id' => $entry_id, 327 'meta_key' => $fields[ $field->field_id ]['sub_fields'][0]['field_id'], 277 328 'meta_value' => $field_values['last'], 278 329 ); 279 $wpdb->insert( $entry_meta_table, $entry_metadata ); 280 break; 281 330 331 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 332 333 if ( $result ) { 334 $count++; 335 } 336 337 break; 282 338 } 283 339 } else { 284 $field_value = $field->meta_value;340 $field_value = $field->meta_value; 285 341 $entry_metadata = array( 286 'uid' => $checkview_test_id,287 'form_id' => $form_id,288 'entry_id' => $entry_id,289 'meta_key' => $fields[ $field->field_id ]['field_id'],342 'uid' => $checkview_test_id, 343 'form_id' => $form_id, 344 'entry_id' => $entry_id, 345 'meta_key' => $fields[ $field->field_id ]['field_id'], 290 346 'meta_value' => $field_value, 291 347 ); 292 $wpdb->insert( $entry_meta_table, $entry_metadata ); 348 349 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 350 351 if ( $result ) { 352 $count++; 353 } 354 } 355 } 356 357 if ( $count > 0 ) { 358 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 359 } else { 360 if ( count( $form_fields ) > 0 ) { 361 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 293 362 } 294 363 } … … 296 365 // Remove test entry form Formidable. 297 366 $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $entry_id ) ); 298 $ result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $entry_id ) );367 $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $entry_id ) ); 299 368 300 369 complete_checkview_test( $checkview_test_id ); -
checkview/trunk/includes/formhelpers/class-checkview-forminator-helper.php
r3216431 r3323842 41 41 public function __construct() { 42 42 $this->loader = new Checkview_Loader(); 43 43 44 if ( defined( 'TEST_EMAIL' ) ) { 44 45 // update email to our test email. … … 91 92 999 92 93 ); 94 93 95 add_filter( 94 96 'forminator_invalid_captcha_message', 95 97 '__return_null' 96 98 ); 99 97 100 // Disbale form action. 98 101 add_filter( … … 151 154 * @param object $entry entry object. 152 155 * @param int $form_id Form entry ID. 153 * @param int$form_fields Form's fields.156 * @param array $form_fields Form's fields. 154 157 * @return void 155 158 */ 156 public function checkview_log_form_test_entry( 157 $entry, 158 $form_id, 159 $form_fields 160 ) { 159 public function checkview_log_form_test_entry($entry, $form_id, $form_fields) { 161 160 global $wpdb; 162 161 163 162 $checkview_test_id = get_checkview_test_id(); 164 $entry_id = $entry->entry_id; 165 $form_id = $entry->form_id; 163 $entry_id = $entry->entry_id; 164 $form_id = $entry->form_id; 165 166 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 167 166 168 if ( empty( $checkview_test_id ) ) { 167 169 $checkview_test_id = $form_id . gmdate( 'Ymd' ); … … 180 182 181 183 $entry_table = $wpdb->prefix . 'cv_entry'; 182 $wpdb->insert( $entry_table, $entry_data ); 183 $inserted_entry_id = $wpdb->insert_id; 184 185 // Insert entry meta. 184 $result = $wpdb->insert( $entry_table, $entry_data ); 185 186 if ( ! $result ) { 187 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 188 } else { 189 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 190 } 191 186 192 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 193 $count = 0; 187 194 188 195 foreach ( $form_fields as $field ) { … … 190 197 continue; 191 198 } 199 192 200 $field_value = $field['value']; 193 201 $meta_key = $field['name']; … … 199 207 'meta_value' => $field_value, 200 208 ); 201 $wpdb->insert( $entry_meta_table, $entry_metadata ); 202 } 203 204 // Remove test entry form Forminator. 209 210 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 211 212 if ( $result ) { 213 $count++; 214 } 215 } 216 217 if ( $count > 0 ) { 218 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 219 } else { 220 if ( count( $form_fields ) > 0 ) { 221 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 222 } 223 } 205 224 206 225 complete_checkview_test( $checkview_test_id ); 226 207 227 // Delete entry. 208 228 Forminator_Form_Entry_Model::delete_by_entry( $entry_id ); -
checkview/trunk/includes/formhelpers/class-checkview-gforms-helper.php
r3216431 r3323842 168 168 foreach ( $form['fields'] as $key => $field ) { 169 169 if ( 'captcha' === $field->type || 'hcaptcha' === $field->type || 'turnstile' === $field->type ) { 170 Checkview_Admin_Logs::add( 'ip-logs', 'Unset captcha field type [' . $field->type . '].' ); 171 170 172 unset( $fields[ $key ] ); 171 173 } … … 173 175 174 176 $form['fields'] = $fields; 177 175 178 return $form; 176 179 } … … 186 189 */ 187 190 public function checkview_clone_entry( $entry, $form ) { 188 $form_id = rgar( $form, 'id' );191 $form_id = rgar( $form, 'id' ); 189 192 $checkview_test_id = get_checkview_test_id(); 190 193 … … 192 195 $checkview_test_id = $form_id . gmdate( 'Ymd' ); 193 196 } 197 194 198 self::checkview_clone_gf_entry( $entry['id'], $form_id, $checkview_test_id ); 199 195 200 if ( isset( $entry['id'] ) ) { 196 201 GFAPI::delete_entry( $entry['id'] ); … … 285 290 global $wpdb; 286 291 292 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . '] with unique ID [' . $uid . ']...' ); 293 287 294 $tablename = $wpdb->prefix . 'gf_entry_meta'; 288 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where entry_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 295 $rows = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where entry_id=%d and form_id=%d order by id ASC', $entry_id, $form_id ) ); 296 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 297 $count = 0; 298 289 299 foreach ( $rows as $row ) { 290 $table = $wpdb->prefix . 'cv_entry_meta';291 300 $data = array( 292 'uid' => $uid,293 'form_id' => $row->form_id,294 'entry_id' => $row->entry_id,295 'meta_key' => $row->meta_key,301 'uid' => $uid, 302 'form_id' => $row->form_id, 303 'entry_id' => $row->entry_id, 304 'meta_key' => $row->meta_key, 296 305 'meta_value' => $row->meta_value, 297 306 ); 298 $wpdb->insert( $table, $data ); 299 } 307 308 $result = $wpdb->insert( $entry_meta_table, $data ); 309 310 if ( $result ) { 311 $count++; 312 } 313 } 314 315 if ( $count > 0 ) { 316 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 317 } else { 318 if ( count( $rows ) > 0 ) { 319 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 320 } 321 } 322 300 323 $tablename = $wpdb->prefix . 'gf_entry'; 301 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A ); 324 $row = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where id=%d and form_id=%d LIMIT 1', $entry_id, $form_id ), ARRAY_A ); 325 302 326 unset( $row['id'] ); 303 327 unset( $row['source_id'] ); 304 $table1 = $wpdb->prefix . 'cv_entry'; 305 $row['uid'] = $uid; 328 329 $entry_table = $wpdb->prefix . 'cv_entry'; 330 $row['uid'] = $uid; 306 331 $row['form_type'] = 'GravityForms'; 307 $wpdb->insert( $table1, $row ); 332 $result = $wpdb->insert( $entry_table, $row ); 333 334 if ( ! $result ) { 335 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 336 } else { 337 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 338 } 308 339 } 309 340 -
checkview/trunk/includes/formhelpers/class-checkview-ninja-forms-helper.php
r3216431 r3323842 42 42 public function __construct() { 43 43 $this->loader = new Checkview_Loader(); 44 44 45 add_action( 45 46 'ninja_forms_after_submission', … … 51 52 1 52 53 ); 54 53 55 add_filter( 54 56 'akismet_get_api_key', … … 65 67 20 66 68 ); 69 67 70 add_filter( 68 71 'ninja_forms_validate_fields', … … 79 82 999 80 83 ); 84 81 85 add_filter( 82 86 'ninja_forms_action_recaptcha__verify_response', … … 84 88 99 85 89 ); 90 86 91 if ( defined( 'TEST_EMAIL' ) ) { 87 92 add_filter( … … 154 159 $entry_id = isset( $form_data['actions']['save']['sub_id'] ) ? $form_data['actions']['save']['sub_id'] : 0; 155 160 161 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 162 156 163 $checkview_test_id = get_checkview_test_id(); 157 164 … … 162 169 // Insert Entry. 163 170 $entry_data = array( 164 'form_id' => $form_id,165 'status' => 'publish',166 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',171 'form_id' => $form_id, 172 'status' => 'publish', 173 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 167 174 'date_created' => current_time( 'mysql' ), 168 175 'date_updated' => current_time( 'mysql' ), 169 'uid' => $checkview_test_id,170 'form_type' => 'NinjaForms',176 'uid' => $checkview_test_id, 177 'form_type' => 'NinjaForms', 171 178 ); 172 179 $entry_table = $wpdb->prefix . 'cv_entry'; 173 $wpdb->insert( $entry_table, $entry_data ); 174 $inserted_entry_id = $wpdb->insert_id; 175 176 // Insert entry meta. 180 181 $result = $wpdb->insert( $entry_table, $entry_data ); 182 183 if ( ! $result ) { 184 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 185 } else { 186 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 187 } 188 177 189 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 178 190 $field_id_prefix = 'nf'; 179 $tablename = $wpdb->prefix . 'postmeta'; 180 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where post_id=%d', $entry_id ) ); 191 $tablename = $wpdb->prefix . 'postmeta'; 192 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where post_id=%d', $entry_id ) ); 193 $count = 0; 194 181 195 foreach ( $form_fields as $field ) { 182 196 if ( ! in_array( $field->meta_key, array( '_form_id', '_seq_num' ) ) ) { … … 188 202 'meta_value' => $field->meta_value, 189 203 ); 190 $wpdb->insert( $entry_meta_table, $entry_metadata ); 204 205 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 206 207 if ( $result ) { 208 $count++; 209 } 210 } 211 } 212 213 if ( $count > 0 ) { 214 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 215 } else { 216 if ( count( $form_fields ) > 0 ) { 217 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 191 218 } 192 219 } -
checkview/trunk/includes/formhelpers/class-checkview-wpforms-helper.php
r3247217 r3323842 42 42 public function __construct() { 43 43 $this->loader = new Checkview_Loader(); 44 44 45 if ( ! is_admin() ) { 45 46 include_once ABSPATH . 'wp-admin/includes/plugin.php'; 46 47 } 47 48 48 $old_settings = (array) get_option( 'wpforms_settings', array() ); 49 if ( ! empty( $old_settings['turnstile-site-key'] ) && null !== $old_settings['turnstile-site-key'] && null !== $old_settings['turnstile-secret-key'] ) { 50 if ( '1x00000000000000000000AA' !== $old_settings['turnstile-site-key'] ) { 51 update_option( 'checkview_wpforms_turnstile-site-key', $old_settings['turnstile-site-key'], true ); 52 update_option( 'checkview_wpforms_turnstile-secret-key', $old_settings['turnstile-secret-key'], true ); 53 $old_settings['turnstile-site-key'] = '1x00000000000000000000AA'; 54 $old_settings['turnstile-secret-key'] = '1x0000000000000000000000000000000AA'; 55 update_option( 'wpforms_settings', $old_settings ); 56 } 57 } else { 58 // Disable reCAPTCHA assets and initialisation on the frontend. 59 add_filter( 60 'wpforms_frontend_recaptcha_disable', 61 '__return_true', 62 99 63 ); 64 } 49 add_filter( 'wpforms_frontend_form_data', array( $this, 'checkview_disable_turnstile' ) ); 50 51 add_filter( 'wpforms_process_before_form_data', array( $this, 'checkview_disable_turnstile' ) ); 52 53 add_filter( 'wpforms_frontend_captcha_api', array( $this, 'checkview_disable_frontend_captcha_api' ) ); 54 55 add_filter( 'wpforms_frontend_recaptcha_disable', '__return_true', 99 ); 65 56 66 57 // Disable validation and verification on the backend. … … 150 141 151 142 /** 143 * Disable Cloudflare Turnstile. 144 * 145 * @param array $form_data Form data. 146 * 147 * @return array Modified form data. 148 * 149 * @since 2.0.19 150 */ 151 public function checkview_disable_turnstile( $form_data ) { 152 $form_data['settings']['recaptcha'] = '0'; 153 154 return $form_data; 155 } 156 157 /** 158 * Disable WP Forms frontend CAPTCHA API. 159 * 160 * @param $captcha_api string CAPTCHA API. 161 * 162 * @return string 163 * 164 * @since 2.0.19 165 */ 166 public function checkview_disable_frontend_captcha_api( $captcha_api ) { 167 $captcha_settings = wpforms_get_captcha_settings(); 168 169 if ( $captcha_settings['provider'] === 'turnstile' ) { 170 return ''; 171 } 172 173 return $captcha_api; 174 } 175 176 /** 152 177 * Injects testing email address. 153 178 * … … 182 207 public function checkview_log_wpform_test_entry( $form_fields, $entry, $form_data, $entry_id ) { 183 208 global $wpdb; 209 210 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 211 184 212 if ( ! function_exists( 'is_plugin_active' ) ) { 185 213 include_once ABSPATH . 'wp-admin/includes/plugin.php'; 186 214 } 187 215 188 $form_id = $form_data['id'];216 $form_id = $form_data['id']; 189 217 $checkview_test_id = get_checkview_test_id(); 190 218 … … 194 222 195 223 $entry_data = array( 196 'form_id' => $form_id,197 'status' => 'publish',198 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',224 'form_id' => $form_id, 225 'status' => 'publish', 226 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 199 227 'date_created' => current_time( 'mysql' ), 200 228 'date_updated' => current_time( 'mysql' ), 201 'uid' => $checkview_test_id,202 'form_type' => 'WpForms',229 'uid' => $checkview_test_id, 230 'form_type' => 'WpForms', 203 231 ); 204 232 $entry_table = $wpdb->prefix . 'cv_entry'; 205 $wpdb->insert( $entry_table, $entry_data ); 233 234 $result = $wpdb->insert( $entry_table, $entry_data ); 235 236 if ( ! $result ) { 237 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 238 } else { 239 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 240 } 241 206 242 $inserted_entry_id = $wpdb->insert_id; 207 243 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 208 244 $field_id_prefix = 'wpforms-' . $form_id . '-field_'; 245 $count = 0; 246 209 247 foreach ( $form_fields as $field ) { 210 211 248 if ( ! isset( $field['value'] ) || '' === $field['value'] ) { 212 249 continue; 213 250 } 251 214 252 $field_value = is_array( $field['value'] ) ? serialize( $field['value'] ) : $field['value']; 215 $type = isset( $field['type'] ) ? $field['type'] : ''; 253 $type = isset( $field['type'] ) ? $field['type'] : ''; 254 216 255 switch ( $type ) { 217 256 case 'name': … … 224 263 'meta_value' => $field['first'], 225 264 ); 226 $wpdb->insert( $entry_meta_table, $entry_metadata ); 227 265 266 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 267 268 if ( $result ) { 269 $count++; 270 } 228 271 } elseif ( '' === $field['middle'] ) { 229 272 $entry_metadata = array( … … 234 277 'meta_value' => $field['first'], 235 278 ); 236 $wpdb->insert( $entry_meta_table, $entry_metadata ); 237 $entry_metadata = array( 238 'uid' => $checkview_test_id, 239 'form_id' => $form_id, 240 'entry_id' => $inserted_entry_id, 241 'meta_key' => $field_id_prefix . $field['id'] . '-last', 279 280 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 281 282 if ( $result ) { 283 $count++; 284 } 285 286 $entry_metadata = array( 287 'uid' => $checkview_test_id, 288 'form_id' => $form_id, 289 'entry_id' => $inserted_entry_id, 290 'meta_key' => $field_id_prefix . $field['id'] . '-last', 242 291 'meta_value' => $field['last'], 243 292 ); 244 $wpdb->insert( $entry_meta_table, $entry_metadata ); 245 293 294 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 295 296 if ( $result ) { 297 $count++; 298 } 246 299 } else { 247 300 $entry_metadata = array( 248 'uid' => $checkview_test_id,249 'form_id' => $form_id,250 'entry_id' => $inserted_entry_id,251 'meta_key' => $field_id_prefix . $field['id'],301 'uid' => $checkview_test_id, 302 'form_id' => $form_id, 303 'entry_id' => $inserted_entry_id, 304 'meta_key' => $field_id_prefix . $field['id'], 252 305 'meta_value' => $field['first'], 253 306 ); 254 $wpdb->insert( $entry_meta_table, $entry_metadata ); 255 $entry_metadata = array( 256 'uid' => $checkview_test_id, 257 'form_id' => $form_id, 258 'entry_id' => $inserted_entry_id, 259 'meta_key' => $field_id_prefix . $field['id'] . '-middle', 307 308 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 309 310 if ( $result ) { 311 $count++; 312 } 313 314 $entry_metadata = array( 315 'uid' => $checkview_test_id, 316 'form_id' => $form_id, 317 'entry_id' => $inserted_entry_id, 318 'meta_key' => $field_id_prefix . $field['id'] . '-middle', 260 319 'meta_value' => $field['middle'], 261 320 ); 262 $wpdb->insert( $entry_meta_table, $entry_metadata ); 263 $entry_metadata = array( 264 'uid' => $checkview_test_id, 265 'form_id' => $form_id, 266 'entry_id' => $inserted_entry_id, 267 'meta_key' => $field_id_prefix . $field['id'] . '-last', 321 322 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 323 324 if ( $result ) { 325 $count++; 326 } 327 328 $entry_metadata = array( 329 'uid' => $checkview_test_id, 330 'form_id' => $form_id, 331 'entry_id' => $inserted_entry_id, 332 'meta_key' => $field_id_prefix . $field['id'] . '-last', 268 333 'meta_value' => $field['last'], 269 334 ); 270 $wpdb->insert( $entry_meta_table, $entry_metadata ); 271 335 336 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 337 338 if ( $result ) { 339 $count++; 340 } 272 341 } 273 342 break; 274 343 default: 275 344 $entry_metadata = array( 276 'uid' => $checkview_test_id,277 'form_id' => $form_id,278 'entry_id' => $inserted_entry_id,279 'meta_key' => $field_id_prefix . $field['id'],345 'uid' => $checkview_test_id, 346 'form_id' => $form_id, 347 'entry_id' => $inserted_entry_id, 348 'meta_key' => $field_id_prefix . $field['id'], 280 349 'meta_value' => $field_value, 281 350 ); 282 $wpdb->insert( $entry_meta_table, $entry_metadata ); 351 352 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 353 354 if ( $result ) { 355 $count++; 356 } 357 283 358 break; 359 } 360 } 361 362 if ( $count > 0 ) { 363 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 364 } else { 365 if ( count( $form_fields ) > 0 ) { 366 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 284 367 } 285 368 } … … 295 378 ) 296 379 ); 380 297 381 $wpdb->delete( 298 382 $wpdb->prefix . 'wpforms_entry_fields', … … 303 387 ); 304 388 } 305 $old_settings = (array) get_option( 'wpforms_settings', array() );306 if ( ! empty( $old_settings['turnstile-site-key'] ) && null !== $old_settings['turnstile-site-key'] && null !== $old_settings['turnstile-secret-key'] ) {307 if ( '1x00000000000000000000AA' === $old_settings['turnstile-site-key'] ) {308 $old_settings['turnstile-site-key'] = get_option( 'checkview_wpforms_turnstile-site-key' );309 $old_settings['turnstile-secret-key'] = get_option( 'checkview_wpforms_turnstile-secret-key' );310 update_option( 'wpforms_settings', $old_settings );311 }312 }313 389 314 390 complete_checkview_test( $checkview_test_id ); -
checkview/trunk/includes/formhelpers/class-checkview-wsf-helper.php
r3216431 r3323842 42 42 public function __construct() { 43 43 $this->loader = new Checkview_Loader(); 44 44 45 add_action( 45 46 'wsf_submit_post_complete', … … 51 52 1 52 53 ); 54 53 55 add_filter( 54 56 'akismet_get_api_key', … … 62 64 999 63 65 ); 66 64 67 if ( defined( 'TEST_EMAIL' ) ) { 65 68 add_filter( … … 83 86 2 84 87 ); 88 85 89 add_filter( 86 90 'wsf_config_meta_keys', … … 96 100 6 97 101 ); 102 98 103 add_filter( 99 104 'wsf_action_email_headers', … … 157 162 $headers = explode( "\r\n", $headers ); 158 163 } 164 159 165 $filtered_headers = array_filter( 160 166 $headers, … … 164 170 } 165 171 ); 172 166 173 return array_values( $filtered_headers ); 167 174 } … … 179 186 $form_id = $form_data->form_id; 180 187 $entry_id = $form_data->id; 181 182 188 $checkview_test_id = get_checkview_test_id(); 189 190 Checkview_Admin_Logs::add( 'ip-logs', 'Cloning submission entry [' . $entry_id . ']...' ); 183 191 184 192 if ( empty( $checkview_test_id ) ) { 185 193 $checkview_test_id = $form_id . gmdate( 'Ymd' ); 186 194 } 195 187 196 // Insert Entry. 188 197 $entry_data = array( 189 'form_id' => $form_id,190 'status' => 'publish',191 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '',198 'form_id' => $form_id, 199 'status' => 'publish', 200 'source_url' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', 192 201 'date_created' => current_time( 'mysql' ), 193 202 'date_updated' => current_time( 'mysql' ), 194 'uid' => $checkview_test_id,195 'form_type' => 'WSForms',203 'uid' => $checkview_test_id, 204 'form_type' => 'WSForms', 196 205 ); 197 206 $entry_table = $wpdb->prefix . 'cv_entry'; 198 $wpdb->insert( $entry_table, $entry_data ); 199 $inserted_entry_id = $wpdb->insert_id; 200 201 // Insert entry meta. 207 208 $result = $wpdb->insert( $entry_table, $entry_data ); 209 210 if ( ! $result ) { 211 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry data.' ); 212 } else { 213 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry data (inserted ' . (int) $result . ' rows into ' . $entry_table . ').' ); 214 } 215 202 216 $entry_meta_table = $wpdb->prefix . 'cv_entry_meta'; 203 217 $field_id_prefix = 'wsf'; 204 $tablename = $wpdb->prefix . 'wsf_submit_meta'; 205 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where parent_id=%d', $entry_id ) ); 218 $tablename = $wpdb->prefix . 'wsf_submit_meta'; 219 $form_fields = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where parent_id=%d', $entry_id ) ); 220 $count = 0; 221 206 222 foreach ( $form_fields as $field ) { 207 223 if ( ! in_array( $field->meta_key, array( '_form_id', 'post_id', 'wsf_meta_key_hidden' ) ) ) { 208 224 $entry_metadata = array( 209 'uid' => $checkview_test_id,210 'form_id' => $form_id,211 'entry_id' => $entry_id,212 'meta_key' => $field_id_prefix . str_replace( '_', '-', $field->meta_key ),225 'uid' => $checkview_test_id, 226 'form_id' => $form_id, 227 'entry_id' => $entry_id, 228 'meta_key' => $field_id_prefix . str_replace( '_', '-', $field->meta_key ), 213 229 'meta_value' => $field->meta_value, 214 230 ); 215 $wpdb->insert( $entry_meta_table, $entry_metadata ); 216 } 217 } 218 update_option( $checkview_test_id . '_wsf_entry_id', $entry_id ); 219 update_option( $checkview_test_id . '_wsf_frm_id', $form_id ); 231 232 $result = $wpdb->insert( $entry_meta_table, $entry_metadata ); 233 234 if ( $result ) { 235 $count++; 236 } 237 } 238 } 239 240 if ( $count > 0 ) { 241 Checkview_Admin_Logs::add( 'ip-logs', 'Cloned submission entry meta data (inserted ' . $count . ' rows into ' . $entry_meta_table . ').' ); 242 } else { 243 if ( count( $form_fields ) > 0 ) { 244 Checkview_Admin_Logs::add( 'ip-logs', 'Failed to clone submission entry meta data.' ); 245 } 246 } 247 248 cv_update_option( $checkview_test_id . '_wsf_entry_id', $entry_id ); 249 cv_update_option( $checkview_test_id . '_wsf_frm_id', $form_id ); 250 220 251 complete_checkview_test( $checkview_test_id ); 221 252 } -
checkview/trunk/includes/woocommercehelper/class-checkview-woo-automated-testing.php
r3303097 r3323842 564 564 */ 565 565 public function checkview_test_mode() { 566 567 // Current Vsitor IP.568 566 $visitor_ip = checkview_get_visitor_ip(); 569 // Check view Bot IP.570 567 $cv_bot_ip = checkview_get_api_ip(); 568 571 569 if ( ! is_array( $cv_bot_ip ) || ! in_array( $visitor_ip, $cv_bot_ip ) ) { 572 573 570 return; 574 571 } 575 Checkview_Admin_Logs::add( 'ip-logs', wp_json_encode( $cv_bot_ip ) . 'bot IP' ); 576 Checkview_Admin_Logs::add( 'ip-logs', wp_json_encode( $visitor_ip ) . 'visitor IP' ); 572 573 Checkview_Admin_Logs::add( 'ip-logs', 'Running Woo test mode hooks, visitor IP [' . $visitor_ip . '] matched a bot IP.' ); 574 577 575 if ( ! is_admin() && class_exists( 'WooCommerce' ) ) { 578 576 // Always use Stripe test mode when on dev or staging. … … 580 578 'option_woocommerce_stripe_settings', 581 579 function ( $value ) { 580 Checkview_Admin_Logs::add( 'ip-logs', 'Setting Woo test mode to true for hook [option_woocommerce_stripe_settings].' ); 582 581 583 582 $value['testmode'] = 'yes'; … … 586 585 } 587 586 ); 587 588 588 // Turn test mode on for stripe payments. 589 589 add_filter( 590 590 'wc_stripe_mode', 591 591 function ( $mode ) { 592 Checkview_Admin_Logs::add( 'ip-logs', 'Setting Woo test mode to true for hook [wc_stripe_mode].' ); 592 593 593 594 $mode = 'test'; … … 615 616 'checkview_woocommerce_block_support', 616 617 ); 618 617 619 add_filter( 618 620 'cfturnstile_whitelisted', … … 620 622 999 621 623 ); 624 622 625 // Make the test product visible in the catalog. 623 626 add_filter( 624 627 'woocommerce_product_is_visible', 625 function ( $visible, $product_id ) {628 function ( bool $visible, $product_id ) { 626 629 $product = $this->checkview_get_test_product(); 627 630 … … 630 633 } 631 634 632 return $product_id === $product->get_id() ? true : $visible; 635 $is_visible = $product_id === $product->get_id() ? true : $visible; 636 637 if ($is_visible) { 638 Checkview_Admin_Logs::add( 'ip-logs', 'Setting Woo test product visibility to true.' ); 639 640 return true; 641 } 642 643 return false; 633 644 }, 634 645 9999, 635 646 2 636 647 ); 648 637 649 $this->loader->add_action( 638 650 'woocommerce_order_status_changed', … … 642 654 3 643 655 ); 644 } 645 } 656 } else { 657 Checkview_Admin_Logs::add( 'ip-logs', 'No Woo hooks were ran (WooCommerce was not found or client is requesting admin area).' ); 658 } 659 } 660 646 661 /** 647 662 * Returns false. … … 729 744 * Adds CheckView dummy payment gateway to Woo. 730 745 * 731 * @param string $methods Methods to add payments.732 * @return array746 * @param string[] $methods Methods to add payments. 747 * @return string[] 733 748 */ 734 749 public function checkview_add_payment_gateway( $methods ) { 735 $methods[] = 'Checkview_Payment_Gateway'; 750 $gateway = 'Checkview_Payment_Gateway'; 751 752 Checkview_Admin_Logs::add( 'ip-logs', 'Adding Woo payment gateway [' . $gateway . '].' ); 753 754 $methods[] = $gateway; 755 736 756 return $methods; 737 757 } … … 749 769 'woocommerce_blocks_payment_method_type_registration', 750 770 function ( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 771 Checkview_Admin_Logs::add( 'ip-logs', 'Added Woo Blocks payment gateway.' ); 772 751 773 $payment_method_registry->register( new Checkview_Blocks_Payment_Gateway() ); 752 774 } … … 767 789 return; 768 790 } 791 769 792 return $this->checkview_delete_orders(); 770 793 } … … 777 800 */ 778 801 public function checkview_delete_orders( $order_id = '' ) { 779 780 global $wpdb; 802 Checkview_Admin_Logs::add( 'ip-logs', 'Deleting CheckView orders from the database...' ); 803 781 804 $orders = array(); 782 // WPDBPREPARE. 783 if ( empty( $orders ) || false === $orders ) { 784 $args = array( 785 'limit' => -1, 786 'type' => 'shop_order', 787 'meta_key' => 'payment_made_by', // Postmeta key field. 788 'meta_value' => 'checkview', // Postmeta value field. 789 'meta_compare' => '=', 790 'return' => 'ids', 791 ); 792 if ( function_exists( 'wc_get_orders' ) ) { 793 $orders = wc_get_orders( $args ); 794 } 795 $orders_cv = array(); 796 $args = array( 797 'limit' => -1, 798 'type' => 'shop_order', 799 'payment_method' => 'checkview', 800 'return' => 'ids', 801 ); 802 if ( function_exists( 'wc_get_orders' ) ) { 803 $orders_cv = wc_get_orders( $args ); 804 } 805 $orders = array_unique( array_merge( $orders, $orders_cv ) ); 806 807 } 805 $args = array( 806 'limit' => -1, 807 'type' => 'shop_order', 808 'meta_key' => 'payment_made_by', // Postmeta key field. 809 'meta_value' => 'checkview', // Postmeta value field. 810 'meta_compare' => '=', 811 'return' => 'ids', 812 ); 813 814 if ( function_exists( 'wc_get_orders' ) ) { 815 $orders = wc_get_orders( $args ); 816 } 817 818 $orders_cv = array(); 819 $args = array( 820 'limit' => -1, 821 'type' => 'shop_order', 822 'payment_method' => 'checkview', 823 'return' => 'ids', 824 ); 825 826 if ( function_exists( 'wc_get_orders' ) ) { 827 $orders_cv = wc_get_orders( $args ); 828 } 829 830 $orders = array_unique( array_merge( $orders, $orders_cv ) ); 831 832 Checkview_Admin_Logs::add( 'cron-logs', 'Found ' . count( $orders ) . ' CheckView orders to delete.' ); 833 808 834 // Delete orders. 809 835 if ( ! empty( $orders ) ) { 810 836 foreach ( $orders as $order ) { 811 837 $order_object = wc_get_order( $order ); 838 839 // Delete order. 812 840 try { 813 $order_object = wc_get_order( $order );814 // Delete order.815 841 if ( $order_object && method_exists( $order_object, 'get_customer_id' ) ) { 816 842 if ( $order_object->get_meta( 'payment_made_by' ) !== 'checkview' && 'checkview' !== $order_object->get_payment_method() ) { 817 843 continue; 818 844 } 845 819 846 $customer_id = $order_object->get_customer_id(); 820 847 $order_object->delete( true ); 848 821 849 delete_transient( 'checkview_store_orders_transient' ); 822 850 823 851 $order_object = null; 824 852 $current_user = get_user_by( 'id', $customer_id ); 853 825 854 // Delete customer if available. 826 855 if ( $customer_id && isset( $current_user->roles ) && isset( $current_user->roles ) && ! in_array( 'administrator', $current_user->roles, true ) ) { … … 831 860 } 832 861 833 $res = $customer->delete( true );862 $res = $customer->delete( true ); 834 863 $customer = null; 835 864 } … … 839 868 require_once CHECKVIEW_ADMIN_DIR . '/class-checkview-admin-logs.php'; 840 869 } 841 Checkview_Admin_Logs::add( 'cron-logs', 'Crone job failed.' ); 870 871 if ($order_object) { 872 Checkview_Admin_Logs::add( 'cron-logs', 'Failed to delete CheckView order [' . $order_object->get_id() . '] from the database.' ); 873 } else { 874 Checkview_Admin_Logs::add( 'cron-logs', 'Failed to delete CheckView order from the database.' ); 875 } 876 842 877 } 843 878 } 879 844 880 return true; 845 881 } … … 858 894 $order = new WC_Order( $order_id ); 859 895 $order->update_meta_data( 'payment_made_by', 'checkview' ); 860 861 896 $order->update_meta_data( 'checkview_test_id', sanitize_text_field( wp_unslash( $_COOKIE['checkview_test_id'] ) ) ); 897 898 Checkview_Admin_Logs::add( 'ip-logs', 'Added meta data to test order.' ); 899 862 900 complete_checkview_test( sanitize_text_field( wp_unslash( $_COOKIE['checkview_test_id'] ) ) ); 863 901 864 902 $order->save(); 903 904 Checkview_Admin_Logs::add( 'ip-logs', 'Saved new order [' . $order->get_id() . '].' ); 905 865 906 unset( $_COOKIE['checkview_test_id'] ); 866 907 setcookie( 'checkview_test_id', '', time() - 6600, COOKIEPATH, COOKIE_DOMAIN );
Note: See TracChangeset
for help on using the changeset viewer.