mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
+1
-1
@@ -159,7 +159,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<script src="scripts/pi-hole/js/ip-address-sorting.js"></script>
|
||||
<script src="scripts/vendor/daterangepicker.min.js"></script>
|
||||
<script src="scripts/pi-hole/js/db_queries.js"></script>
|
||||
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ if(strlen($showing) > 0)
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<script src="scripts/pi-hole/js/ip-address-sorting.js"></script>
|
||||
<script src="scripts/pi-hole/js/utils.js"></script>
|
||||
<script src="scripts/pi-hole/js/queries.js"></script>
|
||||
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -373,7 +373,7 @@ $(function () {
|
||||
},
|
||||
{ width: "10%" },
|
||||
{ width: "40%" },
|
||||
{ width: "20%" },
|
||||
{ width: "20%", type: "ip-address" },
|
||||
{ width: "10%" },
|
||||
{ width: "5%" }
|
||||
],
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -150,7 +150,7 @@ function validateIPv6CIDR(ip) {
|
||||
var ipv6validator = new RegExp(
|
||||
"^(((?:" +
|
||||
ipv6elem +
|
||||
"))((?::" +
|
||||
"))*((?::" +
|
||||
ipv6elem +
|
||||
"))*::((?:" +
|
||||
ipv6elem +
|
||||
|
||||
@@ -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: <strong>' . $db->lastErrorMsg() . '</strong><br>'.
|
||||
'Added ' . $added . " out of ". $total . " domains");
|
||||
}
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
throw new Exception('While executing: <strong>' . $db->lastErrorMsg() . '</strong><br>'.
|
||||
'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!');
|
||||
}
|
||||
|
||||
@@ -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("<br>", $output);
|
||||
if(strlen($error) == 0)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user