Compare commits

..

No commits in common. "f1732c4f263f1a4091c33208e7a8698318c93f0f" and "e48ccbad9998b632ebebc6b032aee654a844ec82" have entirely different histories.

2 changed files with 22 additions and 31 deletions

View File

@ -337,13 +337,11 @@ class BindAPI
/** /**
* @param String $domainName * @param String $domainName
* @param \App\Entity\Panel $panel * @param $panel
* *
* @return void * @return void
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
*/ */
function checkNS(string $domainName, Panel $panel) function checkNS(string $domainName, $panel)
{ {
if ($this->config['debug']) { if ($this->config['debug']) {
$this->log->debug(message: "checkNS()"); $this->log->debug(message: "checkNS()");
@ -390,32 +388,31 @@ class BindAPI
echo COLOR_GREEN . ' OK'; echo COLOR_GREEN . ' OK';
break; break;
case 404: case 404:
echo COLOR_RED . ' ' . $result['header'] . COLOR_DEFAULT; echo COLOR_RED . $result['header'] . COLOR_DEFAULT;
$arguments = $this->parseArguments(); $arguments = $this->parseArguments();
if (!empty($arguments['fix']) && $arguments['fix'] == 'yes') { if (!empty($arguments['fix']) && $arguments['fix'] == 'yes') {
echo 'trying to fix …'; echo 'trying to fix …';
$body = [ $body = [
'name' => $domainName, 'name' => $domainName,
'panel' => $panel->getName(), 'panel_id' => $panel['id']
'content' => $this->domainController->createPanelContent(panel: $panel->getName())
]; ];
try { try {
if (!empty($nameServer->getAaaa())) { if (!empty($nameServer['aaaa'])) {
$create = $this->apiController->sendCommand( $this->apiController->sendCommand(
requestType: 'POST', requestType: 'POST',
serverName: $nameServer->getName(), serverName: $nameServer['name'],
versionIP: 6, versionIP: 6,
apiKey: $nameServer->getApikey(), apiKey: $nameServer['apikey'],
command: 'domains', command: 'domains/name',
serverType: 'nameserver', serverType: 'nameserver',
body: $body); body: $body);
} else { } else {
$create = $this->apiController->sendCommand( $this->apiController->sendCommand(
requestType: 'POST', requestType: 'POST',
serverName: $nameServer->getName(), serverName: $nameServer['name'],
versionIP: 4, versionIP: 4,
apiKey: $nameServer->getAPikey(), apiKey: $nameServer['apikey'],
command: 'domains', command: 'domains/name',
serverType: 'nameserver', serverType: 'nameserver',
body: $body); body: $body);
} }
@ -423,7 +420,6 @@ class BindAPI
echo $e->getMessage(); echo $e->getMessage();
exit(1); exit(1);
} }
print_r($create);
} }
break; break;
default: default:

View File

@ -361,14 +361,14 @@ class RequestController
function handleDomainPostRequest(): void function handleDomainPostRequest(): void
{ {
$name = $_POST['name'] ?? ''; $name = $_POST['name'] ?? '';
$panel = $_POST['panel'] ?? ''; $panelID = intval(value: $_POST['panel_id'] ?? 0);
$content = $_POST['content'] ?? ''; $content = $_POST['content'] ?? '';
if (empty($name)) { if (empty($name)) {
$this->header = "400 Bad Request"; $this->header = "400 Bad Request";
$this->status = "400 Bad Request"; $this->status = "400 Bad Request";
$this->message = "A name is required"; $this->message = "A name is required";
} else { } else {
if (empty($a) && empty($aaaa) && empty($panel)) { if (empty($a) && empty($aaaa) && empty($panelID)) {
$this->header = "400 Bad Request"; $this->header = "400 Bad Request";
$this->status = "400 Bad Request"; $this->status = "400 Bad Request";
$this->message = "At least one IP address or panel ID is required."; $this->message = "At least one IP address or panel ID is required.";
@ -379,14 +379,9 @@ class RequestController
$this->message = "Domain: $name already exists."; $this->message = "Domain: $name already exists.";
} else { } else {
$domain = new Domain(name: $name, content: $content); $domain = new Domain(name: $name, content: $content);
if ($result = $this->domainRepository->insert(domain: $domain)) { $result = $this->domainRepository->insert(domain: $domain);
$this->status = "201 Created"; $this->status = "201 Created";
$this->message = $result; $this->message = $result;
} else {
$this->header = "500 Server error";
$this->status = "500 Server error";
$this->message = $result;
}
} }
} }
} }