From 8f2545dd7ef00d35c637b37dbb2b3a61acde486e Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 13 Feb 2022 16:35:02 +0100 Subject: [PATCH] changed API call from panel_id to name Signed-off-by: tracer --- src/Controller/BindAPI.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Controller/BindAPI.php b/src/Controller/BindAPI.php index ded0684..4f60d7f 100755 --- a/src/Controller/BindAPI.php +++ b/src/Controller/BindAPI.php @@ -336,12 +336,14 @@ class BindAPI } /** - * @param String $domainName - * @param $panel + * @param String $domainName + * @param \App\Entity\Panel $panel * * @return void + * @throws \DI\DependencyException + * @throws \DI\NotFoundException */ - function checkNS(string $domainName, $panel) + function checkNS(string $domainName, Panel $panel) { if ($this->config['debug']) { $this->log->debug(message: "checkNS()"); @@ -385,34 +387,35 @@ class BindAPI switch ($result['header']) { case 200: - echo COLOR_GREEN . ' OK'; + echo COLOR_GREEN . ' OK'; break; case 404: - echo COLOR_RED . $result['header'] . COLOR_DEFAULT; + echo COLOR_RED . ' ' . $result['header'] . COLOR_DEFAULT; $arguments = $this->parseArguments(); if (!empty($arguments['fix']) && $arguments['fix'] == 'yes') { echo 'trying to fix …'; $body = [ - 'name' => $domainName, - 'panel_id' => $panel['id'] - ]; + 'name' => $domainName, + 'panel' => $panel->getName(), + 'content' => $this->domainController->createPanelContent(panel: $panel->getName()) + ]; try { - if (!empty($nameServer['aaaa'])) { - $this->apiController->sendCommand( + if (!empty($nameServer->getAaaa())) { + $create = $this->apiController->sendCommand( requestType: 'POST', - serverName: $nameServer['name'], + serverName: $nameServer->getName(), versionIP: 6, - apiKey: $nameServer['apikey'], - command: 'domains/name', + apiKey: $nameServer->getApikey(), + command: 'domains', serverType: 'nameserver', body: $body); } else { - $this->apiController->sendCommand( + $create = $this->apiController->sendCommand( requestType: 'POST', - serverName: $nameServer['name'], + serverName: $nameServer->getName(), versionIP: 4, - apiKey: $nameServer['apikey'], - command: 'domains/name', + apiKey: $nameServer->getAPikey(), + command: 'domains', serverType: 'nameserver', body: $body); } @@ -420,6 +423,7 @@ class BindAPI echo $e->getMessage(); exit(1); } + print_r($create); } break; default: