mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
Remove obsolete add.php script, use groups.php everywhere instead.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -106,9 +106,15 @@ function updateTopLists() {
|
|||||||
function add(domain, list) {
|
function add(domain, list) {
|
||||||
var token = $("#token").text();
|
var token = $("#token").text();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "scripts/pi-hole/php/add.php",
|
url: "scripts/pi-hole/php/groups.php",
|
||||||
method: "post",
|
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 () {
|
success: function () {
|
||||||
updateTopLists();
|
updateTopLists();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -92,16 +92,19 @@ function add(domain, list) {
|
|||||||
alSuccess.hide();
|
alSuccess.hide();
|
||||||
alFailure.hide();
|
alFailure.hide();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "scripts/pi-hole/php/add.php",
|
url: "scripts/pi-hole/php/groups.php",
|
||||||
method: "post",
|
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) {
|
success: function (response) {
|
||||||
if (
|
if (!response.success) {
|
||||||
response.indexOf("not a valid argument") !== -1 ||
|
|
||||||
response.indexOf("is not a valid domain") !== -1
|
|
||||||
) {
|
|
||||||
alFailure.show();
|
alFailure.show();
|
||||||
err.html(response);
|
err.html(response.message);
|
||||||
alFailure.delay(4000).fadeOut(2000, function () {
|
alFailure.delay(4000).fadeOut(2000, function () {
|
||||||
alFailure.hide();
|
alFailure.hide();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,19 +39,21 @@ function add(domain, list) {
|
|||||||
// add Domain to List after Modal has faded in
|
// add Domain to List after Modal has faded in
|
||||||
alertModal.one("shown.bs.modal", function () {
|
alertModal.one("shown.bs.modal", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "scripts/pi-hole/php/add.php",
|
url: "scripts/pi-hole/php/groups.php",
|
||||||
method: "post",
|
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) {
|
success: function (response) {
|
||||||
alProcessing.hide();
|
alProcessing.hide();
|
||||||
if (
|
if (!response.success) {
|
||||||
response.indexOf("not a valid argument") !== -1 ||
|
|
||||||
response.indexOf("is not a valid domain") !== -1 ||
|
|
||||||
response.indexOf("Wrong token") !== -1
|
|
||||||
) {
|
|
||||||
// Failure
|
// Failure
|
||||||
alNetworkErr.hide();
|
alNetworkErr.hide();
|
||||||
alCustomErr.html(response.replace("[✗]", ""));
|
alCustomErr.html(response.message);
|
||||||
alFailure.fadeIn(1000);
|
alFailure.fadeIn(1000);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
alertModal.modal("hide");
|
alertModal.modal("hide");
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Pi-hole: A black hole for Internet advertisements
|
|
||||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
||||||
* Network-wide ad blocking via your own hardware.
|
|
||||||
*
|
|
||||||
* This file is copyright under the latest version of the EUPL.
|
|
||||||
* Please see LICENSE file for your rights under this license. */
|
|
||||||
|
|
||||||
require_once('auth.php');
|
|
||||||
|
|
||||||
$list = $_POST['list'];
|
|
||||||
|
|
||||||
// Perform all of the authentication for list editing
|
|
||||||
// when NOT invoked and authenticated from API
|
|
||||||
if (empty($api)) {
|
|
||||||
list_verify($list);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split individual domains into array
|
|
||||||
$domains = preg_split('/\s+/', trim($_POST['domain']));
|
|
||||||
|
|
||||||
// Get comment if available
|
|
||||||
$comment = null;
|
|
||||||
if(isset($_POST['comment'])) {
|
|
||||||
$comment = trim($_POST['comment']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert domain name to IDNA ASCII form for international domains
|
|
||||||
// Do this only for exact domains, not for regex filters
|
|
||||||
// Only do it when the php-intl extension is available
|
|
||||||
if (extension_loaded("intl") && ($list === "white" || $list === "black")) {
|
|
||||||
foreach($domains as &$domain)
|
|
||||||
{
|
|
||||||
$domain = idn_to_ascii($domain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only check domains we add to the exact lists.
|
|
||||||
// Regex are validated by FTL during import
|
|
||||||
$check_lists = ["white","black","audit"];
|
|
||||||
if(in_array($list, $check_lists)) {
|
|
||||||
check_domain($domains);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once("func.php");
|
|
||||||
require_once("database.php");
|
|
||||||
$GRAVITYDB = getGravityDBFilename();
|
|
||||||
$db = SQLite3_connect($GRAVITYDB, SQLITE3_OPEN_READWRITE);
|
|
||||||
|
|
||||||
$reload = true;
|
|
||||||
switch($list) {
|
|
||||||
case "white":
|
|
||||||
$domains = array_map('strtolower', $domains);
|
|
||||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::whitelist);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "black":
|
|
||||||
$domains = array_map('strtolower', $domains);
|
|
||||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::blacklist);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "white_regex":
|
|
||||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::regex_whitelist);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "white_wild":
|
|
||||||
echo add_to_table($db, "domainlist", $domains, $comment, true, false, ListType::regex_whitelist);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "black_regex":
|
|
||||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::regex_blacklist);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "black_wild":
|
|
||||||
echo add_to_table($db, "domainlist", $domains, $comment, true, false, ListType::regex_blacklist);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "audit":
|
|
||||||
$reload = false;
|
|
||||||
echo add_to_table($db, "domain_audit", $domains);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
die("Invalid list!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reload lists in pihole-FTL after having added something
|
|
||||||
if ($reload) {
|
|
||||||
$output = pihole_execute("restartdns reload-lists");
|
|
||||||
echo implode("\n", $output);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
@@ -456,7 +456,13 @@ if ($_POST['action'] == 'get_groups') {
|
|||||||
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
|
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)) {
|
if (!$stmt->bindValue(':type', $type, SQLITE3_TEXT)) {
|
||||||
throw new Exception('While binding type: ' . $db->lastErrorMsg());
|
throw new Exception('While binding type: ' . $db->lastErrorMsg());
|
||||||
|
|||||||
Reference in New Issue
Block a user