From a105edc4ab2ffcef9055b10f19827730445122c6 Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Sun, 5 Feb 2017 17:12:38 +0100 Subject: [PATCH] Fixed whitespace errors, removed unneccessary tables --- api/add-domain.php | 16 ++-- api/domains.php | 36 ++++---- api/edit-master.php | 106 ++++++++++++------------ api/edit-remote.php | 36 ++++---- api/edit-user.php | 49 ++++++----- api/install.php | 186 +++++++++--------------------------------- api/password.php | 4 +- api/remote.php | 38 ++++----- api/upgrade.php | 171 +++++++------------------------------- api/users.php | 12 +-- domains.php | 6 +- edit-master.php | 2 +- install.php | 8 +- lib/checkversion.php | 14 ++-- lib/database.php | 4 +- lib/update-serial.php | 6 +- 16 files changed, 236 insertions(+), 458 deletions(-) diff --git a/api/add-domain.php b/api/add-domain.php index 77b85e7..246af49 100644 --- a/api/add-domain.php +++ b/api/add-domain.php @@ -43,7 +43,7 @@ if(isset($input->action) && $input->action == "addDomain") { $soaData[] = $input->expire; $soaData[] = $input->ttl; - $domainsName = strtolower(preg_replace('/\s+/', '', $input->name)); + $domainsName = strtolower(preg_replace('/\s+/', '', $input->name)); $soaContent = implode(" ", $soaData); @@ -55,16 +55,16 @@ if(isset($input->action) && $input->action == "addDomain") { $stmt->execute(); $stmt = $db->prepare("SELECT MAX(id) FROM domains WHERE name=:name AND type=:type"); - $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->execute(); - $newDomainId = $stmt->fetchColumn(); + $newDomainId = $stmt->fetchColumn(); $stmt = $db->prepare("INSERT INTO records(domain_id,name,type,content,ttl) VALUES (:domain_id,:name,'SOA',:content,:ttl)"); - $stmt->bindValue(':domain_id', $newDomainId, PDO::PARAM_INT); - $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); - $stmt->bindValue(':content', $soaContent, PDO::PARAM_STR); - $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $newDomainId, PDO::PARAM_INT); + $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); + $stmt->bindValue(':content', $soaContent, PDO::PARAM_STR); + $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); $stmt->execute(); $db->commit(); diff --git a/api/domains.php b/api/domains.php index d35e728..ab1fe53 100644 --- a/api/domains.php +++ b/api/domains.php @@ -65,18 +65,18 @@ if(isset($input->action) && $input->action == "getDomains") { $type_filter_used = 1; } - $stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR); - $stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); - $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); - $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR); + $stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); + $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); + $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); $stmt->execute(); - $result = $stmt->fetchColumn(); + $result = $stmt->fetchColumn(); - if ($result == 0) { - $result = 1; - } + if ($result == 0) { + $result = 1; + } // Initialize the return value $retval = Array(); @@ -149,14 +149,14 @@ if(isset($input->action) && $input->action == "getDomains") { $type_filter_used = 1; } - $stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR); - $stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); - $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); - $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR); + $stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); + $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); + $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); $stmt->execute(); - + while($obj = $stmt->fetchObject()) { $retval['data'][] = $obj; } @@ -168,7 +168,7 @@ if(isset($input->action) && $input->action == "deleteDomain") { $db->beginTransaction(); $stmt = $db->prepare("DELETE FROM permissions WHERE domain=:domain_id"); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $stmt = $db->prepare("DELETE FROM remote WHERE record IN (SELECT id FROM records WHERE domain_id=:domain_id)"); diff --git a/api/edit-master.php b/api/edit-master.php index dc486ab..c1e0a3f 100644 --- a/api/edit-master.php +++ b/api/edit-master.php @@ -31,9 +31,9 @@ if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { //Permission check if(isset($input->domain)) { - $permquery = $db->prepare("SELECT COUNT(*) FROM permissions WHERE userid=:user AND domain=:domain"); - $permquery->bindValue(':user', $_SESSION['id'], PDO::PARAM_INT); - $permquery->bindValue(':domain', $input->domain, PDO::PARAM_INT); + $permquery = $db->prepare("SELECT COUNT(*) FROM permissions WHERE userid=:user AND domain=:domain"); + $permquery->bindValue(':user', $_SESSION['id'], PDO::PARAM_INT); + $permquery->bindValue(':domain', $input->domain, PDO::PARAM_INT); $permquery->execute(); if($permquery->fetchColumn() < 1 && $_SESSION['type'] != "admin") { echo "Permission denied!"; @@ -113,11 +113,11 @@ if(isset($input->action) && $input->action == "getRecords") { $domainId = (int)$input->domain; - $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); - $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':content1', $content_filter, PDO::PARAM_STR); - $stmt->bindValue(':content2', $content_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); + $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':content1', $content_filter, PDO::PARAM_STR); + $stmt->bindValue(':content2', $content_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $retval = Array(); @@ -133,7 +133,7 @@ if(isset($input->action) && $input->action == "getSoa") { $domainId = (int)$input->domain; $stmt = $db->prepare("SELECT content FROM records WHERE type='SOA' AND domain_id=:domain_id LIMIT 1"); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $content = $stmt->fetchColumn(); @@ -149,8 +149,6 @@ if(isset($input->action) && $input->action == "getSoa") { $retval['retry'] = $content[4]; $retval['expire'] = $content[5]; $retval['ttl'] = $content[6]; - - } //Action for getting SOA Serial @@ -158,7 +156,7 @@ if(isset($input->action) && $input->action == "getSerial") { $domainId = (int)$input->domain; $stmt = $db->prepare("SELECT content FROM records WHERE type='SOA' AND domain_id=:domain_id LIMIT 1"); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $content = $stmt->fetchColumn(); @@ -174,12 +172,12 @@ if(isset($input->action) && $input->action == "getSerial") { if(isset($input->action) && $input->action == "saveSoa") { $domainId = (int)$input->domain; - $db->beginTransaction(); + $db->beginTransaction(); $stmt = $db->prepare("SELECT content FROM records WHERE type='SOA' AND domain_id=:domain_id LIMIT 1"); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); - $content = $stmt->fetchColumn();; + $content = $stmt->fetchColumn();; $content = explode(" ", $content); $serial = $content[2]; @@ -193,9 +191,9 @@ if(isset($input->action) && $input->action == "saveSoa") { $newsoa .= $input->ttl; $stmt = $db->prepare("UPDATE records SET content=:content,ttl=:ttl WHERE type='SOA' AND domain_id=:domain_id"); - $stmt->bindValue(':content', $newsoa, PDO::PARAM_STR); - $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':content', $newsoa, PDO::PARAM_STR); + $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $db->commit(); @@ -209,16 +207,16 @@ if(isset($input->action) && $input->action == "saveSoa") { if(isset($input->action) && $input->action == "saveRecord") { $domainId = $input->domain; $recordName = strtolower(preg_replace('/\s+/', '', $input->name)); - $recordContent = trim($input->content); - + $recordContent = trim($input->content); + $stmt = $db->prepare("UPDATE records SET name=:name,type=:type,content=:content,ttl=:ttl,prio=:prio WHERE id=:id AND domain_id=:domain_id"); - $stmt->bindValue(':name', $recordName, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); - $stmt->bindValue(':content', $recordContent, PDO::PARAM_STR); - $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); - $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); - $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':name', $recordName, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':content', $recordContent, PDO::PARAM_STR); + $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); + $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); + $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); update_serial($db, $domainId); } @@ -226,32 +224,32 @@ if(isset($input->action) && $input->action == "saveRecord") { //Action for adding Record if(isset($input->action) && $input->action == "addRecord") { $domainId = $input->domain; - $recordName = strtolower(preg_replace('/\s+/', '', $input->name)); - $recordContent = trim($input->content); - - $db->beginTransaction(); - - $stmt = $db->prepare("INSERT INTO records (domain_id, name, type, content, prio, ttl) VALUES (:domain_id,:name,:type,:content,:prio,:ttl)"); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); - $stmt->bindValue(':name', $recordName, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); - $stmt->bindValue(':content', $recordContent, PDO::PARAM_STR); - $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); - $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); - $stmt->execute(); - - $stmt = $db->prepare("SELECT MAX(id) FROM records WHERE domain_id=:domain_id AND name=:name AND type=:type AND content=:content AND prio=:prio AND ttl=:ttl"); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); - $stmt->bindValue(':name', $recordName, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); - $stmt->bindValue(':content', $recordContent, PDO::PARAM_STR); - $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); - $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); - $stmt->execute(); - $newId = $stmt->fetchColumn(); + $recordName = strtolower(preg_replace('/\s+/', '', $input->name)); + $recordContent = trim($input->content); + + $db->beginTransaction(); + + $stmt = $db->prepare("INSERT INTO records (domain_id, name, type, content, prio, ttl) VALUES (:domain_id,:name,:type,:content,:prio,:ttl)"); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':name', $recordName, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':content', $recordContent, PDO::PARAM_STR); + $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); + $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); + $stmt->execute(); + + $stmt = $db->prepare("SELECT MAX(id) FROM records WHERE domain_id=:domain_id AND name=:name AND type=:type AND content=:content AND prio=:prio AND ttl=:ttl"); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':name', $recordName, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':content', $recordContent, PDO::PARAM_STR); + $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); + $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); + $stmt->execute(); + $newId = $stmt->fetchColumn(); + + $db->commit(); - $db->commit(); - $retval = Array(); $retval['newId'] = $newId; @@ -264,8 +262,8 @@ if(isset($input->action) && $input->action == "removeRecord") { $recordId = $input->id; $stmt = $db->prepare("DELETE FROM records WHERE id=:id AND domain_id=:domain_id"); - $stmt->bindValue(':id', $recordId, PDO::PARAM_INT); - $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); + $stmt->bindValue(':id', $recordId, PDO::PARAM_INT); + $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); update_serial($db, $domainId); diff --git a/api/edit-remote.php b/api/edit-remote.php index b4f1155..93e2004 100644 --- a/api/edit-remote.php +++ b/api/edit-remote.php @@ -30,8 +30,8 @@ if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { //Permission check if(isset($input->record)) { $permquery = $db->prepare("SELECT COUNT(*) FROM records JOIN permissions ON records.domain_id=permissions.domain WHERE userid=:user AND records.id=:id"); - $permquery->bindValue(':user', $_SESSION['id'], PDO::PARAM_INT); - $permquery->bindValue(':id', $input->record, PDO::PARAM_INT); + $permquery->bindValue(':user', $_SESSION['id'], PDO::PARAM_INT); + $permquery->bindValue(':id', $input->record, PDO::PARAM_INT); $permquery->execute(); if($permquery->fetchColumn() < 1 && $_SESSION['type'] != "admin") { echo "Permission denied!"; @@ -48,7 +48,7 @@ if(isset($input->action) && $input->action == "getPermissions") { $sql = "SELECT id, description, type FROM remote WHERE record=:record"; $stmt = $db->prepare($sql); - $stmt->bindValue(':record', $input->record, PDO::PARAM_INT); + $stmt->bindValue(':record', $input->record, PDO::PARAM_INT); $stmt->execute(); $retval = Array(); @@ -66,9 +66,9 @@ if(isset($input->action) && $input->action == "addPassword") { $sql = "INSERT INTO remote(record,description,type,security) VALUES (:record,:description,'password',:security)"; $stmt = $db->prepare($sql); - $stmt->bindValue(':record', $input->record, PDO::PARAM_INT); - $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); - $stmt->bindValue(':security', $passwordHash, PDO::PARAM_STR); + $stmt->bindValue(':record', $input->record, PDO::PARAM_INT); + $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); + $stmt->bindValue(':security', $passwordHash, PDO::PARAM_STR); $stmt->execute(); } @@ -77,9 +77,9 @@ if(isset($input->action) && $input->action == "addKey") { $sql = "INSERT INTO remote(record,description,type,security) VALUES (:record,:description,'key',:security)"; $stmt = $db->prepare($sql); - $stmt->bindValue(':record', $input->record, PDO::PARAM_INT); - $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); - $stmt->bindValue(':security', $input->key, PDO::PARAM_STR); + $stmt->bindValue(':record', $input->record, PDO::PARAM_INT); + $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); + $stmt->bindValue(':security', $input->key, PDO::PARAM_STR); $stmt->execute(); } @@ -89,14 +89,14 @@ if(isset($input->action) && $input->action == "changePassword") { $passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $sql = "UPDATE remote SET description=:description,security=:security WHERE id=:id"; $stmt = $db->prepare($sql); - $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); - $stmt->bindValue(':security', $passwordHash, PDO::PARAM_STR); - $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); + $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); + $stmt->bindValue(':security', $passwordHash, PDO::PARAM_STR); + $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->execute(); } else { $sql = "UPDATE remote SET description=:description WHERE id=:id"; $stmt = $db->prepare($sql); - $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); + $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->execute(); } @@ -106,10 +106,10 @@ if(isset($input->action) && $input->action == "changePassword") { if(isset($input->action) && $input->action == "changeKey") { $sql = "UPDATE remote SET description=:description,security=:security WHERE id=:id"; $stmt = $db->prepare($sql); - - $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); - $stmt->bindValue(':security', $input->key, PDO::PARAM_STR); - $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); + + $stmt->bindValue(':description', $input->description, PDO::PARAM_STR); + $stmt->bindValue(':security', $input->key, PDO::PARAM_STR); + $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->execute(); } @@ -117,7 +117,7 @@ if(isset($input->action) && $input->action == "changeKey") { if(isset($input->action) && $input->action == "getKey") { $sql = "SELECT security FROM remote WHERE id=:id AND type='key' LIMIT 1"; $stmt = $db->prepare($sql); - $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); + $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->execute(); $key = $stmt->fetchColumn(); diff --git a/api/edit-user.php b/api/edit-user.php index 0f48084..9b33394 100644 --- a/api/edit-user.php +++ b/api/edit-user.php @@ -38,18 +38,17 @@ if(isset($input->action) && $input->action == "addUser") { $db->beginTransaction(); $stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:name,:password,:type)"); - - $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); - $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); + $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->execute(); - $stmt = $db->prepare("SELECT MAX(id) FROM users WHERE name=:name AND password=:password AND type=:type"); - $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); - $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt = $db->prepare("SELECT MAX(id) FROM users WHERE name=:name AND password=:password AND type=:type"); + $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); + $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->execute(); - $newUserId = $stmt->fetchColumn(); + $newUserId = $stmt->fetchColumn(); $db->commit(); @@ -59,10 +58,10 @@ if(isset($input->action) && $input->action == "addUser") { if(isset($input->action) && $input->action == "getUserData") { $stmt = $db->prepare("SELECT name,type FROM users WHERE id=:id LIMIT 1"); - $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); + $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->execute(); - $stmt->bindColumn('name', $userName); - $stmt->bindColumn('type', $userType); + $stmt->bindColumn('name', $userName); + $stmt->bindColumn('type', $userType); $stmt->fetch(PDO::FETCH_BOUND); $retval = Array(); @@ -74,16 +73,16 @@ if(isset($input->action) && $input->action == "saveUserChanges") { if(isset($input->password)) { $passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $stmt = $db->prepare("UPDATE users SET name=:name,password=:password,type=:type WHERE id=:id"); - $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); - $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); - $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); + $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); + $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->execute(); } else { $stmt = $db->prepare("UPDATE users SET name=:name,type=:type WHERE id=:id"); - $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); - $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); - $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); + $stmt->bindValue(':name', $input->name, PDO::PARAM_STR); + $stmt->bindValue(':type', $input->type, PDO::PARAM_STR); + $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->execute(); } } @@ -111,8 +110,8 @@ if(isset($input->action) && $input->action == "removePermission") { $stmt = $db->prepare("DELETE FROM permissions WHERE userid=:user AND domain=:domain"); - $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); - $stmt->bindValue(':domain', $input->domainId, PDO::PARAM_INT); + $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); + $stmt->bindValue(':domain', $input->domainId, PDO::PARAM_INT); $stmt->execute(); } @@ -121,8 +120,8 @@ if(isset($input->action) && $input->action == "searchDomains" && isset($input->t $searchTerm = "%" . $input->term . "%"; - $stmt->bindValue(':name', $searchTerm, PDO::PARAM_STR); - $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); + $stmt->bindValue(':name', $searchTerm, PDO::PARAM_STR); + $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); $stmt->execute(); $retval = Array(); @@ -136,8 +135,8 @@ if(isset($input->action) && $input->action == "addPermissions") { $stmt = $db->prepare("INSERT INTO permissions(userid,domain) VALUES (:user,:domain)"); foreach($input->domains as $domain) { - $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); - $stmt->bindValue(':domain', $domain, PDO::PARAM_INT); + $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); + $stmt->bindValue(':domain', $domain, PDO::PARAM_INT); $stmt->execute(); } } diff --git a/api/install.php b/api/install.php index d35b5b7..ec1d37e 100644 --- a/api/install.php +++ b/api/install.php @@ -83,7 +83,7 @@ CREATE TABLE IF NOT EXISTS remote ( nonce varchar(255) DEFAULT NULL, PRIMARY KEY (id), KEY record (record), - CONSTRAINT remote_ibfk_1 FOREIGN KEY (record) REFERENCES records (id) ON DELETE CASCADE + CONSTRAINT remote_ibfk_1 FOREIGN KEY (record) REFERENCES records (id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE IF NOT EXISTS options ( @@ -94,58 +94,7 @@ CREATE TABLE IF NOT EXISTS options ( DELETE FROM options where name='schema_version'; -INSERT INTO options(name,value) VALUES ('schema_version', 4); - -CREATE TABLE IF NOT EXISTS supermasters ( - ip VARCHAR(64) NOT NULL, - nameserver VARCHAR(255) NOT NULL, - account VARCHAR(40) NOT NULL, - PRIMARY KEY (ip, nameserver) -) Engine=InnoDB DEFAULT CHARSET=latin1; - - -CREATE TABLE IF NOT EXISTS comments ( - id INT AUTO_INCREMENT, - domain_id INT NOT NULL, - name VARCHAR(255) NOT NULL, - type VARCHAR(10) NOT NULL, - modified_at INT NOT NULL, - account VARCHAR(40) NOT NULL, - comment VARCHAR(64000) NOT NULL, - PRIMARY KEY (id), - KEY comments_domain_id_idx (domain_id), - KEY comments_name_type_idx (name,type), - KEY comments_order_idx (domain_id, modified_at) -) Engine=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE IF NOT EXISTS domainmetadata ( - id INT AUTO_INCREMENT, - domain_id INT NOT NULL, - kind VARCHAR(32), - content TEXT, - PRIMARY KEY (id), - KEY domainmetadata_idx (domain_id, kind) -) Engine=InnoDB DEFAULT CHARSET=latin1; - - -CREATE TABLE IF NOT EXISTS cryptokeys ( - id INT AUTO_INCREMENT, - domain_id INT NOT NULL, - flags INT NOT NULL, - active BOOL, - content TEXT, - PRIMARY KEY(id), - KEY domainidindex (domain_id) -) Engine=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE IF NOT EXISTS tsigkeys ( - id INT AUTO_INCREMENT, - name VARCHAR(255), - algorithm VARCHAR(50), - secret VARCHAR(255), - PRIMARY KEY (id), - UNIQUE KEY namealgoindex (name, algorithm) -) Engine=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO options(name,value) VALUES ('schema_version', 3); "; $sql["pgsql"]=" @@ -231,66 +180,9 @@ CREATE TABLE IF NOT EXISTS options ( DELETE FROM options where name='schema_version'; -INSERT INTO options(name,value) VALUES ('schema_version', 4); - -CREATE TABLE IF NOT EXISTS supermasters ( - ip INET NOT NULL, - nameserver VARCHAR(255) NOT NULL, - account VARCHAR(40) NOT NULL, - PRIMARY KEY(ip, nameserver) -); - - -CREATE TABLE IF NOT EXISTS comments ( - id SERIAL PRIMARY KEY, - domain_id INT NOT NULL, - name VARCHAR(255) NOT NULL, - type VARCHAR(10) NOT NULL, - modified_at INT NOT NULL, - account VARCHAR(40) DEFAULT NULL, - comment VARCHAR(65535) NOT NULL, - CONSTRAINT domain_exists - FOREIGN KEY(domain_id) REFERENCES domains(id) - ON DELETE CASCADE, - CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) -); - -CREATE INDEX IF NOT EXISTS comments_domain_id_idx ON comments (domain_id); -CREATE INDEX IF NOT EXISTS comments_name_type_idx ON comments (name, type); -CREATE INDEX IF NOT EXISTS comments_order_idx ON comments (domain_id, modified_at); - - -CREATE TABLE IF NOT EXISTS domainmetadata ( - id SERIAL PRIMARY KEY, - domain_id INT REFERENCES domains(id) ON DELETE CASCADE, - kind VARCHAR(32), - content TEXT -); - -CREATE INDEX IF NOT EXISTS domainidmetaindex ON domainmetadata(domain_id); - - -CREATE TABLE IF NOT EXISTS cryptokeys ( - id SERIAL PRIMARY KEY, - domain_id INT REFERENCES domains(id) ON DELETE CASCADE, - flags INT NOT NULL, - active BOOL, - content TEXT -); - -CREATE INDEX IF NOT EXISTS domainidindex ON cryptokeys(domain_id); - - -CREATE TABLE IF NOT EXISTS tsigkeys ( - id SERIAL PRIMARY KEY, - name VARCHAR(255), - algorithm VARCHAR(50), - secret VARCHAR(255), - CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) -); - -CREATE UNIQUE INDEX IF NOT EXISTS namealgoindex ON tsigkeys(name, algorithm); +INSERT INTO options(name,value) VALUES ('schema_version', 3); "; + try { $db = new PDO("$input->type:dbname=$input->database;host=$input->host;port=$input->port", $input->user, $input->password); } @@ -303,42 +195,42 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (!isset($retval)) { $passwordHash = password_hash($input->userPassword, PASSWORD_DEFAULT); + + $queries = explode(";", $sql[$input->type]); + + $db->beginTransaction(); + + foreach ($queries as $query) { + if (preg_replace('/\s+/', '', $query) != '') { + $db->exec($query); + } + } + + $db->commit(); + + $stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:user,:hash,'admin')"); + $stmt->bindValue(':user', $input->userName, PDO::PARAM_STR); + $stmt->bindValue(':hash', $passwordHash, PDO::PARAM_STR); + $stmt->execute(); + + $configFile = Array(); + + $configFile[] = 'host) . "';"; + $configFile[] = '$config[\'db_user\'] = \'' . addslashes($input->user) . "';"; + $configFile[] = '$config[\'db_password\'] = \'' . addslashes($input->password) . "';"; + $configFile[] = '$config[\'db_name\'] = \'' . addslashes($input->database) . "';"; + $configFile[] = '$config[\'db_port\'] = ' . addslashes($input->port) . ";"; + $configFile[] = '$config[\'db_type\'] = \'' . addslashes($input->type) . "';"; - $queries = explode(";", $sql[$input->type]); - - $db->beginTransaction(); - - foreach ($queries as $query) { - if (preg_replace('/\s+/', '', $query) != '') { - $db->exec($query); - } - } - - $db->commit(); - - $stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:user,:hash,'admin')"); - $stmt->bindValue(':user', $input->userName, PDO::PARAM_STR); - $stmt->bindValue(':hash', $passwordHash, PDO::PARAM_STR); - $stmt->execute(); - - $configFile = Array(); - - $configFile[] = 'host) . "';"; - $configFile[] = '$config[\'db_user\'] = \'' . addslashes($input->user) . "';"; - $configFile[] = '$config[\'db_password\'] = \'' . addslashes($input->password) . "';"; - $configFile[] = '$config[\'db_name\'] = \'' . addslashes($input->database) . "';"; - $configFile[] = '$config[\'db_port\'] = ' . addslashes($input->port) . ";"; - $configFile[] = '$config[\'db_type\'] = \'' . addslashes($input->type) . "';"; - - $retval['status'] = "success"; - try { - file_put_contents("../config/config-user.php", implode("\n", $configFile)); - } - catch (Exception $e) { - $retval['status'] = "error"; - $retval['message'] = serialize($e); - } + $retval['status'] = "success"; + try { + file_put_contents("../config/config-user.php", implode("\n", $configFile)); + } + catch (Exception $e) { + $retval['status'] = "error"; + $retval['message'] = serialize($e); + } } if(isset($retval)) { diff --git a/api/password.php b/api/password.php index 60d41c2..5b51c48 100644 --- a/api/password.php +++ b/api/password.php @@ -31,8 +31,8 @@ if(isset($input->action) && $input->action == "changePassword") { $passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $stmt = $db->prepare("UPDATE users SET password=:password WHERE id=:id"); - $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); - $stmt->bindValue(':id', $_SESSION['id'], PDO::PARAM_INT); + $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); + $stmt->bindValue(':id', $_SESSION['id'], PDO::PARAM_INT); $stmt->execute(); } diff --git a/api/remote.php b/api/remote.php index 3ca5a71..ea2f808 100644 --- a/api/remote.php +++ b/api/remote.php @@ -28,11 +28,11 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { $input_content = filter_input(INPUT_GET, "content"); $stmt = $db->prepare("SELECT security,record FROM remote WHERE type='password' AND id=:id LIMIT 1"); - $stmt->bindValue(':id', $input_id, PDO::PARAM_INT); + $stmt->bindValue(':id', $input_id, PDO::PARAM_INT); $stmt->execute(); - $stmt->bindColumn('security', $passwordHash); - $stmt->bindColumn('record', $record); - $stmt->fetch(PDO::FETCH_BOUND); + $stmt->bindColumn('security', $passwordHash); + $stmt->bindColumn('record', $record); + $stmt->fetch(PDO::FETCH_BOUND); if(!password_verify($input_password, $passwordHash)) { $return['status'] = "error"; @@ -42,15 +42,15 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { } $stmt = $db->prepare("UPDATE records SET content=:content WHERE name=:name AND id=:id"); - $stmt->bindValue(':content', $input_content, PDO::PARAM_STR); - $stmt->bindValue(':name', $input_domain, PDO::PARAM_STR); - $stmt->bindValue(':id', $record, PDO::PARAM_INT); + $stmt->bindValue(':content', $input_content, PDO::PARAM_STR); + $stmt->bindValue(':name', $input_domain, PDO::PARAM_STR); + $stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->execute(); $stmt = $db->prepare("SELECT domain_id FROM records WHERE id=:id LIMIT 1"); $stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->execute(); - $domain_id = $stmt->fetchColumn(); + $domain_id = $stmt->fetchColumn(); update_serial($db, $domain_id); @@ -74,10 +74,10 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { if(isset($input->domain) && isset($input->id) && isset($input->content)) { $stmt = $db->prepare("SELECT E.name,E.id FROM remote R JOIN records E ON R.record = E.id WHERE R.id=:id LIMIT 1"); - $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); + $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->execute(); - $stmt->bindColumn('E.name', $domainName); - $stmt->bindColumn('E.id', $record); + $stmt->bindColumn('E.name', $domainName); + $stmt->bindColumn('E.id', $record); $stmt->fetch(PDO::FETCH_BOUND); if($domainName != $input->domain) { @@ -92,8 +92,8 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { $dbNonce = $newNonce . ":" . time(); $stmt = $db->prepare("UPDATE remote SET nonce=:nonce WHERE id=:id"); - $stmt->bindValue(':nonce', $dbNonce, PDO::PARAM_STR); - $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); + $stmt->bindValue(':nonce', $dbNonce, PDO::PARAM_STR); + $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->execute(); $return['nonce'] = $newNonce; @@ -103,9 +103,9 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { $stmt = $db->prepare("SELECT security,nonce FROM remote WHERE id=:id LIMIT 1"); $stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->execute(); - $stmt->bindColumn('security', $pubkey); - $stmt->bindColumn('nonce', $dbNonce); - $stmt->fetch(PDO::FETCH_BOUND); + $stmt->bindColumn('security', $pubkey); + $stmt->bindColumn('nonce', $dbNonce); + $stmt->fetch(PDO::FETCH_BOUND); $nonce = explode(":", $dbNonce); @@ -127,9 +127,9 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { } $stmt = $db->prepare("UPDATE records SET content=:content WHERE name=:name AND id=:id"); - $stmt->bindValue(':content', $input->content, PDO::PARAM_STR); - $stmt->bindValue(':name', $input->domain, PDO::PARAM_STR); - $stmt->bindValue(':id', $record, PDO::PARAM_INT); + $stmt->bindValue(':content', $input->content, PDO::PARAM_STR); + $stmt->bindValue(':name', $input->domain, PDO::PARAM_STR); + $stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->execute(); $stmt = $db->prepare("SELECT domain_id FROM records WHERE id=:id LIMIT 1"); diff --git a/api/upgrade.php b/api/upgrade.php index 19e4323..20d004a 100644 --- a/api/upgrade.php +++ b/api/upgrade.php @@ -55,17 +55,16 @@ if(isset($input->action) && $input->action == "requestUpgrade") { INSERT INTO options(name,value) VALUES ('schema_version', 1); "; $sql["pgsql"] = "INSERT INTO options(name,value) VALUES ('schema_version', 1);"; - $queries = explode(";", $sql[$dbType]); - - $db->beginTransaction(); - - foreach ($queries as $query) { - if (preg_replace('/\s+/', '', $query) != '') { - $db->exec($query); - } - } + $queries = explode(";", $sql[$dbType]); + $db->beginTransaction(); - $db->commit(); + foreach ($queries as $query) { + if (preg_replace('/\s+/', '', $query) != '') { + $db->exec($query); + } + } + + $db->commit(); } if($currentVersion < 2) { $sql["mysql"] = " @@ -89,18 +88,17 @@ if(isset($input->action) && $input->action == "requestUpgrade") { UPDATE options SET value=2 WHERE name='schema_version'; "; $sql["pgsql"] = "UPDATE options SET value=2 WHERE name='schema_version';"; - $queries = explode(";", $sql[$dbType]); - - $db->beginTransaction(); - - foreach ($queries as $query) { - if (preg_replace('/\s+/', '', $query) != '') { - $db->exec($query); - } - } + $queries = explode(";", $sql[$dbType]); - $db->commit(); - + $db->beginTransaction(); + + foreach ($queries as $query) { + if (preg_replace('/\s+/', '', $query) != '') { + $db->exec($query); + } + } + + $db->commit(); } if($currentVersion < 3) { $sql["mysql"] = " @@ -118,129 +116,20 @@ if(isset($input->action) && $input->action == "requestUpgrade") { UPDATE options SET value=3 WHERE name='schema_version'; "; $sql["pgsql"] = "UPDATE options SET value=3 WHERE name='schema_version';"; - $queries = explode(";", $sql[$dbType]); - - $db->beginTransaction(); - - foreach ($queries as $query) { - if (preg_replace('/\s+/', '', $query) != '') { - $db->exec($query); - } - } - $db->commit(); - + $queries = explode(";", $sql[$dbType]); + + $db->beginTransaction(); + + foreach ($queries as $query) { + if (preg_replace('/\s+/', '', $query) != '') { + $db->exec($query); + } + } + + $db->commit(); } - if($currentVersion < 4) { - $sql["mysql"] = " - CREATE TABLE IF NOT EXISTS supermasters ( - ip VARCHAR(64) NOT NULL, - nameserver VARCHAR(255) NOT NULL, - account VARCHAR(40) NOT NULL, - PRIMARY KEY (ip, nameserver) - ) Engine=InnoDB DEFAULT CHARSET=latin1; - - CREATE TABLE IF NOT EXISTS comments ( - id INT AUTO_INCREMENT, - domain_id INT NOT NULL, - name VARCHAR(255) NOT NULL, - type VARCHAR(10) NOT NULL, - modified_at INT NOT NULL, - account VARCHAR(40) NOT NULL, - comment VARCHAR(64000) NOT NULL, - PRIMARY KEY (id), - KEY comments_domain_id_idx (domain_id), - KEY comments_name_type_idx (name,type), - KEY comments_order_idx (domain_id, modified_at) - ) Engine=InnoDB DEFAULT CHARSET=latin1; - - CREATE TABLE IF NOT EXISTS cryptokeys ( - id INT AUTO_INCREMENT, - domain_id INT NOT NULL, - flags INT NOT NULL, - active BOOL, - content TEXT, - PRIMARY KEY(id), - KEY domainidindex (domain_id) - ) Engine=InnoDB DEFAULT CHARSET=latin1; - - CREATE TABLE IF NOT EXISTS tsigkeys ( - id INT AUTO_INCREMENT, - name VARCHAR(255), - algorithm VARCHAR(50), - secret VARCHAR(255), - PRIMARY KEY (id), - UNIQUE KEY namealgoindex (name, algorithm) - ) Engine=InnoDB DEFAULT CHARSET=latin1; - - DELETE FROM permissions - WHERE user IN ( - SELECT id FROM user - LEFT OUTER JOIN ( - SELECT MIN(U.id) AS minid, U.name - FROM user AS U - GROUP BY U.name - ) as KeepRows ON user.id = KeepRows.minid - WHERE KeepRows.minid IS NULL - ); - - ALTER TABLE permissions ADD userid INT NOT NULL; - - UPDATE permissions SET userid = user; - - ALTER TABLE permissions DROP FOREIGN KEY permissions_ibfk_2; - - ALTER TABLE permissions DROP user; - - CREATE TABLE IF NOT EXISTS users ( - id int(11) NOT NULL, - name varchar(50) NOT NULL, - password varchar(200) NOT NULL, - type varchar(20) NOT NULL, - PRIMARY KEY (id) - ) ENGINE=InnoDB DEFAULT CHARSET=latin1; - - INSERT INTO users (id, name, password, type) SELECT id, name, password, type FROM user; - - DELETE FROM users - WHERE users.id IN ( - SELECT user.id FROM user - LEFT OUTER JOIN ( - SELECT MIN(U.id) AS minid, U.name - FROM user AS U - GROUP BY U.name - ) as KeepRows ON user.id = KeepRows.minid - WHERE KeepRows.minid IS NULL - ); - - ALTER TABLE users ADD CONSTRAINT UNIQUE KEY user_name_index (name); - - ALTER TABLE users MODIFY COLUMN id int(11) NOT NULL AUTO_INCREMENT; - - ALTER TABLE permissions ADD CONSTRAINT permissions_ibfk_2 FOREIGN KEY (userid) REFERENCES users (id) ON DELETE CASCADE; - - DROP TABLE user; - - UPDATE domains SET name=LOWER(name); - - UPDATE records SET name=LOWER(name); - - UPDATE options SET value=4 WHERE name='schema_version'; - "; - $sql["pgsql"] = "UPDATE options SET value=4 WHERE name='schema_version';"; - $queries = explode(";", $sql[$dbType]); - - $db->beginTransaction(); - - foreach ($queries as $query) { - if (preg_replace('/\s+/', '', $query) != '') { - $db->exec($query); - } - } - - $db->commit(); - } $retval['status'] = "success"; } diff --git a/api/users.php b/api/users.php index d4d31c3..d554234 100644 --- a/api/users.php +++ b/api/users.php @@ -78,10 +78,10 @@ if(isset($input->action) && $input->action == "getUsers") { $type_filter_used = 1; } - $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); - $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); - $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); - $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); + $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); + $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); + $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); $stmt->execute(); $retval = Array(); @@ -97,11 +97,11 @@ if(isset($input->action) && $input->action == "deleteUser") { $db->beginTransaction(); $stmt = $db->prepare("DELETE FROM permissions WHERE userid=:userid"); - $stmt->bindValue(':userid', $userId, PDO::PARAM_INT); + $stmt->bindValue(':userid', $userId, PDO::PARAM_INT); $stmt->execute(); $stmt = $db->prepare("DELETE FROM users WHERE id=:id"); - $stmt->bindValue(':id', $userId, PDO::PARAM_INT); + $stmt->bindValue(':id', $userId, PDO::PARAM_INT); $stmt->execute(); $db->commit(); diff --git a/domains.php b/domains.php index 5f82ff3..e897787 100644 --- a/domains.php +++ b/domains.php @@ -73,7 +73,7 @@ limitations under the License. @@ -93,8 +93,8 @@ limitations under the License. '; - echo 'Add NATIVE'; - echo 'Add MASTER'; + echo 'Add MASTER'; + echo 'Add NATIVE'; echo ''; } ?> diff --git a/edit-master.php b/edit-master.php index 1780b02..4107ee6 100644 --- a/edit-master.php +++ b/edit-master.php @@ -70,7 +70,7 @@ limitations under the License.
- +
diff --git a/install.php b/install.php index 263b525..53efd40 100644 --- a/install.php +++ b/install.php @@ -66,10 +66,10 @@ limitations under the License.

Database

- +
diff --git a/lib/checkversion.php b/lib/checkversion.php index 5332d8b..c3eb45b 100644 --- a/lib/checkversion.php +++ b/lib/checkversion.php @@ -17,7 +17,7 @@ */ function getExpectedVersion() { - return 4; + return 3; } function checkVersion($db) { @@ -29,12 +29,12 @@ function checkVersion($db) { } function getVersion($db) { - - $stmt = $db->prepare("SELECT value FROM options WHERE name='schema_version' LIMIT 1"); - $stmt->execute(); - $version = $stmt->fetchColumn(); + $stmt = $db->prepare("SELECT value FROM options WHERE name='schema_version' LIMIT 1"); + $stmt->execute(); + $version = $stmt->fetchColumn(); if (!$version) { - $version = 0; + $version = 0; } + return $version; -} \ No newline at end of file +} diff --git a/lib/database.php b/lib/database.php index 9019270..a248cd7 100644 --- a/lib/database.php +++ b/lib/database.php @@ -17,8 +17,8 @@ */ try { - $db = new PDO($config['db_type'].":dbname=".$config['db_name'].";host=".$config['db_host'].";port=".strval($config['db_port']), $config['db_user'], $config['db_password']); + $db = new PDO($config['db_type'].":dbname=".$config['db_name'].";host=".$config['db_host'].";port=".strval($config['db_port']), $config['db_user'], $config['db_password']); } catch (PDOException $e) { die("Connection to database failed"); -} \ No newline at end of file +} diff --git a/lib/update-serial.php b/lib/update-serial.php index c92d384..e8f9410 100644 --- a/lib/update-serial.php +++ b/lib/update-serial.php @@ -24,7 +24,7 @@ function update_serial($db, $domainId) { $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $content = $stmt->fetchColumn(); - + $content = explode(" ", $content); $serial = $content[2]; @@ -48,10 +48,10 @@ function update_serial($db, $domainId) { $newsoa = implode(" ", $content); $stmt = $db->prepare("UPDATE records SET content=:content WHERE type='SOA' AND domain_id=:domain_id"); - $stmt->bindValue(':content', $newsoa, PDO::PARAM_STR); + $stmt->bindValue(':content', $newsoa, PDO::PARAM_STR); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->execute(); $db->commit(); -} \ No newline at end of file +}