Incorporate upstream changes

Signed-off-by: Matthias Rank <development@m-rank.de>
This commit is contained in:
Matthias rank
2020-06-21 13:46:00 +02:00
parent b597a0fcbb
commit 773fed0f21
4 changed files with 23 additions and 19 deletions

View File

@@ -30,35 +30,35 @@
<div class="row">
<div class="form-group col-md-6">
<label for="domain">Domain:</label>
<input id="domain" type="text" class="form-control" placeholder="Add a domain (example.com or sub.example.com)">
<input id="domain" type="url" class="form-control" placeholder="Add a domain (example.com or sub.example.com)" autocomplete="off" spellcheck="false" autocapitalize="none" autocorrect="off">
</div>
<div class="form-group col-md-6">
<label for="target">Target Domain:</label>
<input id="target" type="url" class="form-control" placeholder="Associated Target Domain Record">
<input id="target" type="url" class="form-control" placeholder="Associated Target Domain" autocomplete="off" spellcheck="false" autocapitalize="none" autocorrect="off">
</div>
</div>
</div>
<div class="box-footer clearfix">
<button id="btnAdd" class="btn btn-primary pull-right">Add</button>
<button type="button" id="btnAdd" class="btn btn-primary pull-right">Add</button>
</div>
</div>
</div>
</div>
<!-- Alerts -->
<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden>
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Updating CNAME records...
</div>
<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden="true">
<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden>
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Success! The list will refresh.
</div>
<div id="alFailure" class="alert alert-danger alert-dismissible fade in" role="alert" hidden="true">
<div id="alFailure" class="alert alert-danger alert-dismissible fade in" role="alert" hidden>
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Failure! Something went wrong, see output below:<br/><br/><pre><span id="err"></span></pre>
</div>
<div id="alWarning" class="alert alert-warning alert-dismissible fade in" role="alert" hidden="true">
<div id="alWarning" class="alert alert-warning alert-dismissible fade in" role="alert" hidden>
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
At least one domain was already present, see output below:<br/><br/><pre><span id="warn"></span></pre>
</div>
@@ -72,7 +72,7 @@
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="customCNAMETable" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<table id="customCNAMETable" class="table table-striped table-bordered" width="100%">
<thead>
<tr>
<th>Domain</th>
@@ -81,7 +81,7 @@
</tr>
</thead>
</table>
<button type="button" id="resetButton" hidden="true" class="btn btn-default btn-sm text-red">Clear Filters</button>
<button type="button" id="resetButton" class="btn btn-default btn-sm text-red hidden">Clear Filters</button>
</div>
<!-- /.box-body -->
</div>
@@ -89,6 +89,7 @@
</div>
</div>
<script src="scripts/pi-hole/js/utils.js"></script>
<script src="scripts/pi-hole/js/customcname.js"></script>
<?php

View File

@@ -5,6 +5,8 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global utils:false */
var table;
var token = $("#token").text();
@@ -37,7 +39,7 @@ function showAlert(type, message) {
alertElement.delay(8000).fadeOut(2000);
}
$(document).ready(function () {
$(function () {
$("#btnAdd").on("click", addCustomCNAME);
table = $("#customCNAMETable").DataTable({
@@ -52,7 +54,7 @@ $(document).ready(function () {
targets: 2,
render: function (data, type, row) {
return (
'<button class="btn btn-danger btn-xs deleteCustomCNAME" type="button" data-domain=\'' +
'<button type="button" class="btn btn-danger btn-xs deleteCustomCNAME" data-domain=\'' +
row[0] +
"' data-target='" +
row[1] +
@@ -76,15 +78,15 @@ $(document).ready(function () {
});
function addCustomCNAME() {
var target = $("#target").val();
var domain = $("#domain").val();
var domain = utils.escapeHtml($("#domain").val());
var target = utils.escapeHtml($("#target").val());
showAlert("info");
$.ajax({
url: "scripts/pi-hole/php/customcname.php",
method: "post",
dataType: "json",
data: { action: "add", target: target, domain: domain, token: token },
data: { action: "add", domain: domain, target: target, token: token },
success: function (response) {
if (response.success) {
showAlert("success");
@@ -98,8 +100,8 @@ function addCustomCNAME() {
}
function deleteCustomCNAME() {
var target = $(this).attr("data-target");
var domain = $(this).attr("data-domain");
var target = $(this).attr("data-target");
showAlert("info");
$.ajax({
@@ -115,7 +117,7 @@ function deleteCustomCNAME() {
},
error: function (jqXHR, exception) {
showAlert("error", "Error while deleting this custom CNAME record");
console.log(exception);
console.log(exception); // eslint-disable-line no-console
}
});
}

View File

@@ -12,7 +12,8 @@
log_and_die('Not allowed (login session invalid or expired, please relogin on the Pi-hole dashboard)!');
}
switch ($_REQUEST['action'])
switch ($_POST['action'])
{
case 'get': echo json_encode(echoCustomCNAMEEntries()); break;
case 'add': echo json_encode(addCustomCNAMEEntry()); break;
@@ -20,4 +21,6 @@
default:
die("Wrong action");
}
?>

View File

@@ -2,8 +2,6 @@
require_once "func.php";
$customDNSFile = "/etc/pihole/custom.list";
require_once('auth.php');
// Authentication checks