Add possibility to blacklist/whitelist entries on the Queries page.

This commit is contained in:
DL6ER
2016-11-13 18:57:25 +01:00
parent 383ea1f365
commit 025c22c287
3 changed files with 44 additions and 5 deletions
+1
View File
@@ -150,6 +150,7 @@
$domain,
hasHostName($client),
$status,
""
));
}
+32 -5
View File
@@ -16,12 +16,39 @@ $(document).ready(function() {
{ "width" : "20%", "type": "date" },
{ "width" : "10%" },
{ "width" : "40%" },
{ "width" : "15%" },
{ "width" : "15%" }
]
})
{ "width" : "12.5%" },
{ "width" : "12.5%" },
{ "width" : "5%" },
],
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button>Do it!</button>"
} ]
});
$('#all-queries tbody').on( 'click', 'button', function () {
var data = tableApi.row( $(this).parents('tr') ).data();
if (data[4] == "Pi-holed")
{
add(data[2],"white");
}
else
{
add(data[2],"black");
}
} );
} );
function refreshData() {
tableApi.ajax.url("api.php?getAllQueries").load();
}
}
function add(domain,list) {
var token = $("#token").html();
$.ajax({
url: "php/add.php",
method: "post",
data: {"domain":domain, "list":list, "token":token}
// success: function(response) { alert(response); }
});
}
+11
View File
@@ -1,6 +1,15 @@
<?php
require "header.php";
session_start();
// Generate CSRF token
if(empty($_SESSION['token'])) {
$_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
}
$token = $_SESSION['token'];
?>
<!-- Send PHP info to JS -->
<div id="token" hidden><?php echo $token ?></div>
<!--
<div class="row">
@@ -26,6 +35,7 @@
<th>Domain</th>
<th>Client</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
@@ -35,6 +45,7 @@
<th>Domain</th>
<th>Client</th>
<th>Status</th>
<th>Action</th>
</tr>
</tfoot>
</table>