diff --git a/db_queries.php b/db_queries.php index fdb2f055..c1d0b6c6 100644 --- a/db_queries.php +++ b/db_queries.php @@ -159,7 +159,7 @@ - + diff --git a/queries.php b/queries.php index cd5978bd..559e9cbf 100644 --- a/queries.php +++ b/queries.php @@ -150,7 +150,7 @@ if(strlen($showing) > 0) - + diff --git a/scripts/pi-hole/js/auditlog.js b/scripts/pi-hole/js/auditlog.js index d794fa1d..65b8eecc 100644 --- a/scripts/pi-hole/js/auditlog.js +++ b/scripts/pi-hole/js/auditlog.js @@ -99,7 +99,7 @@ function add(domain, list) { domain: domain, list: list, token: token, - action: "add_domain", + action: list === "audit" ? "add_audit" : "add_domain", comment: "Added from Audit Log" }, success: function () { diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js index d2af6535..7707dee3 100644 --- a/scripts/pi-hole/js/db_queries.js +++ b/scripts/pi-hole/js/db_queries.js @@ -373,7 +373,7 @@ $(function () { }, { width: "10%" }, { width: "40%" }, - { width: "20%" }, + { width: "20%", type: "ip-address" }, { width: "10%" }, { width: "5%" } ], diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 7f587f2e..5c056fbc 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -287,6 +287,7 @@ function updateQueriesOverTime() { }); } +var querytypeids = []; function updateQueryTypesPie() { $.getJSON("api.php?getQueryTypes", function (data) { if ("FTLnotrunning" in data) { @@ -305,12 +306,16 @@ function updateQueryTypesPie() { iter = data; } + querytypeids = []; Object.keys(iter).forEach(function (key) { if (iter[key] > 0) { v.push(iter[key]); - c.push(THEME_COLORS[i++ % THEME_COLORS.length]); + c.push(THEME_COLORS[i % THEME_COLORS.length]); k.push(key); + querytypeids.push(i + 1); } + + i++; }); // Build a single dataset with the data to be pushed @@ -342,7 +347,7 @@ function updateQueryTypesPie() { ci.update(); } else if (e.which === 1) { // which == 1 is left mouse button - window.open("queries.php?querytype=" + ($(this).index() + 1), "_self"); + window.open("queries.php?querytype=" + querytypeids[$(this).index()], "_self"); } }); }).done(function () { diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index d7008d93..0055ea5a 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -363,7 +363,7 @@ $(function () { }, { width: "4%" }, { width: "36%", render: $.fn.dataTable.render.text() }, - { width: "8%", render: $.fn.dataTable.render.text() }, + { width: "8%", type: "ip-address", render: $.fn.dataTable.render.text() }, { width: "14%", orderData: 4 }, { width: "8%", orderData: 6 }, { width: "10%", orderData: 4 } diff --git a/scripts/pi-hole/js/utils.js b/scripts/pi-hole/js/utils.js index 0364ffe0..27b0f6c2 100644 --- a/scripts/pi-hole/js/utils.js +++ b/scripts/pi-hole/js/utils.js @@ -150,7 +150,7 @@ function validateIPv6CIDR(ip) { var ipv6validator = new RegExp( "^(((?:" + ipv6elem + - "))((?::" + + "))*((?::" + ipv6elem + "))*::((?:" + ipv6elem + diff --git a/scripts/pi-hole/php/groups.php b/scripts/pi-hole/php/groups.php index 04a9030c..04871d17 100644 --- a/scripts/pi-hole/php/groups.php +++ b/scripts/pi-hole/php/groups.php @@ -893,6 +893,53 @@ if ($_POST['action'] == 'get_groups') { } catch (\Exception $ex) { JSON_error($ex->getMessage()); } +} elseif ($_POST['action'] == 'add_audit') { + // Add new domain + try { + $domains = explode(' ', html_entity_decode(trim($_POST['domain']))); + $before = intval($db->querySingle("SELECT COUNT(*) FROM domain_audit;")); + $total = count($domains); + $added = 0; + $stmt = $db->prepare('REPLACE INTO domain_audit (domain) VALUES (:domain)'); + if (!$stmt) { + throw new Exception('While preparing statement: ' . $db->lastErrorMsg()); + } + + foreach ($domains as $domain) { + $input = $domain; + + if (!$stmt->bindValue(':domain', $domain, SQLITE3_TEXT)) { + throw new Exception('While binding domain: ' . $db->lastErrorMsg() . '
'. + 'Added ' . $added . " out of ". $total . " domains"); + } + + if (!$stmt->execute()) { + throw new Exception('While executing: ' . $db->lastErrorMsg() . '
'. + 'Added ' . $added . " out of ". $total . " domains"); + } + $added++; + } + + $after = intval($db->querySingle("SELECT COUNT(*) FROM domain_audit;")); + $difference = $after - $before; + if($total === 1) { + if($difference !== 1) { + $msg = "Not adding ". htmlentities(utf8_encode($domain)) . " as it is already on the list"; + } else { + $msg = "Added " . htmlentities(utf8_encode($domain)); + } + } else { + if($difference !== $total) { + $msg = "Added " . ($after-$before) . " out of ". $total . " domains (skipped duplicates)"; + } else { + $msg = "Added " . $total . " domains"; + } + } + $reload = true; + JSON_success($msg); + } catch (\Exception $ex) { + JSON_error($ex->getMessage()); + } } else { log_and_die('Requested action not supported!'); } diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 23e0efdc..af95c901 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -737,7 +737,7 @@ function addStaticDHCPLease($mac, $ip, $hostname) { break; // Flush network table case "flusharp": - pihole_execute("arpflush quiet", $output); + $output = pihole_execute("arpflush quiet"); $error = implode("
", $output); if(strlen($error) == 0) { diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index cfd4bc47..8948c19f 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -540,7 +540,7 @@ if(isset($_POST["action"])) } else { - $hostname = gethostname() ? gethostname()."-" : ""; + $hostname = gethostname() ? str_replace(".", "_", gethostname())."-" : ""; $tarname = "pi-hole-".$hostname."teleporter_".date("Y-m-d_H-i-s").".tar"; $filename = $tarname.".gz"; $archive_file_name = sys_get_temp_dir() ."/". $tarname;