From 192e51ac51b7534a3b3f025444fb1de758e1221e Mon Sep 17 00:00:00 2001 From: Glomberg Date: Sat, 28 Dec 2024 16:48:14 +0300 Subject: [PATCH] Fix. Common. `Helper::dnsResolve()` method fixed. --- lib/Cleantalk/ApbctWP/Firewall/SFW.php | 4 +++- lib/Cleantalk/Common/Helper.php | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Cleantalk/ApbctWP/Firewall/SFW.php b/lib/Cleantalk/ApbctWP/Firewall/SFW.php index c55184712..12ef53822 100644 --- a/lib/Cleantalk/ApbctWP/Firewall/SFW.php +++ b/lib/Cleantalk/ApbctWP/Firewall/SFW.php @@ -813,7 +813,9 @@ public static function updateWriteToDbExclusions($db, $db__table__data, $exclusi if (Server::get('HTTP_HOST')) { // Do not add exceptions for local hosts if (defined('APBCT_IS_LOCALHOST') && !APBCT_IS_LOCALHOST) { - $exclusions[] = Helper::dnsResolve(Server::get('HTTP_HOST')); + if ( $current_host_ip = Helper::dnsResolve(Server::get('HTTP_HOST')) ) { + $exclusions[] = $current_host_ip; + } $exclusions[] = '127.0.0.1'; // And delete all 127.0.0.1 entries for local hosts } else { diff --git a/lib/Cleantalk/Common/Helper.php b/lib/Cleantalk/Common/Helper.php index 7c9be61a3..49d060110 100644 --- a/lib/Cleantalk/Common/Helper.php +++ b/lib/Cleantalk/Common/Helper.php @@ -545,6 +545,11 @@ public static function ipResolve($ip) */ public static function dnsResolve($host, $out = false) { + // Check if the $url is set and it is an url + if ( ! $host || ! filter_var($host, FILTER_VALIDATE_URL)) { + return $out; + } + // Get DNS records about URL if (function_exists('dns_get_record')) { $records = dns_get_record($host, DNS_A);