Skip to content

Commit

Permalink
Merge pull request #1498 from pi-hole/release/v5.1.1
Browse files Browse the repository at this point in the history
AdminLTE v5.1.1
  • Loading branch information
PromoFaux authored Aug 9, 2020
2 parents d8d3f31 + 0475225 commit a03d1bd
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 10 deletions.
2 changes: 1 addition & 1 deletion db_queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
</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>

Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/auditlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/db_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ $(function () {
},
{ width: "10%" },
{ width: "40%" },
{ width: "20%" },
{ width: "20%", type: "ip-address" },
{ width: "10%" },
{ width: "5%" }
],
Expand Down
9 changes: 7 additions & 2 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ function updateQueriesOverTime() {
});
}

var querytypeids = [];
function updateQueryTypesPie() {
$.getJSON("api.php?getQueryTypes", function (data) {
if ("FTLnotrunning" in data) {
Expand All @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function validateIPv6CIDR(ip) {
var ipv6validator = new RegExp(
"^(((?:" +
ipv6elem +
"))((?::" +
"))*((?::" +
ipv6elem +
"))*::((?:" +
ipv6elem +
Expand Down
47 changes: 47 additions & 0 deletions scripts/pi-hole/php/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,53 @@ function JSON_error($message = null)
} 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!');
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/php/savesettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/php/teleporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function process_file($contents)
}
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;
Expand Down

0 comments on commit a03d1bd

Please sign in to comment.