Skip to content

Commit

Permalink
Remove obsolete add.php script, use groups.php everywhere instead.
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed May 26, 2020
1 parent 5ff1508 commit 6098191
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 111 deletions.
4 changes: 2 additions & 2 deletions scripts/pi-hole/js/auditlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ function updateTopLists() {
function add(domain, list) {
var token = $("#token").text();
$.ajax({
url: "scripts/pi-hole/php/add.php",
url: "scripts/pi-hole/php/groups.php",
method: "post",
data: { domain: domain, list: list, token: token },
data: { domain: domain, list: list, token: token, action: "add_domain", comment: "Added from Audit Log" },
success: function () {
updateTopLists();
},
Expand Down
11 changes: 4 additions & 7 deletions scripts/pi-hole/js/db_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,13 @@ function add(domain, list) {
alSuccess.hide();
alFailure.hide();
$.ajax({
url: "scripts/pi-hole/php/add.php",
url: "scripts/pi-hole/php/groups.php",
method: "post",
data: { domain: domain, list: list, token: token },
data: { domain: domain, list: list, token: token, action: "add_domain", comment: "Added from Long-Term-Data Query Log" },
success: function (response) {
if (
response.indexOf("not a valid argument") !== -1 ||
response.indexOf("is not a valid domain") !== -1
) {
if (!response.success) {
alFailure.show();
err.html(response);
err.html(response.message);
alFailure.delay(4000).fadeOut(2000, function () {
alFailure.hide();
});
Expand Down
13 changes: 5 additions & 8 deletions scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ function add(domain, list) {
// add Domain to List after Modal has faded in
alertModal.one("shown.bs.modal", function () {
$.ajax({
url: "scripts/pi-hole/php/add.php",
url: "scripts/pi-hole/php/groups.php",
method: "post",
data: { domain: domain, list: list, token: token },
data: { domain: domain, list: list, token: token, action: "add_domain", comment: "Added from Query Log" },
success: function (response) {
alProcessing.hide();
if (
response.indexOf("not a valid argument") !== -1 ||
response.indexOf("is not a valid domain") !== -1 ||
response.indexOf("Wrong token") !== -1
) {
console.log(response);
if (!response.success) {
// Failure
alNetworkErr.hide();
alCustomErr.html(response.replace("[✗]", ""));
alCustomErr.html(response.message);
alFailure.fadeIn(1000);
setTimeout(function () {
alertModal.modal("hide");
Expand Down
93 changes: 0 additions & 93 deletions scripts/pi-hole/php/add.php

This file was deleted.

8 changes: 7 additions & 1 deletion scripts/pi-hole/php/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,13 @@ function JSON_error($message = null)
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
}

$type = intval($_POST['type']);
if (isset($_POST['type'])) {
$type = intval($_POST['type']);
} else if (isset($_POST['list']) && $_POST['list'] === "white") {
$type = ListType::whitelist;
} else if (isset($_POST['list']) && $_POST['list'] === "black") {
$type = ListType::blacklist;
}

if (!$stmt->bindValue(':type', $type, SQLITE3_TEXT)) {
throw new Exception('While binding type: ' . $db->lastErrorMsg());
Expand Down

0 comments on commit 6098191

Please sign in to comment.