improved handling/creation of zone files
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
62790a01f3
commit
d8b2082778
|
@ -102,7 +102,7 @@ class DomainController
|
||||||
*/
|
*/
|
||||||
public function insert(String $name, int $panelID, String $a, String $aaaa): bool|string
|
public function insert(String $name, int $panelID, String $a, String $aaaa): bool|string
|
||||||
{
|
{
|
||||||
// TODO create zone file and include
|
print("here");
|
||||||
$sql = "
|
$sql = "
|
||||||
INSERT INTO " . DatabaseConnection::TABLE_DOMAINS . " (name, panel_id, a, aaaa)
|
INSERT INTO " . DatabaseConnection::TABLE_DOMAINS . " (name, panel_id, a, aaaa)
|
||||||
VALUES (:name, :panel_id, :a, :aaaa)";
|
VALUES (:name, :panel_id, :a, :aaaa)";
|
||||||
|
@ -110,13 +110,13 @@ class DomainController
|
||||||
try {
|
try {
|
||||||
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
||||||
$statement->bindParam(param: ':name', var: $name);
|
$statement->bindParam(param: ':name', var: $name);
|
||||||
$statement->bindParam(param: ':panel_d', var: $panelID);
|
$statement->bindParam(param: ':panel_id', var: $panelID);
|
||||||
$statement->bindParam(param: ':a', var: $a);
|
$statement->bindParam(param: ':a', var: $a);
|
||||||
$statement->bindParam(param: ':aaaa', var: $aaaa);
|
$statement->bindParam(param: ':aaaa', var: $aaaa);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
print(PHP_EOL . "there");
|
||||||
|
|
||||||
|
if ($panel = $this->panelController->findByID(id: intval(value: $panelID))) {
|
||||||
if ($panel = $this->panelController->findByID(id: $panelID)) {
|
|
||||||
$a = $panel['a'];
|
$a = $panel['a'];
|
||||||
$aaaa = $panel['aaaa'];
|
$aaaa = $panel['aaaa'];
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,19 @@ class DomainController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function createIncludeFile()
|
||||||
|
{
|
||||||
|
$domains = $this->findAll();
|
||||||
|
|
||||||
|
print("$this->localZoneFile");
|
||||||
|
$oFile = fopen(filename: $this->localZoneFile, mode: 'w');
|
||||||
|
foreach ($domains as $domain) {
|
||||||
|
fputs(stream: $oFile, data: 'include "' . $this->localZonesDir . $domain['name'] . '";' . PHP_EOL);
|
||||||
|
}
|
||||||
|
fclose(stream: $oFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $id
|
* @param $id
|
||||||
*
|
*
|
||||||
|
@ -216,7 +229,15 @@ class DomainController
|
||||||
*/
|
*/
|
||||||
public function delete($id): int
|
public function delete($id): int
|
||||||
{
|
{
|
||||||
// TODO delete zone file and include
|
if ($domain = $this->findByID(id: $id)) {
|
||||||
|
$zoneFile = $this->localZonesDir . $domain['name'];
|
||||||
|
print($zoneFile . PHP_EOL);
|
||||||
|
if (file_exists(filename: $this->localZonesDir . $domain['name'])) {
|
||||||
|
print("file exists");
|
||||||
|
unlink(filename: $zoneFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
DELETE FROM " . DatabaseConnection::TABLE_DOMAINS . "
|
DELETE FROM " . DatabaseConnection::TABLE_DOMAINS . "
|
||||||
WHERE id = :id";
|
WHERE id = :id";
|
||||||
|
@ -225,6 +246,8 @@ class DomainController
|
||||||
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
|
||||||
$statement->bindParam(param: 'id', var: $id);
|
$statement->bindParam(param: 'id', var: $id);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
|
$this->createIncludeFile();
|
||||||
return $statement->rowCount();
|
return $statement->rowCount();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
exit($e->getMessage());
|
exit($e->getMessage());
|
||||||
|
|
Loading…
Reference in New Issue