diff --git a/src/Controller/BindAPI.php b/src/Controller/BindAPI.php index 190ce12..9ff4c19 100755 --- a/src/Controller/BindAPI.php +++ b/src/Controller/BindAPI.php @@ -13,6 +13,7 @@ define(constant_name: 'COLOR_DEFAULT', value: "\033[39m"); use App\Entity\Domain; +use App\Entity\Panel; use App\Repository\ApikeyRepository; use App\Repository\DomainRepository; use App\Repository\NameserverRepository; @@ -185,7 +186,7 @@ class BindAPI } } else { echo "check all …" . PHP_EOL; - $panels = $this->panelController->findAll(); + $panels = $this->panelRepository->findAll(); foreach ($panels as $panel) { $this->checkSinglePanel(panel: $panel); } @@ -197,16 +198,16 @@ class BindAPI * * @return void */ - public function checkSinglePanel(array $panel): void + public function checkSinglePanel(Panel $panel): void { - echo COLOR_DEFAULT . 'Keyhelp-Panel: ' . COLOR_YELLOW . $panel['name'] . PHP_EOL; - if (!empty($panel['aaaa'])) { + echo COLOR_DEFAULT . 'Keyhelp-Panel: ' . COLOR_YELLOW . $panel->getName() . PHP_EOL; + if (!empty($panel->getAaaa())) { try { $result = $this->checkController->sendCommand( requestType: 'GET', - serverName: $panel['name'], + serverName: $panel->getName(), versionIP: 6, - apiKey: $panel['apikey'], + apiKey: $panel->getApikey(), command: 'domains', serverType: 'panel' ); @@ -217,9 +218,9 @@ class BindAPI try { $result = $this->checkController->sendCommand( requestType: 'GET', - serverName: $panel['name'], + serverName: $panel->getName(), versionIP: 4, - apiKey: $panel['apikey'], + apiKey: $panel->getApikey(), command: 'domains', serverType: 'panel'); } catch (DependencyException|NotFoundException $e) { @@ -241,14 +242,14 @@ class BindAPI $maxDomainName = 0; // TODO this is ugly code ↓↓↓ foreach ($domains as $domain) { - if ($this->isValidSecondLevelDomain(domainName: $domain->domain, panel: $panel['name'], parent: $domain->id_parent_domain) && (strlen(string: $domain->domain) > $maxDomainName)) { + if ($this->isValidSecondLevelDomain(domainName: $domain->domain, panel: $panel->getName(), parent: $domain->id_parent_domain) && (strlen(string: $domain->domain) > $maxDomainName)) { $maxDomainName = strlen(string: $domain->domain); } } $domainCount = 0; foreach ($domains as $domain) { - if ($this->isValidSecondLevelDomain(domainName: $domain->domain, panel: $panel['name'], parent: $domain->id_parent_domain)) { + if ($this->isValidSecondLevelDomain(domainName: $domain->domain, panel: $panel->getName(), parent: $domain->id_parent_domain)) { echo COLOR_DEFAULT . "Domain: " . COLOR_YELLOW . str_pad(string: $domain->domain, length: $maxDomainName); $this->checkNS(domainName: $domain->domain, panel: $panel); $domainCount++; @@ -294,28 +295,33 @@ class BindAPI function checkNS(string $domainName, $panel) { try { - $nameServers = $this->nameserverController->findAll(); + $nameServers = $this->nameserverRepository->findAll(); } catch (DependencyException|NotFoundException $e) { echo $e->getMessage(); exit(1); } foreach ($nameServers as $nameServer) { - echo COLOR_YELLOW . ' ' . $nameServer['name']; try { - if (!empty($nameServer['aaaa'])) { + echo COLOR_YELLOW . ' ' . $nameServer->getName(); + } catch (DependencyException|NotFoundException $e) { + echo $e->getMessage(); + exit(1); + } + try { + if (!empty($nameServer->getName())) { $result = $this->checkController->sendCommand( requestType: 'GET', - serverName: $nameServer['name'], + serverName: $nameServer->getName(), versionIP: 6, - apiKey: $nameServer['apikey'], + apiKey: $nameServer->getApikey(), command: 'domains/' . $domainName, serverType: 'nameserver'); } else { $result = $this->checkController->sendCommand( requestType: 'GET', - serverName: $nameServer['name'], + serverName: $nameServer->getName(), versionIP: 4, - apiKey: $nameServer['apikey'], + apiKey: $nameServer->getApikey(), command: 'domains', serverType: 'nameserver' . $domainName); }