Removed spaces from empty lines

This commit is contained in:
Maurice Meyer 2017-07-20 16:22:46 +02:00
parent 39dd3f86c6
commit b1a06a8684
42 changed files with 0 additions and 756 deletions

View file

@ -1,22 +1,16 @@
# PDNS Manager # PDNS Manager
[PDNS Manager](https://pdnsmanager.lmitsystems.de) is a simple yet powerful free administration tool for the [PDNS Manager](https://pdnsmanager.lmitsystems.de) is a simple yet powerful free administration tool for the
Powerdns authoritative nameserver. It supports master and native zones. Powerdns authoritative nameserver. It supports master and native zones.
PNDS Manager was developed from scratch to achieve a user-friendly PNDS Manager was developed from scratch to achieve a user-friendly
and pretty looking interface. and pretty looking interface.
PDNS Manager also features a powerful API to set records programatically. PDNS Manager also features a powerful API to set records programatically.
This can be used e.g. for a dynamic DNS service, but also to obtain certificates This can be used e.g. for a dynamic DNS service, but also to obtain certificates
from [Let's Encrypt](https://letsencrypt.org/) via the dns-01 challenge. from [Let's Encrypt](https://letsencrypt.org/) via the dns-01 challenge.
PDNS Manager is written in PHP using [Bootstrap](http://getbootstrap.com/) PDNS Manager is written in PHP using [Bootstrap](http://getbootstrap.com/)
and [jQuery](http://jquery.com/). The backend uses a MySQL/Maria DB or Postgres and [jQuery](http://jquery.com/). The backend uses a MySQL/Maria DB or Postgres
database. The database is also used by Powerdns using the pdns-backend-mysql or database. The database is also used by Powerdns using the pdns-backend-mysql or
pdns-backend-pgsql backend. pdns-backend-pgsql backend.
## More information ## More information
You can find more information and documentation as well as contact information on [pdnsmanager.lmitsystems.de](https://pdnsmanager.lmitsystems.de). There are also some tutorials to get you quickly up and running. You can find more information and documentation as well as contact information on [pdnsmanager.lmitsystems.de](https://pdnsmanager.lmitsystems.de). There are also some tutorials to get you quickly up and running.
## Contribute ## Contribute
If you are looking for a new feature or you found a bug, feel free to create a pull request or open a issue. If you are looking for a new feature or you found a bug, feel free to create a pull request or open a issue.

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,14 +20,11 @@ limitations under the License.
<title>PDNS Manager - Domains</title> <title>PDNS Manager - Domains</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="js/add-domain.js"></script> <script src="js/add-domain.js"></script>
</head> </head>
<body> <body>
@ -47,13 +41,10 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2 id="domain-name">Add Domain</h2> <h2 id="domain-name">Add Domain</h2>
</row> </row>
<row> <row>
<form> <form>
<div class="col-md-3"> <div class="col-md-3">
@ -71,7 +62,6 @@ limitations under the License.
</div> </div>
<button id="zone-button-add" class="btn btn-primary" tabindex="8">Add</button> <button id="zone-button-add" class="btn btn-primary" tabindex="8">Add</button>
</div> </div>
<div class="col-md-2 col-md-offset-1"> <div class="col-md-2 col-md-offset-1">
<div class="form-group"> <div class="form-group">
<label for="zone-refresh" class="control-label">Refresh</label> <label for="zone-refresh" class="control-label">Refresh</label>
@ -82,7 +72,6 @@ limitations under the License.
<input type="text" class="form-control" id="zone-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="5" value="900"> <input type="text" class="form-control" id="zone-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="5" value="900">
</div> </div>
</div> </div>
<div class="col-md-2 col-md-offset-1"> <div class="col-md-2 col-md-offset-1">
<div class="form-group"> <div class="form-group">
<label for="zone-expire" class="control-label">Expire</label> <label for="zone-expire" class="control-label">Expire</label>
@ -95,9 +84,7 @@ limitations under the License.
</div> </div>
</form> </form>
</row> </row>
</div> </div>
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?> <?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
</body> </body>
</html> </html>

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,24 +14,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
require_once '../lib/soa-mail.php'; require_once '../lib/soa-mail.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") { if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(isset($input->action) && $input->action == "addDomain") { if(isset($input->action) && $input->action == "addDomain") {
$soaData = Array(); $soaData = Array();
$soaData[] = strtolower(preg_replace('/\s+/', '', $input->primary)); $soaData[] = strtolower(preg_replace('/\s+/', '', $input->primary));
@ -42,37 +36,28 @@ if(isset($input->action) && $input->action == "addDomain") {
$soaData[] = $input->retry; $soaData[] = $input->retry;
$soaData[] = $input->expire; $soaData[] = $input->expire;
$soaData[] = $input->ttl; $soaData[] = $input->ttl;
$domainsName = strtolower(preg_replace('/\s+/', '', $input->name)); $domainsName = strtolower(preg_replace('/\s+/', '', $input->name));
$soaContent = implode(" ", $soaData); $soaContent = implode(" ", $soaData);
$db->beginTransaction(); $db->beginTransaction();
$stmt = $db->prepare("INSERT INTO domains(name,type) VALUES (:name,:type)"); $stmt = $db->prepare("INSERT INTO domains(name,type) VALUES (:name,:type)");
$stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR);
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$stmt = $db->prepare("SELECT MAX(id) FROM domains WHERE name=:name AND type=:type"); $stmt = $db->prepare("SELECT MAX(id) FROM domains WHERE name=:name AND type=:type");
$stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR);
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
$stmt->execute(); $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 = $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(':domain_id', $newDomainId, PDO::PARAM_INT);
$stmt->bindValue(':name', $domainsName, PDO::PARAM_STR); $stmt->bindValue(':name', $domainsName, PDO::PARAM_STR);
$stmt->bindValue(':content', $soaContent, PDO::PARAM_STR); $stmt->bindValue(':content', $soaContent, PDO::PARAM_STR);
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$db->commit(); $db->commit();
$retval = Array(); $retval = Array();
$retval['newId'] = $newDomainId; $retval['newId'] = $newDomainId;
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,25 +14,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(isset($input->action) && $input->action == "getDomains") { if(isset($input->action) && $input->action == "getDomains") {
// Check if the requested page is a number // Check if the requested page is a number
if(!(isset($input->page) && is_int($input->page) && $input->page > 0)) { if(!(isset($input->page) && is_int($input->page) && $input->page > 0)) {
echo "Requested page must be a positive number!"; echo "Requested page must be a positive number!";
exit(); exit();
} }
// Here we get the number of matching records // Here we get the number of matching records
$sql = " $sql = "
SELECT COUNT(*) AS anzahl SELECT COUNT(*) AS anzahl
@ -43,9 +37,7 @@ if(isset($input->action) && $input->action == "getDomains") {
(D.name LIKE :name1 OR :name2) AND (D.name LIKE :name1 OR :name2) AND
(D.type=:type1 OR :type2) (D.type=:type1 OR :type2)
"; ";
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
if(isset($input->name)) { if(isset($input->name)) {
$name_filter = "%" . $input->name . "%"; $name_filter = "%" . $input->name . "%";
$name_filter_used = 0; $name_filter_used = 0;
@ -53,10 +45,8 @@ if(isset($input->action) && $input->action == "getDomains") {
$name_filter = ""; $name_filter = "";
$name_filter_used = 1; $name_filter_used = 1;
} }
$id_filter = $_SESSION['id']; $id_filter = $_SESSION['id'];
$id_filter_used = (int)($_SESSION['type'] == "admin" ? 1 : 0); $id_filter_used = (int)($_SESSION['type'] == "admin" ? 1 : 0);
if(isset($input->type)) { if(isset($input->type)) {
$type_filter = $input->type; $type_filter = $input->type;
$type_filter_used = 0; $type_filter_used = 0;
@ -64,7 +54,6 @@ if(isset($input->action) && $input->action == "getDomains") {
$type_filter = ""; $type_filter = "";
$type_filter_used = 1; $type_filter_used = 1;
} }
$stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR); $stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR);
$stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT); $stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT);
$stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR);
@ -73,18 +62,13 @@ if(isset($input->action) && $input->action == "getDomains") {
$stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$result = $stmt->fetchColumn(); $result = $stmt->fetchColumn();
if ($result == 0) { if ($result == 0) {
$result = 1; $result = 1;
} }
// Initialize the return value // Initialize the return value
$retval = Array(); $retval = Array();
$retval['pages']['current'] = $input->page; $retval['pages']['current'] = $input->page;
$retval['pages']['total'] = ceil($result / $config['domain_rows']); $retval['pages']['total'] = ceil($result / $config['domain_rows']);
// Now the real search is done on the database // Now the real search is done on the database
$sql = " $sql = "
SELECT D.id,D.name,D.type,count(R.domain_id) AS records SELECT D.id,D.name,D.type,count(R.domain_id) AS records
@ -97,7 +81,6 @@ if(isset($input->action) && $input->action == "getDomains") {
(D.name LIKE :name1 OR :name2) AND (D.name LIKE :name1 OR :name2) AND
(D.type=:type1 OR :type2) (D.type=:type1 OR :type2)
"; ";
if(isset($input->sort->field) && $input->sort->field != "") { if(isset($input->sort->field) && $input->sort->field != "") {
if($input->sort->field == "id") { if($input->sort->field == "id") {
$sql .= "ORDER BY id"; $sql .= "ORDER BY id";
@ -108,7 +91,6 @@ if(isset($input->action) && $input->action == "getDomains") {
} else if($input->sort->field == "records") { } else if($input->sort->field == "records") {
$sql .= "ORDER BY records"; $sql .= "ORDER BY records";
} }
if(isset($input->sort->order)) { if(isset($input->sort->order)) {
if($input->sort->order == 0) { if($input->sort->order == 0) {
$sql .= " DESC"; $sql .= " DESC";
@ -117,7 +99,6 @@ if(isset($input->action) && $input->action == "getDomains") {
} }
} }
} }
/* /*
* Now the number of entries gets limited to the domainRows config value. * Now the number of entries gets limited to the domainRows config value.
* SQL LIMIT and OFFSET is used for that: * SQL LIMIT and OFFSET is used for that:
@ -125,11 +106,8 @@ if(isset($input->action) && $input->action == "getDomains") {
* Note that LIMIT 5 OFFSET 0 returns the first five rows! * Note that LIMIT 5 OFFSET 0 returns the first five rows!
*/ */
$lower_limit = ($config['domain_rows'] * ($input->page - 1)); $lower_limit = ($config['domain_rows'] * ($input->page - 1));
$sql .= " LIMIT " . $config['domain_rows'] . " OFFSET " . $lower_limit; $sql .= " LIMIT " . $config['domain_rows'] . " OFFSET " . $lower_limit;
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
if(isset($input->name)) { if(isset($input->name)) {
$name_filter = "%" . $input->name . "%"; $name_filter = "%" . $input->name . "%";
$name_filter_used = 0; $name_filter_used = 0;
@ -137,10 +115,8 @@ if(isset($input->action) && $input->action == "getDomains") {
$name_filter = ""; $name_filter = "";
$name_filter_used = 1; $name_filter_used = 1;
} }
$id_filter = $_SESSION['id']; $id_filter = $_SESSION['id'];
$id_filter_used = (int)($_SESSION['type'] == "admin" ? 1 : 0); $id_filter_used = (int)($_SESSION['type'] == "admin" ? 1 : 0);
if(isset($input->type)) { if(isset($input->type)) {
$type_filter = $input->type; $type_filter = $input->type;
$type_filter_used = 0; $type_filter_used = 0;
@ -148,7 +124,6 @@ if(isset($input->action) && $input->action == "getDomains") {
$type_filter = ""; $type_filter = "";
$type_filter_used = 1; $type_filter_used = 1;
} }
$stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR); $stmt->bindValue(':user1', $id_filter, PDO::PARAM_STR);
$stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT); $stmt->bindValue(':user2', $id_filter_used, PDO::PARAM_INT);
$stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR);
@ -156,36 +131,27 @@ if(isset($input->action) && $input->action == "getDomains") {
$stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT);
$stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
while($obj = $stmt->fetchObject()) { while($obj = $stmt->fetchObject()) {
$retval['data'][] = $obj; $retval['data'][] = $obj;
} }
} }
if(isset($input->action) && $input->action == "deleteDomain") { if(isset($input->action) && $input->action == "deleteDomain") {
$domainId = $input->id; $domainId = $input->id;
$db->beginTransaction(); $db->beginTransaction();
$stmt = $db->prepare("DELETE FROM permissions WHERE domain=:domain_id"); $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->execute();
$stmt = $db->prepare("DELETE FROM remote WHERE record IN (SELECT id FROM records WHERE domain_id=:domain_id)"); $stmt = $db->prepare("DELETE FROM remote WHERE record IN (SELECT id FROM records WHERE domain_id=:domain_id)");
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$stmt = $db->prepare("DELETE FROM records WHERE domain_id=:domain_id"); $stmt = $db->prepare("DELETE FROM records WHERE domain_id=:domain_id");
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$stmt = $db->prepare("DELETE FROM domains WHERE id=:domain_id"); $stmt = $db->prepare("DELETE FROM domains WHERE id=:domain_id");
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$db->commit(); $db->commit();
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,20 +14,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
require_once '../lib/soa-mail.php'; require_once '../lib/soa-mail.php';
require_once '../lib/update-serial.php'; require_once '../lib/update-serial.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
//Permission check //Permission check
if(isset($input->domain)) { if(isset($input->domain)) {
$permquery = $db->prepare("SELECT COUNT(*) FROM permissions WHERE userid=:user AND domain=:domain"); $permquery = $db->prepare("SELECT COUNT(*) FROM permissions WHERE userid=:user AND domain=:domain");
@ -43,11 +38,8 @@ if(isset($input->domain)) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
//Action for getting Records //Action for getting Records
if(isset($input->action) && $input->action == "getRecords") { if(isset($input->action) && $input->action == "getRecords") {
$sql = " $sql = "
SELECT id,name,type,content,ttl,prio AS priority SELECT id,name,type,content,ttl,prio AS priority
FROM records FROM records
@ -57,10 +49,8 @@ if(isset($input->action) && $input->action == "getRecords") {
(domain_id = :domain_id) AND (domain_id = :domain_id) AND
(type != 'SOA') (type != 'SOA')
"; ";
if(isset($input->type)) { if(isset($input->type)) {
$sql .= " AND type IN("; $sql .= " AND type IN(";
foreach($input->type as $filtertype) { foreach($input->type as $filtertype) {
$filtertype = $db->escape_string($filtertype); $filtertype = $db->escape_string($filtertype);
$sql .= "'" . $filtertype . "'" . ","; $sql .= "'" . $filtertype . "'" . ",";
@ -68,7 +58,6 @@ if(isset($input->action) && $input->action == "getRecords") {
$sql = rtrim($sql, ","); $sql = rtrim($sql, ",");
$sql .= ")"; $sql .= ")";
} }
if(isset($input->sort->field) && $input->sort->field != "") { if(isset($input->sort->field) && $input->sort->field != "") {
if($input->sort->field == "id") { if($input->sort->field == "id") {
$sql .= " ORDER BY id"; $sql .= " ORDER BY id";
@ -83,7 +72,6 @@ if(isset($input->action) && $input->action == "getRecords") {
} else if($input->sort->field == "priority") { } else if($input->sort->field == "priority") {
$sql .= " ORDER BY prio"; $sql .= " ORDER BY prio";
} }
if(isset($input->sort->order)) { if(isset($input->sort->order)) {
if($input->sort->order == 0) { if($input->sort->order == 0) {
$sql .= " DESC"; $sql .= " DESC";
@ -92,9 +80,7 @@ if(isset($input->action) && $input->action == "getRecords") {
} }
} }
} }
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
if(isset($input->name)) { if(isset($input->name)) {
$name_filter = "%" . $input->name . "%"; $name_filter = "%" . $input->name . "%";
$name_filter_used = 0; $name_filter_used = 0;
@ -102,7 +88,6 @@ if(isset($input->action) && $input->action == "getRecords") {
$name_filter = ""; $name_filter = "";
$name_filter_used = 1; $name_filter_used = 1;
} }
if(isset($input->content)) { if(isset($input->content)) {
$content_filter = "%" . $input->content . "%"; $content_filter = "%" . $input->content . "%";
$content_filter_used = 0; $content_filter_used = 0;
@ -110,38 +95,27 @@ if(isset($input->action) && $input->action == "getRecords") {
$content_filter = ""; $content_filter = "";
$content_filter_used = 1; $content_filter_used = 1;
} }
$domainId = (int)$input->domain; $domainId = (int)$input->domain;
$stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR);
$stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT);
$stmt->bindValue(':content1', $content_filter, PDO::PARAM_STR); $stmt->bindValue(':content1', $content_filter, PDO::PARAM_STR);
$stmt->bindValue(':content2', $content_filter_used, PDO::PARAM_INT); $stmt->bindValue(':content2', $content_filter_used, PDO::PARAM_INT);
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$retval = Array(); $retval = Array();
while($obj = $stmt->fetchObject()) { while($obj = $stmt->fetchObject()) {
$retval[] = $obj; $retval[] = $obj;
} }
} }
//Action for getting SOA //Action for getting SOA
if(isset($input->action) && $input->action == "getSoa") { if(isset($input->action) && $input->action == "getSoa") {
$domainId = (int)$input->domain; $domainId = (int)$input->domain;
$stmt = $db->prepare("SELECT content FROM records WHERE type='SOA' AND domain_id=:domain_id LIMIT 1"); $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(); $stmt->execute();
$content = $stmt->fetchColumn(); $content = $stmt->fetchColumn();
$content = explode(" ", $content); $content = explode(" ", $content);
$retval = Array(); $retval = Array();
$retval['primary'] = $content[0]; $retval['primary'] = $content[0];
$retval['email'] = soa_to_mail($content[1]); $retval['email'] = soa_to_mail($content[1]);
$retval['serial'] = $content[2]; $retval['serial'] = $content[2];
@ -150,38 +124,27 @@ if(isset($input->action) && $input->action == "getSoa") {
$retval['expire'] = $content[5]; $retval['expire'] = $content[5];
$retval['ttl'] = $content[6]; $retval['ttl'] = $content[6];
} }
//Action for getting SOA Serial //Action for getting SOA Serial
if(isset($input->action) && $input->action == "getSerial") { if(isset($input->action) && $input->action == "getSerial") {
$domainId = (int)$input->domain; $domainId = (int)$input->domain;
$stmt = $db->prepare("SELECT content FROM records WHERE type='SOA' AND domain_id=:domain_id LIMIT 1"); $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(); $stmt->execute();
$content = $stmt->fetchColumn(); $content = $stmt->fetchColumn();
$content = explode(" ", $content); $content = explode(" ", $content);
$retval = Array(); $retval = Array();
$retval['serial'] = $content[2]; $retval['serial'] = $content[2];
} }
//Action for saving SOA //Action for saving SOA
if(isset($input->action) && $input->action == "saveSoa") { if(isset($input->action) && $input->action == "saveSoa") {
$domainId = (int)$input->domain; $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 = $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(); $stmt->execute();
$content = $stmt->fetchColumn();; $content = $stmt->fetchColumn();;
$content = explode(" ", $content); $content = explode(" ", $content);
$serial = $content[2]; $serial = $content[2];
$newsoa = strtolower(preg_replace('/\s+/', '', $input->primary)) . " "; $newsoa = strtolower(preg_replace('/\s+/', '', $input->primary)) . " ";
$newsoa .= strtolower(mail_to_soa(preg_replace('/\s+/', '', $input->email))) . " "; $newsoa .= strtolower(mail_to_soa(preg_replace('/\s+/', '', $input->email))) . " ";
$newsoa .= $serial . " "; $newsoa .= $serial . " ";
@ -189,26 +152,20 @@ if(isset($input->action) && $input->action == "saveSoa") {
$newsoa .= $input->retry . " "; $newsoa .= $input->retry . " ";
$newsoa .= $input->expire . " "; $newsoa .= $input->expire . " ";
$newsoa .= $input->ttl; $newsoa .= $input->ttl;
$stmt = $db->prepare("UPDATE records SET content=:content,ttl=:ttl WHERE type='SOA' AND domain_id=:domain_id"); $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(':content', $newsoa, PDO::PARAM_STR);
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$db->commit(); $db->commit();
$retval = Array(); $retval = Array();
update_serial($db, $domainId); update_serial($db, $domainId);
} }
//Action for saving Record //Action for saving Record
if(isset($input->action) && $input->action == "saveRecord") { if(isset($input->action) && $input->action == "saveRecord") {
$domainId = $input->domain; $domainId = $input->domain;
$recordName = strtolower(preg_replace('/\s+/', '', $input->name)); $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 = $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(':name', $recordName, PDO::PARAM_STR);
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
@ -220,15 +177,12 @@ if(isset($input->action) && $input->action == "saveRecord") {
$stmt->execute(); $stmt->execute();
update_serial($db, $domainId); update_serial($db, $domainId);
} }
//Action for adding Record //Action for adding Record
if(isset($input->action) && $input->action == "addRecord") { if(isset($input->action) && $input->action == "addRecord") {
$domainId = $input->domain; $domainId = $input->domain;
$recordName = strtolower(preg_replace('/\s+/', '', $input->name)); $recordName = strtolower(preg_replace('/\s+/', '', $input->name));
$recordContent = trim($input->content); $recordContent = trim($input->content);
$db->beginTransaction(); $db->beginTransaction();
$stmt = $db->prepare("INSERT INTO records (domain_id, name, type, content, prio, ttl) VALUES (:domain_id,:name,:type,:content,:prio,:ttl)"); $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(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->bindValue(':name', $recordName, PDO::PARAM_STR); $stmt->bindValue(':name', $recordName, PDO::PARAM_STR);
@ -237,7 +191,6 @@ if(isset($input->action) && $input->action == "addRecord") {
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT); $stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
$stmt->execute(); $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 = $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(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->bindValue(':name', $recordName, PDO::PARAM_STR); $stmt->bindValue(':name', $recordName, PDO::PARAM_STR);
@ -247,41 +200,31 @@ if(isset($input->action) && $input->action == "addRecord") {
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT); $stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$newId = $stmt->fetchColumn(); $newId = $stmt->fetchColumn();
$db->commit(); $db->commit();
$retval = Array(); $retval = Array();
$retval['newId'] = $newId; $retval['newId'] = $newId;
update_serial($db, $domainId); update_serial($db, $domainId);
} }
//Action for removing Record //Action for removing Record
if(isset($input->action) && $input->action == "removeRecord") { if(isset($input->action) && $input->action == "removeRecord") {
$domainId = $input->domain; $domainId = $input->domain;
$recordId = $input->id; $recordId = $input->id;
$stmt = $db->prepare("DELETE FROM records WHERE id=:id AND domain_id=:domain_id"); $stmt = $db->prepare("DELETE FROM records WHERE id=:id AND domain_id=:domain_id");
$stmt->bindValue(':id', $recordId, PDO::PARAM_INT); $stmt->bindValue(':id', $recordId, PDO::PARAM_INT);
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
update_serial($db, $domainId); update_serial($db, $domainId);
} }
//Action for getting domain name //Action for getting domain name
if(isset($input->action) && $input->action == "getDomainName") { if(isset($input->action) && $input->action == "getDomainName") {
$domainId = $input->domain; $domainId = $input->domain;
$stmt = $db->prepare("SELECT name FROM domains WHERE id=:id LIMIT 1"); $stmt = $db->prepare("SELECT name FROM domains WHERE id=:id LIMIT 1");
$stmt->bindValue(':id', $domainId, PDO::PARAM_INT); $stmt->bindValue(':id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$domainName = $stmt->fetchColumn(); $domainName = $stmt->fetchColumn();
$retval = Array(); $retval = Array();
$retval['name'] = $domainName; $retval['name'] = $domainName;
} }
if (isset($retval)) { if (isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,18 +14,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
//Permission check //Permission check
if(isset($input->record)) { 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 = $db->prepare("SELECT COUNT(*) FROM records JOIN permissions ON records.domain_id=permissions.domain WHERE userid=:user AND records.id=:id");
@ -41,48 +36,36 @@ if(isset($input->record)) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
//Action for getting permission //Action for getting permission
if(isset($input->action) && $input->action == "getPermissions") { if(isset($input->action) && $input->action == "getPermissions") {
$sql = "SELECT id, description, type FROM remote WHERE record=:record"; $sql = "SELECT id, description, type FROM remote WHERE record=:record";
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
$stmt->bindValue(':record', $input->record, PDO::PARAM_INT); $stmt->bindValue(':record', $input->record, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$retval = Array(); $retval = Array();
while($obj = $stmt->fetchObject()) { while($obj = $stmt->fetchObject()) {
$retval[] = $obj; $retval[] = $obj;
} }
} }
//Action for adding password //Action for adding password
if(isset($input->action) && $input->action == "addPassword") { if(isset($input->action) && $input->action == "addPassword") {
$passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $passwordHash = password_hash($input->password, PASSWORD_DEFAULT);
$sql = "INSERT INTO remote(record,description,type,security) VALUES (:record,:description,'password',:security)"; $sql = "INSERT INTO remote(record,description,type,security) VALUES (:record,:description,'password',:security)";
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
$stmt->bindValue(':record', $input->record, PDO::PARAM_INT); $stmt->bindValue(':record', $input->record, PDO::PARAM_INT);
$stmt->bindValue(':description', $input->description, PDO::PARAM_STR); $stmt->bindValue(':description', $input->description, PDO::PARAM_STR);
$stmt->bindValue(':security', $passwordHash, PDO::PARAM_STR); $stmt->bindValue(':security', $passwordHash, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
} }
//Action for adding key //Action for adding key
if(isset($input->action) && $input->action == "addKey") { if(isset($input->action) && $input->action == "addKey") {
$sql = "INSERT INTO remote(record,description,type,security) VALUES (:record,:description,'key',:security)"; $sql = "INSERT INTO remote(record,description,type,security) VALUES (:record,:description,'key',:security)";
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
$stmt->bindValue(':record', $input->record, PDO::PARAM_INT); $stmt->bindValue(':record', $input->record, PDO::PARAM_INT);
$stmt->bindValue(':description', $input->description, PDO::PARAM_STR); $stmt->bindValue(':description', $input->description, PDO::PARAM_STR);
$stmt->bindValue(':security', $input->key, PDO::PARAM_STR); $stmt->bindValue(':security', $input->key, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
} }
//Action for updating password //Action for updating password
if(isset($input->action) && $input->action == "changePassword") { if(isset($input->action) && $input->action == "changePassword") {
if(isset($input->password)) { if(isset($input->password)) {
@ -101,18 +84,15 @@ if(isset($input->action) && $input->action == "changePassword") {
$stmt->execute(); $stmt->execute();
} }
} }
//Action for updating key //Action for updating key
if(isset($input->action) && $input->action == "changeKey") { if(isset($input->action) && $input->action == "changeKey") {
$sql = "UPDATE remote SET description=:description,security=:security WHERE id=:id"; $sql = "UPDATE remote SET description=:description,security=:security WHERE id=:id";
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
$stmt->bindValue(':description', $input->description, PDO::PARAM_STR); $stmt->bindValue(':description', $input->description, PDO::PARAM_STR);
$stmt->bindValue(':security', $input->key, PDO::PARAM_STR); $stmt->bindValue(':security', $input->key, PDO::PARAM_STR);
$stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
} }
//Action for getting key //Action for getting key
if(isset($input->action) && $input->action == "getKey") { if(isset($input->action) && $input->action == "getKey") {
$sql = "SELECT security FROM remote WHERE id=:id AND type='key' LIMIT 1"; $sql = "SELECT security FROM remote WHERE id=:id AND type='key' LIMIT 1";
@ -120,20 +100,16 @@ if(isset($input->action) && $input->action == "getKey") {
$stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$key = $stmt->fetchColumn(); $key = $stmt->fetchColumn();
$retval = Array(); $retval = Array();
$retval['key'] = $key; $retval['key'] = $key;
} }
//Action for deleting permission //Action for deleting permission
if(isset($input->action) && $input->action == "deletePermission") { if(isset($input->action) && $input->action == "deletePermission") {
$sql = "DELETE FROM remote WHERE id=:id"; $sql = "DELETE FROM remote WHERE id=:id";
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
$stmt->bindValue(':id', $input->permission, PDO::PARAM_INT); $stmt->bindValue(':id', $input->permission, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,47 +14,36 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") { if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(isset($input->action) && $input->action == "addUser") { if(isset($input->action) && $input->action == "addUser") {
$passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $passwordHash = password_hash($input->password, PASSWORD_DEFAULT);
$db->beginTransaction(); $db->beginTransaction();
$stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:name,:password,:type)"); $stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:name,:password,:type)");
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR); $stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
$stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR);
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$stmt = $db->prepare("SELECT MAX(id) FROM users WHERE name=:name AND password=:password AND type=:type"); $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(':name', $input->name, PDO::PARAM_STR);
$stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR);
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR); $stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$newUserId = $stmt->fetchColumn(); $newUserId = $stmt->fetchColumn();
$db->commit(); $db->commit();
$retval = Array(); $retval = Array();
$retval['newId'] = $newUserId; $retval['newId'] = $newUserId;
} }
if(isset($input->action) && $input->action == "getUserData") { if(isset($input->action) && $input->action == "getUserData") {
$stmt = $db->prepare("SELECT name,type FROM users WHERE id=:id LIMIT 1"); $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);
@ -63,12 +51,10 @@ if(isset($input->action) && $input->action == "getUserData") {
$stmt->bindColumn('name', $userName); $stmt->bindColumn('name', $userName);
$stmt->bindColumn('type', $userType); $stmt->bindColumn('type', $userType);
$stmt->fetch(PDO::FETCH_BOUND); $stmt->fetch(PDO::FETCH_BOUND);
$retval = Array(); $retval = Array();
$retval['name'] = $userName; $retval['name'] = $userName;
$retval['type'] = $userType; $retval['type'] = $userType;
} }
if(isset($input->action) && $input->action == "saveUserChanges") { if(isset($input->action) && $input->action == "saveUserChanges") {
if(isset($input->password)) { if(isset($input->password)) {
$passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $passwordHash = password_hash($input->password, PASSWORD_DEFAULT);
@ -86,61 +72,45 @@ if(isset($input->action) && $input->action == "saveUserChanges") {
$stmt->execute(); $stmt->execute();
} }
} }
if(isset($input->action) && $input->action == "getPermissions") { if(isset($input->action) && $input->action == "getPermissions") {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT D.id,D.name SELECT D.id,D.name
FROM permissions P FROM permissions P
JOIN domains D ON P.domain=D.id JOIN domains D ON P.domain=D.id
WHERE P.userid=:user WHERE P.userid=:user
"); ");
$stmt->bindValue(':user', $input->id, PDO::PARAM_INT); $stmt->bindValue(':user', $input->id, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$retval = Array(); $retval = Array();
while($obj = $stmt->fetchObject()) { while($obj = $stmt->fetchObject()) {
$retval[] = $obj; $retval[] = $obj;
} }
} }
if(isset($input->action) && $input->action == "removePermission") { if(isset($input->action) && $input->action == "removePermission") {
$stmt = $db->prepare("DELETE FROM permissions WHERE userid=:user AND domain=:domain"); $stmt = $db->prepare("DELETE FROM permissions WHERE userid=:user AND domain=:domain");
$stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT);
$stmt->bindValue(':domain', $input->domainId, PDO::PARAM_INT); $stmt->bindValue(':domain', $input->domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
} }
if(isset($input->action) && $input->action == "searchDomains" && isset($input->term)) { if(isset($input->action) && $input->action == "searchDomains" && isset($input->term)) {
$stmt = $db->prepare("SELECT id,name AS text FROM domains WHERE name LIKE :name AND id NOT IN(SELECT domain FROM permissions WHERE userid=:user)"); $stmt = $db->prepare("SELECT id,name AS text FROM domains WHERE name LIKE :name AND id NOT IN(SELECT domain FROM permissions WHERE userid=:user)");
$searchTerm = "%" . $input->term . "%"; $searchTerm = "%" . $input->term . "%";
$stmt->bindValue(':name', $searchTerm, PDO::PARAM_STR); $stmt->bindValue(':name', $searchTerm, PDO::PARAM_STR);
$stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$retval = Array(); $retval = Array();
while($obj = $stmt->fetchObject()) { while($obj = $stmt->fetchObject()) {
$retval[] = $obj; $retval[] = $obj;
} }
} }
if(isset($input->action) && $input->action == "addPermissions") { if(isset($input->action) && $input->action == "addPermissions") {
$stmt = $db->prepare("INSERT INTO permissions(userid,domain) VALUES (:user,:domain)"); $stmt = $db->prepare("INSERT INTO permissions(userid,domain) VALUES (:user,:domain)");
foreach($input->domains as $domain) { foreach($input->domains as $domain) {
$stmt->bindValue(':user', $input->userId, PDO::PARAM_INT); $stmt->bindValue(':user', $input->userId, PDO::PARAM_INT);
$stmt->bindValue(':domain', $domain, PDO::PARAM_INT); $stmt->bindValue(':domain', $domain, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
} }
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,12 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
$stmt = $db->prepare("SELECT id,password,type FROM users WHERE name=:name LIMIT 1"); $stmt = $db->prepare("SELECT id,password,type FROM users WHERE name=:name LIMIT 1");
$stmt->bindValue(':name', $input->user, PDO::PARAM_STR); $stmt->bindValue(':name', $input->user, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
@ -28,23 +24,17 @@ $stmt->bindColumn('id', $id);
$stmt->bindColumn('password', $password); $stmt->bindColumn('password', $password);
$stmt->bindColumn('type', $type); $stmt->bindColumn('type', $type);
$stmt->fetch(PDO::FETCH_BOUND); $stmt->fetch(PDO::FETCH_BOUND);
if (password_verify($input->password, $password)) { if (password_verify($input->password, $password)) {
$retval['status'] = "success"; $retval['status'] = "success";
session_start(); session_start();
$_SESSION['id'] = $id; $_SESSION['id'] = $id;
$_SESSION['type'] = $type; $_SESSION['type'] = $type;
$randomSecret = base64_encode(openssl_random_pseudo_bytes(32)); $randomSecret = base64_encode(openssl_random_pseudo_bytes(32));
$_SESSION['secret'] = $randomSecret; $_SESSION['secret'] = $randomSecret;
setcookie("authSecret", $randomSecret, 0, "/", "", false, true); setcookie("authSecret", $randomSecret, 0, "/", "", false, true);
$csrfToken = base64_encode(openssl_random_pseudo_bytes(32)); $csrfToken = base64_encode(openssl_random_pseudo_bytes(32));
$_SESSION['csrfToken'] = $csrfToken; $_SESSION['csrfToken'] = $csrfToken;
} else { } else {
$retval['status'] = "fail"; $retval['status'] = "fail";
} }
echo json_encode($retval); echo json_encode($retval);

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,15 +14,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
if(file_exists("../config/config-user.php")) { if(file_exists("../config/config-user.php")) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
//Get input //Get input
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
//Database command //Database command
$sql["mysql"] = " $sql["mysql"] = "
CREATE TABLE IF NOT EXISTS domains ( CREATE TABLE IF NOT EXISTS domains (
@ -37,7 +33,6 @@ CREATE TABLE IF NOT EXISTS domains (
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE KEY name_index (name) UNIQUE KEY name_index (name)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS records ( CREATE TABLE IF NOT EXISTS records (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
domain_id int(11) DEFAULT NULL, domain_id int(11) DEFAULT NULL,
@ -55,7 +50,6 @@ CREATE TABLE IF NOT EXISTS records (
KEY domain_id (domain_id), KEY domain_id (domain_id),
CONSTRAINT records_ibfk_1 FOREIGN KEY (domain_id) REFERENCES domains (id) ON DELETE CASCADE CONSTRAINT records_ibfk_1 FOREIGN KEY (domain_id) REFERENCES domains (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL, name varchar(50) NOT NULL,
@ -64,7 +58,6 @@ CREATE TABLE IF NOT EXISTS users (
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE KEY user_name_index (name) UNIQUE KEY user_name_index (name)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS permissions ( CREATE TABLE IF NOT EXISTS permissions (
userid int(11) NOT NULL, userid int(11) NOT NULL,
domain int(11) NOT NULL, domain int(11) NOT NULL,
@ -73,7 +66,6 @@ CREATE TABLE IF NOT EXISTS permissions (
CONSTRAINT permissions_ibfk_1 FOREIGN KEY (domain) REFERENCES domains (id) ON DELETE CASCADE, CONSTRAINT permissions_ibfk_1 FOREIGN KEY (domain) REFERENCES domains (id) ON DELETE CASCADE,
CONSTRAINT permissions_ibfk_2 FOREIGN KEY (userid) REFERENCES users (id) ON DELETE CASCADE CONSTRAINT permissions_ibfk_2 FOREIGN KEY (userid) REFERENCES users (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS remote ( CREATE TABLE IF NOT EXISTS remote (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
record int(11) NOT NULL, record int(11) NOT NULL,
@ -85,18 +77,14 @@ CREATE TABLE IF NOT EXISTS remote (
KEY record (record), 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; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS options ( CREATE TABLE IF NOT EXISTS options (
name varchar(255) NOT NULL, name varchar(255) NOT NULL,
value varchar(2000) DEFAULT NULL, value varchar(2000) DEFAULT NULL,
PRIMARY KEY (name) PRIMARY KEY (name)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DELETE FROM options where name='schema_version'; DELETE FROM options where name='schema_version';
INSERT INTO options(name,value) VALUES ('schema_version', 4); INSERT INTO options(name,value) VALUES ('schema_version', 4);
"; ";
$sql["pgsql"]=" $sql["pgsql"]="
CREATE TABLE IF NOT EXISTS domains ( CREATE TABLE IF NOT EXISTS domains (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
@ -108,9 +96,7 @@ CREATE TABLE IF NOT EXISTS domains (
account VARCHAR(40) DEFAULT NULL, account VARCHAR(40) DEFAULT NULL,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT)))
); );
CREATE UNIQUE INDEX IF NOT EXISTS name_index ON domains(name); CREATE UNIQUE INDEX IF NOT EXISTS name_index ON domains(name);
CREATE TABLE IF NOT EXISTS records ( CREATE TABLE IF NOT EXISTS records (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
domain_id INT DEFAULT NULL, domain_id INT DEFAULT NULL,
@ -128,21 +114,17 @@ CREATE TABLE IF NOT EXISTS records (
ON DELETE CASCADE, ON DELETE CASCADE,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT)))
); );
CREATE INDEX IF NOT EXISTS rec_name_index ON records(name); CREATE INDEX IF NOT EXISTS rec_name_index ON records(name);
CREATE INDEX IF NOT EXISTS nametype_index ON records(name,type); CREATE INDEX IF NOT EXISTS nametype_index ON records(name,type);
CREATE INDEX IF NOT EXISTS domain_id ON records(domain_id); CREATE INDEX IF NOT EXISTS domain_id ON records(domain_id);
CREATE INDEX IF NOT EXISTS recordorder ON records (domain_id, ordername text_pattern_ops); CREATE INDEX IF NOT EXISTS recordorder ON records (domain_id, ordername text_pattern_ops);
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name varchar(50) NOT NULL, name varchar(50) NOT NULL,
password varchar(200) NOT NULL, password varchar(200) NOT NULL,
type varchar(20) NOT NULL type varchar(20) NOT NULL
); );
CREATE UNIQUE INDEX IF NOT EXISTS user_name_index ON users(name); CREATE UNIQUE INDEX IF NOT EXISTS user_name_index ON users(name);
CREATE TABLE IF NOT EXISTS permissions ( CREATE TABLE IF NOT EXISTS permissions (
userid INT NOT NULL, userid INT NOT NULL,
domain INT NOT NULL, domain INT NOT NULL,
@ -154,10 +136,8 @@ CREATE TABLE IF NOT EXISTS permissions (
FOREIGN KEY(userid) REFERENCES users(id) FOREIGN KEY(userid) REFERENCES users(id)
ON DELETE CASCADE ON DELETE CASCADE
); );
CREATE INDEX IF NOT EXISTS perm_domain_index ON permissions(domain); CREATE INDEX IF NOT EXISTS perm_domain_index ON permissions(domain);
CREATE INDEX IF NOT EXISTS perm_userid_index ON permissions(userid); CREATE INDEX IF NOT EXISTS perm_userid_index ON permissions(userid);
CREATE TABLE IF NOT EXISTS remote ( CREATE TABLE IF NOT EXISTS remote (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
record INT NOT NULL, record INT NOT NULL,
@ -169,20 +149,15 @@ CREATE TABLE IF NOT EXISTS remote (
FOREIGN KEY(record) REFERENCES records(id) FOREIGN KEY(record) REFERENCES records(id)
ON DELETE CASCADE ON DELETE CASCADE
); );
CREATE INDEX IF NOT EXISTS rem_record_index ON remote(record); CREATE INDEX IF NOT EXISTS rem_record_index ON remote(record);
CREATE TABLE IF NOT EXISTS options ( CREATE TABLE IF NOT EXISTS options (
name varchar(255) NOT NULL, name varchar(255) NOT NULL,
value varchar(2000) DEFAULT NULL, value varchar(2000) DEFAULT NULL,
PRIMARY KEY (name) PRIMARY KEY (name)
); );
DELETE FROM options where name='schema_version'; DELETE FROM options where name='schema_version';
INSERT INTO options(name,value) VALUES ('schema_version', 4); INSERT INTO options(name,value) VALUES ('schema_version', 4);
"; ";
try { try {
$db = new PDO("$input->type:dbname=$input->database;host=$input->host;port=" . intval($input->port), $input->user, $input->password); $db = new PDO("$input->type:dbname=$input->database;host=$input->host;port=" . intval($input->port), $input->user, $input->password);
} }
@ -190,33 +165,22 @@ catch (PDOException $e) {
$retval['status'] = "error"; $retval['status'] = "error";
$retval['message'] = serialize($e); $retval['message'] = serialize($e);
} }
if (!isset($retval)) { if (!isset($retval)) {
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$passwordHash = password_hash($input->userPassword, PASSWORD_DEFAULT); $passwordHash = password_hash($input->userPassword, PASSWORD_DEFAULT);
$queries = explode(";", $sql[$input->type]); $queries = explode(";", $sql[$input->type]);
$db->beginTransaction(); $db->beginTransaction();
foreach ($queries as $query) { foreach ($queries as $query) {
if (preg_replace('/\s+/', '', $query) != '') { if (preg_replace('/\s+/', '', $query) != '') {
$db->exec($query); $db->exec($query);
} }
} }
$db->commit(); $db->commit();
$stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:user,:hash,'admin')"); $stmt = $db->prepare("INSERT INTO users(name,password,type) VALUES (:user,:hash,'admin')");
$stmt->bindValue(':user', $input->userName, PDO::PARAM_STR); $stmt->bindValue(':user', $input->userName, PDO::PARAM_STR);
$stmt->bindValue(':hash', $passwordHash, PDO::PARAM_STR); $stmt->bindValue(':hash', $passwordHash, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$configFile = Array(); $configFile = Array();
$configFile[] = '<?php'; $configFile[] = '<?php';
$configFile[] = '$config[\'db_host\'] = \'' . addslashes($input->host) . "';"; $configFile[] = '$config[\'db_host\'] = \'' . addslashes($input->host) . "';";
$configFile[] = '$config[\'db_user\'] = \'' . addslashes($input->user) . "';"; $configFile[] = '$config[\'db_user\'] = \'' . addslashes($input->user) . "';";
@ -224,7 +188,6 @@ if (!isset($retval)) {
$configFile[] = '$config[\'db_name\'] = \'' . addslashes($input->database) . "';"; $configFile[] = '$config[\'db_name\'] = \'' . addslashes($input->database) . "';";
$configFile[] = '$config[\'db_port\'] = ' . intval($input->port) . ";"; $configFile[] = '$config[\'db_port\'] = ' . intval($input->port) . ";";
$configFile[] = '$config[\'db_type\'] = \'' . addslashes($input->type) . "';"; $configFile[] = '$config[\'db_type\'] = \'' . addslashes($input->type) . "';";
$retval['status'] = "success"; $retval['status'] = "success";
try { try {
file_put_contents("../config/config-user.php", implode("\n", $configFile)); file_put_contents("../config/config-user.php", implode("\n", $configFile));
@ -234,7 +197,6 @@ if (!isset($retval)) {
$retval['message'] = serialize($e); $retval['message'] = serialize($e);
} }
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,27 +14,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(isset($input->action) && $input->action == "changePassword") { if(isset($input->action) && $input->action == "changePassword") {
$passwordHash = password_hash($input->password, PASSWORD_DEFAULT); $passwordHash = password_hash($input->password, PASSWORD_DEFAULT);
$stmt = $db->prepare("UPDATE users SET password=:password WHERE id=:id"); $stmt = $db->prepare("UPDATE users SET password=:password WHERE id=:id");
$stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR); $stmt->bindValue(':password', $passwordHash, PDO::PARAM_STR);
$stmt->bindValue(':id', $_SESSION['id'], PDO::PARAM_INT); $stmt->bindValue(':id', $_SESSION['id'], PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,45 +14,37 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/update-serial.php'; require_once '../lib/update-serial.php';
if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") { if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") {
if(filter_input(INPUT_GET, "action") == "updateRecord") { if(filter_input(INPUT_GET, "action") == "updateRecord") {
$input_domain = filter_input(INPUT_GET, "domain"); $input_domain = filter_input(INPUT_GET, "domain");
$input_id = filter_input(INPUT_GET, "id"); $input_id = filter_input(INPUT_GET, "id");
$input_password = filter_input(INPUT_GET, "password"); $input_password = filter_input(INPUT_GET, "password");
$input_content = filter_input(INPUT_GET, "content"); $input_content = filter_input(INPUT_GET, "content");
$stmt = $db->prepare("SELECT security,record FROM remote WHERE type='password' AND id=:id LIMIT 1"); $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->execute();
$stmt->bindColumn('security', $passwordHash); $stmt->bindColumn('security', $passwordHash);
$stmt->bindColumn('record', $record); $stmt->bindColumn('record', $record);
$stmt->fetch(PDO::FETCH_BOUND); $stmt->fetch(PDO::FETCH_BOUND);
if(!password_verify($input_password, $passwordHash)) { if(!password_verify($input_password, $passwordHash)) {
$return['status'] = "error"; $return['status'] = "error";
$return['error'] = "Permission denied"; $return['error'] = "Permission denied";
echo json_encode($return); echo json_encode($return);
exit(); exit();
} }
$stmt = $db->prepare("UPDATE records SET content=:content WHERE name=:name AND id=:id"); $stmt = $db->prepare("UPDATE records SET content=:content WHERE name=:name AND id=:id");
$stmt->bindValue(':content', $input_content, PDO::PARAM_STR); $stmt->bindValue(':content', $input_content, PDO::PARAM_STR);
$stmt->bindValue(':name', $input_domain, PDO::PARAM_STR); $stmt->bindValue(':name', $input_domain, PDO::PARAM_STR);
$stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->bindValue(':id', $record, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$stmt = $db->prepare("SELECT domain_id FROM records WHERE id=:id LIMIT 1"); $stmt = $db->prepare("SELECT domain_id FROM records WHERE id=:id LIMIT 1");
$stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->bindValue(':id', $record, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$domain_id = $stmt->fetchColumn(); $domain_id = $stmt->fetchColumn();
update_serial($db, $domain_id); update_serial($db, $domain_id);
$return['status'] = "success"; $return['status'] = "success";
echo json_encode($return); echo json_encode($return);
exit(); exit();
@ -61,17 +52,14 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") {
// If we are behind a proxy, return the first IP the request was forwarded for. // If we are behind a proxy, return the first IP the request was forwarded for.
if(filter_input(INPUT_SERVER, "HTTP_X_FORWARDED_FOR") != null){ if(filter_input(INPUT_SERVER, "HTTP_X_FORWARDED_FOR") != null){
$return['ip'] = explode(",", filter_input(INPUT_SERVER, "HTTP_X_FORWARDED_FOR"))[0]; $return['ip'] = explode(",", filter_input(INPUT_SERVER, "HTTP_X_FORWARDED_FOR"))[0];
} else { } else {
$return['ip'] = filter_input(INPUT_SERVER, "REMOTE_ADDR"); $return['ip'] = filter_input(INPUT_SERVER, "REMOTE_ADDR");
} }
echo json_encode($return); echo json_encode($return);
exit(); exit();
} }
} else if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "POST") { } else if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "POST") {
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(isset($input->domain) && isset($input->id) && isset($input->content)) { 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 = $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);
@ -79,23 +67,19 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") {
$stmt->bindColumn('E.name', $domainName); $stmt->bindColumn('E.name', $domainName);
$stmt->bindColumn('E.id', $record); $stmt->bindColumn('E.id', $record);
$stmt->fetch(PDO::FETCH_BOUND); $stmt->fetch(PDO::FETCH_BOUND);
if($domainName != $input->domain) { if($domainName != $input->domain) {
$return['status'] = "error"; $return['status'] = "error";
$return['error'] = "Id and domain do not match!"; $return['error'] = "Id and domain do not match!";
echo json_encode($return); echo json_encode($return);
exit(); exit();
} }
if(isset($_GET['getNonce'])) { if(isset($_GET['getNonce'])) {
$newNonce = base64_encode(openssl_random_pseudo_bytes(32)); $newNonce = base64_encode(openssl_random_pseudo_bytes(32));
$dbNonce = $newNonce . ":" . time(); $dbNonce = $newNonce . ":" . time();
$stmt = $db->prepare("UPDATE remote SET nonce=:nonce WHERE id=:id"); $stmt = $db->prepare("UPDATE remote SET nonce=:nonce WHERE id=:id");
$stmt->bindValue(':nonce', $dbNonce, PDO::PARAM_STR); $stmt->bindValue(':nonce', $dbNonce, PDO::PARAM_STR);
$stmt->bindValue(':id', $input->id, PDO::PARAM_INT); $stmt->bindValue(':id', $input->id, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$return['nonce'] = $newNonce; $return['nonce'] = $newNonce;
echo json_encode($return); echo json_encode($return);
exit(); exit();
@ -106,39 +90,31 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") {
$stmt->bindColumn('security', $pubkey); $stmt->bindColumn('security', $pubkey);
$stmt->bindColumn('nonce', $dbNonce); $stmt->bindColumn('nonce', $dbNonce);
$stmt->fetch(PDO::FETCH_BOUND); $stmt->fetch(PDO::FETCH_BOUND);
$nonce = explode(":", $dbNonce); $nonce = explode(":", $dbNonce);
if($dbNonce == NULL || (time() - $nonce[1]) > $config['nonce_lifetime']) { if($dbNonce == NULL || (time() - $nonce[1]) > $config['nonce_lifetime']) {
$return['status'] = "error"; $return['status'] = "error";
$return['error'] = "No valid nonce available!"; $return['error'] = "No valid nonce available!";
echo json_encode($return); echo json_encode($return);
exit(); exit();
} }
$verifyString = $input->domain . $input->id . $input->content . $nonce[0]; $verifyString = $input->domain . $input->id . $input->content . $nonce[0];
$signature = base64_decode($input->signature); $signature = base64_decode($input->signature);
if(openssl_verify($verifyString, $signature, $pubkey, OPENSSL_ALGO_SHA512) != 1) { if(openssl_verify($verifyString, $signature, $pubkey, OPENSSL_ALGO_SHA512) != 1) {
$return['status'] = "error"; $return['status'] = "error";
$return['error'] = "Bad signature!"; $return['error'] = "Bad signature!";
echo json_encode($return); echo json_encode($return);
exit(); exit();
} }
$stmt = $db->prepare("UPDATE records SET content=:content WHERE name=:name AND id=:id"); $stmt = $db->prepare("UPDATE records SET content=:content WHERE name=:name AND id=:id");
$stmt->bindValue(':content', $input->content, PDO::PARAM_STR); $stmt->bindValue(':content', $input->content, PDO::PARAM_STR);
$stmt->bindValue(':name', $input->domain, PDO::PARAM_STR); $stmt->bindValue(':name', $input->domain, PDO::PARAM_STR);
$stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->bindValue(':id', $record, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$stmt = $db->prepare("SELECT domain_id FROM records WHERE id=:id LIMIT 1"); $stmt = $db->prepare("SELECT domain_id FROM records WHERE id=:id LIMIT 1");
$stmt->bindValue(':id', $record, PDO::PARAM_INT); $stmt->bindValue(':id', $record, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$domain_id = $stmt->fetchColumn(); $domain_id = $stmt->fetchColumn();
update_serial($db, $domain_id); update_serial($db, $domain_id);
$return['status'] = "success"; $return['status'] = "success";
echo json_encode($return); echo json_encode($return);
exit(); exit();
@ -148,7 +124,6 @@ if(filter_input(INPUT_SERVER, "REQUEST_METHOD") == "GET") {
echo json_encode($return); echo json_encode($return);
exit(); exit();
} }
} else { } else {
$return['status'] = "error"; $return['status'] = "error";
$return['error'] = "Missing data"; $return['error'] = "Missing data";

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,18 +14,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/checkversion.php'; require_once '../lib/checkversion.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(isset($input->action) && $input->action == "getVersions") { if(isset($input->action) && $input->action == "getVersions") {
$retval['from'] = getVersion($db); $retval['from'] = getVersion($db);
$retval['to'] = getExpectedVersion(); $retval['to'] = getExpectedVersion();
} }
if(isset($input->action) && $input->action == "requestUpgrade") { if(isset($input->action) && $input->action == "requestUpgrade") {
$currentVersion = getVersion($db); $currentVersion = getVersion($db);
$dbType = $config['db_type']; $dbType = $config['db_type'];
@ -42,28 +37,23 @@ if(isset($input->action) && $input->action == "requestUpgrade") {
PRIMARY KEY (id), PRIMARY KEY (id),
KEY record (record) KEY record (record)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `remote` ALTER TABLE `remote`
ADD CONSTRAINT `remote_ibfk_1` FOREIGN KEY (`record`) REFERENCES `records` (`id`); ADD CONSTRAINT `remote_ibfk_1` FOREIGN KEY (`record`) REFERENCES `records` (`id`);
CREATE TABLE IF NOT EXISTS options ( CREATE TABLE IF NOT EXISTS options (
name varchar(255) NOT NULL, name varchar(255) NOT NULL,
value varchar(2000) DEFAULT NULL, value varchar(2000) DEFAULT NULL,
PRIMARY KEY (name) PRIMARY KEY (name)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO options(name,value) VALUES ('schema_version', 1); INSERT INTO options(name,value) VALUES ('schema_version', 1);
"; ";
$sql["pgsql"] = "INSERT INTO options(name,value) VALUES ('schema_version', 1);"; $sql["pgsql"] = "INSERT INTO options(name,value) VALUES ('schema_version', 1);";
$queries = explode(";", $sql[$dbType]); $queries = explode(";", $sql[$dbType]);
$db->beginTransaction(); $db->beginTransaction();
foreach ($queries as $query) { foreach ($queries as $query) {
if (preg_replace('/\s+/', '', $query) != '') { if (preg_replace('/\s+/', '', $query) != '') {
$db->exec($query); $db->exec($query);
} }
} }
$db->commit(); $db->commit();
} }
if($currentVersion < 2) { if($currentVersion < 2) {
@ -76,28 +66,22 @@ if(isset($input->action) && $input->action == "requestUpgrade") {
ADD CONSTRAINT permissions_ibfk_1 FOREIGN KEY (domain) REFERENCES domains (id) ON DELETE CASCADE; ADD CONSTRAINT permissions_ibfk_1 FOREIGN KEY (domain) REFERENCES domains (id) ON DELETE CASCADE;
ALTER TABLE permissions ALTER TABLE permissions
ADD CONSTRAINT permissions_ibfk_2 FOREIGN KEY (user) REFERENCES user (id) ON DELETE CASCADE; ADD CONSTRAINT permissions_ibfk_2 FOREIGN KEY (user) REFERENCES user (id) ON DELETE CASCADE;
ALTER TABLE remote ALTER TABLE remote
DROP FOREIGN KEY remote_ibfk_1; DROP FOREIGN KEY remote_ibfk_1;
ALTER TABLE remote ALTER TABLE remote
ADD CONSTRAINT remote_ibfk_1 FOREIGN KEY (record) REFERENCES records (id) ON DELETE CASCADE; ADD CONSTRAINT remote_ibfk_1 FOREIGN KEY (record) REFERENCES records (id) ON DELETE CASCADE;
ALTER TABLE records ALTER TABLE records
ADD CONSTRAINT records_ibfk_1 FOREIGN KEY (domain_id) REFERENCES domains (id) ON DELETE CASCADE; ADD CONSTRAINT records_ibfk_1 FOREIGN KEY (domain_id) REFERENCES domains (id) ON DELETE CASCADE;
UPDATE options SET value=2 WHERE name='schema_version'; UPDATE options SET value=2 WHERE name='schema_version';
"; ";
$sql["pgsql"] = "UPDATE options SET value=2 WHERE name='schema_version';"; $sql["pgsql"] = "UPDATE options SET value=2 WHERE name='schema_version';";
$queries = explode(";", $sql[$dbType]); $queries = explode(";", $sql[$dbType]);
$db->beginTransaction(); $db->beginTransaction();
foreach ($queries as $query) { foreach ($queries as $query) {
if (preg_replace('/\s+/', '', $query) != '') { if (preg_replace('/\s+/', '', $query) != '') {
$db->exec($query); $db->exec($query);
} }
} }
$db->commit(); $db->commit();
} }
if($currentVersion < 3) { if($currentVersion < 3) {
@ -109,24 +93,18 @@ if(isset($input->action) && $input->action == "requestUpgrade") {
content TEXT, content TEXT,
PRIMARY KEY (id) PRIMARY KEY (id)
) Engine=InnoDB; ) Engine=InnoDB;
ALTER TABLE records ADD disabled TINYINT(1) DEFAULT 0; ALTER TABLE records ADD disabled TINYINT(1) DEFAULT 0;
ALTER TABLE records ADD auth TINYINT(1) DEFAULT 1; ALTER TABLE records ADD auth TINYINT(1) DEFAULT 1;
UPDATE options SET value=3 WHERE name='schema_version'; UPDATE options SET value=3 WHERE name='schema_version';
"; ";
$sql["pgsql"] = "UPDATE options SET value=3 WHERE name='schema_version';"; $sql["pgsql"] = "UPDATE options SET value=3 WHERE name='schema_version';";
$queries = explode(";", $sql[$dbType]); $queries = explode(";", $sql[$dbType]);
$db->beginTransaction(); $db->beginTransaction();
foreach ($queries as $query) { foreach ($queries as $query) {
if (preg_replace('/\s+/', '', $query) != '') { if (preg_replace('/\s+/', '', $query) != '') {
$db->exec($query); $db->exec($query);
} }
} }
$db->commit(); $db->commit();
} }
if($currentVersion < 4) { if($currentVersion < 4) {
@ -136,29 +114,21 @@ if(isset($input->action) && $input->action == "requestUpgrade") {
ALTER TABLE permissions CHANGE user userid INT(11); ALTER TABLE permissions CHANGE user userid INT(11);
ALTER TABLE permissions ALTER TABLE permissions
ADD CONSTRAINT permissions_ibfk_2 FOREIGN KEY (userid) REFERENCES users (id) ON DELETE CASCADE; ADD CONSTRAINT permissions_ibfk_2 FOREIGN KEY (userid) REFERENCES users (id) ON DELETE CASCADE;
ALTER TABLE users ADD CONSTRAINT UNIQUE KEY user_name_index (name); ALTER TABLE users ADD CONSTRAINT UNIQUE KEY user_name_index (name);
UPDATE options SET value=4 WHERE name='schema_version'; UPDATE options SET value=4 WHERE name='schema_version';
"; ";
$sql["pgsql"] = "UPDATE options SET value=4 WHERE name='schema_version';"; $sql["pgsql"] = "UPDATE options SET value=4 WHERE name='schema_version';";
$queries = explode(";", $sql[$dbType]); $queries = explode(";", $sql[$dbType]);
$db->beginTransaction(); $db->beginTransaction();
foreach ($queries as $query) { foreach ($queries as $query) {
if (preg_replace('/\s+/', '', $query) != '') { if (preg_replace('/\s+/', '', $query) != '') {
$db->exec($query); $db->exec($query);
} }
} }
$db->commit(); $db->commit();
} }
$retval['status'] = "success"; $retval['status'] = "success";
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,25 +14,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require_once '../config/config-default.php'; require_once '../config/config-default.php';
require_once '../lib/database.php'; require_once '../lib/database.php';
require_once '../lib/session.php'; require_once '../lib/session.php';
$input = json_decode(file_get_contents('php://input')); $input = json_decode(file_get_contents('php://input'));
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) { if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") { if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
echo "Permission denied!"; echo "Permission denied!";
exit(); exit();
} }
if(isset($input->action) && $input->action == "getUsers") { if(isset($input->action) && $input->action == "getUsers") {
$sql = " $sql = "
SELECT id,name,type SELECT id,name,type
FROM users FROM users
@ -41,7 +34,6 @@ if(isset($input->action) && $input->action == "getUsers") {
(name LIKE :name1 OR :name2) AND (name LIKE :name1 OR :name2) AND
(type=:type1 OR :type2) (type=:type1 OR :type2)
"; ";
if(isset($input->sort->field) && $input->sort->field != "") { if(isset($input->sort->field) && $input->sort->field != "") {
if($input->sort->field == "id") { if($input->sort->field == "id") {
$sql .= "ORDER BY id"; $sql .= "ORDER BY id";
@ -50,7 +42,6 @@ if(isset($input->action) && $input->action == "getUsers") {
} else if($input->sort->field == "type") { } else if($input->sort->field == "type") {
$sql .= "ORDER BY type"; $sql .= "ORDER BY type";
} }
if(isset($input->sort->order)) { if(isset($input->sort->order)) {
if($input->sort->order == 0) { if($input->sort->order == 0) {
$sql .= " DESC"; $sql .= " DESC";
@ -59,9 +50,7 @@ if(isset($input->action) && $input->action == "getUsers") {
} }
} }
} }
$stmt = $db->prepare($sql); $stmt = $db->prepare($sql);
if(isset($input->name)) { if(isset($input->name)) {
$name_filter = "%" . $input->name . "%"; $name_filter = "%" . $input->name . "%";
$name_filter_used = 0; $name_filter_used = 0;
@ -69,7 +58,6 @@ if(isset($input->action) && $input->action == "getUsers") {
$name_filter = ""; $name_filter = "";
$name_filter_used = 1; $name_filter_used = 1;
} }
if(isset($input->type)) { if(isset($input->type)) {
$type_filter = $input->type; $type_filter = $input->type;
$type_filter_used = 0; $type_filter_used = 0;
@ -77,36 +65,27 @@ if(isset($input->action) && $input->action == "getUsers") {
$type_filter = ""; $type_filter = "";
$type_filter_used = 1; $type_filter_used = 1;
} }
$stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR); $stmt->bindValue(':name1', $name_filter, PDO::PARAM_STR);
$stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT); $stmt->bindValue(':name2', $name_filter_used, PDO::PARAM_INT);
$stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT); $stmt->bindValue(':type1', $type_filter, PDO::PARAM_INT);
$stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT); $stmt->bindValue(':type2', $type_filter_used, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$retval = Array(); $retval = Array();
while($obj = $stmt->fetchObject()) { while($obj = $stmt->fetchObject()) {
$retval[] = $obj; $retval[] = $obj;
} }
} }
if(isset($input->action) && $input->action == "deleteUser") { if(isset($input->action) && $input->action == "deleteUser") {
$userId = $input->id; $userId = $input->id;
$db->beginTransaction(); $db->beginTransaction();
$stmt = $db->prepare("DELETE FROM permissions WHERE userid=:userid"); $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->execute();
$stmt = $db->prepare("DELETE FROM users WHERE id=:id"); $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(); $stmt->execute();
$db->commit(); $db->commit();
} }
if(isset($retval)) { if(isset($retval)) {
echo json_encode($retval); echo json_encode($retval);
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,7 +14,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
//Database settings //Database settings
$config['db_type'] = "mysql"; $config['db_type'] = "mysql";
$config['db_host'] = "localhost"; $config['db_host'] = "localhost";
@ -23,11 +21,8 @@ $config['db_user'] = "root";
$config['db_password'] = ""; $config['db_password'] = "";
$config['db_port'] = 3306; $config['db_port'] = 3306;
$config['db_name'] = "pdnsmanager"; $config['db_name'] = "pdnsmanager";
//Remote update //Remote update
$config['nonce_lifetime'] = 15; $config['nonce_lifetime'] = 15;
//Number of rows in domain overview //Number of rows in domain overview
$config['domain_rows'] = 15; $config['domain_rows'] = 15;
require 'config-user.php'; require 'config-user.php';

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,17 +20,14 @@ limitations under the License.
<title>PDNS Manager - Domains</title> <title>PDNS Manager - Domains</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/select2/select2.min.css" rel="stylesheet"> <link href="include/select2/select2.min.css" rel="stylesheet">
<link href="include/select2/select2-bootstrap.min.css" rel="stylesheet"> <link href="include/select2/select2-bootstrap.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="include/select2/select2.min.js"></script> <script src="include/select2/select2.min.js"></script>
<script src="js/domains.js"></script> <script src="js/domains.js"></script>
</head> </head>
<body> <body>
@ -50,7 +44,6 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<table class="table table-hover" id="table-domains"> <table class="table table-hover" id="table-domains">
<thead> <thead>
@ -86,10 +79,8 @@ limitations under the License.
</table> </table>
<nav id="pagination-wrapper" class="text-center defaulthidden"> <nav id="pagination-wrapper" class="text-center defaulthidden">
<ul id="pagination" class="pagination cursor-pointer"> <ul id="pagination" class="pagination cursor-pointer">
</ul> </ul>
</nav> </nav>
<?php <?php
if($_SESSION['type'] == "admin") { if($_SESSION['type'] == "admin") {
echo '<div class="row text-center">'; echo '<div class="row text-center">';
@ -99,7 +90,6 @@ limitations under the License.
} }
?> ?>
</div> </div>
<div class="modal fade" id="deleteConfirm" tabindex="-1" role="dialog"> <div class="modal fade" id="deleteConfirm" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@ -113,8 +103,6 @@ limitations under the License.
</div> </div>
</div> </div>
</div> </div>
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?> <?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
</body> </body>
</html> </html>

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,17 +20,14 @@ limitations under the License.
<title>PDNS Manager - Domains</title> <title>PDNS Manager - Domains</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/select2/select2.min.css" rel="stylesheet"> <link href="include/select2/select2.min.css" rel="stylesheet">
<link href="include/select2/select2-bootstrap.min.css" rel="stylesheet"> <link href="include/select2/select2-bootstrap.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="include/select2/select2.min.js"></script> <script src="include/select2/select2.min.js"></script>
<script src="js/edit-master.js"></script> <script src="js/edit-master.js"></script>
</head> </head>
<body> <body>
@ -50,13 +44,10 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2 id="domain-name"></h2> <h2 id="domain-name"></h2>
</row> </row>
<div id="soa" class="container"> <div id="soa" class="container">
<row> <row>
<h3>SOA</h3> <h3>SOA</h3>
@ -74,7 +65,6 @@ limitations under the License.
</div> </div>
<button disabled type="submit" class="btn btn-primary" tabindex="7">Save</button> <button disabled type="submit" class="btn btn-primary" tabindex="7">Save</button>
</div> </div>
<div class="col-md-2 col-md-offset-1"> <div class="col-md-2 col-md-offset-1">
<div class="form-group"> <div class="form-group">
<label for="soa-refresh" class="control-label">Refresh</label> <label for="soa-refresh" class="control-label">Refresh</label>
@ -85,7 +75,6 @@ limitations under the License.
<input type="text" class="form-control" id="soa-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="4"> <input type="text" class="form-control" id="soa-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="4">
</div> </div>
</div> </div>
<div class="col-md-2 col-md-offset-1"> <div class="col-md-2 col-md-offset-1">
<div class="form-group"> <div class="form-group">
<label for="soa-expire" class="control-label">Expire</label> <label for="soa-expire" class="control-label">Expire</label>
@ -96,7 +85,6 @@ limitations under the License.
<input type="text" class="form-control" id="soa-ttl" placeholder="TTL" autocomplete="off" data-regex="^[0-9]+$" tabindex="6"> <input type="text" class="form-control" id="soa-ttl" placeholder="TTL" autocomplete="off" data-regex="^[0-9]+$" tabindex="6">
</div> </div>
</div> </div>
<div class="col-md-2 col-md-offset-1"> <div class="col-md-2 col-md-offset-1">
<div class="form-group"> <div class="form-group">
<label for="soa-serial" class="control-label">Serial</label> <label for="soa-serial" class="control-label">Serial</label>
@ -106,7 +94,6 @@ limitations under the License.
</form> </form>
</row> </row>
</div> </div>
<div id="records" class="container"> <div id="records" class="container">
<row> <row>
<h3>Records</h3> <h3>Records</h3>
@ -166,7 +153,5 @@ limitations under the License.
</div> </div>
</div> </div>
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?> <?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
</body> </body>
</html> </html>

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,17 +20,14 @@ limitations under the License.
<title>PDNS Manager - Remotes</title> <title>PDNS Manager - Remotes</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/select2/select2.min.css" rel="stylesheet"> <link href="include/select2/select2.min.css" rel="stylesheet">
<link href="include/select2/select2-bootstrap.min.css" rel="stylesheet"> <link href="include/select2/select2-bootstrap.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="include/select2/select2.min.js"></script> <script src="include/select2/select2.min.js"></script>
<script src="js/edit-remote.js"></script> <script src="js/edit-remote.js"></script>
</head> </head>
<body> <body>
@ -50,13 +44,10 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2 id="heading">Remote access</h2> <h2 id="heading">Remote access</h2>
</row> </row>
<row> <row>
<div class="col-md-4"> <div class="col-md-4">
<table id="permissions" class="table table-hover"> <table id="permissions" class="table table-hover">
@ -72,7 +63,6 @@ limitations under the License.
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
<row> <row>
<button id="button-add-password" class="btn btn-success">Add password</button> <button id="button-add-password" class="btn btn-success">Add password</button>
<button id="button-add-key" class="btn btn-success">Add key</button> <button id="button-add-key" class="btn btn-success">Add key</button>
@ -97,7 +87,6 @@ limitations under the License.
<button id="data-password-cancel" class="btn btn-default">Cancel</button> <button id="data-password-cancel" class="btn btn-default">Cancel</button>
</form> </form>
</row> </row>
<row id="data-key" class="defaulthidden"> <row id="data-key" class="defaulthidden">
<form> <form>
<div class="form-group"> <div class="form-group">
@ -116,7 +105,5 @@ limitations under the License.
</row> </row>
</div> </div>
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?> <?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
</body> </body>
</html> </html>

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,17 +20,14 @@ limitations under the License.
<title>PDNS Manager - Users</title> <title>PDNS Manager - Users</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/select2/select2.min.css" rel="stylesheet"> <link href="include/select2/select2.min.css" rel="stylesheet">
<link href="include/select2/select2-bootstrap.min.css" rel="stylesheet"> <link href="include/select2/select2-bootstrap.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="include/select2/select2.min.js"></script> <script src="include/select2/select2.min.js"></script>
<script src="js/edit-user.js"></script> <script src="js/edit-user.js"></script>
</head> </head>
<body> <body>
@ -50,17 +44,13 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2 id="heading">Change user</h2> <h2 id="heading">Change user</h2>
</row> </row>
<row> <row>
<div class="col-md-3"> <div class="col-md-3">
<form> <form>
<div class="form-group"> <div class="form-group">
<label for="user-name" class="control-label">Name</label> <label for="user-name" class="control-label">Name</label>
<input type="text" class="form-control" id="user-name" placeholder="Username" autocomplete="off" data-regex="^[A-Za-z0-9\._-]+$" tabindex="1"> <input type="text" class="form-control" id="user-name" placeholder="Username" autocomplete="off" data-regex="^[A-Za-z0-9\._-]+$" tabindex="1">
@ -83,25 +73,19 @@ limitations under the License.
<button id="user-button-add" class="btn btn-primary" tabindex="5">Change</button> <button id="user-button-add" class="btn btn-primary" tabindex="5">Change</button>
</form> </form>
</div> </div>
<div class="col-md-3 col-md-offset-1 defaulthidden" id="permissions"> <div class="col-md-3 col-md-offset-1 defaulthidden" id="permissions">
<h3>Permissions</h3> <h3>Permissions</h3>
<table class="table table-hover"> <table class="table table-hover">
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
<label for="selectAdd" class="control-label">Add</label> <label for="selectAdd" class="control-label">Add</label>
<select multiple class="form-control" id="selectAdd"></select> <select multiple class="form-control" id="selectAdd"></select>
<div class="vspacer-15"></div> <div class="vspacer-15"></div>
<button class="btn btn-primary" id="btnAddPermissions">Add</button> <button class="btn btn-primary" id="btnAddPermissions">Add</button>
</div> </div>
</row> </row>
</div> </div>
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?> <?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
</body> </body>
</html> </html>

View file

@ -8,25 +8,18 @@
.vspacer-80 { height: 80px; } .vspacer-80 { height: 80px; }
.vspacer-100 { height: 100px; } .vspacer-100 { height: 100px; }
.vspacer-150 { height: 150px; } .vspacer-150 { height: 150px; }
.margin-left-20 { margin-left: 20px; } .margin-left-20 { margin-left: 20px; }
.defaulthidden { display: none; } .defaulthidden { display: none; }
.cursor-pointer {cursor: pointer; } .cursor-pointer {cursor: pointer; }
.wrap-all-words { .wrap-all-words {
word-wrap: break-word; word-wrap: break-word;
max-width: 350px; max-width: 350px;
} }
.no-shadow { .no-shadow {
box-shadow: none!important; box-shadow: none!important;
border-color: #CCC!important; border-color: #CCC!important;
} }
.cell-vertical-bottom { vertical-align: bottom !important; } .cell-vertical-bottom { vertical-align: bottom !important; }
.cell-vertical-middle { vertical-align: middle !important; } .cell-vertical-middle { vertical-align: middle !important; }
.cell-vertical-top { vertical-align: top !important; } .cell-vertical-top { vertical-align: top !important; }
.select-narrow-70 { width: 70%; } .select-narrow-70 { width: 70%; }

View file

@ -3,7 +3,6 @@
require_once 'config/config-default.php'; require_once 'config/config-default.php';
require_once 'lib/database.php'; require_once 'lib/database.php';
require_once 'lib/checkversion.php'; require_once 'lib/checkversion.php';
if(!checkVersion($db)) { if(!checkVersion($db)) {
Header("Location: upgrade.php"); Header("Location: upgrade.php");
} }
@ -11,13 +10,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -29,14 +25,11 @@ limitations under the License.
<title>PDNS Manager</title> <title>PDNS Manager</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="js/index.js"></script> <script src="js/index.js"></script>
</head> </head>
<body> <body>
@ -49,7 +42,6 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<div class="row vspacer-60"></div> <div class="row vspacer-60"></div>
<div class="row"> <div class="row">

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -25,14 +22,11 @@ limitations under the License.
<title>PDNS Manager - Domains</title> <title>PDNS Manager - Domains</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="js/install.js"></script> <script src="js/install.js"></script>
</head> </head>
<body> <body>
@ -46,21 +40,16 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2 id="domain-name">Install PDNS Manager</h2> <h2 id="domain-name">Install PDNS Manager</h2>
</row> </row>
<row> <row>
<div class="alert alert-danger defaulthidden" id="alertFailed" role="alert"> <div class="alert alert-danger defaulthidden" id="alertFailed" role="alert">
Error Error
</div> </div>
</row> </row>
<row> <row>
<form> <form>
<div class="container col-md-3"> <div class="container col-md-3">
<h3>Database</h3> <h3>Database</h3>
@ -93,10 +82,8 @@ limitations under the License.
</div> </div>
<button id="buttonInstall" class="btn btn-primary">Install</button> <button id="buttonInstall" class="btn btn-primary">Install</button>
</div> </div>
<div class="container col-md-3"> <div class="container col-md-3">
<h3>Admin</h3> <h3>Admin</h3>
<div class="form-group"> <div class="form-group">
<label for="adminName" class="control-label">Name</label> <label for="adminName" class="control-label">Name</label>
<input type="text" class="form-control" id="adminName" placeholder="Name" autocomplete="off"> <input type="text" class="form-control" id="adminName" placeholder="Name" autocomplete="off">
@ -112,9 +99,6 @@ limitations under the License.
</div> </div>
</form> </form>
</row> </row>
</div> </div>
</body> </body>
</html> </html>

View file

@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#zone-button-add').click(function(evt){ $('#zone-button-add').click(function(evt){
evt.preventDefault(); evt.preventDefault();
if(validateData()) { if(validateData()) {
@ -26,26 +24,19 @@ $(document).ready(function() {
shake($('#zone-button-add')); shake($('#zone-button-add'));
} }
}); });
$('form input').bind("paste keyup change", regexValidate); $('form input').bind("paste keyup change", regexValidate);
}); });
function validateData() { function validateData() {
var error = 0; var error = 0;
$('form input').change(); $('form input').change();
$('form input').each(function() { $('form input').each(function() {
if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) { if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) {
error++; error++;
$(this).parent().addClass('has-error'); $(this).parent().addClass('has-error');
} }
}); });
return error<=0; return error<=0;
} }
function regexValidate() { function regexValidate() {
var regex = new RegExp($(this).attr('data-regex')); var regex = new RegExp($(this).attr('data-regex'));
if(!regex.test($(this).val())) { if(!regex.test($(this).val())) {
@ -54,7 +45,6 @@ function regexValidate() {
$(this).parent().removeClass("has-error"); $(this).parent().removeClass("has-error");
} }
} }
function saveData(callback) { function saveData(callback) {
var data = { var data = {
name: $('#zone-name').val(), name: $('#zone-name').val(),
@ -68,7 +58,6 @@ function saveData(callback) {
action: "addDomain", action: "addDomain",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/add-domain.php", "api/add-domain.php",
JSON.stringify(data), JSON.stringify(data),
@ -78,19 +67,15 @@ function saveData(callback) {
"json" "json"
); );
} }
function shake(element){ function shake(element){
var interval = 50; var interval = 50;
var distance = 5; var distance = 5;
var times = 6; var times = 6;
$(element).css('position','relative'); $(element).css('position','relative');
for(var iter=0;iter<(times+1);iter++){ for(var iter=0;iter<(times+1);iter++){
$(element).animate({ $(element).animate({
left:((iter%2===0 ? distance : distance*-1)) left:((iter%2===0 ? distance : distance*-1))
},interval); },interval);
} }
$(element).animate({ left: 0},interval); $(element).animate({ left: 0},interval);
} }

View file

@ -13,15 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var sort = { var sort = {
field: "", field: "",
order: 1 order: 1
} }
$(document).ready(function() { $(document).ready(function() {
requestData(); requestData();
$('#table-domains>thead>tr>td span').click(function() { $('#table-domains>thead>tr>td span').click(function() {
var field = $(this).siblings('strong').text().toLowerCase(); var field = $(this).siblings('strong').text().toLowerCase();
if(sort.field == field) { if(sort.field == field) {
@ -32,51 +29,40 @@ $(document).ready(function() {
sort.order = 1; sort.order = 1;
} }
$('#table-domains>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt"); $('#table-domains>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt");
if(sort.field == field) { if(sort.field == field) {
if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes"); if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes");
else $(this).addClass("glyphicon-sort-by-attributes-alt"); else $(this).addClass("glyphicon-sort-by-attributes-alt");
} }
requestData(); requestData();
}); });
$('#searchName').bind("paste keyup", function() { $('#searchName').bind("paste keyup", function() {
requestData(); requestData();
}); });
$('#searchType').change(function() { $('#searchType').change(function() {
requestData(); requestData();
}); });
$('#searchType').select2({ $('#searchType').select2({
minimumResultsForSearch: Infinity minimumResultsForSearch: Infinity
}); });
}); });
function requestData(page) { function requestData(page) {
if(typeof(page) !== 'number' || page <= 0) { if(typeof(page) !== 'number' || page <= 0) {
page = 1; page = 1;
} }
var restrictions = { var restrictions = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
}; };
restrictions.sort = sort; restrictions.sort = sort;
var searchName = $('#searchName').val(); var searchName = $('#searchName').val();
if(searchName.length > 0) { if(searchName.length > 0) {
restrictions.name = searchName; restrictions.name = searchName;
} }
var searchType = $('#searchType').val(); var searchType = $('#searchType').val();
if(searchType != "none") { if(searchType != "none") {
restrictions.type = searchType; restrictions.type = searchType;
} }
restrictions.action = "getDomains"; restrictions.action = "getDomains";
restrictions.page = page; restrictions.page = page;
$.post( $.post(
"api/domains.php", "api/domains.php",
JSON.stringify(restrictions), JSON.stringify(restrictions),
@ -87,25 +73,19 @@ function requestData(page) {
"json" "json"
); );
} }
function recreatePagination(data) { function recreatePagination(data) {
$('#pagination').empty(); $('#pagination').empty();
if(data.total === 1) { if(data.total === 1) {
$('#pagination-wrapper').hide(); $('#pagination-wrapper').hide();
return; return;
} }
if(data.current > 1) { if(data.current > 1) {
$('<li><a href="#"><span class="glyphicon glyphicon-chevron-left"></span></a></li>').appendTo('#pagination').data("page", data.current - 1).click(paginationClicked); $('<li><a href="#"><span class="glyphicon glyphicon-chevron-left"></span></a></li>').appendTo('#pagination').data("page", data.current - 1).click(paginationClicked);
} }
$('<li><span>1</span></li>').appendTo('#pagination').data("page", 1).click(paginationClicked); $('<li><span>1</span></li>').appendTo('#pagination').data("page", 1).click(paginationClicked);
if(data.current > 4) { if(data.current > 4) {
$('<li class="disabled"><span>&hellip;</span></li>').appendTo('#pagination'); $('<li class="disabled"><span>&hellip;</span></li>').appendTo('#pagination');
} }
for(var i = data.current - 2; i <= data.current + 2; i++) { for(var i = data.current - 2; i <= data.current + 2; i++) {
if(i > 1 && i < data.total) { if(i > 1 && i < data.total) {
if(data.current === i) { if(data.current === i) {
@ -115,23 +95,17 @@ function recreatePagination(data) {
} }
} }
} }
if(data.current < data.total - 3) { if(data.current < data.total - 3) {
$('<li class="disabled"><span>&hellip;</span></li>').appendTo('#pagination'); $('<li class="disabled"><span>&hellip;</span></li>').appendTo('#pagination');
} }
$('<li><span>' + data.total + '</span></li>').appendTo('#pagination').data("page", data.total).click(paginationClicked); $('<li><span>' + data.total + '</span></li>').appendTo('#pagination').data("page", data.total).click(paginationClicked);
if(data.current < data.total) { if(data.current < data.total) {
$('<li><a href="#"><span class="glyphicon glyphicon-chevron-right"></span></a></li>').appendTo('#pagination').data("page", data.current + 1).click(paginationClicked); $('<li><a href="#"><span class="glyphicon glyphicon-chevron-right"></span></a></li>').appendTo('#pagination').data("page", data.current + 1).click(paginationClicked);
} }
$('#pagination-wrapper').show(); $('#pagination-wrapper').show();
} }
function recreateTable(data) { function recreateTable(data) {
$('#table-domains>tbody').empty(); $('#table-domains>tbody').empty();
$.each(data, function(index,item) { $.each(data, function(index,item) {
$('<tr></tr>').appendTo('#table-domains>tbody') $('<tr></tr>').appendTo('#table-domains>tbody')
.append('<td>' + item.id + '</td>') .append('<td>' + item.id + '</td>')
@ -139,50 +113,40 @@ function recreateTable(data) {
.append('<td>' + item.type + '</td>') .append('<td>' + item.type + '</td>')
.append('<td>' + item.records + '</td>') .append('<td>' + item.records + '</td>')
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>'); .append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>');
}); });
$('#table-domains>tbody>tr>td:not(:last-child)').click(function() { $('#table-domains>tbody>tr>td:not(:last-child)').click(function() {
var id = $(this).parent().children('td').first().text(); var id = $(this).parent().children('td').first().text();
var type = $(this).parent().children('td').eq(2).text(); var type = $(this).parent().children('td').eq(2).text();
if(type == 'MASTER') { if(type == 'MASTER') {
location.assign('edit-master.php#' + id); location.assign('edit-master.php#' + id);
} else if(type == 'NATIVE') { } else if(type == 'NATIVE') {
location.assign('edit-master.php#' + id); location.assign('edit-master.php#' + id);
} }
}); });
$('#table-domains>tbody>tr>td>span.glyphicon-trash').click(function() { $('#table-domains>tbody>tr>td>span.glyphicon-trash').click(function() {
$(this).parent().parent().unbind(); $(this).parent().parent().unbind();
deleteDomain.call(this); deleteDomain.call(this);
}); });
} }
function deleteDomain() { function deleteDomain() {
var deleteId = $(this).parent().parent().children('td').eq(0).text(); var deleteId = $(this).parent().parent().children('td').eq(0).text();
var deleteZone = $(this).parent().parent().children('td').eq(1).text(); var deleteZone = $(this).parent().parent().children('td').eq(1).text();
var rowToRemove = $(this).parent().parent(); var rowToRemove = $(this).parent().parent();
$('#zoneToDelete').text(deleteZone); $('#zoneToDelete').text(deleteZone);
$('#deleteConfirm #buttonDelete').click(function() { $('#deleteConfirm #buttonDelete').click(function() {
deleteDomainWithId(deleteId, function() { deleteDomainWithId(deleteId, function() {
$('#deleteConfirm').modal("hide"); $('#deleteConfirm').modal("hide");
$(rowToRemove).remove(); $(rowToRemove).remove();
}); });
}); });
$('#deleteConfirm').modal(); $('#deleteConfirm').modal();
} }
function deleteDomainWithId(id, callback) { function deleteDomainWithId(id, callback) {
var data = { var data = {
action: "deleteDomain", action: "deleteDomain",
id: id, id: id,
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/domains.php", "api/domains.php",
JSON.stringify(data), JSON.stringify(data),
@ -192,7 +156,6 @@ function deleteDomainWithId(id, callback) {
"json" "json"
); );
} }
function paginationClicked() { function paginationClicked() {
requestData($(this).data("page")); requestData($(this).data("page"));
} }

View file

@ -13,14 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var sort = { var sort = {
field: "", field: "",
order: 1 order: 1
}; };
var domainName = ""; var domainName = "";
var recordTypes = [ var recordTypes = [
"A","A6","AAAA","AFSDB","ALIAS","CAA","CDNSKEY","CDS","CERT","CNAME","DHCID", "A","A6","AAAA","AFSDB","ALIAS","CAA","CDNSKEY","CDS","CERT","CNAME","DHCID",
"DLV","DNAME","DNSKEY","DS","EUI48","EUI64","HINFO", "DLV","DNAME","DNSKEY","DS","EUI48","EUI64","HINFO",
@ -29,9 +26,7 @@ var recordTypes = [
"OPT","PTR","RKEY","RP","RRSIG","SIG","SPF", "OPT","PTR","RKEY","RP","RRSIG","SIG","SPF",
"SRV","TKEY","SSHFP","TLSA","TSIG","TXT","WKS","MBOXFW","URL" "SRV","TKEY","SSHFP","TLSA","TSIG","TXT","WKS","MBOXFW","URL"
]; ];
$(document).ready(function() { $(document).ready(function() {
$('#soa button[type=submit]').click(function(){ $('#soa button[type=submit]').click(function(){
if(validateSoaData()) { if(validateSoaData()) {
saveSoaData(); saveSoaData();
@ -40,23 +35,18 @@ $(document).ready(function() {
shake($('#soa button[type=submit]')); shake($('#soa button[type=submit]'));
} }
}); });
$('#soa input').bind("paste keyup change", function() { $('#soa input').bind("paste keyup change", function() {
$('#soa button[type=submit]').prop("disabled", false); $('#soa button[type=submit]').prop("disabled", false);
}); });
$('#soa form input').bind("paste keyup change", regexValidate); $('#soa form input').bind("paste keyup change", regexValidate);
$('#table-records>tfoot input').bind("paste keyup change", regexValidate); $('#table-records>tfoot input').bind("paste keyup change", regexValidate);
$('#searchType').select2({ $('#searchType').select2({
placeholder: "Filter...", placeholder: "Filter...",
data: recordTypes data: recordTypes
}); });
$('#addType').select2({ $('#addType').select2({
data: recordTypes data: recordTypes
}); });
$('#table-records>thead>tr>td span.glyphicon').click(function() { $('#table-records>thead>tr>td span.glyphicon').click(function() {
var field = $(this).siblings('strong').text().toLowerCase(); var field = $(this).siblings('strong').text().toLowerCase();
if(sort.field == field) { if(sort.field == field) {
@ -67,45 +57,35 @@ $(document).ready(function() {
sort.order = 1; sort.order = 1;
} }
$('#table-records>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt"); $('#table-records>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt");
if(sort.field == field) { if(sort.field == field) {
if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes"); if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes");
else $(this).addClass("glyphicon-sort-by-attributes-alt"); else $(this).addClass("glyphicon-sort-by-attributes-alt");
} }
requestRecordData(); requestRecordData();
}); });
$('#searchName, #searchContent').bind("paste keyup", function() { $('#searchName, #searchContent').bind("paste keyup", function() {
requestRecordData(); requestRecordData();
}); });
$('#searchType').change(function() { $('#searchType').change(function() {
requestRecordData(); requestRecordData();
}); });
requestRecordData(); requestRecordData();
requestSoaData(); requestSoaData();
requestSerial(); requestSerial();
requestDomainName(); requestDomainName();
}); });
function validateSoaData() { function validateSoaData() {
var error = 0; var error = 0;
$('#soa form input:not(#soa-serial)').each(function() { $('#soa form input:not(#soa-serial)').each(function() {
if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) { if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) {
error++; error++;
$(this).parent().addClass('has-error'); $(this).parent().addClass('has-error');
} }
}); });
return error<=0; return error<=0;
} }
function recreateTable(data) { function recreateTable(data) {
$('#table-records>tbody').empty(); $('#table-records>tbody').empty();
$.each(data, function(index,item) { $.each(data, function(index,item) {
$('<tr></tr>').appendTo('#table-records>tbody') $('<tr></tr>').appendTo('#table-records>tbody')
.append('<td>' + item.id + '</td>') .append('<td>' + item.id + '</td>')
@ -117,40 +97,30 @@ function recreateTable(data) {
.append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-share cursor-pointer"></span></td>'); .append('<td><span class="glyphicon glyphicon-share cursor-pointer"></span></td>');
}); });
$('#table-records>tbody>tr>td>span.glyphicon-trash').click(trashClicked); $('#table-records>tbody>tr>td>span.glyphicon-trash').click(trashClicked);
$('#table-records>tbody>tr>td>span.glyphicon-pencil').click(editClicked); $('#table-records>tbody>tr>td>span.glyphicon-pencil').click(editClicked);
$('#table-records>tbody>tr>td>span.glyphicon-share').click(remoteClicked); $('#table-records>tbody>tr>td>span.glyphicon-share').click(remoteClicked);
} }
function requestRecordData() { function requestRecordData() {
var restrictions = { var restrictions = {
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
restrictions.sort = sort; restrictions.sort = sort;
var searchName = $('#searchName').val(); var searchName = $('#searchName').val();
if(searchName.length > 0) { if(searchName.length > 0) {
restrictions.name = searchName; restrictions.name = searchName;
} }
var searchType = $('#searchType').val(); var searchType = $('#searchType').val();
if(searchType != null && searchType.length > 0) { if(searchType != null && searchType.length > 0) {
restrictions.type = searchType; restrictions.type = searchType;
} }
var searchContent = $('#searchContent').val(); var searchContent = $('#searchContent').val();
if(searchContent.length > 0) { if(searchContent.length > 0) {
restrictions.content = searchContent; restrictions.content = searchContent;
} }
restrictions.action = "getRecords"; restrictions.action = "getRecords";
restrictions.domain = location.hash.substring(1); restrictions.domain = location.hash.substring(1);
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(restrictions), JSON.stringify(restrictions),
@ -160,15 +130,12 @@ function requestRecordData() {
"json" "json"
); );
} }
function requestSoaData() { function requestSoaData() {
var data = { var data = {
action: "getSoa", action: "getSoa",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
data.domain = location.hash.substring(1); data.domain = location.hash.substring(1);
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -183,15 +150,12 @@ function requestSoaData() {
"json" "json"
); );
} }
function requestSerial() { function requestSerial() {
var data = { var data = {
action: "getSerial", action: "getSerial",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
data.domain = location.hash.substring(1); data.domain = location.hash.substring(1);
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -201,22 +165,18 @@ function requestSerial() {
"json" "json"
); );
} }
function saveSoaData() { function saveSoaData() {
var data = { var data = {
action: "saveSoa", action: "saveSoa",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
data.domain = location.hash.substring(1); data.domain = location.hash.substring(1);
data.primary = $('#soa-primary').val(); data.primary = $('#soa-primary').val();
data.email = $('#soa-mail').val(); data.email = $('#soa-mail').val();
data.refresh = $('#soa-refresh').val(); data.refresh = $('#soa-refresh').val();
data.retry = $('#soa-retry').val(); data.retry = $('#soa-retry').val();
data.expire = $('#soa-expire').val(); data.expire = $('#soa-expire').val();
data.ttl = $('#soa-ttl').val(); data.ttl = $('#soa-ttl').val();
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -226,11 +186,9 @@ function saveSoaData() {
"json" "json"
); );
} }
function editClicked() { function editClicked() {
var tableCells = $(this).parent().parent().children('td'); var tableCells = $(this).parent().parent().children('td');
var tableRow = $(this).parent().parent(); var tableRow = $(this).parent().parent();
var valueExtractRegex = new RegExp('\.?' + domainName + "$"); var valueExtractRegex = new RegExp('\.?' + domainName + "$");
var valueName = tableCells.eq(1).text(); var valueName = tableCells.eq(1).text();
valueName = valueName.replace(valueExtractRegex, ""); valueName = valueName.replace(valueExtractRegex, "");
@ -238,47 +196,34 @@ function editClicked() {
var inputGroupName = $('<div class="input-group"></div>').appendTo(tableCells.eq(1)); var inputGroupName = $('<div class="input-group"></div>').appendTo(tableCells.eq(1));
$('<input type="text" class="form-control input-sm" data-regex="^([^.]+\.)*[^.]*$">').appendTo(inputGroupName).val(valueName); $('<input type="text" class="form-control input-sm" data-regex="^([^.]+\.)*[^.]*$">').appendTo(inputGroupName).val(valueName);
$('<span class="input-group-addon"></span>').appendTo(inputGroupName).text("." + domainName); $('<span class="input-group-addon"></span>').appendTo(inputGroupName).text("." + domainName);
var valueType = tableCells.eq(2).text(); var valueType = tableCells.eq(2).text();
tableCells.eq(2).empty(); tableCells.eq(2).empty();
$('<select class="form-control select-narrow-70"></select>').appendTo(tableCells.eq(2)).select2({ $('<select class="form-control select-narrow-70"></select>').appendTo(tableCells.eq(2)).select2({
data: recordTypes data: recordTypes
}).val(valueType).trigger("change"); }).val(valueType).trigger("change");
var valueContent = tableCells.eq(3).text(); var valueContent = tableCells.eq(3).text();
tableCells.eq(3).empty(); tableCells.eq(3).empty();
$('<input type="text" class="form-control input-sm" data-regex="^.+$">').appendTo(tableCells.eq(3)).val(valueContent); $('<input type="text" class="form-control input-sm" data-regex="^.+$">').appendTo(tableCells.eq(3)).val(valueContent);
var valuePrio = tableCells.eq(4).text(); var valuePrio = tableCells.eq(4).text();
tableCells.eq(4).empty(); tableCells.eq(4).empty();
$('<input type="text" class="form-control input-sm" size="1" data-regex="^[0-9]+$">').appendTo(tableCells.eq(4)).val(valuePrio); $('<input type="text" class="form-control input-sm" size="1" data-regex="^[0-9]+$">').appendTo(tableCells.eq(4)).val(valuePrio);
var valueTtl = tableCells.eq(5).text(); var valueTtl = tableCells.eq(5).text();
tableCells.eq(5).empty(); tableCells.eq(5).empty();
$('<input type="text" class="form-control input-sm" size="3" data-regex="^[0-9]+$">').appendTo(tableCells.eq(5)).val(valueTtl); $('<input type="text" class="form-control input-sm" size="3" data-regex="^[0-9]+$">').appendTo(tableCells.eq(5)).val(valueTtl);
tableCells.eq(6).remove(); tableCells.eq(6).remove();
tableCells.eq(7).remove(); tableCells.eq(7).remove();
tableCells.eq(8).remove(); tableCells.eq(8).remove();
$(tableRow).append('<td colspan="3"><button class="btn btn-primary btn-sm">Save</button></td>'); $(tableRow).append('<td colspan="3"><button class="btn btn-primary btn-sm">Save</button></td>');
$(tableRow).find('button').click(saveRecord); $(tableRow).find('button').click(saveRecord);
enableFilter(false); enableFilter(false);
$(tableRow).find("input").bind("paste keyup change", regexValidate); $(tableRow).find("input").bind("paste keyup change", regexValidate);
} }
function saveRecord() { function saveRecord() {
var tableRow = $(this).parent().parent(); var tableRow = $(this).parent().parent();
if(!validateLine.call(this)) { if(!validateLine.call(this)) {
shake($(this)); shake($(this));
return; return;
} }
var data = { var data = {
id: tableRow.children('td').eq(0).text(), id: tableRow.children('td').eq(0).text(),
name: tableRow.children('td').eq(1).find('input').val(), name: tableRow.children('td').eq(1).find('input').val(),
@ -290,31 +235,25 @@ function saveRecord() {
domain: location.hash.substring(1), domain: location.hash.substring(1),
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
if(data.name.length > 0) { if(data.name.length > 0) {
data.name = data.name + "." + domainName; data.name = data.name + "." + domainName;
} else { } else {
data.name = domainName; data.name = domainName;
} }
tableRow.children('td').eq(0).empty().text(data.id); tableRow.children('td').eq(0).empty().text(data.id);
tableRow.children('td').eq(1).empty().text(data.name); tableRow.children('td').eq(1).empty().text(data.name);
tableRow.children('td').eq(2).empty().text(data.type); tableRow.children('td').eq(2).empty().text(data.type);
tableRow.children('td').eq(3).empty().text(data.content); tableRow.children('td').eq(3).empty().text(data.content);
tableRow.children('td').eq(4).empty().text(data.prio); tableRow.children('td').eq(4).empty().text(data.prio);
tableRow.children('td').eq(5).empty().text(data.ttl); tableRow.children('td').eq(5).empty().text(data.ttl);
tableRow.children('td').eq(6).remove(); tableRow.children('td').eq(6).remove();
tableRow.append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>') tableRow.append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-share cursor-pointer"></span></td>'); .append('<td><span class="glyphicon glyphicon-share cursor-pointer"></span></td>');
tableRow.find('span.glyphicon-trash').click(trashClicked); tableRow.find('span.glyphicon-trash').click(trashClicked);
tableRow.find('span.glyphicon-pencil').click(editClicked); tableRow.find('span.glyphicon-pencil').click(editClicked);
tableRow.find('span.glyphicon-share').click(remoteClicked); tableRow.find('span.glyphicon-share').click(remoteClicked);
enableFilter(true); enableFilter(true);
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -324,19 +263,15 @@ function saveRecord() {
"json" "json"
); );
} }
function addRecord() { function addRecord() {
if(!validateLine.call(this)) { if(!validateLine.call(this)) {
shake($('#addButton')); shake($('#addButton'));
return; return;
} }
var prio = $('#addPrio').val(); var prio = $('#addPrio').val();
if(prio.length === 0) prio = 0; if(prio.length === 0) prio = 0;
var ttl = $('#addTtl').val(); var ttl = $('#addTtl').val();
if(ttl.length === 0) ttl = 86400; if(ttl.length === 0) ttl = 86400;
var data = { var data = {
type: $('#addType').val(), type: $('#addType').val(),
content: $('#addContent').val(), content: $('#addContent').val(),
@ -346,13 +281,11 @@ function addRecord() {
domain: location.hash.substring(1), domain: location.hash.substring(1),
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
if($('#addName').val().length > 0) { if($('#addName').val().length > 0) {
data.name = $('#addName').val() + "." + domainName; data.name = $('#addName').val() + "." + domainName;
} else { } else {
data.name = domainName; data.name = domainName;
} }
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -367,12 +300,10 @@ function addRecord() {
.append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-share cursor-pointer"></span></td>'); .append('<td><span class="glyphicon glyphicon-share cursor-pointer"></span></td>');
$('#table-records>tbody>tr').last().find('span.glyphicon-pencil').click(editClicked); $('#table-records>tbody>tr').last().find('span.glyphicon-pencil').click(editClicked);
$('#table-records>tbody>tr').last().find('span.glyphicon-trash').click(trashClicked); $('#table-records>tbody>tr').last().find('span.glyphicon-trash').click(trashClicked);
$('#table-records>tbody>tr').last().find('span.glyphicon-share').click(remoteClicked); $('#table-records>tbody>tr').last().find('span.glyphicon-share').click(remoteClicked);
requestSerial(); requestSerial();
$('#addName').val(""); $('#addName').val("");
$('#addType').val("A").change(); $('#addType').val("A").change();
$('#addContent').val(""); $('#addContent').val("");
@ -382,7 +313,6 @@ function addRecord() {
"json" "json"
); );
} }
function trashClicked() { function trashClicked() {
var data = { var data = {
id: $(this).parent().parent().children().eq(0).text(), id: $(this).parent().parent().children().eq(0).text(),
@ -390,9 +320,7 @@ function trashClicked() {
action: "removeRecord", action: "removeRecord",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
var lineAffected = $(this).parent().parent(); var lineAffected = $(this).parent().parent();
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -403,14 +331,12 @@ function trashClicked() {
"json" "json"
); );
} }
function requestDomainName() { function requestDomainName() {
var data = { var data = {
action: "getDomainName", action: "getDomainName",
domain: location.hash.substring(1), domain: location.hash.substring(1),
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/edit-master.php", "api/edit-master.php",
JSON.stringify(data), JSON.stringify(data),
@ -423,7 +349,6 @@ function requestDomainName() {
"json" "json"
); );
} }
function enableFilter(enable) { function enableFilter(enable) {
if(enable) { if(enable) {
$('#searchName').prop("disabled", false); $('#searchName').prop("disabled", false);
@ -435,7 +360,6 @@ function enableFilter(enable) {
$('#searchContent').prop("disabled", true); $('#searchContent').prop("disabled", true);
} }
} }
function regexValidate() { function regexValidate() {
var regex = new RegExp($(this).attr('data-regex')); var regex = new RegExp($(this).attr('data-regex'));
if(!regex.test($(this).val())) { if(!regex.test($(this).val())) {
@ -444,7 +368,6 @@ function regexValidate() {
$(this).parent().removeClass("has-error"); $(this).parent().removeClass("has-error");
} }
} }
function validateLine() { function validateLine() {
$(this).parent().parent().find('input[data-regex]').change(); $(this).parent().parent().find('input[data-regex]').change();
var errors = 0; var errors = 0;
@ -453,27 +376,21 @@ function validateLine() {
errors++; errors++;
} }
}); });
return errors <= 0; return errors <= 0;
} }
function remoteClicked() { function remoteClicked() {
var recordId = $(this).parent().siblings().eq(0).text(); var recordId = $(this).parent().siblings().eq(0).text();
location.assign("edit-remote.php#" + recordId); location.assign("edit-remote.php#" + recordId);
} }
function shake(element){ function shake(element){
var interval = 50; var interval = 50;
var distance = 5; var distance = 5;
var times = 6; var times = 6;
$(element).css('position','relative'); $(element).css('position','relative');
for(var iter=0;iter<(times+1);iter++){ for(var iter=0;iter<(times+1);iter++){
$(element).animate({ $(element).animate({
left:((iter%2===0 ? distance : distance*-1)) left:((iter%2===0 ? distance : distance*-1))
},interval); },interval);
} }
$(element).animate({ left: 0},interval); $(element).animate({ left: 0},interval);
} }

View file

@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#data-password-password2').bind("paste keyup change", function() { $('#data-password-password2').bind("paste keyup change", function() {
if($('#data-password-password').val() != $('#data-password-password2').val()) { if($('#data-password-password').val() != $('#data-password-password2').val()) {
@ -22,32 +21,26 @@ $(document).ready(function() {
$(this).parent().removeClass("has-error"); $(this).parent().removeClass("has-error");
} }
}); });
$('#button-add-password').click(function() { $('#button-add-password').click(function() {
resetFields(); resetFields();
$('#data-password').show(); $('#data-password').show();
$('#data-key').hide(); $('#data-key').hide();
$('#data-password-confirm').unbind().click(addPassword); $('#data-password-confirm').unbind().click(addPassword);
}); });
$('#button-add-key').click(function() { $('#button-add-key').click(function() {
resetFields(); resetFields();
$('#data-key').show(); $('#data-key').show();
$('#data-password').hide(); $('#data-password').hide();
$('#data-key-confirm').unbind().click(addKey); $('#data-key-confirm').unbind().click(addKey);
}); });
$('#data-password-cancel').click(function() { $('#data-password-cancel').click(function() {
$('#data-password').hide(); $('#data-password').hide();
}); });
$('#data-key-cancel').click(function() { $('#data-key-cancel').click(function() {
$('#data-key').hide(); $('#data-key').hide();
}); });
requestPermissions(); requestPermissions();
}); });
function regexValidate() { function regexValidate() {
var regex = new RegExp($(this).attr('data-regex')); var regex = new RegExp($(this).attr('data-regex'));
if(!regex.test($(this).val())) { if(!regex.test($(this).val())) {
@ -56,10 +49,8 @@ function regexValidate() {
$(this).parent().removeClass("has-error"); $(this).parent().removeClass("has-error");
} }
} }
function createTable(data) { function createTable(data) {
$('#permissions tbody').empty(); $('#permissions tbody').empty();
$.each(data, function(index,item) { $.each(data, function(index,item) {
$('<tr></tr>').appendTo('#permissions tbody') $('<tr></tr>').appendTo('#permissions tbody')
.append('<td>' + item.id + '</td>') .append('<td>' + item.id + '</td>')
@ -68,18 +59,15 @@ function createTable(data) {
.append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-pencil cursor-pointer"></span></td>')
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>'); .append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>');
}); });
$('#permissions tbody span.glyphicon-trash').click(deletePermission); $('#permissions tbody span.glyphicon-trash').click(deletePermission);
$('#permissions tbody span.glyphicon-pencil').click(prepareEdit); $('#permissions tbody span.glyphicon-pencil').click(prepareEdit);
} }
function requestPermissions() { function requestPermissions() {
var data = { var data = {
action: "getPermissions", action: "getPermissions",
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
record: location.hash.substring(1) record: location.hash.substring(1)
}; };
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -89,7 +77,6 @@ function requestPermissions() {
"json" "json"
); );
} }
function resetFields() { function resetFields() {
$('#info-dialogs input').val(""); $('#info-dialogs input').val("");
$('#info-dialogs textarea').val(""); $('#info-dialogs textarea').val("");
@ -99,14 +86,12 @@ function resetFields() {
$('#data-password-confirm').text("Add"); $('#data-password-confirm').text("Add");
$('#data-key-confirm').text("Add"); $('#data-key-confirm').text("Add");
} }
function addPassword() { function addPassword() {
if($('#data-password-password').val() != $('#data-password-password2').val() || $('#data-password-password').val().length <= 0) { if($('#data-password-password').val() != $('#data-password-password2').val() || $('#data-password-password').val().length <= 0) {
$('#data-password-password2').parent().addClass("has-error"); $('#data-password-password2').parent().addClass("has-error");
shake($('#data-password-confirm')); shake($('#data-password-confirm'));
return; return;
} }
var data = { var data = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
action: "addPassword", action: "addPassword",
@ -114,7 +99,6 @@ function addPassword() {
password: $('#data-password-password').val(), password: $('#data-password-password').val(),
record: location.hash.substring(1) record: location.hash.substring(1)
}; };
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -125,14 +109,12 @@ function addPassword() {
"json" "json"
); );
} }
function addKey() { function addKey() {
if($('#data-key-key').val().length <= 0) { if($('#data-key-key').val().length <= 0) {
$('#data-key-key').parent().addClass("has-error"); $('#data-key-key').parent().addClass("has-error");
shake($('#data-key-confirm')); shake($('#data-key-confirm'));
return; return;
} }
var data = { var data = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
action: "addKey", action: "addKey",
@ -140,7 +122,6 @@ function addKey() {
key: $('#data-key-key').val(), key: $('#data-key-key').val(),
record: location.hash.substring(1) record: location.hash.substring(1)
}; };
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -151,7 +132,6 @@ function addKey() {
"json" "json"
); );
} }
function deletePermission() { function deletePermission() {
var data = { var data = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
@ -159,7 +139,6 @@ function deletePermission() {
permission: $(this).parent().siblings().eq(0).text(), permission: $(this).parent().siblings().eq(0).text(),
record: location.hash.substring(1) record: location.hash.substring(1)
}; };
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -169,7 +148,6 @@ function deletePermission() {
"json" "json"
); );
} }
function prepareEdit() { function prepareEdit() {
var type = $(this).parent().siblings().eq(2).text(); var type = $(this).parent().siblings().eq(2).text();
if(type === "password") { if(type === "password") {
@ -177,32 +155,25 @@ function prepareEdit() {
$('#data-password').show(); $('#data-password').show();
$('#data-key').hide(); $('#data-key').hide();
$('#data-password-confirm').unbind().click(changePassword); $('#data-password-confirm').unbind().click(changePassword);
$('#data-password-password').attr("placeholder", "(Unchanged)"); $('#data-password-password').attr("placeholder", "(Unchanged)");
$('#data-password-password2').attr("placeholder", "(Unchanged)"); $('#data-password-password2').attr("placeholder", "(Unchanged)");
$('#data-password-confirm').text("Change"); $('#data-password-confirm').text("Change");
$('#data-password-description').val($(this).parent().siblings().eq(1).text()); $('#data-password-description').val($(this).parent().siblings().eq(1).text());
$('#data-password-confirm').data("permission-id", $(this).parent().siblings().eq(0).text()); $('#data-password-confirm').data("permission-id", $(this).parent().siblings().eq(0).text());
} else if(type === "key") { } else if(type === "key") {
resetFields(); resetFields();
$('#data-key').show(); $('#data-key').show();
$('#data-password').hide(); $('#data-password').hide();
$('#data-key-confirm').unbind().click(changeKey); $('#data-key-confirm').unbind().click(changeKey);
$('#data-key-confirm').text("Change"); $('#data-key-confirm').text("Change");
$('#data-key-description').val($(this).parent().siblings().eq(1).text()); $('#data-key-description').val($(this).parent().siblings().eq(1).text());
$('#data-key-confirm').data("permission-id", $(this).parent().siblings().eq(0).text()); $('#data-key-confirm').data("permission-id", $(this).parent().siblings().eq(0).text());
var data = { var data = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
action: "getKey", action: "getKey",
permission: $(this).parent().siblings().eq(0).text(), permission: $(this).parent().siblings().eq(0).text(),
record: location.hash.substring(1) record: location.hash.substring(1)
}; };
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -213,13 +184,11 @@ function prepareEdit() {
); );
} }
} }
function changePassword() { function changePassword() {
if($('#data-password-password').val() != $('#data-password-password2').val()) { if($('#data-password-password').val() != $('#data-password-password2').val()) {
$('#data-password-password2').parent().addClass("has-error"); $('#data-password-password2').parent().addClass("has-error");
return; return;
} }
var data = { var data = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
action: "changePassword", action: "changePassword",
@ -227,11 +196,9 @@ function changePassword() {
record: location.hash.substring(1), record: location.hash.substring(1),
permission: $('#data-password-confirm').data("permission-id") permission: $('#data-password-confirm').data("permission-id")
}; };
if($('#data-password-password').val().length >= 0) { if($('#data-password-password').val().length >= 0) {
data.password = $('#data-password-password').val(); data.password = $('#data-password-password').val();
} }
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -242,13 +209,11 @@ function changePassword() {
"json" "json"
); );
} }
function changeKey() { function changeKey() {
if($('#data-key-key').val().length <= 0) { if($('#data-key-key').val().length <= 0) {
$('#data-key-key').parent().addClass("has-error"); $('#data-key-key').parent().addClass("has-error");
return; return;
} }
var data = { var data = {
csrfToken: $('#csrfToken').text(), csrfToken: $('#csrfToken').text(),
action: "changeKey", action: "changeKey",
@ -257,7 +222,6 @@ function changeKey() {
record: location.hash.substring(1), record: location.hash.substring(1),
permission: $('#data-key-confirm').data("permission-id") permission: $('#data-key-confirm').data("permission-id")
}; };
$.post( $.post(
"api/edit-remote.php", "api/edit-remote.php",
JSON.stringify(data), JSON.stringify(data),
@ -268,19 +232,15 @@ function changeKey() {
"json" "json"
); );
} }
function shake(element){ function shake(element){
var interval = 50; var interval = 50;
var distance = 5; var distance = 5;
var times = 6; var times = 6;
$(element).css('position','relative'); $(element).css('position','relative');
for(var iter=0;iter<(times+1);iter++){ for(var iter=0;iter<(times+1);iter++){
$(element).animate({ $(element).animate({
left:((iter%2===0 ? distance : distance*-1)) left:((iter%2===0 ? distance : distance*-1))
},interval); },interval);
} }
$(element).animate({ left: 0},interval); $(element).animate({ left: 0},interval);
} }

View file

@ -13,25 +13,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#user-button-add').click(function(evt){ $('#user-button-add').click(function(evt){
evt.preventDefault(); evt.preventDefault();
if(location.hash.substring(1) == "new") { if(location.hash.substring(1) == "new") {
addUser(); addUser();
} else { } else {
saveUserChanges(); saveUserChanges();
} }
}); });
$('form input#user-name').bind("paste keyup change", regexValidate); $('form input#user-name').bind("paste keyup change", regexValidate);
$('#user-password').unbind().bind("paste keyup change", function() { $('#user-password').unbind().bind("paste keyup change", function() {
$('#user-password').parent().removeClass("has-error"); $('#user-password').parent().removeClass("has-error");
}); });
$('#user-password2').unbind().bind("paste keyup change", function() { $('#user-password2').unbind().bind("paste keyup change", function() {
if($('#user-password').val() != $('#user-password2').val()) { if($('#user-password').val() != $('#user-password2').val()) {
$('#user-password2').parent().addClass("has-error"); $('#user-password2').parent().addClass("has-error");
@ -39,11 +33,9 @@ $(document).ready(function() {
$('#user-password2').parent().removeClass("has-error"); $('#user-password2').parent().removeClass("has-error");
} }
}); });
$('#user-type').select2({ $('#user-type').select2({
minimumResultsForSearch: Infinity minimumResultsForSearch: Infinity
}); });
//Prepare for new user //Prepare for new user
if(location.hash.substring(1) == "new") { if(location.hash.substring(1) == "new") {
$('#heading').text("Add user"); $('#heading').text("Add user");
@ -55,7 +47,6 @@ $(document).ready(function() {
requestPermissions(); requestPermissions();
$('#permissions').removeClass("defaulthidden"); $('#permissions').removeClass("defaulthidden");
} }
$('#permissions select#selectAdd').select2({ $('#permissions select#selectAdd').select2({
ajax: { ajax: {
url: "api/edit-user.php", url: "api/edit-user.php",
@ -80,10 +71,8 @@ $(document).ready(function() {
placeholder: "Search...", placeholder: "Search...",
minimumInputLength: 1 minimumInputLength: 1
}); });
$('#btnAddPermissions').click(addPermissions); $('#btnAddPermissions').click(addPermissions);
}); });
function regexValidate() { function regexValidate() {
var regex = new RegExp($(this).attr('data-regex')); var regex = new RegExp($(this).attr('data-regex'));
if(!regex.test($(this).val())) { if(!regex.test($(this).val())) {
@ -92,16 +81,13 @@ function regexValidate() {
$(this).parent().removeClass("has-error"); $(this).parent().removeClass("has-error");
} }
} }
function addUser() { function addUser() {
$('form input').change(); $('form input').change();
if($('#user-password').val().length <= 0) { if($('#user-password').val().length <= 0) {
$('#user-password').parent().addClass("has-error"); $('#user-password').parent().addClass("has-error");
$('#user-password2').parent().addClass("has-error"); $('#user-password2').parent().addClass("has-error");
shake($('#user-button-add')); shake($('#user-button-add'));
} }
if($('#user-name').parent().hasClass("has-error")) { if($('#user-name').parent().hasClass("has-error")) {
shake($('#user-button-add')); shake($('#user-button-add'));
return; return;
@ -110,7 +96,6 @@ function addUser() {
shake($('#user-button-add')); shake($('#user-button-add'));
return; return;
} }
var data = { var data = {
name: $('#user-name').val(), name: $('#user-name').val(),
password: $('#user-password').val(), password: $('#user-password').val(),
@ -118,7 +103,6 @@ function addUser() {
action: "addUser", action: "addUser",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/edit-user.php", "api/edit-user.php",
JSON.stringify(data), JSON.stringify(data),
@ -129,14 +113,12 @@ function addUser() {
"json" "json"
); );
} }
function getUserData() { function getUserData() {
var data = { var data = {
id: location.hash.substring(1), id: location.hash.substring(1),
action: "getUserData", action: "getUserData",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/edit-user.php", "api/edit-user.php",
JSON.stringify(data), JSON.stringify(data),
@ -147,9 +129,7 @@ function getUserData() {
"json" "json"
); );
} }
function saveUserChanges() { function saveUserChanges() {
if($('#user-name').parent().hasClass("has-error")) { if($('#user-name').parent().hasClass("has-error")) {
shake($('#user-button-add')); shake($('#user-button-add'));
return; return;
@ -158,7 +138,6 @@ function saveUserChanges() {
shake($('#user-button-add')); shake($('#user-button-add'));
return; return;
} }
var data = { var data = {
id: location.hash.substring(1), id: location.hash.substring(1),
name: $('#user-name').val(), name: $('#user-name').val(),
@ -166,11 +145,9 @@ function saveUserChanges() {
action: "saveUserChanges", action: "saveUserChanges",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
if($('#user-password').val().length > 0) { if($('#user-password').val().length > 0) {
data.password = $('#user-password').val(); data.password = $('#user-password').val();
} }
$.post( $.post(
"api/edit-user.php", "api/edit-user.php",
JSON.stringify(data), JSON.stringify(data),
@ -178,14 +155,12 @@ function saveUserChanges() {
"json" "json"
); );
} }
function requestPermissions() { function requestPermissions() {
var data = { var data = {
id: location.hash.substring(1), id: location.hash.substring(1),
action: "getPermissions", action: "getPermissions",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/edit-user.php", "api/edit-user.php",
JSON.stringify(data), JSON.stringify(data),
@ -195,20 +170,16 @@ function requestPermissions() {
"json" "json"
); );
} }
function createTable(data) { function createTable(data) {
$('#permissions table>tbody').empty(); $('#permissions table>tbody').empty();
$.each(data, function(index,item) { $.each(data, function(index,item) {
$('<tr></tr>').appendTo('#permissions table>tbody') $('<tr></tr>').appendTo('#permissions table>tbody')
.append('<td>' + item.name + '</td>') .append('<td>' + item.name + '</td>')
.append('<td><span class="glyphicon glyphicon-remove cursor-pointer"></span></td>') .append('<td><span class="glyphicon glyphicon-remove cursor-pointer"></span></td>')
.data("id", item.id); .data("id", item.id);
}); });
$('#permissions table>tbody>tr>td>span.glyphicon-remove').click(removePermission); $('#permissions table>tbody>tr>td>span.glyphicon-remove').click(removePermission);
} }
function removePermission() { function removePermission() {
var data = { var data = {
domainId: $(this).parent().parent().data("id"), domainId: $(this).parent().parent().data("id"),
@ -216,9 +187,7 @@ function removePermission() {
action: "removePermission", action: "removePermission",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
var lineToRemove = $(this).parent().parent(); var lineToRemove = $(this).parent().parent();
$.post( $.post(
"api/edit-user.php", "api/edit-user.php",
JSON.stringify(data), JSON.stringify(data),
@ -228,7 +197,6 @@ function removePermission() {
"json" "json"
); );
} }
function addPermissions() { function addPermissions() {
var data = { var data = {
action: "addPermissions", action: "addPermissions",
@ -236,7 +204,6 @@ function addPermissions() {
domains: $('#permissions select#selectAdd').val(), domains: $('#permissions select#selectAdd').val(),
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
} }
$.post( $.post(
"api/edit-user.php", "api/edit-user.php",
JSON.stringify(data), JSON.stringify(data),
@ -247,19 +214,15 @@ function addPermissions() {
"json" "json"
); );
} }
function shake(element){ function shake(element){
var interval = 50; var interval = 50;
var distance = 5; var distance = 5;
var times = 6; var times = 6;
$(element).css('position','relative'); $(element).css('position','relative');
for(var iter=0;iter<(times+1);iter++){ for(var iter=0;iter<(times+1);iter++){
$(element).animate({ $(element).animate({
left:((iter%2===0 ? distance : distance*-1)) left:((iter%2===0 ? distance : distance*-1))
},interval); },interval);
} }
$(element).animate({ left: 0},interval); $(element).animate({ left: 0},interval);
} }

View file

@ -13,18 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#buttonSubmit').click(function(event) { $('#buttonSubmit').click(function(event) {
event.preventDefault(); event.preventDefault();
$('#alertLoginFailed').slideUp(300); $('#alertLoginFailed').slideUp(300);
var data = {}; var data = {};
data.user=$('#inputUser').val(); data.user=$('#inputUser').val();
data.password=$('#inputPassword').val(); data.password=$('#inputPassword').val();
$.post( $.post(
"api/index.php", "api/index.php",
JSON.stringify(data), JSON.stringify(data),
@ -37,6 +32,5 @@ $(document).ready(function() {
}, },
"json" "json"
); );
}); });
}); });

View file

@ -13,14 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#buttonInstall').click(function(evt){ $('#buttonInstall').click(function(evt){
evt.preventDefault(); evt.preventDefault();
checkSettings(); checkSettings();
}); });
$('#dbType').change(function() { $('#dbType').change(function() {
if($(this).val() == 'mysql') { if($(this).val() == 'mysql') {
$('#dbPort').val(3306); $('#dbPort').val(3306);
@ -28,7 +25,6 @@ $(document).ready(function() {
$('#dbPort').val(5432); $('#dbPort').val(5432);
} }
}); });
$('#adminPassword2').bind("change keyup paste", function() { $('#adminPassword2').bind("change keyup paste", function() {
if($('#adminPassword').val() == $('#adminPassword2').val()) { if($('#adminPassword').val() == $('#adminPassword2').val()) {
$(this).parent().removeClass("has-error"); $(this).parent().removeClass("has-error");
@ -37,21 +33,16 @@ $(document).ready(function() {
} }
}) })
}); });
function checkSettings() { function checkSettings() {
if($('#adminPassword').val() != $('#adminPassword2').val()) { if($('#adminPassword').val() != $('#adminPassword2').val()) {
$('#adminPassword2').parent().addClass("has-error"); $('#adminPassword2').parent().addClass("has-error");
} }
if($('#adminPassword').val().length <= 0) { if($('#adminPassword').val().length <= 0) {
$('#adminPassword').parent().addClass("has-error"); $('#adminPassword').parent().addClass("has-error");
} }
if($('#adminName').val().length <= 0) { if($('#adminName').val().length <= 0) {
$('#adminName').parent().addClass("has-error"); $('#adminName').parent().addClass("has-error");
} }
var data = { var data = {
host: $('#dbHost').val(), host: $('#dbHost').val(),
user: $('#dbUser').val(), user: $('#dbUser').val(),
@ -62,7 +53,6 @@ function checkSettings() {
userPassword: $('#adminPassword').val(), userPassword: $('#adminPassword').val(),
type: $('#dbType').val() type: $('#dbType').val()
}; };
$.post( $.post(
"api/install.php", "api/install.php",
JSON.stringify(data), JSON.stringify(data),
@ -77,4 +67,3 @@ function checkSettings() {
"json" "json"
); );
} }

View file

@ -13,18 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#saveChanges').click(function(evt){ $('#saveChanges').click(function(evt){
evt.preventDefault(); evt.preventDefault();
savePassword(); savePassword();
}); });
$('#user-password').unbind().bind("paste keyup change", function() { $('#user-password').unbind().bind("paste keyup change", function() {
$('#user-password').parent().removeClass("has-error"); $('#user-password').parent().removeClass("has-error");
}); });
$('#user-password2').unbind().bind("paste keyup change", function() { $('#user-password2').unbind().bind("paste keyup change", function() {
if($('#user-password').val() != $('#user-password2').val()) { if($('#user-password').val() != $('#user-password2').val()) {
$('#user-password2').parent().addClass("has-error"); $('#user-password2').parent().addClass("has-error");
@ -33,9 +29,7 @@ $(document).ready(function() {
} }
}); });
}); });
function savePassword() { function savePassword() {
if($('#user-password').val().length <= 0) { if($('#user-password').val().length <= 0) {
$('#user-password').parent().addClass("has-error"); $('#user-password').parent().addClass("has-error");
$('#user-password2').parent().addClass("has-error"); $('#user-password2').parent().addClass("has-error");
@ -44,13 +38,11 @@ function savePassword() {
shake($('#saveChanges')); shake($('#saveChanges'));
return; return;
} }
var data = { var data = {
password: $('#user-password').val(), password: $('#user-password').val(),
action: "changePassword", action: "changePassword",
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/password.php", "api/password.php",
JSON.stringify(data), JSON.stringify(data),
@ -61,19 +53,15 @@ function savePassword() {
"json" "json"
); );
} }
function shake(element){ function shake(element){
var interval = 50; var interval = 50;
var distance = 5; var distance = 5;
var times = 6; var times = 6;
$(element).css('position','relative'); $(element).css('position','relative');
for(var iter=0;iter<(times+1);iter++){ for(var iter=0;iter<(times+1);iter++){
$(element).animate({ $(element).animate({
left:((iter%2===0 ? distance : distance*-1)) left:((iter%2===0 ? distance : distance*-1))
},interval); },interval);
} }
$(element).animate({ left: 0},interval); $(element).animate({ left: 0},interval);
} }

View file

@ -13,20 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
$(document).ready(function() { $(document).ready(function() {
$('#button-start').click(function() { $('#button-start').click(function() {
$('#row-button-start').hide(); $('#row-button-start').hide();
requestVersions(); requestVersions();
}); });
}); });
function requestVersions() { function requestVersions() {
var data = { var data = {
action: "getVersions" action: "getVersions"
}; };
$.post( $.post(
"api/upgrade.php", "api/upgrade.php",
JSON.stringify(data), JSON.stringify(data),
@ -37,12 +33,10 @@ function requestVersions() {
"json" "json"
); );
} }
function requestUpdate() { function requestUpdate() {
var data = { var data = {
action: "requestUpgrade" action: "requestUpgrade"
}; };
$.post( $.post(
"api/upgrade.php", "api/upgrade.php",
JSON.stringify(data), JSON.stringify(data),

View file

@ -13,15 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var sort = { var sort = {
field: "", field: "",
order: 1 order: 1
} }
$(document).ready(function() { $(document).ready(function() {
requestData(); requestData();
$('#table-users>thead>tr>td span').click(function() { $('#table-users>thead>tr>td span').click(function() {
var field = $(this).siblings('strong').text().toLowerCase(); var field = $(this).siblings('strong').text().toLowerCase();
if(sort.field == field) { if(sort.field == field) {
@ -32,46 +29,36 @@ $(document).ready(function() {
sort.order = 1; sort.order = 1;
} }
$('#table-users>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt"); $('#table-users>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt");
if(sort.field == field) { if(sort.field == field) {
if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes"); if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes");
else $(this).addClass("glyphicon-sort-by-attributes-alt"); else $(this).addClass("glyphicon-sort-by-attributes-alt");
} }
requestData(); requestData();
}); });
$('#searchName').bind("paste keyup", function() { $('#searchName').bind("paste keyup", function() {
requestData(); requestData();
}); });
$('#searchType').change(function() { $('#searchType').change(function() {
requestData(); requestData();
}); });
$('#searchType').select2({ $('#searchType').select2({
minimumResultsForSearch: Infinity minimumResultsForSearch: Infinity
}); });
}); });
function requestData() { function requestData() {
var restrictions = { var restrictions = {
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
restrictions.sort = sort; restrictions.sort = sort;
var searchName = $('#searchName').val(); var searchName = $('#searchName').val();
if(searchName.length > 0) { if(searchName.length > 0) {
restrictions.name = searchName; restrictions.name = searchName;
} }
var searchType = $('#searchType').val(); var searchType = $('#searchType').val();
if(searchType != "none") { if(searchType != "none") {
restrictions.type = searchType; restrictions.type = searchType;
} }
restrictions.action = "getUsers"; restrictions.action = "getUsers";
$.post( $.post(
"api/users.php", "api/users.php",
JSON.stringify(restrictions), JSON.stringify(restrictions),
@ -81,54 +68,43 @@ function requestData() {
"json" "json"
); );
} }
function recreateTable(data) { function recreateTable(data) {
$('#table-users>tbody').empty(); $('#table-users>tbody').empty();
$.each(data, function(index,item) { $.each(data, function(index,item) {
$('<tr></tr>').appendTo('#table-users>tbody') $('<tr></tr>').appendTo('#table-users>tbody')
.append('<td>' + item.id + '</td>') .append('<td>' + item.id + '</td>')
.append('<td>' + item.name + '</td>') .append('<td>' + item.name + '</td>')
.append('<td>' + item.type + '</td>') .append('<td>' + item.type + '</td>')
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>'); .append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>');
}); });
$('#table-users>tbody>tr>td:not(:last-child)').click(function() { $('#table-users>tbody>tr>td:not(:last-child)').click(function() {
var id = $(this).parent().children('td').first().text(); var id = $(this).parent().children('td').first().text();
location.assign('edit-user.php#' + id); location.assign('edit-user.php#' + id);
}); });
$('#table-users>tbody>tr>td>span.glyphicon-trash').click(function() { $('#table-users>tbody>tr>td>span.glyphicon-trash').click(function() {
$(this).parent().parent().unbind(); $(this).parent().parent().unbind();
deleteDomain.call(this); deleteDomain.call(this);
}); });
} }
function deleteDomain() { function deleteDomain() {
var deleteId = $(this).parent().parent().children('td').eq(0).text(); var deleteId = $(this).parent().parent().children('td').eq(0).text();
var deleteName = $(this).parent().parent().children('td').eq(1).text(); var deleteName = $(this).parent().parent().children('td').eq(1).text();
var rowToRemove = $(this).parent().parent(); var rowToRemove = $(this).parent().parent();
$('#userToDelete').text(deleteName); $('#userToDelete').text(deleteName);
$('#deleteConfirm #buttonDelete').click(function() { $('#deleteConfirm #buttonDelete').click(function() {
deleteUserWithId(deleteId, function() { deleteUserWithId(deleteId, function() {
$('#deleteConfirm').modal("hide"); $('#deleteConfirm').modal("hide");
$(rowToRemove).remove(); $(rowToRemove).remove();
}); });
}); });
$('#deleteConfirm').modal(); $('#deleteConfirm').modal();
} }
function deleteUserWithId(id, callback) { function deleteUserWithId(id, callback) {
var data = { var data = {
action: "deleteUser", action: "deleteUser",
id: id, id: id,
csrfToken: $('#csrfToken').text() csrfToken: $('#csrfToken').text()
}; };
$.post( $.post(
"api/users.php", "api/users.php",
JSON.stringify(data), JSON.stringify(data),

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,11 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function getExpectedVersion() { function getExpectedVersion() {
return 4; return 4;
} }
function checkVersion($db) { function checkVersion($db) {
if(getVersion($db) == getExpectedVersion()) { if(getVersion($db) == getExpectedVersion()) {
return true; return true;
@ -27,7 +24,6 @@ function checkVersion($db) {
return false; return false;
} }
} }
function getVersion($db) { function getVersion($db) {
$stmt = $db->prepare("SELECT value FROM options WHERE name='schema_version' LIMIT 1"); $stmt = $db->prepare("SELECT value FROM options WHERE name='schema_version' LIMIT 1");
$stmt->execute(); $stmt->execute();
@ -35,6 +31,5 @@ function getVersion($db) {
if (!$version) { if (!$version) {
$version = 0; $version = 0;
} }
return $version; return $version;
} }

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,7 +14,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
try { 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']);
} }

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,5 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
Header("Content-Security-Policy: default-src 'self';"); Header("Content-Security-Policy: default-src 'self';");

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,10 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
session_start(); session_start();
if( if(
!isset($_SESSION['id']) || !isset($_SESSION['id']) ||
!isset($_SESSION['secret']) || !isset($_SESSION['secret']) ||

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,21 +14,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function soa_to_mail($soa) { function soa_to_mail($soa) {
$tmp = preg_replace('/([^\\\\])\\./', '\\1@', $soa, 1); $tmp = preg_replace('/([^\\\\])\\./', '\\1@', $soa, 1);
$tmp = preg_replace('/\\\\\\./', ".", $tmp); $tmp = preg_replace('/\\\\\\./', ".", $tmp);
$tmp = preg_replace('/\\.$/', "", $tmp); $tmp = preg_replace('/\\.$/', "", $tmp);
return $tmp; return $tmp;
} }
function mail_to_soa($mail) { function mail_to_soa($mail) {
$parts = explode("@", $mail); $parts = explode("@", $mail);
$parts[0] = str_replace(".", "\.", $parts[0]); $parts[0] = str_replace(".", "\.", $parts[0]);
$parts[] = ""; $parts[] = "";
return implode(".", $parts); return implode(".", $parts);
} }

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. * Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
* *
@ -15,25 +14,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function update_serial($db, $domainId) { function update_serial($db, $domainId) {
$db->beginTransaction(); $db->beginTransaction();
$stmt = $db->prepare("SELECT content FROM records WHERE type='SOA' AND domain_id=:domain_id LIMIT 1"); $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(); $stmt->execute();
$content = $stmt->fetchColumn(); $content = $stmt->fetchColumn();
$content = explode(" ", $content); $content = explode(" ", $content);
$serial = $content[2]; $serial = $content[2];
$currentSerialDate = (int)($serial / 100); $currentSerialDate = (int)($serial / 100);
$currentSerialSequence = $serial % 100; $currentSerialSequence = $serial % 100;
$currentDate = (int)date("Ymd"); $currentDate = (int)date("Ymd");
if($currentDate != $currentSerialDate) { if($currentDate != $currentSerialDate) {
$newSerial = $currentDate . "00"; $newSerial = $currentDate . "00";
} else { } else {
@ -41,17 +32,11 @@ function update_serial($db, $domainId) {
$newSerialSequence = str_pad($newSerialSequence, 2, "0", STR_PAD_LEFT); $newSerialSequence = str_pad($newSerialSequence, 2, "0", STR_PAD_LEFT);
$newSerial = $currentDate . "" . $newSerialSequence; $newSerial = $currentDate . "" . $newSerialSequence;
} }
$content[2] = $newSerial; $content[2] = $newSerial;
$newsoa = implode(" ", $content); $newsoa = implode(" ", $content);
$stmt = $db->prepare("UPDATE records SET content=:content WHERE type='SOA' AND domain_id=:domain_id"); $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->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
$db->commit(); $db->commit();
} }

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -25,11 +22,9 @@ limitations under the License.
<title>PDNS Manager</title> <title>PDNS Manager</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
</head> </head>
@ -41,7 +36,6 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<div class="row vspacer-60"></div> <div class="row vspacer-60"></div>
<div class="row"> <div class="row">
@ -53,4 +47,3 @@ limitations under the License.
</div> </div>
</body> </body>
</html> </html>

View file

@ -1,5 +1,3 @@
#!/bin/bash #!/bin/bash
mkdir -p releases/ mkdir -p releases/
tar -czf releases/pdns-manager-$( git describe | cut -c 2- ).tar.gz *.php LICENSE lib/ js/ include/ api/ config/config-default.php tar -czf releases/pdns-manager-$( git describe | cut -c 2- ).tar.gz *.php LICENSE lib/ js/ include/ api/ config/config-default.php

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,17 +20,14 @@ limitations under the License.
<title>PDNS Manager - Password</title> <title>PDNS Manager - Password</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/select2/select2.min.css" rel="stylesheet"> <link href="include/select2/select2.min.css" rel="stylesheet">
<link href="include/select2/select2-bootstrap.min.css" rel="stylesheet"> <link href="include/select2/select2-bootstrap.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="include/select2/select2.min.js"></script> <script src="include/select2/select2.min.js"></script>
<script src="js/password.js"></script> <script src="js/password.js"></script>
</head> </head>
<body> <body>
@ -50,13 +44,10 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2 id="heading">Change password</h2> <h2 id="heading">Change password</h2>
</row> </row>
<row> <row>
<div class="col-md-3"> <div class="col-md-3">
<form> <form>
@ -72,10 +63,7 @@ limitations under the License.
</form> </form>
</div> </div>
</row> </row>
</div> </div>
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?> <?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
</body> </body>
</html> </html>

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,7 +16,6 @@ limitations under the License.
require_once 'config/config-default.php'; require_once 'config/config-default.php';
require_once 'lib/database.php'; require_once 'lib/database.php';
require_once 'lib/checkversion.php'; require_once 'lib/checkversion.php';
if(checkVersion($db)) { if(checkVersion($db)) {
Header("Location: index.php"); Header("Location: index.php");
} }
@ -29,14 +25,11 @@ limitations under the License.
<title>PDNS Manager - Upgrade</title> <title>PDNS Manager - Upgrade</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="js/upgrade.js"></script> <script src="js/upgrade.js"></script>
</head> </head>
<body> <body>
@ -50,34 +43,24 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<row> <row>
<h2>Upgrade PDNS Manager</h2> <h2>Upgrade PDNS Manager</h2>
</row> </row>
<row> <row>
An upgrade for your PDNS Manager database is available and must be installed! An upgrade for your PDNS Manager database is available and must be installed!
</row> </row>
<div class="row vspacer-20"></div> <div class="row vspacer-20"></div>
<div class="col-md-6"> <div class="col-md-6">
<row class="row" id="row-button-start"> <row class="row" id="row-button-start">
<button id="button-start" class="btn btn-primary">Start</button> <button id="button-start" class="btn btn-primary">Start</button>
</row> </row>
<row class="row" id="status"> <row class="row" id="status">
</row> </row>
<row class="row defaulthidden" id="row-button-home"> <row class="row defaulthidden" id="row-button-home">
<a href="index.php" class="btn btn-primary">Login</a> <a href="index.php" class="btn btn-primary">Login</a>
</row> </row>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View file

@ -1,13 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>. Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,17 +20,14 @@ limitations under the License.
<title>PDNS Manager - Users</title> <title>PDNS Manager - Users</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link href="include/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="include/select2/select2.min.css" rel="stylesheet"> <link href="include/select2/select2.min.css" rel="stylesheet">
<link href="include/select2/select2-bootstrap.min.css" rel="stylesheet"> <link href="include/select2/select2-bootstrap.min.css" rel="stylesheet">
<link href="include/custom.css" rel="stylesheet"> <link href="include/custom.css" rel="stylesheet">
<script src="include/jquery.js"></script> <script src="include/jquery.js"></script>
<script src="include/bootstrap/js/bootstrap.min.js"></script> <script src="include/bootstrap/js/bootstrap.min.js"></script>
<script src="include/select2/select2.min.js"></script> <script src="include/select2/select2.min.js"></script>
<script src="js/users.js"></script> <script src="js/users.js"></script>
</head> </head>
<body> <body>
@ -50,7 +44,6 @@ limitations under the License.
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<table class="table table-hover" id="table-users"> <table class="table table-hover" id="table-users">
<thead> <thead>
@ -82,12 +75,9 @@ limitations under the License.
</thead> </thead>
<tbody class="cursor-pointer"> <tbody class="cursor-pointer">
</tbody> </tbody>
</table> </table>
<a class="btn btn-success" href="edit-user.php#new">Add</a> <a class="btn btn-success" href="edit-user.php#new">Add</a>
</div> </div>
<div class="modal fade" id="deleteConfirm" tabindex="-1" role="dialog"> <div class="modal fade" id="deleteConfirm" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">