diff --git a/src/Base.php b/src/Base.php index edd326c..e31780b 100644 --- a/src/Base.php +++ b/src/Base.php @@ -582,9 +582,7 @@ public function downloadData($url, $sink) [ 'progress' => function( $downloadTotal, - $downloadedBytes, - $uploadTotal, - $uploadedBytes + $downloadedBytes ) { if ($downloadTotal === 0 || $downloadedBytes === 0) { return; @@ -698,8 +696,6 @@ public function importFilters($fileName) $csv->setHeaderOffset(0); - $header = $csv->getHeader(); - $records = $csv->getRecords(); $totalCount = $csv->count(); diff --git a/src/Firewall.php b/src/Firewall.php index e4ae9fc..724fc2b 100644 --- a/src/Firewall.php +++ b/src/Firewall.php @@ -110,7 +110,7 @@ public function getFilters($defaultStore = false) if (count($ip2locationSortArr) > 0) { ksort($ip2locationSortArr); - foreach ($ip2locationSortArr as $ip2locationSortKey => $ip2locationSort) { + foreach (array_keys($ip2locationSortArr) as $ip2locationSortKey) { $filters = array_merge($filters, $ip2locationSortArr[$ip2locationSortKey]); } } @@ -390,7 +390,6 @@ public function addFilter(array $data, $defaultStore = false) if (isset($data['address'])) { if ($data['address_type'] === 'host' || $data['address_type'] === 'network') { - if ($data['address_type'] === 'network' && !str_contains($data['address'], '/') ) { @@ -408,13 +407,13 @@ public function addFilter(array $data, $defaultStore = false) } if ($data['address_type'] === 'network') { - try { - if (str_contains($data['address'], ':')) { - $range = $this->ip2location->ipTools->cidrToIpv6($data['address']); - } else { - $range = $this->ip2location->ipTools->cidrToIpv4($data['address']); - } - } catch (\throwable $e) { + if (str_contains($data['address'], ':')) { + $range = $this->ip2location->ipTools->cidrToIpv6($data['address']); + } else { + $range = $this->ip2location->ipTools->cidrToIpv4($data['address']); + } + + if (!isset($range['ip_start']) && !isset($range['ip_end'])) { $this->addResponse('Please type correct network address. Format is CIDR - network address/network mask', 1); return false; @@ -622,8 +621,6 @@ public function moveFilter($id)//Move filter from default store to main store return false; } - $oldFilterId = $filter['id']; - unset($filter['id']); $newFilter = $this->addFilter($filter); @@ -695,7 +692,7 @@ public function validateIP($address) $allow_reserved_range = false; } - if (!$allow_private_range) { + if (!$allow_reserved_range) { if (!filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) { $this->addResponse('Please enter correct ip address, reserved range is not allowed.', 1); diff --git a/src/Indexes.php b/src/Indexes.php index 4aded9b..43c1aed 100644 --- a/src/Indexes.php +++ b/src/Indexes.php @@ -268,6 +268,8 @@ public function removeFromIndex($ip) protected function cleanupPath(array $pathArr) { foreach ($pathArr as $path) { + $path = null;//We dont need path as we will be popping it in the end. + $checkPath = join('/', $pathArr); $folders = $this->firewall->localContent->listContents($checkPath)->toArray() ; diff --git a/src/Ip2location.php b/src/Ip2location.php index 9568448..a01e34a 100644 --- a/src/Ip2location.php +++ b/src/Ip2location.php @@ -273,7 +273,7 @@ public function processDownloadedBinFile($download, $trackCounter = null, $proxy $renamedFile = false; - foreach ($folderContents as $key => $content) { + foreach ($folderContents as $content) { if ($content instanceof FileAttributes) { if ($proxy && str_contains($content->path(), '.BIN') &&