Remove old stuff, so that only the backend can be used as mock backend
This commit is contained in:
parent
5c9f0da3aa
commit
fae6ac469b
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1 @@
|
|||
nbproject/private/
|
||||
config/config-user.php
|
||||
releases/
|
||||
backend-legacy/config/config-user.php
|
||||
|
|
103
add-domain.php
103
add-domain.php
|
@ -1,103 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Domains</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.min.css" rel="stylesheet">
|
||||
<link href="include/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/add-domain.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li><a href="users.php">Users</a></li>'; ?>
|
||||
<li><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2 id="domain-name">Add Domain</h2>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<form>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="zone-name" class="control-label">Name</label>
|
||||
<input type="text" class="form-control" id="zone-name" placeholder="Name" autocomplete="off" data-regex="^([^.]+\.)*[^.]+$" tabindex="1">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="zone-primary" class="control-label">Primary</label>
|
||||
<input type="text" class="form-control" id="zone-primary" placeholder="Primary" autocomplete="off" data-regex="^([^.]+\.)*[^.]+$" tabindex="2">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="zone-mail" class="control-label">Email</label>
|
||||
<input type="text" class="form-control" id="zone-mail" placeholder="Email" autocomplete="off" data-regex="^.+@[^.]+(\.[^.]+)*$" tabindex="3">
|
||||
</div>
|
||||
<button id="zone-button-add" class="btn btn-primary" tabindex="8">Add</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 col-md-offset-1">
|
||||
<div class="form-group">
|
||||
<label for="zone-refresh" class="control-label">Refresh</label>
|
||||
<input type="text" class="form-control" id="zone-refresh" placeholder="Refresh" autocomplete="off" data-regex="^[0-9]+$" tabindex="4" value="3600">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="zone-retry" class="control-label">Retry</label>
|
||||
<input type="text" class="form-control" id="zone-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="5" value="900">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 col-md-offset-1">
|
||||
<div class="form-group">
|
||||
<label for="zone-expire" class="control-label">Expire</label>
|
||||
<input type="text" class="form-control" id="zone-expire" placeholder="Expire" autocomplete="off" data-regex="^[0-9]+$" tabindex="6" value="604800">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="zone-ttl" class="control-label">TTL</label>
|
||||
<input type="text" class="form-control" id="zone-ttl" placeholder="TTL" autocomplete="off" data-regex="^[0-9]+$" tabindex="7" value="86400">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</row>
|
||||
|
||||
</div>
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -23,11 +23,6 @@ require_once '../lib/soa-mail.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
|
||||
echo "Permission denied!";
|
||||
exit();
|
|
@ -22,11 +22,6 @@ require_once '../lib/session.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
if(isset($input->action) && $input->action == "getDomains") {
|
||||
// Check if the requested page is a number
|
||||
if(!(isset($input->page) && is_int($input->page) && $input->page > 0)) {
|
|
@ -24,11 +24,6 @@ require_once '../lib/update-serial.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
//Permission check
|
||||
if(isset($input->domain)) {
|
||||
$permquery = $db->prepare("SELECT COUNT(*) FROM permissions WHERE userid=:user AND domain=:domain");
|
|
@ -22,11 +22,6 @@ require_once '../lib/session.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
//Permission check
|
||||
if(isset($input->record)) {
|
||||
$permquery = $db->prepare("SELECT COUNT(*) FROM records JOIN permissions ON records.domain_id=permissions.domain WHERE userid=:user AND records.id=:id");
|
|
@ -22,11 +22,6 @@ require_once '../lib/session.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
|
||||
echo "Permission denied!";
|
||||
exit();
|
8
backend-legacy/api/logout.php
Normal file
8
backend-legacy/api/logout.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
require_once '../lib/headers.php';
|
||||
session_start();
|
||||
session_destroy();
|
||||
setcookie("authSecret", "", 1, "/", "", false, true);
|
||||
echo('{}');
|
||||
?>
|
||||
|
|
@ -22,11 +22,6 @@ require_once '../lib/session.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
if(isset($input->action) && $input->action == "changePassword") {
|
||||
$passwordHash = password_hash($input->password, PASSWORD_DEFAULT);
|
||||
|
|
@ -22,11 +22,6 @@ require_once '../lib/session.php';
|
|||
|
||||
$input = json_decode(file_get_contents('php://input'));
|
||||
|
||||
if(!isset($input->csrfToken) || $input->csrfToken !== $_SESSION['csrfToken']) {
|
||||
echo "Permission denied!";
|
||||
exit();
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
|
||||
echo "Permission denied!";
|
||||
exit();
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
120
domains.php
120
domains.php
|
@ -1,120 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Domains</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.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/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="include/select2/select2.min.js"></script>
|
||||
|
||||
<script src="js/domains.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li><a href="users.php">Users</a></li>'; ?>
|
||||
<li><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<table class="table table-hover" id="table-domains">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="cell-vertical-middle"><strong>ID</strong> <span class="glyphicon glyphicon-sort cursor-pointer"></span></td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Name</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer cursor-pointer"></span>
|
||||
<input type="text" class="form-control no-shadow" id="searchName" placeholder="Search" autocomplete="off">
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Type</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer cursor-pointer"></span>
|
||||
<select class="form-control no-shadow" id="searchType">
|
||||
<option value="none">No filter...</option>
|
||||
<option value="MASTER">MASTER</option>
|
||||
<option value="NATIVE">NATIVE</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td class="cell-vertical-middle"><strong>Records</strong> <span class="glyphicon glyphicon-sort cursor-pointer"></span></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="cursor-pointer">
|
||||
</tbody>
|
||||
</table>
|
||||
<nav id="pagination-wrapper" class="text-center defaulthidden">
|
||||
<ul id="pagination" class="pagination cursor-pointer">
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<?php
|
||||
if($_SESSION['type'] == "admin") {
|
||||
echo '<div class="row text-center">';
|
||||
echo '<a class="btn btn-success" href="add-domain.php#MASTER">Add MASTER</a>';
|
||||
echo '<a class="btn btn-primary margin-left-20" href="add-domain.php#NATIVE">Add NATIVE</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="deleteConfirm" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
Are you sure you want to <strong class="text-danger">delete</strong> the zone <strong><span id="zoneToDelete"></span></strong> including all associated data?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button id="buttonDelete" type="button" class="btn btn-danger">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
172
edit-master.php
172
edit-master.php
|
@ -1,172 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Domains</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.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/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="include/select2/select2.min.js"></script>
|
||||
|
||||
<script src="js/edit-master.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li><a href="users.php">Users</a></li>'; ?>
|
||||
<li><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2 id="domain-name"></h2>
|
||||
</row>
|
||||
|
||||
<div id="soa" class="container">
|
||||
<row>
|
||||
<h3>SOA</h3>
|
||||
</row>
|
||||
<row>
|
||||
<form>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="soa-primary" class="control-label">Primary</label>
|
||||
<input type="text" class="form-control" id="soa-primary" placeholder="Primary" autocomplete="off" data-regex="^([^.]+\.)*[^.]+$" tabindex="1">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="soa-mail" class="control-label">Email</label>
|
||||
<input type="text" class="form-control" id="soa-mail" placeholder="Email" autocomplete="off" data-regex="^.+@[^.]+(\.[^.]+)*$" tabindex="2">
|
||||
</div>
|
||||
<button disabled type="submit" class="btn btn-primary" tabindex="7">Save</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 col-md-offset-1">
|
||||
<div class="form-group">
|
||||
<label for="soa-refresh" class="control-label">Refresh</label>
|
||||
<input type="text" class="form-control" id="soa-refresh" placeholder="Refresh" autocomplete="off" data-regex="^[0-9]+$" tabindex="3">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="soa-retry" class="control-label">Retry</label>
|
||||
<input type="text" class="form-control" id="soa-retry" placeholder="Retry" autocomplete="off" data-regex="^[0-9]+$" tabindex="4">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 col-md-offset-1">
|
||||
<div class="form-group">
|
||||
<label for="soa-expire" class="control-label">Expire</label>
|
||||
<input type="text" class="form-control" id="soa-expire" placeholder="Expire" autocomplete="off" data-regex="^[0-9]+$" tabindex="5">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="soa-ttl" class="control-label">TTL</label>
|
||||
<input type="text" class="form-control" id="soa-ttl" placeholder="TTL" autocomplete="off" data-regex="^[0-9]+$" tabindex="6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 col-md-offset-1">
|
||||
<div class="form-group">
|
||||
<label for="soa-serial" class="control-label">Serial</label>
|
||||
<input type="text" class="form-control" id="soa-serial" placeholder="Serial" disabled data-regex=".*">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</row>
|
||||
</div>
|
||||
|
||||
<div id="records" class="container">
|
||||
<row>
|
||||
<h3>Records</h3>
|
||||
</row>
|
||||
<table class="table table-hover" id="table-records">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="cell-vertical-middle"><strong>ID</strong> <span class="glyphicon glyphicon-sort cursor-pointer"></span></td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Name</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer "></span>
|
||||
<input type="text" class="form-control no-shadow" id="searchName" placeholder="Search" autocomplete="off">
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Type</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer"></span>
|
||||
<select class="form-control no-shadow" id="searchType" multiple></select>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Content</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer"></span>
|
||||
<input type="text" class="form-control no-shadow" id="searchContent" placeholder="Search" autocomplete="off">
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td class="cell-vertical-middle"><strong>Priority</strong> <span class="glyphicon glyphicon-sort cursor-pointer"></span></td>
|
||||
<td class="cell-vertical-middle"><strong>TTL</strong> <span class="glyphicon glyphicon-sort cursor-pointer"></span></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<td>New</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<input id="addName" type="text" class="form-control input-sm" data-regex="^([^.]+\.)*[^.]*$">
|
||||
<span class="input-group-addon" id="add-domain-name"></span>
|
||||
</div>
|
||||
</td>
|
||||
<td><select id="addType" class="form-control select-narrow-70"></select></td>
|
||||
<td><input id="addContent" type="text" class="form-control input-sm" data-regex="^.+$"></td>
|
||||
<td><input id="addPrio" type="text" class="form-control input-sm" placeholder="0" size="1" data-regex="^[0-9]*$"></td>
|
||||
<td><input id="addTtl" type="text" class="form-control input-sm" placeholder="86400" size="3" data-regex="^[0-9]*$"></td>
|
||||
<td colspan="3"><button id="addButton" class="btn btn-success btn-sm"> Add </button></td>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
122
edit-remote.php
122
edit-remote.php
|
@ -1,122 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Remotes</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.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/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="include/select2/select2.min.js"></script>
|
||||
|
||||
<script src="js/edit-remote.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li><a href="users.php">Users</a></li>'; ?>
|
||||
<li><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2 id="heading">Remote access</h2>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<div class="col-md-4">
|
||||
<table id="permissions" class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><strong>ID</strong></td>
|
||||
<td><strong>Description</strong></td>
|
||||
<td><strong>Type</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<row>
|
||||
<button id="button-add-password" class="btn btn-success">Add password</button>
|
||||
<button id="button-add-key" class="btn btn-success">Add key</button>
|
||||
</row>
|
||||
</div>
|
||||
<div class="col-md-4 col-md-offset-1" id="info-dialogs">
|
||||
<row id="data-password" class="defaulthidden">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="data-password-description" class="control-label">Description</label>
|
||||
<input type="text" class="form-control" id="data-password-description" placeholder="Description" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="data-password-password" class="control-label">Password</label>
|
||||
<input type="password" class="form-control" id="data-password-password" placeholder="Password" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="data-password-password2" class="control-label">Password repeated</label>
|
||||
<input type="password" class="form-control" id="data-password-password2" placeholder="Password repeated" autocomplete="off">
|
||||
</div>
|
||||
<button id="data-password-confirm" class="btn btn-primary">Add</button>
|
||||
<button id="data-password-cancel" class="btn btn-default">Cancel</button>
|
||||
</form>
|
||||
</row>
|
||||
|
||||
<row id="data-key" class="defaulthidden">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="data-key-description" class="control-label">Description</label>
|
||||
<input type="text" class="form-control" id="data-key-description" placeholder="Description" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="data-key-key" class="control-label">RSA Public Key</label>
|
||||
<textarea class="form-control" id="data-key-key" placeholder="Enter RSA Public Key" autocomplete="off" cols="100" rows="10"></textarea>
|
||||
</div>
|
||||
<button id="data-key-confirm" class="btn btn-primary">Add</button>
|
||||
<button id="data-key-cancel" class="btn btn-default">Cancel</button>
|
||||
</form>
|
||||
</row>
|
||||
</div>
|
||||
</row>
|
||||
</div>
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
107
edit-user.php
107
edit-user.php
|
@ -1,107 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Users</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.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/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="include/select2/select2.min.js"></script>
|
||||
|
||||
<script src="js/edit-user.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li><a href="users.php">Users</a></li>'; ?>
|
||||
<li><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2 id="heading">Change user</h2>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<div class="col-md-3">
|
||||
<form>
|
||||
|
||||
<div class="form-group">
|
||||
<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">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="user-password" class="control-label">Password</label>
|
||||
<input type="password" class="form-control" id="user-password" placeholder="(Unchanged)" autocomplete="off" tabindex="2">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="user-password2" class="control-label">Password repeated</label>
|
||||
<input type="password" class="form-control" id="user-password2" placeholder="(Unchanged)" autocomplete="off" tabindex="3">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="user-type" class="control-label">Type</label>
|
||||
<select id="user-type" class="form-control" tabindex="4">
|
||||
<option value="user">User</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select>
|
||||
</div>
|
||||
<button id="user-button-add" class="btn btn-primary" tabindex="5">Change</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-md-offset-1 defaulthidden" id="permissions">
|
||||
<h3>Permissions</h3>
|
||||
|
||||
<table class="table table-hover">
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<label for="selectAdd" class="control-label">Add</label>
|
||||
<select multiple class="form-control" id="selectAdd"></select>
|
||||
<div class="vspacer-15"></div>
|
||||
<button class="btn btn-primary" id="btnAddPermissions">Add</button>
|
||||
</div>
|
||||
</row>
|
||||
|
||||
</div>
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
75
index.php
75
index.php
|
@ -1,75 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'config/config-default.php';
|
||||
require_once 'lib/database.php';
|
||||
require_once 'lib/checkversion.php';
|
||||
|
||||
if(!checkVersion($db)) {
|
||||
Header("Location: upgrade.php");
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.min.css" rel="stylesheet">
|
||||
<link href="include/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="row vspacer-60"></div>
|
||||
<div class="row">
|
||||
<div class="col-md-3 col-md-offset-6">
|
||||
<div class="alert alert-danger defaulthidden" id="alertLoginFailed" role="alert">
|
||||
Username and/or password wrong!
|
||||
</div>
|
||||
<form id="formLogin">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="inputUser">Username</label>
|
||||
<input type="text" class="form-control" id="inputUser" placeholder="Username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="inputPassword">Password</label>
|
||||
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
|
||||
</div>
|
||||
<button id="buttonSubmit" type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
120
install.php
120
install.php
|
@ -1,120 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
if(file_exists("config/config-user.php")) {
|
||||
Header("Location: index.php");
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Domains</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.min.css" rel="stylesheet">
|
||||
<link href="include/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/install.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="#">Install</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2 id="domain-name">Install PDNS Manager</h2>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<div class="alert alert-danger defaulthidden" id="alertFailed" role="alert">
|
||||
Error
|
||||
</div>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
|
||||
<form>
|
||||
<div class="container col-md-3">
|
||||
<h3>Database</h3>
|
||||
<div class="form-group">
|
||||
<label for="dbType" class="control-label">Type</label>
|
||||
<select class="form-control" id="dbType">
|
||||
<option value="mysql" selected>MySQL</option>
|
||||
<option value="pgsql">PgSQL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbHost" class="control-label">Host</label>
|
||||
<input type="text" class="form-control" id="dbHost" placeholder="Host" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbUser" class="control-label">User</label>
|
||||
<input type="text" class="form-control" id="dbUser" placeholder="User" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbPassword" class="control-label">Password</label>
|
||||
<input type="password" class="form-control" id="dbPassword" placeholder="Password" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbDatabase" class="control-label">Database</label>
|
||||
<input type="text" class="form-control" id="dbDatabase" placeholder="Database" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dbPort" class="control-label">Port</label>
|
||||
<input type="text" class="form-control" id="dbPort" value="3306" autocomplete="off">
|
||||
</div>
|
||||
<button id="buttonInstall" class="btn btn-primary">Install</button>
|
||||
</div>
|
||||
|
||||
<div class="container col-md-3">
|
||||
<h3>Admin</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="adminName" class="control-label">Name</label>
|
||||
<input type="text" class="form-control" id="adminName" placeholder="Name" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="adminPassword" class="control-label">Password</label>
|
||||
<input type="password" class="form-control" id="adminPassword" placeholder="Password" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="adminPassword2" class="control-label">Password repeated</label>
|
||||
<input type="password" class="form-control" id="adminPassword2" placeholder="Password repeated" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</row>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#zone-button-add').click(function(evt){
|
||||
evt.preventDefault();
|
||||
if(validateData()) {
|
||||
saveData(function(id) {
|
||||
location.assign("edit-master.php#" + id);
|
||||
});
|
||||
} else {
|
||||
shake($('#zone-button-add'));
|
||||
}
|
||||
});
|
||||
|
||||
$('form input').bind("paste keyup change", regexValidate);
|
||||
});
|
||||
|
||||
function validateData() {
|
||||
|
||||
var error = 0;
|
||||
|
||||
$('form input').change();
|
||||
|
||||
$('form input').each(function() {
|
||||
if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) {
|
||||
error++;
|
||||
$(this).parent().addClass('has-error');
|
||||
}
|
||||
});
|
||||
|
||||
return error<=0;
|
||||
}
|
||||
|
||||
function regexValidate() {
|
||||
var regex = new RegExp($(this).attr('data-regex'));
|
||||
if(!regex.test($(this).val())) {
|
||||
$(this).parent().addClass("has-error");
|
||||
} else {
|
||||
$(this).parent().removeClass("has-error");
|
||||
}
|
||||
}
|
||||
|
||||
function saveData(callback) {
|
||||
var data = {
|
||||
name: $('#zone-name').val(),
|
||||
primary: $('#zone-primary').val(),
|
||||
mail: $('#zone-mail').val(),
|
||||
refresh: $('#zone-refresh').val(),
|
||||
retry: $('#zone-retry').val(),
|
||||
expire: $('#zone-expire').val(),
|
||||
ttl: $('#zone-ttl').val(),
|
||||
type: window.location.hash.substring(1),
|
||||
action: "addDomain",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/add-domain.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
callback(data.newId);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function shake(element){
|
||||
var interval = 50;
|
||||
var distance = 5;
|
||||
var times = 6;
|
||||
|
||||
$(element).css('position','relative');
|
||||
|
||||
for(var iter=0;iter<(times+1);iter++){
|
||||
$(element).animate({
|
||||
left:((iter%2===0 ? distance : distance*-1))
|
||||
},interval);
|
||||
}
|
||||
|
||||
$(element).animate({ left: 0},interval);
|
||||
}
|
198
js/domains.js
198
js/domains.js
|
@ -1,198 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var sort = {
|
||||
field: "",
|
||||
order: 1
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
requestData();
|
||||
|
||||
$('#table-domains>thead>tr>td span').click(function() {
|
||||
var field = $(this).siblings('strong').text().toLowerCase();
|
||||
if(sort.field == field) {
|
||||
if(sort.order == 1) sort.order = 0;
|
||||
else sort.field = "";
|
||||
} else {
|
||||
sort.field = field;
|
||||
sort.order = 1;
|
||||
}
|
||||
$('#table-domains>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt");
|
||||
|
||||
if(sort.field == field) {
|
||||
if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes");
|
||||
else $(this).addClass("glyphicon-sort-by-attributes-alt");
|
||||
}
|
||||
requestData();
|
||||
});
|
||||
|
||||
$('#searchName').bind("paste keyup", function() {
|
||||
requestData();
|
||||
});
|
||||
|
||||
$('#searchType').change(function() {
|
||||
requestData();
|
||||
});
|
||||
|
||||
$('#searchType').select2({
|
||||
minimumResultsForSearch: Infinity
|
||||
});
|
||||
});
|
||||
|
||||
function requestData(page) {
|
||||
if(typeof(page) !== 'number' || page <= 0) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
var restrictions = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
};
|
||||
|
||||
restrictions.sort = sort;
|
||||
|
||||
var searchName = $('#searchName').val();
|
||||
if(searchName.length > 0) {
|
||||
restrictions.name = searchName;
|
||||
}
|
||||
|
||||
var searchType = $('#searchType').val();
|
||||
if(searchType != "none") {
|
||||
restrictions.type = searchType;
|
||||
}
|
||||
|
||||
restrictions.action = "getDomains";
|
||||
restrictions.page = page;
|
||||
|
||||
$.post(
|
||||
"api/domains.php",
|
||||
JSON.stringify(restrictions),
|
||||
function(data) {
|
||||
recreateTable(data.data);
|
||||
recreatePagination(data.pages)
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function recreatePagination(data) {
|
||||
$('#pagination').empty();
|
||||
|
||||
if(data.total === 1) {
|
||||
$('#pagination-wrapper').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
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><span>1</span></li>').appendTo('#pagination').data("page", 1).click(paginationClicked);
|
||||
|
||||
if(data.current > 4) {
|
||||
$('<li class="disabled"><span>…</span></li>').appendTo('#pagination');
|
||||
}
|
||||
|
||||
for(var i = data.current - 2; i <= data.current + 2; i++) {
|
||||
if(i > 1 && i < data.total) {
|
||||
if(data.current === i) {
|
||||
$('<li class="active"><span>' + i + '</span></li>').appendTo('#pagination');
|
||||
} else {
|
||||
$('<li><span>' + i + '</span></li>').appendTo('#pagination').data("page", i).click(paginationClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(data.current < data.total - 3) {
|
||||
$('<li class="disabled"><span>…</span></li>').appendTo('#pagination');
|
||||
}
|
||||
|
||||
$('<li><span>' + data.total + '</span></li>').appendTo('#pagination').data("page", data.total).click(paginationClicked);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$('#pagination-wrapper').show();
|
||||
}
|
||||
|
||||
function recreateTable(data) {
|
||||
$('#table-domains>tbody').empty();
|
||||
|
||||
$.each(data, function(index,item) {
|
||||
$('<tr></tr>').appendTo('#table-domains>tbody')
|
||||
.append('<td>' + item.id + '</td>')
|
||||
.append('<td>' + item.name + '</td>')
|
||||
.append('<td>' + item.type + '</td>')
|
||||
.append('<td>' + item.records + '</td>')
|
||||
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>');
|
||||
|
||||
});
|
||||
|
||||
$('#table-domains>tbody>tr>td:not(:last-child)').click(function() {
|
||||
var id = $(this).parent().children('td').first().text();
|
||||
var type = $(this).parent().children('td').eq(2).text();
|
||||
|
||||
if(type == 'MASTER') {
|
||||
location.assign('edit-master.php#' + id);
|
||||
} else if(type == 'NATIVE') {
|
||||
location.assign('edit-master.php#' + id);
|
||||
}
|
||||
});
|
||||
|
||||
$('#table-domains>tbody>tr>td>span.glyphicon-trash').click(function() {
|
||||
$(this).parent().parent().unbind();
|
||||
deleteDomain.call(this);
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDomain() {
|
||||
var deleteId = $(this).parent().parent().children('td').eq(0).text();
|
||||
var deleteZone = $(this).parent().parent().children('td').eq(1).text();
|
||||
var rowToRemove = $(this).parent().parent();
|
||||
|
||||
$('#zoneToDelete').text(deleteZone);
|
||||
|
||||
$('#deleteConfirm #buttonDelete').click(function() {
|
||||
deleteDomainWithId(deleteId, function() {
|
||||
$('#deleteConfirm').modal("hide");
|
||||
$(rowToRemove).remove();
|
||||
});
|
||||
});
|
||||
|
||||
$('#deleteConfirm').modal();
|
||||
}
|
||||
|
||||
function deleteDomainWithId(id, callback) {
|
||||
var data = {
|
||||
action: "deleteDomain",
|
||||
id: id,
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/domains.php",
|
||||
JSON.stringify(data),
|
||||
function() {
|
||||
callback();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function paginationClicked() {
|
||||
requestData($(this).data("page"));
|
||||
}
|
|
@ -1,479 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var sort = {
|
||||
field: "",
|
||||
order: 1
|
||||
};
|
||||
|
||||
var domainName = "";
|
||||
|
||||
var recordTypes = [
|
||||
"A","AAAA","AFSDB","CERT","CNAME","DHCID",
|
||||
"DLV","DNSKEY","DS","EUI48","EUI64","HINFO",
|
||||
"IPSECKEY","KEY","KX","LOC","MINFO","MR",
|
||||
"MX","NAPTR","NS","NSEC","NSEC3","NSEC3PARAM",
|
||||
"OPT","PTR","RKEY","RP","RRSIG","SPF",
|
||||
"SRV","SSHFP","TLSA","TSIG","TXT","WKS"
|
||||
];
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#soa button[type=submit]').click(function(){
|
||||
if(validateSoaData()) {
|
||||
saveSoaData();
|
||||
$('#soa button[type=submit]').prop("disabled", true);
|
||||
} else {
|
||||
shake($('#soa button[type=submit]'));
|
||||
}
|
||||
});
|
||||
|
||||
$('#soa input').bind("paste keyup change", function() {
|
||||
$('#soa button[type=submit]').prop("disabled", false);
|
||||
});
|
||||
|
||||
$('#soa form input').bind("paste keyup change", regexValidate);
|
||||
$('#table-records>tfoot input').bind("paste keyup change", regexValidate);
|
||||
|
||||
$('#searchType').select2({
|
||||
placeholder: "Filter...",
|
||||
data: recordTypes
|
||||
});
|
||||
|
||||
$('#addType').select2({
|
||||
data: recordTypes
|
||||
});
|
||||
|
||||
$('#table-records>thead>tr>td span.glyphicon').click(function() {
|
||||
var field = $(this).siblings('strong').text().toLowerCase();
|
||||
if(sort.field == field) {
|
||||
if(sort.order == 1) sort.order = 0;
|
||||
else sort.field = "";
|
||||
} else {
|
||||
sort.field = field;
|
||||
sort.order = 1;
|
||||
}
|
||||
$('#table-records>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt");
|
||||
|
||||
if(sort.field == field) {
|
||||
if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes");
|
||||
else $(this).addClass("glyphicon-sort-by-attributes-alt");
|
||||
}
|
||||
requestRecordData();
|
||||
});
|
||||
|
||||
$('#searchName, #searchContent').bind("paste keyup", function() {
|
||||
requestRecordData();
|
||||
});
|
||||
|
||||
$('#searchType').change(function() {
|
||||
requestRecordData();
|
||||
});
|
||||
|
||||
requestRecordData();
|
||||
requestSoaData();
|
||||
requestSerial();
|
||||
requestDomainName();
|
||||
});
|
||||
|
||||
function validateSoaData() {
|
||||
|
||||
var error = 0;
|
||||
|
||||
$('#soa form input:not(#soa-serial)').each(function() {
|
||||
if($(this).val().length <= 0 || $(this).parent().hasClass('has-error')) {
|
||||
error++;
|
||||
$(this).parent().addClass('has-error');
|
||||
}
|
||||
});
|
||||
|
||||
return error<=0;
|
||||
}
|
||||
|
||||
function recreateTable(data) {
|
||||
$('#table-records>tbody').empty();
|
||||
|
||||
$.each(data, function(index,item) {
|
||||
$('<tr></tr>').appendTo('#table-records>tbody')
|
||||
.append('<td>' + item.id + '</td>')
|
||||
.append('<td>' + item.name + '</td>')
|
||||
.append('<td>' + item.type + '</td>')
|
||||
.append('<td class="wrap-all-words">' + item.content + '</td>')
|
||||
.append('<td>' + item.priority + '</td>')
|
||||
.append('<td>' + item.ttl + '</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-share cursor-pointer"></span></td>');
|
||||
|
||||
});
|
||||
|
||||
$('#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-share').click(remoteClicked);
|
||||
}
|
||||
|
||||
function requestRecordData() {
|
||||
var restrictions = {
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
restrictions.sort = sort;
|
||||
|
||||
var searchName = $('#searchName').val();
|
||||
if(searchName.length > 0) {
|
||||
restrictions.name = searchName;
|
||||
}
|
||||
|
||||
var searchType = $('#searchType').val();
|
||||
if(searchType != null && searchType.length > 0) {
|
||||
restrictions.type = searchType;
|
||||
}
|
||||
|
||||
var searchContent = $('#searchContent').val();
|
||||
if(searchContent.length > 0) {
|
||||
restrictions.content = searchContent;
|
||||
}
|
||||
|
||||
restrictions.action = "getRecords";
|
||||
|
||||
restrictions.domain = location.hash.substring(1);
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(restrictions),
|
||||
function(data) {
|
||||
recreateTable(data);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function requestSoaData() {
|
||||
var data = {
|
||||
action: "getSoa",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
data.domain = location.hash.substring(1);
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#soa-primary').val(data.primary);
|
||||
$('#soa-mail').val(data.email);
|
||||
$('#soa-refresh').val(data.refresh);
|
||||
$('#soa-retry').val(data.retry);
|
||||
$('#soa-expire').val(data.expire);
|
||||
$('#soa-ttl').val(data.ttl);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function requestSerial() {
|
||||
var data = {
|
||||
action: "getSerial",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
data.domain = location.hash.substring(1);
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#soa-serial').val(data.serial);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function saveSoaData() {
|
||||
var data = {
|
||||
action: "saveSoa",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
data.domain = location.hash.substring(1);
|
||||
|
||||
data.primary = $('#soa-primary').val();
|
||||
data.email = $('#soa-mail').val();
|
||||
data.refresh = $('#soa-refresh').val();
|
||||
data.retry = $('#soa-retry').val();
|
||||
data.expire = $('#soa-expire').val();
|
||||
data.ttl = $('#soa-ttl').val();
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function() {
|
||||
requestSerial();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function editClicked() {
|
||||
var tableCells = $(this).parent().parent().children('td');
|
||||
var tableRow = $(this).parent().parent();
|
||||
|
||||
var valueExtractRegex = new RegExp('\.?' + domainName + "$");
|
||||
var valueName = tableCells.eq(1).text();
|
||||
valueName = valueName.replace(valueExtractRegex, "");
|
||||
tableCells.eq(1).empty();
|
||||
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);
|
||||
$('<span class="input-group-addon"></span>').appendTo(inputGroupName).text("." + domainName);
|
||||
|
||||
var valueType = tableCells.eq(2).text();
|
||||
tableCells.eq(2).empty();
|
||||
$('<select class="form-control select-narrow-70"></select>').appendTo(tableCells.eq(2)).select2({
|
||||
data: recordTypes
|
||||
}).val(valueType).trigger("change");
|
||||
|
||||
var valueContent = tableCells.eq(3).text();
|
||||
tableCells.eq(3).empty();
|
||||
$('<input type="text" class="form-control input-sm" data-regex="^.+$">').appendTo(tableCells.eq(3)).val(valueContent);
|
||||
|
||||
var valuePrio = tableCells.eq(4).text();
|
||||
tableCells.eq(4).empty();
|
||||
$('<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();
|
||||
tableCells.eq(5).empty();
|
||||
$('<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(7).remove();
|
||||
tableCells.eq(8).remove();
|
||||
|
||||
$(tableRow).append('<td colspan="3"><button class="btn btn-primary btn-sm">Save</button></td>');
|
||||
|
||||
$(tableRow).find('button').click(saveRecord);
|
||||
|
||||
enableFilter(false);
|
||||
|
||||
$(tableRow).find("input").bind("paste keyup change", regexValidate);
|
||||
}
|
||||
|
||||
function saveRecord() {
|
||||
|
||||
var tableRow = $(this).parent().parent();
|
||||
|
||||
if(!validateLine.call(this)) {
|
||||
shake($(this));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
id: tableRow.children('td').eq(0).text(),
|
||||
name: tableRow.children('td').eq(1).find('input').val(),
|
||||
type: tableRow.children('td').eq(2).children('select').val(),
|
||||
content: tableRow.children('td').eq(3).children('input').val(),
|
||||
prio: tableRow.children('td').eq(4).children('input').val(),
|
||||
ttl: tableRow.children('td').eq(5).children('input').val(),
|
||||
action: "saveRecord",
|
||||
domain: location.hash.substring(1),
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
if(data.name.length > 0) {
|
||||
data.name = data.name + "." + domainName;
|
||||
} else {
|
||||
data.name = domainName;
|
||||
}
|
||||
|
||||
tableRow.children('td').eq(0).empty().text(data.id);
|
||||
tableRow.children('td').eq(1).empty().text(data.name);
|
||||
tableRow.children('td').eq(2).empty().text(data.type);
|
||||
tableRow.children('td').eq(3).empty().text(data.content);
|
||||
tableRow.children('td').eq(4).empty().text(data.prio);
|
||||
tableRow.children('td').eq(5).empty().text(data.ttl);
|
||||
|
||||
tableRow.children('td').eq(6).remove();
|
||||
|
||||
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-share cursor-pointer"></span></td>');
|
||||
tableRow.find('span.glyphicon-trash').click(trashClicked);
|
||||
tableRow.find('span.glyphicon-pencil').click(editClicked);
|
||||
tableRow.find('span.glyphicon-share').click(remoteClicked);
|
||||
|
||||
enableFilter(true);
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function() {
|
||||
requestSerial();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function addRecord() {
|
||||
if(!validateLine.call(this)) {
|
||||
shake($('#addButton'));
|
||||
return;
|
||||
}
|
||||
|
||||
var prio = $('#addPrio').val();
|
||||
if(prio.length === 0) prio = 0;
|
||||
|
||||
var ttl = $('#addTtl').val();
|
||||
if(ttl.length === 0) ttl = 86400;
|
||||
|
||||
var data = {
|
||||
type: $('#addType').val(),
|
||||
content: $('#addContent').val(),
|
||||
prio: prio,
|
||||
ttl: ttl,
|
||||
action: "addRecord",
|
||||
domain: location.hash.substring(1),
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
if($('#addName').val().length > 0) {
|
||||
data.name = $('#addName').val() + "." + domainName;
|
||||
} else {
|
||||
data.name = domainName;
|
||||
}
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function(dataRecv) {
|
||||
$('<tr></tr>').appendTo('#table-records>tbody')
|
||||
.append('<td>' + dataRecv.newId + '</td>')
|
||||
.append('<td>' + data.name + '</td>')
|
||||
.append('<td>' + data.type + '</td>')
|
||||
.append('<td class="wrap-all-words">' + data.content + '</td>')
|
||||
.append('<td>' + data.prio + '</td>')
|
||||
.append('<td>' + data.ttl + '</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-share cursor-pointer"></span></td>');
|
||||
|
||||
$('#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-share').click(remoteClicked);
|
||||
requestSerial();
|
||||
|
||||
$('#addName').val("");
|
||||
$('#addType').val("A").change();
|
||||
$('#addContent').val("");
|
||||
$('#addPrio').val("");
|
||||
$('#addTtl').val("");
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function trashClicked() {
|
||||
var data = {
|
||||
id: $(this).parent().parent().children().eq(0).text(),
|
||||
domain: location.hash.substring(1),
|
||||
action: "removeRecord",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
var lineAffected = $(this).parent().parent();
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function() {
|
||||
lineAffected.remove();
|
||||
requestSerial();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function requestDomainName() {
|
||||
var data = {
|
||||
action: "getDomainName",
|
||||
domain: location.hash.substring(1),
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-master.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#domain-name').text(data.name);
|
||||
$('#add-domain-name').text("." + data.name);
|
||||
domainName = data.name;
|
||||
$('#addButton').unbind().click(addRecord);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function enableFilter(enable) {
|
||||
if(enable) {
|
||||
$('#searchName').prop("disabled", false);
|
||||
$('#searchType').prop("disabled", false);
|
||||
$('#searchContent').prop("disabled", false);
|
||||
} else {
|
||||
$('#searchName').prop("disabled", true);
|
||||
$('#searchType').prop("disabled", true);
|
||||
$('#searchContent').prop("disabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
function regexValidate() {
|
||||
var regex = new RegExp($(this).attr('data-regex'));
|
||||
if(!regex.test($(this).val())) {
|
||||
$(this).parent().addClass("has-error");
|
||||
} else {
|
||||
$(this).parent().removeClass("has-error");
|
||||
}
|
||||
}
|
||||
|
||||
function validateLine() {
|
||||
$(this).parent().parent().find('input[data-regex]').change();
|
||||
var errors = 0;
|
||||
$(this).parent().parent().find('input[data-regex]').each(function() {
|
||||
if($(this).parent().hasClass('has-error')) {
|
||||
errors++;
|
||||
}
|
||||
});
|
||||
|
||||
return errors <= 0;
|
||||
}
|
||||
|
||||
function remoteClicked() {
|
||||
var recordId = $(this).parent().siblings().eq(0).text();
|
||||
location.assign("edit-remote.php#" + recordId);
|
||||
}
|
||||
|
||||
function shake(element){
|
||||
var interval = 50;
|
||||
var distance = 5;
|
||||
var times = 6;
|
||||
|
||||
$(element).css('position','relative');
|
||||
|
||||
for(var iter=0;iter<(times+1);iter++){
|
||||
$(element).animate({
|
||||
left:((iter%2===0 ? distance : distance*-1))
|
||||
},interval);
|
||||
}
|
||||
|
||||
$(element).animate({ left: 0},interval);
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#data-password-password2').bind("paste keyup change", function() {
|
||||
if($('#data-password-password').val() != $('#data-password-password2').val()) {
|
||||
$(this).parent().addClass("has-error");
|
||||
} else {
|
||||
$(this).parent().removeClass("has-error");
|
||||
}
|
||||
});
|
||||
|
||||
$('#button-add-password').click(function() {
|
||||
resetFields();
|
||||
$('#data-password').show();
|
||||
$('#data-key').hide();
|
||||
$('#data-password-confirm').unbind().click(addPassword);
|
||||
});
|
||||
|
||||
$('#button-add-key').click(function() {
|
||||
resetFields();
|
||||
$('#data-key').show();
|
||||
$('#data-password').hide();
|
||||
$('#data-key-confirm').unbind().click(addKey);
|
||||
});
|
||||
|
||||
$('#data-password-cancel').click(function() {
|
||||
$('#data-password').hide();
|
||||
});
|
||||
|
||||
$('#data-key-cancel').click(function() {
|
||||
$('#data-key').hide();
|
||||
});
|
||||
|
||||
requestPermissions();
|
||||
});
|
||||
|
||||
function regexValidate() {
|
||||
var regex = new RegExp($(this).attr('data-regex'));
|
||||
if(!regex.test($(this).val())) {
|
||||
$(this).parent().addClass("has-error");
|
||||
} else {
|
||||
$(this).parent().removeClass("has-error");
|
||||
}
|
||||
}
|
||||
|
||||
function createTable(data) {
|
||||
$('#permissions tbody').empty();
|
||||
|
||||
$.each(data, function(index,item) {
|
||||
$('<tr></tr>').appendTo('#permissions tbody')
|
||||
.append('<td>' + item.id + '</td>')
|
||||
.append('<td>' + item.description + '</td>')
|
||||
.append('<td>' + item.type + '</td>')
|
||||
.append('<td><span class="glyphicon glyphicon-pencil 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-pencil').click(prepareEdit);
|
||||
}
|
||||
|
||||
function requestPermissions() {
|
||||
var data = {
|
||||
action: "getPermissions",
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
record: location.hash.substring(1)
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
createTable(data);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function resetFields() {
|
||||
$('#info-dialogs input').val("");
|
||||
$('#info-dialogs textarea').val("");
|
||||
$('#info-dialogs .form-group').removeClass("has-error");
|
||||
$('#data-password-password').attr("placeholder", "Password");
|
||||
$('#data-password-password2').attr("placeholder", "Password repeated");
|
||||
$('#data-password-confirm').text("Add");
|
||||
$('#data-key-confirm').text("Add");
|
||||
}
|
||||
|
||||
function addPassword() {
|
||||
if($('#data-password-password').val() != $('#data-password-password2').val() || $('#data-password-password').val().length <= 0) {
|
||||
$('#data-password-password2').parent().addClass("has-error");
|
||||
shake($('#data-password-confirm'));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
action: "addPassword",
|
||||
description: $('#data-password-description').val(),
|
||||
password: $('#data-password-password').val(),
|
||||
record: location.hash.substring(1)
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#data-password').hide();
|
||||
requestPermissions();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function addKey() {
|
||||
if($('#data-key-key').val().length <= 0) {
|
||||
$('#data-key-key').parent().addClass("has-error");
|
||||
shake($('#data-key-confirm'));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
action: "addKey",
|
||||
description: $('#data-key-description').val(),
|
||||
key: $('#data-key-key').val(),
|
||||
record: location.hash.substring(1)
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#data-key').hide();
|
||||
requestPermissions();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function deletePermission() {
|
||||
var data = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
action: "deletePermission",
|
||||
permission: $(this).parent().siblings().eq(0).text(),
|
||||
record: location.hash.substring(1)
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
requestPermissions();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function prepareEdit() {
|
||||
var type = $(this).parent().siblings().eq(2).text();
|
||||
if(type === "password") {
|
||||
resetFields();
|
||||
$('#data-password').show();
|
||||
$('#data-key').hide();
|
||||
$('#data-password-confirm').unbind().click(changePassword);
|
||||
|
||||
$('#data-password-password').attr("placeholder", "(Unchanged)");
|
||||
$('#data-password-password2').attr("placeholder", "(Unchanged)");
|
||||
$('#data-password-confirm').text("Change");
|
||||
|
||||
$('#data-password-description').val($(this).parent().siblings().eq(1).text());
|
||||
|
||||
$('#data-password-confirm').data("permission-id", $(this).parent().siblings().eq(0).text());
|
||||
} else if(type === "key") {
|
||||
resetFields();
|
||||
$('#data-key').show();
|
||||
$('#data-password').hide();
|
||||
$('#data-key-confirm').unbind().click(changeKey);
|
||||
|
||||
$('#data-key-confirm').text("Change");
|
||||
$('#data-key-description').val($(this).parent().siblings().eq(1).text());
|
||||
|
||||
$('#data-key-confirm').data("permission-id", $(this).parent().siblings().eq(0).text());
|
||||
|
||||
var data = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
action: "getKey",
|
||||
permission: $(this).parent().siblings().eq(0).text(),
|
||||
record: location.hash.substring(1)
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#data-key-key').val(data.key);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function changePassword() {
|
||||
if($('#data-password-password').val() != $('#data-password-password2').val()) {
|
||||
$('#data-password-password2').parent().addClass("has-error");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
action: "changePassword",
|
||||
description: $('#data-password-description').val(),
|
||||
record: location.hash.substring(1),
|
||||
permission: $('#data-password-confirm').data("permission-id")
|
||||
};
|
||||
|
||||
if($('#data-password-password').val().length >= 0) {
|
||||
data.password = $('#data-password-password').val();
|
||||
}
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#data-password').hide();
|
||||
requestPermissions();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function changeKey() {
|
||||
if($('#data-key-key').val().length <= 0) {
|
||||
$('#data-key-key').parent().addClass("has-error");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
csrfToken: $('#csrfToken').text(),
|
||||
action: "changeKey",
|
||||
description: $('#data-key-description').val(),
|
||||
key: $('#data-key-key').val(),
|
||||
record: location.hash.substring(1),
|
||||
permission: $('#data-key-confirm').data("permission-id")
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-remote.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#data-key').hide();
|
||||
requestPermissions();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function shake(element){
|
||||
var interval = 50;
|
||||
var distance = 5;
|
||||
var times = 6;
|
||||
|
||||
$(element).css('position','relative');
|
||||
|
||||
for(var iter=0;iter<(times+1);iter++){
|
||||
$(element).animate({
|
||||
left:((iter%2===0 ? distance : distance*-1))
|
||||
},interval);
|
||||
}
|
||||
|
||||
$(element).animate({ left: 0},interval);
|
||||
}
|
265
js/edit-user.js
265
js/edit-user.js
|
@ -1,265 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#user-button-add').click(function(evt){
|
||||
evt.preventDefault();
|
||||
|
||||
if(location.hash.substring(1) == "new") {
|
||||
addUser();
|
||||
} else {
|
||||
saveUserChanges();
|
||||
}
|
||||
});
|
||||
|
||||
$('form input#user-name').bind("paste keyup change", regexValidate);
|
||||
|
||||
$('#user-password').unbind().bind("paste keyup change", function() {
|
||||
$('#user-password').parent().removeClass("has-error");
|
||||
});
|
||||
|
||||
$('#user-password2').unbind().bind("paste keyup change", function() {
|
||||
if($('#user-password').val() != $('#user-password2').val()) {
|
||||
$('#user-password2').parent().addClass("has-error");
|
||||
} else {
|
||||
$('#user-password2').parent().removeClass("has-error");
|
||||
}
|
||||
});
|
||||
|
||||
$('#user-type').select2({
|
||||
minimumResultsForSearch: Infinity
|
||||
});
|
||||
|
||||
//Prepare for new user
|
||||
if(location.hash.substring(1) == "new") {
|
||||
$('#heading').text("Add user");
|
||||
$('#user-button-add').text("Add");
|
||||
$('#user-password').attr("placeholder", "Password");
|
||||
$('#user-password2').attr("placeholder", "Password repeated");
|
||||
} else {
|
||||
getUserData();
|
||||
requestPermissions();
|
||||
$('#permissions').removeClass("defaulthidden");
|
||||
}
|
||||
|
||||
$('#permissions select#selectAdd').select2({
|
||||
ajax: {
|
||||
url: "api/edit-user.php",
|
||||
dataType: "json",
|
||||
delay: 200,
|
||||
method: "post",
|
||||
data: function(params) {
|
||||
return JSON.stringify({
|
||||
action: "searchDomains",
|
||||
term: params.term,
|
||||
userId: location.hash.substring(1),
|
||||
csrfToken: $('#csrfToken').text()
|
||||
});
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: data
|
||||
};
|
||||
},
|
||||
minimumInputLength: 1
|
||||
},
|
||||
placeholder: "Search...",
|
||||
minimumInputLength: 1
|
||||
});
|
||||
|
||||
$('#btnAddPermissions').click(addPermissions);
|
||||
});
|
||||
|
||||
function regexValidate() {
|
||||
var regex = new RegExp($(this).attr('data-regex'));
|
||||
if(!regex.test($(this).val())) {
|
||||
$(this).parent().addClass("has-error");
|
||||
} else {
|
||||
$(this).parent().removeClass("has-error");
|
||||
}
|
||||
}
|
||||
|
||||
function addUser() {
|
||||
$('form input').change();
|
||||
|
||||
if($('#user-password').val().length <= 0) {
|
||||
$('#user-password').parent().addClass("has-error");
|
||||
$('#user-password2').parent().addClass("has-error");
|
||||
shake($('#user-button-add'));
|
||||
}
|
||||
|
||||
if($('#user-name').parent().hasClass("has-error")) {
|
||||
shake($('#user-button-add'));
|
||||
return;
|
||||
}
|
||||
if($('#user-password2').parent().hasClass("has-error")) {
|
||||
shake($('#user-button-add'));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
name: $('#user-name').val(),
|
||||
password: $('#user-password').val(),
|
||||
type: $('#user-type').val(),
|
||||
action: "addUser",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-user.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
location.assign("edit-user.php#" + data.newId);
|
||||
location.reload();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function getUserData() {
|
||||
var data = {
|
||||
id: location.hash.substring(1),
|
||||
action: "getUserData",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-user.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#user-name').val(data.name);
|
||||
$('#user-type').val(data.type).change();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function saveUserChanges() {
|
||||
|
||||
if($('#user-name').parent().hasClass("has-error")) {
|
||||
shake($('#user-button-add'));
|
||||
return;
|
||||
}
|
||||
if($('#user-password2').parent().hasClass("has-error")) {
|
||||
shake($('#user-button-add'));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
id: location.hash.substring(1),
|
||||
name: $('#user-name').val(),
|
||||
type: $('#user-type').val(),
|
||||
action: "saveUserChanges",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
if($('#user-password').val().length > 0) {
|
||||
data.password = $('#user-password').val();
|
||||
}
|
||||
|
||||
$.post(
|
||||
"api/edit-user.php",
|
||||
JSON.stringify(data),
|
||||
null,
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function requestPermissions() {
|
||||
var data = {
|
||||
id: location.hash.substring(1),
|
||||
action: "getPermissions",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/edit-user.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
createTable(data);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function createTable(data) {
|
||||
$('#permissions table>tbody').empty();
|
||||
|
||||
$.each(data, function(index,item) {
|
||||
$('<tr></tr>').appendTo('#permissions table>tbody')
|
||||
.append('<td>' + item.name + '</td>')
|
||||
.append('<td><span class="glyphicon glyphicon-remove cursor-pointer"></span></td>')
|
||||
.data("id", item.id);
|
||||
});
|
||||
|
||||
$('#permissions table>tbody>tr>td>span.glyphicon-remove').click(removePermission);
|
||||
}
|
||||
|
||||
function removePermission() {
|
||||
var data = {
|
||||
domainId: $(this).parent().parent().data("id"),
|
||||
userId: location.hash.substring(1),
|
||||
action: "removePermission",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
var lineToRemove = $(this).parent().parent();
|
||||
|
||||
$.post(
|
||||
"api/edit-user.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$(lineToRemove).remove();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function addPermissions() {
|
||||
var data = {
|
||||
action: "addPermissions",
|
||||
userId: location.hash.substring(1),
|
||||
domains: $('#permissions select#selectAdd').val(),
|
||||
csrfToken: $('#csrfToken').text()
|
||||
}
|
||||
|
||||
$.post(
|
||||
"api/edit-user.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#permissions select#selectAdd').val(null).change();
|
||||
requestPermissions();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function shake(element){
|
||||
var interval = 50;
|
||||
var distance = 5;
|
||||
var times = 6;
|
||||
|
||||
$(element).css('position','relative');
|
||||
|
||||
for(var iter=0;iter<(times+1);iter++){
|
||||
$(element).animate({
|
||||
left:((iter%2===0 ? distance : distance*-1))
|
||||
},interval);
|
||||
}
|
||||
|
||||
$(element).animate({ left: 0},interval);
|
||||
}
|
42
js/index.js
42
js/index.js
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#buttonSubmit').click(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('#alertLoginFailed').slideUp(300);
|
||||
|
||||
var data = {};
|
||||
data.user=$('#inputUser').val();
|
||||
data.password=$('#inputPassword').val();
|
||||
|
||||
$.post(
|
||||
"api/index.php",
|
||||
JSON.stringify(data),
|
||||
function(data){
|
||||
if(data.status == "fail") {
|
||||
$('#alertLoginFailed').slideDown(600);
|
||||
} else {
|
||||
location.assign("domains.php");
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
});
|
||||
});
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#buttonInstall').click(function(evt){
|
||||
evt.preventDefault();
|
||||
checkSettings();
|
||||
});
|
||||
|
||||
$('#adminPassword2').bind("change keyup paste", function() {
|
||||
if($('#adminPassword').val() == $('#adminPassword2').val()) {
|
||||
$(this).parent().removeClass("has-error");
|
||||
} else {
|
||||
$(this).parent().addClass("has-error");
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function checkSettings() {
|
||||
|
||||
if($('#adminPassword').val() != $('#adminPassword2').val()) {
|
||||
$('#adminPassword2').parent().addClass("has-error");
|
||||
}
|
||||
|
||||
if($('#adminPassword').val().length <= 0) {
|
||||
$('#adminPassword').parent().addClass("has-error");
|
||||
}
|
||||
|
||||
if($('#adminName').val().length <= 0) {
|
||||
$('#adminName').parent().addClass("has-error");
|
||||
}
|
||||
|
||||
var data = {
|
||||
host: $('#dbHost').val(),
|
||||
user: $('#dbUser').val(),
|
||||
password: $('#dbPassword').val(),
|
||||
database: $('#dbDatabase').val(),
|
||||
port: $('#dbPort').val(),
|
||||
userName: $('#adminName').val(),
|
||||
userPassword: $('#adminPassword').val(),
|
||||
type: $('#dbType').val()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/install.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
if(data.status == "error") {
|
||||
$('#alertFailed').text(data.message);
|
||||
$('#alertFailed').slideDown(600);
|
||||
} else if(data.status == "success") {
|
||||
location.assign("index.php");
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#saveChanges').click(function(evt){
|
||||
evt.preventDefault();
|
||||
savePassword();
|
||||
});
|
||||
|
||||
$('#user-password').unbind().bind("paste keyup change", function() {
|
||||
$('#user-password').parent().removeClass("has-error");
|
||||
});
|
||||
|
||||
$('#user-password2').unbind().bind("paste keyup change", function() {
|
||||
if($('#user-password').val() != $('#user-password2').val()) {
|
||||
$('#user-password2').parent().addClass("has-error");
|
||||
} else {
|
||||
$('#user-password2').parent().removeClass("has-error");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function savePassword() {
|
||||
|
||||
if($('#user-password').val().length <= 0) {
|
||||
$('#user-password').parent().addClass("has-error");
|
||||
$('#user-password2').parent().addClass("has-error");
|
||||
}
|
||||
if($('#user-password2').parent().hasClass("has-error")) {
|
||||
shake($('#saveChanges'));
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
password: $('#user-password').val(),
|
||||
action: "changePassword",
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/password.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#user-password').val("");
|
||||
$('#user-password2').val("");
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function shake(element){
|
||||
var interval = 50;
|
||||
var distance = 5;
|
||||
var times = 6;
|
||||
|
||||
$(element).css('position','relative');
|
||||
|
||||
for(var iter=0;iter<(times+1);iter++){
|
||||
$(element).animate({
|
||||
left:((iter%2===0 ? distance : distance*-1))
|
||||
},interval);
|
||||
}
|
||||
|
||||
$(element).animate({ left: 0},interval);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#button-start').click(function() {
|
||||
$('#row-button-start').hide();
|
||||
requestVersions();
|
||||
});
|
||||
});
|
||||
|
||||
function requestVersions() {
|
||||
var data = {
|
||||
action: "getVersions"
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/upgrade.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#status').append('<p class="bg-warning">Upgrading from version ' + data.from + ' to ' + data.to + '</p>');
|
||||
requestUpdate();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
var data = {
|
||||
action: "requestUpgrade"
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/upgrade.php",
|
||||
JSON.stringify(data),
|
||||
function(data) {
|
||||
$('#status').append('<p class="bg-warning">Upgrade successfull!</p>');
|
||||
$('#row-button-home').show();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
140
js/users.js
140
js/users.js
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var sort = {
|
||||
field: "",
|
||||
order: 1
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
requestData();
|
||||
|
||||
$('#table-users>thead>tr>td span').click(function() {
|
||||
var field = $(this).siblings('strong').text().toLowerCase();
|
||||
if(sort.field == field) {
|
||||
if(sort.order == 1) sort.order = 0;
|
||||
else sort.field = "";
|
||||
} else {
|
||||
sort.field = field;
|
||||
sort.order = 1;
|
||||
}
|
||||
$('#table-users>thead>tr>td span').removeClass("glyphicon-sort-by-attributes glyphicon-sort-by-attributes-alt");
|
||||
|
||||
if(sort.field == field) {
|
||||
if(sort.order == 1) $(this).addClass("glyphicon-sort-by-attributes");
|
||||
else $(this).addClass("glyphicon-sort-by-attributes-alt");
|
||||
}
|
||||
requestData();
|
||||
});
|
||||
|
||||
$('#searchName').bind("paste keyup", function() {
|
||||
requestData();
|
||||
});
|
||||
|
||||
$('#searchType').change(function() {
|
||||
requestData();
|
||||
});
|
||||
|
||||
$('#searchType').select2({
|
||||
minimumResultsForSearch: Infinity
|
||||
});
|
||||
});
|
||||
|
||||
function requestData() {
|
||||
var restrictions = {
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
restrictions.sort = sort;
|
||||
|
||||
var searchName = $('#searchName').val();
|
||||
if(searchName.length > 0) {
|
||||
restrictions.name = searchName;
|
||||
}
|
||||
|
||||
var searchType = $('#searchType').val();
|
||||
if(searchType != "none") {
|
||||
restrictions.type = searchType;
|
||||
}
|
||||
|
||||
restrictions.action = "getUsers";
|
||||
|
||||
$.post(
|
||||
"api/users.php",
|
||||
JSON.stringify(restrictions),
|
||||
function(data) {
|
||||
recreateTable(data);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function recreateTable(data) {
|
||||
$('#table-users>tbody').empty();
|
||||
|
||||
$.each(data, function(index,item) {
|
||||
$('<tr></tr>').appendTo('#table-users>tbody')
|
||||
.append('<td>' + item.id + '</td>')
|
||||
.append('<td>' + item.name + '</td>')
|
||||
.append('<td>' + item.type + '</td>')
|
||||
.append('<td><span class="glyphicon glyphicon-trash cursor-pointer"></span></td>');
|
||||
|
||||
});
|
||||
|
||||
$('#table-users>tbody>tr>td:not(:last-child)').click(function() {
|
||||
var id = $(this).parent().children('td').first().text();
|
||||
location.assign('edit-user.php#' + id);
|
||||
});
|
||||
|
||||
$('#table-users>tbody>tr>td>span.glyphicon-trash').click(function() {
|
||||
$(this).parent().parent().unbind();
|
||||
deleteDomain.call(this);
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDomain() {
|
||||
var deleteId = $(this).parent().parent().children('td').eq(0).text();
|
||||
var deleteName = $(this).parent().parent().children('td').eq(1).text();
|
||||
var rowToRemove = $(this).parent().parent();
|
||||
|
||||
$('#userToDelete').text(deleteName);
|
||||
|
||||
$('#deleteConfirm #buttonDelete').click(function() {
|
||||
deleteUserWithId(deleteId, function() {
|
||||
$('#deleteConfirm').modal("hide");
|
||||
$(rowToRemove).remove();
|
||||
});
|
||||
});
|
||||
|
||||
$('#deleteConfirm').modal();
|
||||
}
|
||||
|
||||
function deleteUserWithId(id, callback) {
|
||||
var data = {
|
||||
action: "deleteUser",
|
||||
id: id,
|
||||
csrfToken: $('#csrfToken').text()
|
||||
};
|
||||
|
||||
$.post(
|
||||
"api/users.php",
|
||||
JSON.stringify(data),
|
||||
function() {
|
||||
callback();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
56
logout.php
56
logout.php
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
session_destroy();
|
||||
setcookie("authSecret", "", 1, "/", "", false, true);
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.min.css" rel="stylesheet">
|
||||
<link href="include/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="index.php">PDNS Manager</a>
|
||||
<ul class="nav navbar-nav">
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="row vspacer-60"></div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-6">
|
||||
<h4>You have been logged out successfully!</h4>
|
||||
<a class="btn btn-primary" href="index.php">Login again</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
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
|
|
@ -1,10 +0,0 @@
|
|||
auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs
|
||||
browser.reload.on.save=true
|
||||
include.path=${php.global.include.path}
|
||||
php.version=PHP_56
|
||||
project.license=apache20
|
||||
source.encoding=UTF-8
|
||||
src.dir=.
|
||||
tags.asp=false
|
||||
tags.short=false
|
||||
web.root=.
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.php.project</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/php-project/1">
|
||||
<name>pdnsmanager</name>
|
||||
</data>
|
||||
<libraries xmlns="http://www.netbeans.org/ns/cdnjs-libraries/1"/>
|
||||
</configuration>
|
||||
</project>
|
81
password.php
81
password.php
|
@ -1,81 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Password</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.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/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="include/select2/select2.min.js"></script>
|
||||
|
||||
<script src="js/password.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li><a href="users.php">Users</a></li>'; ?>
|
||||
<li class="active"><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2 id="heading">Change password</h2>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<div class="col-md-3">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="user-password" class="control-label">Password</label>
|
||||
<input type="password" class="form-control" id="user-password" placeholder="Password" autocomplete="off" tabindex="2">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="user-password2" class="control-label">Password repeated</label>
|
||||
<input type="password" class="form-control" id="user-password2" placeholder="Password repeated" autocomplete="off" tabindex="3">
|
||||
</div>
|
||||
<button id="saveChanges" class="btn btn-primary" tabindex="5">Change</button>
|
||||
</form>
|
||||
</div>
|
||||
</row>
|
||||
|
||||
</div>
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
83
upgrade.php
83
upgrade.php
|
@ -1,83 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'config/config-default.php';
|
||||
require_once 'lib/database.php';
|
||||
require_once 'lib/checkversion.php';
|
||||
|
||||
if(checkVersion($db)) {
|
||||
Header("Location: index.php");
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Upgrade</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.min.css" rel="stylesheet">
|
||||
<link href="include/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/upgrade.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="#">Upgrade</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<row>
|
||||
<h2>Upgrade PDNS Manager</h2>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
An upgrade for your PDNS Manager database is available and must be installed!
|
||||
</row>
|
||||
|
||||
<div class="row vspacer-20"></div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<row class="row" id="row-button-start">
|
||||
<button id="button-start" class="btn btn-primary">Start</button>
|
||||
</row>
|
||||
|
||||
<row class="row" id="status">
|
||||
|
||||
</row>
|
||||
|
||||
<row class="row defaulthidden" id="row-button-home">
|
||||
<a href="index.php" class="btn btn-primary">Login</a>
|
||||
</row>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
106
users.php
106
users.php
|
@ -1,106 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2016 Lukas Metzger <developer@lukas-metzger.com>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?php
|
||||
require_once 'lib/headers.php';
|
||||
require_once 'lib/session.php';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDNS Manager - Users</title>
|
||||
<meta charset="UTF-8">
|
||||
<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-theme.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/custom.css" rel="stylesheet">
|
||||
|
||||
<script src="include/jquery.js"></script>
|
||||
<script src="include/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="include/select2/select2.min.js"></script>
|
||||
|
||||
<script src="js/users.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
PDNS Manager
|
||||
</div>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="domains.php">Domains</a></li>
|
||||
<?php if($_SESSION['type'] == "admin") echo '<li class="active"><a href="users.php">Users</a></li>'; ?>
|
||||
<li><a href="password.php">Password</a></li>
|
||||
<li><a href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<table class="table table-hover" id="table-users">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="cell-vertical-middle"><strong>ID</strong> <span class="glyphicon glyphicon-sort cursor-pointer"></span></td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Name</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer cursor-pointer"></span>
|
||||
<input type="text" class="form-control no-shadow" id="searchName" placeholder="Search" autocomplete="off">
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td class="cell-vertical-middle">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<strong>Type</strong>
|
||||
<span class="glyphicon glyphicon-sort cursor-pointer cursor-pointer"></span>
|
||||
<select class="form-control no-shadow" id="searchType">
|
||||
<option value="none">No filter...</option>
|
||||
<option value="admin">Admin</option>
|
||||
<option value="user">User</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="cursor-pointer">
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<a class="btn btn-success" href="edit-user.php#new">Add</a>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="deleteConfirm" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
Are you sure you want to <strong class="text-danger">delete</strong> the user <strong><span id="userToDelete"></span></strong> including all associated data?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button id="buttonDelete" type="button" class="btn btn-danger">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo '<span class="hidden" id="csrfToken">' . $_SESSION['csrfToken'] . '</span>'; ?>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue