Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions inc/spbc-firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use CleantalkSP\SpbctWP\Firewall\WAF;
use CleantalkSP\SpbctWP\Firewall\WafBlocker;
use CleantalkSP\SpbctWP\Firewall\UploadChecker;
use CleantalkSP\SpbctWP\Helpers\IP;
use CleantalkSP\SpbctWP\Variables\Cookie;

// Prevent direct call
Expand Down Expand Up @@ -249,26 +248,9 @@ function spbc_firewall_skip_check()
return true;
}

// By cookie
if ( ! empty($_GET['access']) ) {
$apbct_settings = get_option('cleantalk_settings');
$apbct_key = ! empty($apbct_settings['apikey']) ? $apbct_settings['apikey'] : false;
if ( ( $_GET['access'] === $spbc->settings['spbc_key'] || ( $apbct_key !== false && $_GET['access'] === $apbct_key ) ) ) {
Cookie::set('spbc_firewall_pass_key', md5($_SERVER['REMOTE_ADDR'] . $spbc->settings['spbc_key']), time() + 1200, '/');
Cookie::set('ct_sfw_pass_key', md5($_SERVER['REMOTE_ADDR'] . $apbct_key), time() + 1200, '/');

return true;
}
}

// Legacy bypass: keep the old IP/API-key cookie mechanism for the transition period.
$ip_set = IP::get();
$ip_set = empty($ip_set) ? array() : $ip_set;
$ip_set = is_array($ip_set) ? $ip_set : array($ip_set);
foreach ( $ip_set as $spbc_cur_ip ) {
if ( Cookie::getString('spbc_firewall_pass_key') === md5($spbc_cur_ip . $spbc->settings['spbc_key']) ) {
return true;
}
// Emergency bypass: let the signed token from the control panel reach its admin-post.php handler.
if ( Firewall\FirewallBypass::isJwtBypassRequest() ) {
return true;
}

// Turn off the SpamFireWall if Remote Call is in progress
Expand Down
Loading
Loading