Changeset 3296764
- Timestamp:
- 05/19/2025 07:12:10 PM (10 months ago)
- Location:
- checkview
- Files:
-
- 8 edited
- 1 copied
-
tags/2.0.16 (copied) (copied from checkview/trunk)
-
tags/2.0.16/README.txt (modified) (3 diffs)
-
tags/2.0.16/checkview.php (modified) (2 diffs)
-
tags/2.0.16/includes/checkview-functions.php (modified) (7 diffs)
-
tags/2.0.16/includes/class-checkview.php (modified) (1 diff)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/checkview.php (modified) (2 diffs)
-
trunk/includes/checkview-functions.php (modified) (7 diffs)
-
trunk/includes/class-checkview.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
checkview/tags/2.0.16/README.txt
r3294839 r3296764 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 Stable tag: 2.0.1 510 Stable tag: 2.0.16 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.16 = 89 * Check status of CleanTalk token before attempting API requests. 90 * Separate transients for CleanTalk Antispam and CleanTalk Spam Firewall IPs. 91 * Improve validation and handling of data from CleanTalk requests. 92 * Utilize CleanTalk service ID for requests, greatly reducing CleanTalk API response times. 93 * Lower CleanTalk API timeout errors. 94 * Correct record types in CleanTalk POST requests. 95 * Loosen checks for IPs/domains in CleanTalk responses. 96 * Improve logging. 97 88 98 = 2.0.15 = 89 99 * Fixed an issue where CleanTalk requests were not properly being requested and cached. … … 341 351 342 352 == Upgrade Notice == 353 = 2.0.16 = 354 * Check status of CleanTalk token before attempting API requests. 355 * Separate transients for CleanTalk Antispam and CleanTalk Spam Firewall IPs. 356 * Improve validation and handling of data from CleanTalk requests. 357 * Utilize CleanTalk service ID for requests, greatly reducing CleanTalk API response times. 358 * Lower CleanTalk API timeout errors. 359 * Correct record types in CleanTalk POST requests. 360 * Loosen checks for IPs/domains in CleanTalk responses. 361 * Improve logging. 362 343 363 = 2.0.15 = 344 364 * Fixed an issue where CleanTalk requests were not properly being requested and cached. -
checkview/tags/2.0.16/checkview.php
r3294839 r3296764 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 514 * Version: 2.0.16 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 5' );38 define( 'CHECKVIEW_VERSION', '2.0.16' ); 39 39 40 40 if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) { -
checkview/tags/2.0.16/includes/checkview-functions.php
r3294839 r3296764 360 360 * 361 361 * @param string $service_type Service type. 362 * @return array List of whitelisted IPs. 363 */ 364 function checkview_get_cleantalk_whitelisted_ips( $service_type = 'antispam' ) { 365 $ip_array = get_transient( 'checkview_whitelisted_ips' ); 362 * @param string $service_id Service ID. 363 * @return array|false List of whitelisted IPs, false on error. 364 */ 365 function checkview_get_cleantalk_whitelisted_ips( $service_type = 'antispam', $service_id = 'all' ) { 366 $ip_array = get_transient( 'checkview_whitelisted_ips_' . $service_type ); 367 366 368 if ( ! empty( $ip_array ) && is_array( $ip_array ) ) { 367 369 return $ip_array; 368 370 } 371 369 372 $spbc_data = get_option( 'cleantalk_data', array() ); 370 373 $user_token = $spbc_data['user_token']; 371 372 // CleanTalk API endpoint to get whitelisted IPs. 373 $api_url = "https://api.cleantalk.org/?method_name=private_list_get&user_token=$user_token&service_type=" . $service_type . '&product_id=1'; 374 375 // Perform a remote GET request using WordPress' wp_remote_get() function. 376 $response = wp_remote_get( $api_url ); 374 $api_url = "https://api.cleantalk.org/?method_name=private_list_get&user_token=$user_token&service_type=" . $service_type . '&product_id=1&service_id=' . $service_id; 375 376 $response = wp_remote_get( $api_url, array( 377 'timeout' => 20, 378 ) ); 377 379 378 380 if ( is_wp_error( $response ) ) { … … 380 382 Checkview_Admin_Logs::add( 'ip-logs', esc_html__( 'Error fetching whitelisted IPs: ' . $response->get_error_message(), 'checkview' ) ); 381 383 382 return array();384 return false; 383 385 } 384 386 … … 393 395 394 396 // Check if we have valid data. 395 if ( isset( $whitelisted_ips['data'] ) && ! empty( $whitelisted_ips['data'] ) ) {397 if ( isset( $whitelisted_ips['data'] ) && is_array( $whitelisted_ips['data'] ) && ! empty( $whitelisted_ips['data'] ) ) { 396 398 // Loop through and add IPs to the array. 397 399 foreach ( $whitelisted_ips['data'] as $entry ) { … … 402 404 } 403 405 } 404 set_transient( 'checkview_whitelisted_ips', $ip_array, 12 * HOUR_IN_SECONDS ); 406 407 set_transient( 'checkview_whitelisted_ips_' . $service_type, $ip_array, 12 * HOUR_IN_SECONDS ); 408 405 409 return $ip_array; 406 410 } … … 412 416 * 413 417 * @since 1.0.0 414 * 415 * @modified 2.0.13 416 * @updated 2.0.14 417 * @return mixed 418 * 419 * @return null 418 420 */ 419 421 function checkview_whitelist_api_ip() { 422 global $apbct; 423 424 if ( ! isset($apbct->data['service_id'] ) ) { 425 error_log( 'CleanTalk service ID could not be found.' ); 426 } 427 428 $service_id = $apbct->data['service_id']; 420 429 $spbc_data = get_option( 'cleantalk_data', array() ); 421 430 $user_token = $spbc_data['user_token']; 431 432 if ( empty( $user_token ) || ( function_exists('apbct_api_key__is_correct') && ! apbct_api_key__is_correct() ) ) { 433 return null; 434 } 435 422 436 $current_ip = checkview_get_visitor_ip(); 423 437 $api_ip = checkview_get_api_ip(); 424 438 425 439 if ( is_array( $api_ip ) && in_array( $current_ip, $api_ip ) ) { 426 $host_name = parse_url( home_url(), PHP_URL_HOST ); 440 $home_url = parse_url( home_url() ); // Returns `false`, `null`, or an assosiative array. 441 442 if ( $home_url === false || $home_url === null ) { 443 error_log( sprintf( 'Error parsing the home url [%1$s].', home_url() ) ); 444 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'Error parsing the home url [%1$s].', home_url() ) ); 445 446 return null; 447 } 448 449 if ( is_array( $home_url ) && ! isset( $home_url[ 'host' ] ) ) { 450 error_log( sprintf( 'Cannot determine host when parsing URL [%1$s].', json_encode( $home_url ) ) ); 451 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'Cannot determine host when parsing URL [%1$s].', json_encode( $home_url ) ) ); 452 453 return null; 454 } 455 456 $host_name = $home_url['host']; 427 457 428 458 // Check antispam whitelist. 429 $antispam_ips = checkview_get_cleantalk_whitelisted_ips( 'antispam' ); 430 431 if ( ! in_array( $current_ip, $antispam_ips[ $host_name ] ) ) { 432 checkview_add_to_cleantalk( $user_token, 'antispam', $current_ip, 1 ); 433 } 434 435 if ( ! in_array( 'checkview.io', $antispam_ips[ $host_name ] ) ) { 436 checkview_add_to_cleantalk( $user_token, 'antispam', 'checkview.io', 1 ); 437 } 438 439 if ( ! in_array( 'test-mail.checkview.io', $antispam_ips[ $host_name ] ) ) { 440 checkview_add_to_cleantalk( $user_token, 'antispam', 'test-mail.checkview.io', 4 ); 459 $antispam_ips = checkview_get_cleantalk_whitelisted_ips( 'antispam', $service_id ); 460 461 if ( is_array( $antispam_ips ) ) { 462 if ( ! isset( $antispam_ips[ $host_name ] ) ) { 463 error_log( 'No host name found in Antispam IP list.' ); 464 465 // If the host name is not in the whitelist, request to add our IPs/hosts. 466 checkview_add_to_cleantalk( $user_token, 'antispam', $current_ip, 1, $service_id ); 467 checkview_add_to_cleantalk( $user_token, 'antispam', 'checkview.io', 4, $service_id ); 468 checkview_add_to_cleantalk( $user_token, 'antispam', 'test-mail.checkview.io', 4, $service_id ); 469 } else { 470 // Otherwise, check for our IPs/hosts individually, and request to add them if needed. 471 if ( is_array( $antispam_ips[ $host_name ] ) ) { 472 $has_current_ip = array_find( $antispam_ips[ $host_name ], function( $value, $key ) use ($current_ip) { 473 $position = strpos( $value, $current_ip ); 474 475 return $position === false ? false : true; 476 }); 477 478 if ( ! $has_current_ip ) { 479 checkview_add_to_cleantalk( $user_token, 'antispam', $current_ip, 1, $service_id ); 480 } 481 482 $has_checkview_hostname = array_find( $antispam_ips[ $host_name ], function( $value, $key ) { 483 $position = strpos( $value, 'checkview.io' ); 484 485 // Skip test-mail domain 486 if ($value === 'test-mail.checkview.io') { 487 return false; 488 } 489 490 return $position === false ? false : true; 491 }); 492 493 if ( ! $has_checkview_hostname ) { 494 checkview_add_to_cleantalk( $user_token, 'antispam', 'checkview.io', 4, $service_id ); 495 } 496 497 $has_mail_hostname = array_find( $antispam_ips[ $host_name ], function( $value, $key ) { 498 $position = strpos( $value, 'test-mail.checkview.io' ); 499 500 return $position === false ? false : true; 501 }); 502 503 if ( ! $has_mail_hostname ) { 504 checkview_add_to_cleantalk( $user_token, 'antispam', 'test-mail.checkview.io', 4, $service_id ); 505 } 506 } else { 507 error_log( sprintf( 'The value for antispam IPs at hostname [%1$s] is not an array.', $host_name ) ); 508 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'The value for antispam IPs at hostname [%1$s] is not an array.', $host_name ) ); 509 } 510 } 441 511 } 442 512 443 513 // Check spamfirewall whitelist. 444 $spamfirewall_ips = checkview_get_cleantalk_whitelisted_ips( 'spamfirewall' ); 445 446 if ( empty( $spamfirewall_ips[ $host_name ] ) || ! in_array( $current_ip, $spamfirewall_ips[ $host_name ] ) ) { 447 checkview_add_to_cleantalk( $user_token, 'spamfirewall', $current_ip . '/32', 6 ); 448 } 449 } 514 $spamfirewall_ips = checkview_get_cleantalk_whitelisted_ips( 'spamfirewall', $service_id ); 515 516 if ( is_array( $spamfirewall_ips ) ) { 517 if ( ! isset( $spamfirewall_ips[ $host_name ] ) ) { 518 error_log( 'No host name found in Spam Firewall IP list.' ); 519 520 // If host name is not set, request to add it. 521 checkview_add_to_cleantalk( $user_token, 'spamfirewall', $current_ip . '/32', 6, $service_id ); 522 } else { 523 if ( is_array( $spamfirewall_ips[ $host_name ] ) ) { 524 $has_current_ip = array_find( $spamfirewall_ips[ $host_name ], function( $value, $key ) use ($current_ip) { 525 $position = strpos( $value, $current_ip ); 526 527 return $position === false ? false : true; 528 }); 529 530 if ( ! $has_current_ip ) { 531 checkview_add_to_cleantalk( $user_token, 'spamfirewall', $current_ip, 6, $service_id ); 532 } 533 } else { 534 error_log( sprintf( 'Value for spam firewall IPs at hostname [%1$s] is unexpected type [%2$s], expected array.', $host_name, gettype( $antispam_ips[ $host_name ] ) ) ); 535 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'Value for spam firewall IPs at hostname [%1$s] is unexpected type [%2$s], expected array.', $host_name, gettype( $antispam_ips[ $host_name ] ) ) ); 536 } 537 } 538 } 539 } 540 450 541 return null; 451 542 } … … 461 552 * @param string $record Record. 462 553 * @param string $record_type Record type. 554 * @param string $service_id Service ID. 463 555 * @return mixed 464 556 */ 465 function checkview_add_to_cleantalk( $user_token, $service_type, $record, $record_type ) { 557 function checkview_add_to_cleantalk( $user_token, $service_type, $record, $record_type, $service_id ) { 558 error_log( sprintf( 559 'Adding record [%1$s] with type [%2$s] and service type [%3$s] to CleanTalk\'s API with service id [%4$s]', 560 $record, 561 $record_type, 562 $service_type, 563 $service_id, 564 ) ); 565 466 566 $response = wp_remote_get( 467 567 'https://api.cleantalk.org/?method_name=private_list_add&user_token=' . $user_token . 468 '&service_id= all&service_type=' . $service_type .568 '&service_id=' . $service_id . '&service_type=' . $service_type . 469 569 '&product_id=1&record_type=' . $record_type . 470 570 '&status=allow¬e=Checkview Bot&records=' . $record, 471 571 array( 472 572 'method' => 'POST', 473 'timeout' => 30,573 'timeout' => 20, 474 574 ) 475 575 ); 576 577 delete_transient('checkview_whitelisted_ips_' . $service_type); 476 578 477 579 if ( is_wp_error( $response ) ) { … … 638 740 delete_transient( 'checkview_store_products_transient' ); 639 741 delete_transient( 'checkview_store_shipping_transient' ); 640 delete_transient( 'checkview_whitelisted_ips' ); 742 delete_transient( 'checkview_whitelisted_ips_spamfirewall' ); 743 delete_transient( 'checkview_whitelisted_ips_antispam' ); 641 744 $sync = true; 642 745 return $sync; -
checkview/tags/2.0.16/includes/class-checkview.php
r3294839 r3296764 71 71 $this->version = CHECKVIEW_VERSION; 72 72 } else { 73 $this->version = '2.0.1 5';73 $this->version = '2.0.16'; 74 74 } 75 75 $this->plugin_name = 'checkview'; -
checkview/trunk/README.txt
r3294839 r3296764 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 Stable tag: 2.0.1 510 Stable tag: 2.0.16 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.16 = 89 * Check status of CleanTalk token before attempting API requests. 90 * Separate transients for CleanTalk Antispam and CleanTalk Spam Firewall IPs. 91 * Improve validation and handling of data from CleanTalk requests. 92 * Utilize CleanTalk service ID for requests, greatly reducing CleanTalk API response times. 93 * Lower CleanTalk API timeout errors. 94 * Correct record types in CleanTalk POST requests. 95 * Loosen checks for IPs/domains in CleanTalk responses. 96 * Improve logging. 97 88 98 = 2.0.15 = 89 99 * Fixed an issue where CleanTalk requests were not properly being requested and cached. … … 341 351 342 352 == Upgrade Notice == 353 = 2.0.16 = 354 * Check status of CleanTalk token before attempting API requests. 355 * Separate transients for CleanTalk Antispam and CleanTalk Spam Firewall IPs. 356 * Improve validation and handling of data from CleanTalk requests. 357 * Utilize CleanTalk service ID for requests, greatly reducing CleanTalk API response times. 358 * Lower CleanTalk API timeout errors. 359 * Correct record types in CleanTalk POST requests. 360 * Loosen checks for IPs/domains in CleanTalk responses. 361 * Improve logging. 362 343 363 = 2.0.15 = 344 364 * Fixed an issue where CleanTalk requests were not properly being requested and cached. -
checkview/trunk/checkview.php
r3294839 r3296764 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 514 * Version: 2.0.16 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 5' );38 define( 'CHECKVIEW_VERSION', '2.0.16' ); 39 39 40 40 if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) { -
checkview/trunk/includes/checkview-functions.php
r3294839 r3296764 360 360 * 361 361 * @param string $service_type Service type. 362 * @return array List of whitelisted IPs. 363 */ 364 function checkview_get_cleantalk_whitelisted_ips( $service_type = 'antispam' ) { 365 $ip_array = get_transient( 'checkview_whitelisted_ips' ); 362 * @param string $service_id Service ID. 363 * @return array|false List of whitelisted IPs, false on error. 364 */ 365 function checkview_get_cleantalk_whitelisted_ips( $service_type = 'antispam', $service_id = 'all' ) { 366 $ip_array = get_transient( 'checkview_whitelisted_ips_' . $service_type ); 367 366 368 if ( ! empty( $ip_array ) && is_array( $ip_array ) ) { 367 369 return $ip_array; 368 370 } 371 369 372 $spbc_data = get_option( 'cleantalk_data', array() ); 370 373 $user_token = $spbc_data['user_token']; 371 372 // CleanTalk API endpoint to get whitelisted IPs. 373 $api_url = "https://api.cleantalk.org/?method_name=private_list_get&user_token=$user_token&service_type=" . $service_type . '&product_id=1'; 374 375 // Perform a remote GET request using WordPress' wp_remote_get() function. 376 $response = wp_remote_get( $api_url ); 374 $api_url = "https://api.cleantalk.org/?method_name=private_list_get&user_token=$user_token&service_type=" . $service_type . '&product_id=1&service_id=' . $service_id; 375 376 $response = wp_remote_get( $api_url, array( 377 'timeout' => 20, 378 ) ); 377 379 378 380 if ( is_wp_error( $response ) ) { … … 380 382 Checkview_Admin_Logs::add( 'ip-logs', esc_html__( 'Error fetching whitelisted IPs: ' . $response->get_error_message(), 'checkview' ) ); 381 383 382 return array();384 return false; 383 385 } 384 386 … … 393 395 394 396 // Check if we have valid data. 395 if ( isset( $whitelisted_ips['data'] ) && ! empty( $whitelisted_ips['data'] ) ) {397 if ( isset( $whitelisted_ips['data'] ) && is_array( $whitelisted_ips['data'] ) && ! empty( $whitelisted_ips['data'] ) ) { 396 398 // Loop through and add IPs to the array. 397 399 foreach ( $whitelisted_ips['data'] as $entry ) { … … 402 404 } 403 405 } 404 set_transient( 'checkview_whitelisted_ips', $ip_array, 12 * HOUR_IN_SECONDS ); 406 407 set_transient( 'checkview_whitelisted_ips_' . $service_type, $ip_array, 12 * HOUR_IN_SECONDS ); 408 405 409 return $ip_array; 406 410 } … … 412 416 * 413 417 * @since 1.0.0 414 * 415 * @modified 2.0.13 416 * @updated 2.0.14 417 * @return mixed 418 * 419 * @return null 418 420 */ 419 421 function checkview_whitelist_api_ip() { 422 global $apbct; 423 424 if ( ! isset($apbct->data['service_id'] ) ) { 425 error_log( 'CleanTalk service ID could not be found.' ); 426 } 427 428 $service_id = $apbct->data['service_id']; 420 429 $spbc_data = get_option( 'cleantalk_data', array() ); 421 430 $user_token = $spbc_data['user_token']; 431 432 if ( empty( $user_token ) || ( function_exists('apbct_api_key__is_correct') && ! apbct_api_key__is_correct() ) ) { 433 return null; 434 } 435 422 436 $current_ip = checkview_get_visitor_ip(); 423 437 $api_ip = checkview_get_api_ip(); 424 438 425 439 if ( is_array( $api_ip ) && in_array( $current_ip, $api_ip ) ) { 426 $host_name = parse_url( home_url(), PHP_URL_HOST ); 440 $home_url = parse_url( home_url() ); // Returns `false`, `null`, or an assosiative array. 441 442 if ( $home_url === false || $home_url === null ) { 443 error_log( sprintf( 'Error parsing the home url [%1$s].', home_url() ) ); 444 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'Error parsing the home url [%1$s].', home_url() ) ); 445 446 return null; 447 } 448 449 if ( is_array( $home_url ) && ! isset( $home_url[ 'host' ] ) ) { 450 error_log( sprintf( 'Cannot determine host when parsing URL [%1$s].', json_encode( $home_url ) ) ); 451 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'Cannot determine host when parsing URL [%1$s].', json_encode( $home_url ) ) ); 452 453 return null; 454 } 455 456 $host_name = $home_url['host']; 427 457 428 458 // Check antispam whitelist. 429 $antispam_ips = checkview_get_cleantalk_whitelisted_ips( 'antispam' ); 430 431 if ( ! in_array( $current_ip, $antispam_ips[ $host_name ] ) ) { 432 checkview_add_to_cleantalk( $user_token, 'antispam', $current_ip, 1 ); 433 } 434 435 if ( ! in_array( 'checkview.io', $antispam_ips[ $host_name ] ) ) { 436 checkview_add_to_cleantalk( $user_token, 'antispam', 'checkview.io', 1 ); 437 } 438 439 if ( ! in_array( 'test-mail.checkview.io', $antispam_ips[ $host_name ] ) ) { 440 checkview_add_to_cleantalk( $user_token, 'antispam', 'test-mail.checkview.io', 4 ); 459 $antispam_ips = checkview_get_cleantalk_whitelisted_ips( 'antispam', $service_id ); 460 461 if ( is_array( $antispam_ips ) ) { 462 if ( ! isset( $antispam_ips[ $host_name ] ) ) { 463 error_log( 'No host name found in Antispam IP list.' ); 464 465 // If the host name is not in the whitelist, request to add our IPs/hosts. 466 checkview_add_to_cleantalk( $user_token, 'antispam', $current_ip, 1, $service_id ); 467 checkview_add_to_cleantalk( $user_token, 'antispam', 'checkview.io', 4, $service_id ); 468 checkview_add_to_cleantalk( $user_token, 'antispam', 'test-mail.checkview.io', 4, $service_id ); 469 } else { 470 // Otherwise, check for our IPs/hosts individually, and request to add them if needed. 471 if ( is_array( $antispam_ips[ $host_name ] ) ) { 472 $has_current_ip = array_find( $antispam_ips[ $host_name ], function( $value, $key ) use ($current_ip) { 473 $position = strpos( $value, $current_ip ); 474 475 return $position === false ? false : true; 476 }); 477 478 if ( ! $has_current_ip ) { 479 checkview_add_to_cleantalk( $user_token, 'antispam', $current_ip, 1, $service_id ); 480 } 481 482 $has_checkview_hostname = array_find( $antispam_ips[ $host_name ], function( $value, $key ) { 483 $position = strpos( $value, 'checkview.io' ); 484 485 // Skip test-mail domain 486 if ($value === 'test-mail.checkview.io') { 487 return false; 488 } 489 490 return $position === false ? false : true; 491 }); 492 493 if ( ! $has_checkview_hostname ) { 494 checkview_add_to_cleantalk( $user_token, 'antispam', 'checkview.io', 4, $service_id ); 495 } 496 497 $has_mail_hostname = array_find( $antispam_ips[ $host_name ], function( $value, $key ) { 498 $position = strpos( $value, 'test-mail.checkview.io' ); 499 500 return $position === false ? false : true; 501 }); 502 503 if ( ! $has_mail_hostname ) { 504 checkview_add_to_cleantalk( $user_token, 'antispam', 'test-mail.checkview.io', 4, $service_id ); 505 } 506 } else { 507 error_log( sprintf( 'The value for antispam IPs at hostname [%1$s] is not an array.', $host_name ) ); 508 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'The value for antispam IPs at hostname [%1$s] is not an array.', $host_name ) ); 509 } 510 } 441 511 } 442 512 443 513 // Check spamfirewall whitelist. 444 $spamfirewall_ips = checkview_get_cleantalk_whitelisted_ips( 'spamfirewall' ); 445 446 if ( empty( $spamfirewall_ips[ $host_name ] ) || ! in_array( $current_ip, $spamfirewall_ips[ $host_name ] ) ) { 447 checkview_add_to_cleantalk( $user_token, 'spamfirewall', $current_ip . '/32', 6 ); 448 } 449 } 514 $spamfirewall_ips = checkview_get_cleantalk_whitelisted_ips( 'spamfirewall', $service_id ); 515 516 if ( is_array( $spamfirewall_ips ) ) { 517 if ( ! isset( $spamfirewall_ips[ $host_name ] ) ) { 518 error_log( 'No host name found in Spam Firewall IP list.' ); 519 520 // If host name is not set, request to add it. 521 checkview_add_to_cleantalk( $user_token, 'spamfirewall', $current_ip . '/32', 6, $service_id ); 522 } else { 523 if ( is_array( $spamfirewall_ips[ $host_name ] ) ) { 524 $has_current_ip = array_find( $spamfirewall_ips[ $host_name ], function( $value, $key ) use ($current_ip) { 525 $position = strpos( $value, $current_ip ); 526 527 return $position === false ? false : true; 528 }); 529 530 if ( ! $has_current_ip ) { 531 checkview_add_to_cleantalk( $user_token, 'spamfirewall', $current_ip, 6, $service_id ); 532 } 533 } else { 534 error_log( sprintf( 'Value for spam firewall IPs at hostname [%1$s] is unexpected type [%2$s], expected array.', $host_name, gettype( $antispam_ips[ $host_name ] ) ) ); 535 Checkview_Admin_Logs::add( 'ip-logs', sprintf( 'Value for spam firewall IPs at hostname [%1$s] is unexpected type [%2$s], expected array.', $host_name, gettype( $antispam_ips[ $host_name ] ) ) ); 536 } 537 } 538 } 539 } 540 450 541 return null; 451 542 } … … 461 552 * @param string $record Record. 462 553 * @param string $record_type Record type. 554 * @param string $service_id Service ID. 463 555 * @return mixed 464 556 */ 465 function checkview_add_to_cleantalk( $user_token, $service_type, $record, $record_type ) { 557 function checkview_add_to_cleantalk( $user_token, $service_type, $record, $record_type, $service_id ) { 558 error_log( sprintf( 559 'Adding record [%1$s] with type [%2$s] and service type [%3$s] to CleanTalk\'s API with service id [%4$s]', 560 $record, 561 $record_type, 562 $service_type, 563 $service_id, 564 ) ); 565 466 566 $response = wp_remote_get( 467 567 'https://api.cleantalk.org/?method_name=private_list_add&user_token=' . $user_token . 468 '&service_id= all&service_type=' . $service_type .568 '&service_id=' . $service_id . '&service_type=' . $service_type . 469 569 '&product_id=1&record_type=' . $record_type . 470 570 '&status=allow¬e=Checkview Bot&records=' . $record, 471 571 array( 472 572 'method' => 'POST', 473 'timeout' => 30,573 'timeout' => 20, 474 574 ) 475 575 ); 576 577 delete_transient('checkview_whitelisted_ips_' . $service_type); 476 578 477 579 if ( is_wp_error( $response ) ) { … … 638 740 delete_transient( 'checkview_store_products_transient' ); 639 741 delete_transient( 'checkview_store_shipping_transient' ); 640 delete_transient( 'checkview_whitelisted_ips' ); 742 delete_transient( 'checkview_whitelisted_ips_spamfirewall' ); 743 delete_transient( 'checkview_whitelisted_ips_antispam' ); 641 744 $sync = true; 642 745 return $sync; -
checkview/trunk/includes/class-checkview.php
r3294839 r3296764 71 71 $this->version = CHECKVIEW_VERSION; 72 72 } else { 73 $this->version = '2.0.1 5';73 $this->version = '2.0.16'; 74 74 } 75 75 $this->plugin_name = 'checkview';
Note: See TracChangeset
for help on using the changeset viewer.