mirror of
https://github.com/pi-hole/web.git
synced 2026-06-08 16:56:15 +01:00
Merge branch 'devel' into listallqueries
Conflicts: js/pihole/queries.js
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
$log = array();
|
||||
$ipv6 = parse_ini_file("/etc/pihole/setupVars.conf")['IPv6_address'] != "";
|
||||
$divide = parse_ini_file("/etc/pihole/setupVars.conf")['IPv6_address'] != "" && parse_ini_file("/etc/pihole/setupVars.conf")['IPv4_address'] != "";
|
||||
$hosts = file_exists("/etc/hosts") ? file("/etc/hosts") : array();
|
||||
$log = new \SplFileObject('/var/log/pihole.log');
|
||||
|
||||
/******* Public Members ********/
|
||||
function getSummaryData() {
|
||||
global $log, $ipv6;
|
||||
$domains_being_blocked = gravityCount() / ($ipv6 ? 2 : 1);
|
||||
global $log, $divide;
|
||||
$domains_being_blocked = gravityCount() / ($divide ? 2 : 1);
|
||||
|
||||
$dns_queries_today = count(getDnsQueries($log));
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
$domain,
|
||||
hasHostName($client),
|
||||
$status,
|
||||
""
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
+80
-5
@@ -2,10 +2,12 @@ $(document).ready(function() {
|
||||
tableApi = $('#all-queries').DataTable( {
|
||||
"rowCallback": function( row, data, index ){
|
||||
if (data[4] == "Pi-holed") {
|
||||
$(row).css('color','red')
|
||||
$(row).css('color','red');
|
||||
$('td:eq(5)', row).html( '<button style="color:green;"><i class="fa fa-pencil-square-o"></i> Whitelist</button>' );
|
||||
}
|
||||
else{
|
||||
$(row).css('color','green')
|
||||
$(row).css('color','green');
|
||||
$('td:eq(5)', row).html( '<button style="color:red;"><i class="fa fa-ban"></i> Blacklist</button>' );
|
||||
}
|
||||
|
||||
},
|
||||
@@ -16,13 +18,86 @@ $(document).ready(function() {
|
||||
{ "width" : "20%", "type": "date" },
|
||||
{ "width" : "10%" },
|
||||
{ "width" : "40%" },
|
||||
{ "width" : "15%" },
|
||||
{ "width" : "15%" }
|
||||
{ "width" : "10%" },
|
||||
{ "width" : "10%" },
|
||||
{ "width" : "10%" },
|
||||
],
|
||||
"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
|
||||
})
|
||||
"columnDefs": [ {
|
||||
"targets": -1,
|
||||
"data": null,
|
||||
"defaultContent": ''
|
||||
} ]
|
||||
});
|
||||
$('#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();
|
||||
var alInfo = $("#alInfo");
|
||||
var alList = $("#alList");
|
||||
var alDomain = $("#alDomain");
|
||||
alDomain.html(domain);
|
||||
var alSuccess = $("#alSuccess");
|
||||
var alFailure = $("#alFailure");
|
||||
|
||||
if(list == "white")
|
||||
{
|
||||
alList.html("Whitelist");
|
||||
}
|
||||
else
|
||||
{
|
||||
alList.html("Blacklist");
|
||||
}
|
||||
|
||||
alInfo.show();
|
||||
alSuccess.hide();
|
||||
alFailure.hide();
|
||||
$.ajax({
|
||||
url: "php/add.php",
|
||||
method: "post",
|
||||
data: {"domain":domain, "list":list, "token":token},
|
||||
success: function(response) {
|
||||
if (response.indexOf("not a valid argument") >= 0 || response.indexOf("is not a valid domain") >= 0)
|
||||
{
|
||||
alFailure.show();
|
||||
alFailure.delay(1000).fadeOut(2000, function() { alFailure.hide(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
alSuccess.show();
|
||||
alSuccess.delay(1000).fadeOut(2000, function() { alSuccess.hide(); });
|
||||
}
|
||||
alInfo.delay(1000).fadeOut(2000, function() {
|
||||
alInfo.hide();
|
||||
alList.html("");
|
||||
alDomain.html("");
|
||||
});
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
alFailure.show();
|
||||
alFailure.delay(1000).fadeOut(2000, function() {
|
||||
alFailure.hide();
|
||||
});
|
||||
alInfo.delay(1000).fadeOut(2000, function() {
|
||||
alInfo.hide();
|
||||
alList.html("");
|
||||
alDomain.html("");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+26
@@ -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">
|
||||
@@ -9,6 +18,21 @@
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!-- Alerts -->
|
||||
<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
|
||||
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
Adding <span id="alDomain"></span> to the <span id="alList"></span>...
|
||||
</div>
|
||||
<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden="true">
|
||||
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
Success!
|
||||
</div>
|
||||
<div id="alFailure" class="alert alert-danger alert-dismissible fade in" role="alert" hidden="true">
|
||||
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
Failure! Something went wrong.
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box" id="recent-queries">
|
||||
@@ -26,6 +50,7 @@
|
||||
<th>Domain</th>
|
||||
<th>Client</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
@@ -35,6 +60,7 @@
|
||||
<th>Domain</th>
|
||||
<th>Client</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user