changed from content to panel
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
1ad945fbf2
commit
8c7755e096
|
@ -316,7 +316,7 @@ class RequestController
|
||||||
$domain = [
|
$domain = [
|
||||||
'id' => $result->getId(),
|
'id' => $result->getId(),
|
||||||
'name' => $result->getName(),
|
'name' => $result->getName(),
|
||||||
'content' => json_decode(json: $result->getContent())
|
'panel' => $result->getPanel()
|
||||||
];
|
];
|
||||||
$this->result = $domain;
|
$this->result = $domain;
|
||||||
} else {
|
} else {
|
||||||
|
@ -334,7 +334,7 @@ class RequestController
|
||||||
$domain = [
|
$domain = [
|
||||||
'id' => $result->getId(),
|
'id' => $result->getId(),
|
||||||
'name' => $result->getName(),
|
'name' => $result->getName(),
|
||||||
'content' => json_decode(json: $result->getContent())
|
'panel' => $result->getPanel()
|
||||||
];
|
];
|
||||||
$this->result = $domain;
|
$this->result = $domain;
|
||||||
} else {
|
} else {
|
||||||
|
@ -342,7 +342,6 @@ class RequestController
|
||||||
$this->status = "404 Not Found ";
|
$this->status = "404 Not Found ";
|
||||||
$this->message = "The specified domain was not found.";
|
$this->message = "The specified domain was not found.";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->header = "400 Bad request";
|
$this->header = "400 Bad request";
|
||||||
$this->status = "400 Not Found";
|
$this->status = "400 Not Found";
|
||||||
|
@ -362,23 +361,22 @@ class RequestController
|
||||||
{
|
{
|
||||||
$name = $_POST['name'] ?? '';
|
$name = $_POST['name'] ?? '';
|
||||||
$panel = $_POST['panel'] ?? '';
|
$panel = $_POST['panel'] ?? '';
|
||||||
$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($panel)) {
|
||||||
$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 = "A panel ID is required.";
|
||||||
} else {
|
} else {
|
||||||
if ($this->domainRepository->findByName(name: $name)) {
|
if ($this->domainRepository->findByName(name: $name)) {
|
||||||
$this->header = "400 Bad request";
|
$this->header = "400 Bad request";
|
||||||
$this->status = "400 Bad request";
|
$this->status = "400 Bad request";
|
||||||
$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, panel: $panel);
|
||||||
if ($result = $this->domainRepository->insert(domain: $domain)) {
|
if ($result = $this->domainRepository->insert(domain: $domain)) {
|
||||||
$this->header = "201 Created";
|
$this->header = "201 Created";
|
||||||
$this->status = "201 Created";
|
$this->status = "201 Created";
|
||||||
|
@ -396,8 +394,7 @@ class RequestController
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public
|
public function handleDomainPutRequest(): void
|
||||||
function handleDomainPutRequest(): void
|
|
||||||
{
|
{
|
||||||
$putData = fopen(filename: 'php://input', mode: 'r');
|
$putData = fopen(filename: 'php://input', mode: 'r');
|
||||||
$data = fread(stream: $putData, length: 512);
|
$data = fread(stream: $putData, length: 512);
|
||||||
|
@ -409,9 +406,10 @@ class RequestController
|
||||||
}
|
}
|
||||||
$id = $put['id'] ?? 0;
|
$id = $put['id'] ?? 0;
|
||||||
$name = $put['name'] ?? '';
|
$name = $put['name'] ?? '';
|
||||||
$content = $put['content'] ?? "";
|
$panel = $put['panel'] ?? "";
|
||||||
|
|
||||||
if ($id == 0) {
|
if ($id == 0) {
|
||||||
|
$this->header = "400 Bad Request";
|
||||||
$this->status = "400 Bad Request";
|
$this->status = "400 Bad Request";
|
||||||
$this->message = "An ID is required";
|
$this->message = "An ID is required";
|
||||||
} else {
|
} else {
|
||||||
|
@ -420,15 +418,7 @@ class RequestController
|
||||||
$this->message = "Domain with ID : $id doesn't exist.";
|
$this->message = "Domain with ID : $id doesn't exist.";
|
||||||
} else {
|
} else {
|
||||||
// TODO not required, as we rely on the ID
|
// TODO not required, as we rely on the ID
|
||||||
if (empty($name)) {
|
$domain = new Domain(name: $name, panel: $panel, id: $id);
|
||||||
$this->status = "400 Bad Request";
|
|
||||||
$this->message = "A name is required";
|
|
||||||
} else {
|
|
||||||
if (empty($a) && empty($aaaa)) {
|
|
||||||
$this->status = "400 Bad Request";
|
|
||||||
$this->message = "At least one IP address is required.";
|
|
||||||
} else {
|
|
||||||
$domain = new Domain(name: $name, id: $id, content: $content);
|
|
||||||
$this->domainRepository->update(domain: $domain);
|
$this->domainRepository->update(domain: $domain);
|
||||||
$this->header = "201 Updated";
|
$this->header = "201 Updated";
|
||||||
$this->status = "201 Updated";
|
$this->status = "201 Updated";
|
||||||
|
@ -436,8 +426,6 @@ class RequestController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue