mirror of
https://github.com/pi-hole/web.git
synced 2026-02-27 13:14:20 +00:00
Disable Whitelist/Blacklist feature for release
See #39 for why this is needed
This commit is contained in:
115
list.php
115
list.php
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
require "header.html";
|
||||
|
||||
$list = $_GET['l'];
|
||||
|
||||
function getFullName() {
|
||||
global $list;
|
||||
if($list == "white")
|
||||
echo "Whitelist";
|
||||
else
|
||||
echo "Blacklist";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
<h1><?php getFullName(); ?></h1>
|
||||
</div>
|
||||
|
||||
<!-- Domain Input -->
|
||||
<div class="form-group input-group">
|
||||
<input id="domain" type="text" class="form-control" placeholder="Add a domain (example.com or sub.example.com)">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button" onclick="add()">Add</button>
|
||||
<button class="btn btn-default" type="button" onclick="refresh()">Refresh</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Alerts -->
|
||||
<div id="alInfo" class="alert alert-info" role="alert" hidden="true">
|
||||
Adding to the <?php getFullName(); ?>...
|
||||
</div>
|
||||
<div id="alSuccess" class="alert alert-success" role="alert" hidden="true">
|
||||
Success! The list will refresh.
|
||||
</div>
|
||||
<div id="alFailure" class="alert alert-danger" role="alert" hidden="true">
|
||||
Failure! Something went wrong.
|
||||
</div>
|
||||
|
||||
<!-- Domain List -->
|
||||
<ul class="list-group" id="list"></ul>
|
||||
|
||||
<?php
|
||||
require "footer.php";
|
||||
?>
|
||||
|
||||
<script>
|
||||
window.onload = refresh;
|
||||
|
||||
function refresh() {
|
||||
$.ajax({
|
||||
url: "php/get.php",
|
||||
method: "get",
|
||||
data: {"list":"<?php echo $list ?>"},
|
||||
success: function(response) {
|
||||
var list = document.getElementById("list");
|
||||
list.innerHTML = "";
|
||||
var data = JSON.parse(response);
|
||||
|
||||
if(data.length == 0) {
|
||||
list.innerHTML =
|
||||
'<div class="alert alert-info" role="alert">Your <?php getFullName(); ?> is empty!</div>';
|
||||
}
|
||||
else {
|
||||
data.forEach(function (entry, index) {
|
||||
list.innerHTML +=
|
||||
'<li id="' + index + '" class="list-group-item clearfix">' + entry +
|
||||
'<button class="btn btn-danger btn-xs pull-right" type="button" onclick="sub(\'' + index + '\', \'' + entry + '\')">' +
|
||||
'<span class="glyphicon glyphicon-trash"></span></button></li>';
|
||||
})
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
document.getElementById("alFailure").hidden = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add() {
|
||||
var domain = document.getElementById("domain").value;
|
||||
if(domain == "")
|
||||
return;
|
||||
|
||||
document.getElementById("alInfo").hidden = false;
|
||||
document.getElementById("alSuccess").hidden = true;
|
||||
document.getElementById("alFailure").hidden = true;
|
||||
$.ajax({
|
||||
url: "php/add.php",
|
||||
method: "get",
|
||||
data: {"domain":domain, "list":"<?php echo $list ?>"},
|
||||
success: function(response) {
|
||||
document.getElementById("alSuccess").hidden = false;
|
||||
refresh();
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
document.getElementById("alFailure").hidden = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sub(index, entry) {
|
||||
$("#"+index).hide("highlight");
|
||||
$.ajax({
|
||||
url: "php/sub.php",
|
||||
method: "get",
|
||||
data: {"domain":entry, "list":"<?php echo $list ?>"},
|
||||
success: function(response) {
|
||||
document.getElementById("list").removeChild(document.getElementById(index));
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
alert("Failed to remove the domain!");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
12
php/add.php
12
php/add.php
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
if(!isset($_GET['domain'], $_GET['list']))
|
||||
die();
|
||||
|
||||
switch($_GET['list']) {
|
||||
case "white":
|
||||
exec("/usr/local/bin/whitelist.sh -q ${_GET['domain']}");
|
||||
break;
|
||||
case "black":
|
||||
exec("/usr/local/bin/blacklist.sh -q ${_GET['domain']}");
|
||||
break;
|
||||
}
|
||||
15
php/get.php
15
php/get.php
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
if(!isset($_GET['list']))
|
||||
die();
|
||||
|
||||
$type = $_GET['list'];
|
||||
$rawList = file_get_contents("/etc/pihole/${type}list.txt");
|
||||
$list = explode("\n", $rawList);
|
||||
|
||||
// Get rid of empty lines
|
||||
for($i = sizeof($list)-1; $i >= 0; $i--) {
|
||||
if($list[$i] == "")
|
||||
unset($list[$i]);
|
||||
}
|
||||
|
||||
echo json_encode(array_values($list));
|
||||
12
php/sub.php
12
php/sub.php
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
if(!isset($_GET['domain'], $_GET['list']))
|
||||
die();
|
||||
|
||||
switch($_GET['list']) {
|
||||
case "white":
|
||||
exec("/usr/local/bin/whitelist.sh -q -d ${_GET['domain']}");
|
||||
break;
|
||||
case "black":
|
||||
exec("/usr/local/bin/blacklist.sh -q -d ${_GET['domain']}");
|
||||
break;
|
||||
}
|
||||
Reference in New Issue
Block a user