From 9db78f23df49755962331dd6442b04104de3fabc Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Sun, 24 Jan 2016 15:13:33 +0100 Subject: [PATCH] Added add-domain.php --- add-domain.php | 100 +++++++++++++++++++++++++++++++++++++++++++++ api/add-domain.php | 66 ++++++++++++++++++++++++++++++ domains.php | 4 +- js/add-domain.js | 76 ++++++++++++++++++++++++++++++++++ 4 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 add-domain.php create mode 100644 api/add-domain.php create mode 100644 js/add-domain.js diff --git a/add-domain.php b/add-domain.php new file mode 100644 index 0000000..e779492 --- /dev/null +++ b/add-domain.php @@ -0,0 +1,100 @@ + + + + + + PDNS Manager - Domains + + + + + + + + + + + + + + + +
+ + +

Add Domain

+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+ + + + diff --git a/api/add-domain.php b/api/add-domain.php new file mode 100644 index 0000000..b8343de --- /dev/null +++ b/api/add-domain.php @@ -0,0 +1,66 @@ +. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +require_once '../config/config-default.php'; +require_once '../lib/database.php'; +require_once '../lib/session.php'; +require_once '../lib/soa-mail.php'; + +$input = json_decode(file_get_contents('php://input')); + +if(isset($input->action) && $input->action == "addDomain") { + $soaData = Array(); + $soaData[] = $input->primary; + $soaData[] = mail_to_soa($input->mail); + $soaData[] = date("Ymd") . "00"; + $soaData[] = $input->refresh; + $soaData[] = $input->retry; + $soaData[] = $input->expire; + $soaData[] = $input->ttl; + + $soaContent = implode(" ", $soaData); + + $db->autocommit(false); + + $stmt = $db->prepare("INSERT INTO domains(name,type) VALUES (?,'MASTER')"); + $stmt->bind_param("s", $input->name); + $stmt->execute(); + $stmt->close(); + + $stmt = $db->prepare("SELECT LAST_INSERT_ID()"); + $stmt->execute(); + $stmt->bind_result($newDomainId); + $stmt->fetch(); + $stmt->close(); + + $stmt = $db->prepare("INSERT INTO records(domain_id,name,type,content,ttl) VALUES (?,?,'SOA',?,?)"); + $stmt->bind_param("issi", $newDomainId, $input->name, $soaContent, $input->ttl); + $stmt->execute(); + $stmt->close(); + + $db->commit(); + + $retval = Array(); + $retval['newId'] = $newDomainId; +} + +if(isset($retval)) { + echo json_encode($retval); +} else { + echo "{}"; +} diff --git a/domains.php b/domains.php index dab1764..bdeb47f 100644 --- a/domains.php +++ b/domains.php @@ -81,13 +81,15 @@ limitations under the License. + + Add