Compare commits

..

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

2 changed files with 22 additions and 31 deletions

View File

@ -336,14 +336,12 @@ class BindAPI
}
/**
* @param String $domainName
* @param \App\Entity\Panel $panel
* @param String $domainName
* @param $panel
*
* @return void
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
*/
function checkNS(string $domainName, Panel $panel)
function checkNS(string $domainName, $panel)
{
if ($this->config['debug']) {
$this->log->debug(message: "checkNS()");
@ -387,35 +385,34 @@ 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' => $panel->getName(),
'content' => $this->domainController->createPanelContent(panel: $panel->getName())
];
'name' => $domainName,
'panel_id' => $panel['id']
];
try {
if (!empty($nameServer->getAaaa())) {
$create = $this->apiController->sendCommand(
if (!empty($nameServer['aaaa'])) {
$this->apiController->sendCommand(
requestType: 'POST',
serverName: $nameServer->getName(),
serverName: $nameServer['name'],
versionIP: 6,
apiKey: $nameServer->getApikey(),
command: 'domains',
apiKey: $nameServer['apikey'],
command: 'domains/name',
serverType: 'nameserver',
body: $body);
} else {
$create = $this->apiController->sendCommand(
$this->apiController->sendCommand(
requestType: 'POST',
serverName: $nameServer->getName(),
serverName: $nameServer['name'],
versionIP: 4,
apiKey: $nameServer->getAPikey(),
command: 'domains',
apiKey: $nameServer['apikey'],
command: 'domains/name',
serverType: 'nameserver',
body: $body);
}
@ -423,7 +420,6 @@ class BindAPI
echo $e->getMessage();
exit(1);
}
print_r($create);
}
break;
default:

View File

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