Compare commits
2 Commits
e48ccbad99
...
f1732c4f26
Author | SHA1 | Date |
---|---|---|
tracer | f1732c4f26 | |
tracer | 8f2545dd7e |
|
@ -337,11 +337,13 @@ class BindAPI
|
|||
|
||||
/**
|
||||
* @param String $domainName
|
||||
* @param $panel
|
||||
* @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()");
|
||||
|
@ -388,31 +390,32 @@ class BindAPI
|
|||
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']
|
||||
'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:
|
||||
|
|
|
@ -361,14 +361,14 @@ class RequestController
|
|||
function handleDomainPostRequest(): void
|
||||
{
|
||||
$name = $_POST['name'] ?? '';
|
||||
$panelID = intval(value: $_POST['panel_id'] ?? 0);
|
||||
$panel = $_POST['panel'] ?? '';
|
||||
$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($panelID)) {
|
||||
if (empty($a) && empty($aaaa) && empty($panel)) {
|
||||
$this->header = "400 Bad Request";
|
||||
$this->status = "400 Bad Request";
|
||||
$this->message = "At least one IP address or panel ID is required.";
|
||||
|
@ -379,9 +379,14 @@ class RequestController
|
|||
$this->message = "Domain: $name already exists.";
|
||||
} else {
|
||||
$domain = new Domain(name: $name, content: $content);
|
||||
$result = $this->domainRepository->insert(domain: $domain);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue