Skip to content

Commit

Permalink
bug fix on authorityNameserverLookup
Browse files Browse the repository at this point in the history
undefined offset problem
  • Loading branch information
gurkanbicer committed Aug 20, 2019
1 parent 8b7ec73 commit 58c5426
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions src/AdvancedDns.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Gürkan Biçer <[email protected]>
* @link https://github.com/gurkanbicer/advanced-dns
* @license MIT (https://opensource.org/licenses/MIT)
* @version 0.2
* @version 0.2.1
*/

namespace Gurkanbicer\AdvancedDns;
Expand Down Expand Up @@ -210,6 +210,7 @@ public function authorityNameserverLookup()

$actualResults = [];
$actualResults['type'] = 'DOMAINNS';
$actualResults['response'] = [];
$countAType = 0;

foreach ($lines as $line) {
Expand All @@ -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;
Expand Down

0 comments on commit 58c5426

Please sign in to comment.