From 58c542664bb146b710ed9e70bd4002e0b2c81e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrkan=20Bi=C3=A7er?= Date: Wed, 21 Aug 2019 02:41:21 +0300 Subject: [PATCH] bug fix on authorityNameserverLookup undefined offset problem --- src/AdvancedDns.php | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/AdvancedDns.php b/src/AdvancedDns.php index f75904c..4abcbb0 100644 --- a/src/AdvancedDns.php +++ b/src/AdvancedDns.php @@ -6,7 +6,7 @@ * @author Gürkan Biçer * @link https://github.com/gurkanbicer/advanced-dns * @license MIT (https://opensource.org/licenses/MIT) - * @version 0.2 + * @version 0.2.1 */ namespace Gurkanbicer\AdvancedDns; @@ -210,6 +210,7 @@ public function authorityNameserverLookup() $actualResults = []; $actualResults['type'] = 'DOMAINNS'; + $actualResults['response'] = []; $countAType = 0; foreach ($lines as $line) { @@ -223,43 +224,47 @@ public function authorityNameserverLookup() 'data' => [] ]; } - } - if ($explLine[3] == 'A') { + } elseif ($explLine[3] == 'A') { $countAType++; $host = rtrim($explLine[0], '.'); $actualResults['response'][$host]['data'][] = $explLine[4]; + } else { + break; } } // if domain pointing different nameservers - if ($countAType == 0) { - foreach ($actualResults['response'] as $key => $value) { - $command2 = $this->getAnswerCmd($key, 'A', null); - $command2 = str_ireplace('+comments', '', $command2); - $process2 = new Process($command2); - $process2->setTimeout(1); - $process2->run(); - - if ($process2->isSuccessful()) { - $outputSnapshot2 = $process2->getOutput(); - if ($outputSnapshot2 === '') - continue; - else - $explResult2 = explode("\n", $outputSnapshot2); - - $lines2 = []; - foreach ($explResult2 as $item2) { - if ($item2 != '') { - $lines2[] = str_ireplace(["\t\t", "\t"], " ", $item2); + if (!empty($actualResults['response'])) { + if ($countAType == 0) { + foreach ($actualResults['response'] as $key => $value) { + $command2 = $this->getAnswerCmd($key, 'A', null); + $command2 = str_ireplace('+comments', '', $command2); + $process2 = new Process($command2); + $process2->setTimeout(1); + $process2->run(); + + if ($process2->isSuccessful()) { + $outputSnapshot2 = $process2->getOutput(); + if ($outputSnapshot2 === '') + continue; + else + $explResult2 = explode("\n", $outputSnapshot2); + + $lines2 = []; + foreach ($explResult2 as $item2) { + if ($item2 != '') { + $lines2[] = str_ireplace(["\t\t", "\t"], " ", $item2); + } } - } - foreach ($lines2 as $line2) { - $explLine2 = explode(' ', $line2); - $actualResults['response'][$key]['data'][] = $explLine2[4]; + foreach ($lines2 as $line2) { + $explLine2 = explode(' ', $line2); + $actualResults['response'][$key]['data'][] = $explLine2[4]; + } } } } + } $actualResults['status'] = $status;