From 964c9e8b3ca001fb4779fbcbab86453da78c57cf Mon Sep 17 00:00:00 2001 From: svfcode Date: Thu, 18 Jul 2024 12:19:25 +0300 Subject: [PATCH] Update names. --- inc/spbc-settings.php | 6 +++--- .../{DirExclusion.php => FilesScanDirExclusion.php} | 11 ++++++++++- ...nExclusion.php => FrontendScanDomainExclusion.php} | 8 ++++++-- security-malware-firewall.php | 6 +++--- 4 files changed, 22 insertions(+), 9 deletions(-) rename lib/CleantalkSP/SpbctWP/Settings/{DirExclusion.php => FilesScanDirExclusion.php} (92%) mode change 100644 => 100755 rename lib/CleantalkSP/SpbctWP/Settings/{DomainExclusion.php => FrontendScanDomainExclusion.php} (93%) mode change 100644 => 100755 diff --git a/inc/spbc-settings.php b/inc/spbc-settings.php index 98178bcaa..cba42f295 100644 --- a/inc/spbc-settings.php +++ b/inc/spbc-settings.php @@ -4554,7 +4554,7 @@ function spbc_sanitize_settings($settings) // Sanitizing scanner dirs exceptions if ($settings['scanner__dir_exclusions_view']) { - $dirExclusion = new \CleantalkSP\SpbctWP\Settings\DirExclusion(); + $dirExclusion = new \CleantalkSP\SpbctWP\Settings\FilesScanDirExclusion(); $settings['scanner__dir_exclusions_view'] = $dirExclusion->dirExclusionsView($settings['scanner__dir_exclusions_view']); $settings['scanner__dir_exclusions'] = $dirExclusion->dirExclusions($settings['scanner__dir_exclusions_view']); @@ -4562,9 +4562,9 @@ function spbc_sanitize_settings($settings) // Sanitizing frontend scanner URL exclusions if ($settings['scanner__frontend_analysis__domains_exclusions_view']) { - $domainExclusion = new \CleantalkSP\SpbctWP\Settings\DomainExclusion(); + $domainExclusion = new \CleantalkSP\SpbctWP\Settings\FrontendScanDomainExclusion(); - $domainExclusionView = $domainExclusion->domainExclusionsView($settings['scanner__frontend_analysis__domains_exclusions_view']); + $domainExclusionView = $domainExclusion->frontendScanDomainExclusionsView($settings['scanner__frontend_analysis__domains_exclusions_view']); $settings['scanner__frontend_analysis__domains_exclusions_view'] = $domainExclusionView; $domainExclusionSets = $domainExclusion->domainExclusions($settings['scanner__frontend_analysis__domains_exclusions_view']); diff --git a/lib/CleantalkSP/SpbctWP/Settings/DirExclusion.php b/lib/CleantalkSP/SpbctWP/Settings/FilesScanDirExclusion.php old mode 100644 new mode 100755 similarity index 92% rename from lib/CleantalkSP/SpbctWP/Settings/DirExclusion.php rename to lib/CleantalkSP/SpbctWP/Settings/FilesScanDirExclusion.php index 165f7191e..a7dff197d --- a/lib/CleantalkSP/SpbctWP/Settings/DirExclusion.php +++ b/lib/CleantalkSP/SpbctWP/Settings/FilesScanDirExclusion.php @@ -4,7 +4,7 @@ use CleantalkSP\SpbctWP\Helpers\CSV; -class DirExclusion +class FilesScanDirExclusion { private $DIR_EXCLUSION_FILE_NAME = 'spbct_directory_exclusions.txt'; @@ -57,6 +57,10 @@ public function dirExclusions($exclusions) $upload_dirs = $this->getUploadDirs($upload_urls); + $upload_dirs = array_filter($upload_dirs, function ($dir) { + return $dir !== ''; + }); + $dirs = array_merge($dirs, $upload_dirs); $dirs = array_unique($dirs); @@ -106,8 +110,13 @@ private function getUploadDirs($urls) continue; } + $dir_content = array_filter($dir_content, function ($dir) { + return $dir !== ''; + }); + $upload_dirs_stat[$dir] = count($dir_content); } + update_option('spbc_upload_dirs_stat', $upload_dirs_stat); $upload_dirs_merged = []; diff --git a/lib/CleantalkSP/SpbctWP/Settings/DomainExclusion.php b/lib/CleantalkSP/SpbctWP/Settings/FrontendScanDomainExclusion.php old mode 100644 new mode 100755 similarity index 93% rename from lib/CleantalkSP/SpbctWP/Settings/DomainExclusion.php rename to lib/CleantalkSP/SpbctWP/Settings/FrontendScanDomainExclusion.php index 2909f7e43..f90b6e47f --- a/lib/CleantalkSP/SpbctWP/Settings/DomainExclusion.php +++ b/lib/CleantalkSP/SpbctWP/Settings/FrontendScanDomainExclusion.php @@ -5,11 +5,11 @@ use CleantalkSP\SpbctWP\Scanner; use CleantalkSP\SpbctWP\Helpers\CSV; -class DomainExclusion +class FrontendScanDomainExclusion { private $DOMAIN_EXCLUSION_FILE_NAME = 'spbct_allowed_domains.txt'; - public function domainExclusionsView($exclusions) + public function frontendScanDomainExclusionsView($exclusions) { $urls = CSV::parseNSV($exclusions); @@ -111,6 +111,10 @@ private function getUploadUrls($urls) continue; } + $url_content = array_filter($url_content, function ($url) { + return $url !== ''; + }); + $upload_urls_stat[$url] = count($url_content); } update_option('spbc_upload_urls_stat', $upload_urls_stat); diff --git a/security-malware-firewall.php b/security-malware-firewall.php index ca4cbd6f5..18f7f7674 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -276,14 +276,14 @@ function spbc_update_scan_settings_exclusions() $settings = $spbc->settings; try { - $dirExclusion = new \CleantalkSP\SpbctWP\Settings\DirExclusion(); + $dirExclusion = new \CleantalkSP\SpbctWP\Settings\FilesScanDirExclusion(); $settings['scanner__dir_exclusions_view'] = $dirExclusion->dirExclusionsView($settings['scanner__dir_exclusions_view']); $settings['scanner__dir_exclusions'] = $dirExclusion->dirExclusions($settings['scanner__dir_exclusions_view']); - $domainExclusion = new \CleantalkSP\SpbctWP\Settings\DomainExclusion(); + $domainExclusion = new \CleantalkSP\SpbctWP\Settings\FrontendScanDomainExclusion(); - $domainExclusionView = $domainExclusion->domainExclusionsView($settings['scanner__frontend_analysis__domains_exclusions_view']); + $domainExclusionView = $domainExclusion->frontendScanDomainExclusionsView($settings['scanner__frontend_analysis__domains_exclusions_view']); $settings['scanner__frontend_analysis__domains_exclusions_view'] = $domainExclusionView; $domainExclusionSets = $domainExclusion->domainExclusions($settings['scanner__frontend_analysis__domains_exclusions_view']);