mirror of
https://github.com/pi-hole/web.git
synced 2026-05-08 09:39:05 +01:00
Merge branch 'devel' into tweak/exact_searching
This commit is contained in:
@@ -131,18 +131,20 @@ $(function () {
|
||||
// Pull in data via AJAX
|
||||
updateTopLists();
|
||||
|
||||
$("#domain-frequency tbody").on("click", "button", function () {
|
||||
$("#domain-frequency tbody").on("click", "button", function (event) {
|
||||
var url = $(this).parents("tr")[0].textContent.split(" ")[0];
|
||||
if ($(this).context.textContent === " Blacklist") {
|
||||
|
||||
if (event.target.textContent.trim() === "Blacklist") {
|
||||
blacklistUrl(url);
|
||||
} else {
|
||||
auditUrl(url);
|
||||
}
|
||||
});
|
||||
|
||||
$("#ad-frequency tbody").on("click", "button", function () {
|
||||
$("#ad-frequency tbody").on("click", "button", function (event) {
|
||||
var url = $(this).parents("tr")[0].textContent.split(" ")[0];
|
||||
if ($(this).context.textContent === " Whitelist") {
|
||||
|
||||
if (event.target.textContent.trim() === "Whitelist") {
|
||||
whitelistUrl(url);
|
||||
} else {
|
||||
auditUrl(url);
|
||||
|
||||
@@ -100,14 +100,14 @@ function updateQueriesOverTime() {
|
||||
|
||||
for (hour in data.domains_over_time[0]) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.domains_over_time[0], hour)) {
|
||||
dates.push(parseInt(data.domains_over_time[0][hour]));
|
||||
dates.push(parseInt(data.domains_over_time[0][hour], 10));
|
||||
}
|
||||
}
|
||||
|
||||
for (hour in data.ads_over_time[0]) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.ads_over_time[0], hour)) {
|
||||
if (dates.indexOf(parseInt(data.ads_over_time[0][hour])) === -1) {
|
||||
dates.push(parseInt(data.ads_over_time[0][hour]));
|
||||
if (dates.indexOf(parseInt(data.ads_over_time[0][hour], 10)) === -1) {
|
||||
dates.push(parseInt(data.ads_over_time[0][hour], 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,8 +248,8 @@ $(function () {
|
||||
label: function (tooltipItems, data) {
|
||||
if (tooltipItems.datasetIndex === 0) {
|
||||
var percentage = 0;
|
||||
var permitted = parseInt(data.datasets[1].data[tooltipItems.index]);
|
||||
var blocked = parseInt(data.datasets[0].data[tooltipItems.index]);
|
||||
var permitted = parseInt(data.datasets[1].data[tooltipItems.index], 10);
|
||||
var blocked = parseInt(data.datasets[0].data[tooltipItems.index], 10);
|
||||
if (permitted + blocked > 0) {
|
||||
percentage = (100 * blocked) / (permitted + blocked);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ window.location.search
|
||||
});
|
||||
|
||||
if ("from" in GETDict && "until" in GETDict) {
|
||||
from = parseInt(GETDict.from);
|
||||
until = parseInt(GETDict.until);
|
||||
from = parseInt(GETDict.from, 10);
|
||||
until = parseInt(GETDict.until, 10);
|
||||
start__ = moment(1000 * from);
|
||||
end__ = moment(1000 * until);
|
||||
instantquery = true;
|
||||
@@ -142,7 +142,11 @@ function handleAjaxError(xhr, textStatus) {
|
||||
} else if (xhr.responseText.indexOf("Connection refused") !== -1) {
|
||||
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
|
||||
} else {
|
||||
alert("An unknown error occurred while loading the data.\n" + xhr.responseText);
|
||||
alert(
|
||||
"An unknown error occurred while loading the data.\n" +
|
||||
xhr.responseText +
|
||||
"\nCheck the server's log files (/var/log/lighttpd/error.log when you're using the default Pi-hole web server) for details. You may need to increase the memory available for Pi-hole in case you requested a lot of data."
|
||||
);
|
||||
}
|
||||
|
||||
$("#all-queries_processing").hide();
|
||||
|
||||
@@ -44,7 +44,7 @@ function piholeChanged(action) {
|
||||
function countDown() {
|
||||
var ena = $("#enableLabel");
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html()));
|
||||
var target = new Date(parseInt(enaT.html(), 10));
|
||||
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
|
||||
|
||||
if (seconds > 0) {
|
||||
@@ -207,7 +207,7 @@ function initCPUtemp() {
|
||||
|
||||
$(function () {
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html()));
|
||||
var target = new Date(parseInt(enaT.html(), 10));
|
||||
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
|
||||
if (seconds > 0) {
|
||||
setTimeout(countDown, 100);
|
||||
@@ -262,7 +262,7 @@ $("#pihole-disable-custom").on("click", function (e) {
|
||||
|
||||
// Session timer
|
||||
var sessionTimerCounter = document.getElementById("sessiontimercounter");
|
||||
var sessionvalidity = parseInt(sessionTimerCounter.textContent);
|
||||
var sessionvalidity = parseInt(sessionTimerCounter.textContent, 10);
|
||||
var start = new Date();
|
||||
|
||||
function updateSessionTimer() {
|
||||
|
||||
@@ -221,7 +221,7 @@ function initTable() {
|
||||
var applyBtn = "#btn_apply_" + data.id;
|
||||
|
||||
// Highlight row (if url parameter "domainid=" is used)
|
||||
if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid)) {
|
||||
if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid, 10)) {
|
||||
$(row).find("td").addClass("highlight");
|
||||
}
|
||||
|
||||
@@ -265,7 +265,10 @@ function initTable() {
|
||||
},
|
||||
initComplete: function () {
|
||||
if ("domainid" in GETDict) {
|
||||
var pos = table.column(0, { order: "current" }).data().indexOf(parseInt(GETDict.domainid));
|
||||
var pos = table
|
||||
.column(0, { order: "current" })
|
||||
.data()
|
||||
.indexOf(parseInt(GETDict.domainid, 10));
|
||||
if (pos >= 0) {
|
||||
var page = Math.floor(pos / table.page.info().length);
|
||||
table.page(page).draw(false);
|
||||
@@ -361,7 +364,7 @@ function addDomain() {
|
||||
success: function (response) {
|
||||
utils.enableAll();
|
||||
if (response.success) {
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added " + domainRegex, domain);
|
||||
utils.showAlert("success", "fas fa-plus", "Success!", response.message);
|
||||
domainEl.val("");
|
||||
commentEl.val("");
|
||||
wildcardEl.prop("checked", false);
|
||||
|
||||
+34
-47
@@ -227,15 +227,33 @@ function updateQueriesOverTime() {
|
||||
data.ads_over_time[0].splice(-1, 1);
|
||||
// Remove possibly already existing data
|
||||
timeLineChart.data.labels = [];
|
||||
timeLineChart.data.datasets[0].data = [];
|
||||
timeLineChart.data.datasets[1].data = [];
|
||||
timeLineChart.data.datasets = [];
|
||||
|
||||
var labels = ["Blocked DNS Queries", "Permitted DNS Queries"];
|
||||
var blockedColor = $(".queries-blocked").css("background-color");
|
||||
var permittedColor = $(".queries-permitted").css("background-color");
|
||||
var colors = [blockedColor, permittedColor];
|
||||
|
||||
// Collect values and colors, and labels
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
timeLineChart.data.datasets.push({
|
||||
data: [],
|
||||
// If we ran out of colors, make a random one
|
||||
backgroundColor: colors[i],
|
||||
pointRadius: 0,
|
||||
pointHitRadius: 5,
|
||||
pointHoverRadius: 5,
|
||||
label: labels[i],
|
||||
cubicInterpolationMode: "monotone"
|
||||
});
|
||||
}
|
||||
|
||||
// Add data for each hour that is available
|
||||
for (var hour in data.ads_over_time[0]) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.ads_over_time[0], hour)) {
|
||||
var d, h;
|
||||
h = parseInt(data.domains_over_time[0][hour]);
|
||||
if (parseInt(data.ads_over_time[0][0]) < 1200) {
|
||||
h = parseInt(data.domains_over_time[0][hour], 10);
|
||||
if (parseInt(data.ads_over_time[0][0], 10) < 1200) {
|
||||
// Fallback - old style
|
||||
d = new Date().setHours(Math.floor(h / 6), 10 * (h % 6), 0, 0);
|
||||
} else {
|
||||
@@ -299,7 +317,6 @@ function updateQueryTypesPie() {
|
||||
queryTypePieChart.data.datasets[0] = dd;
|
||||
queryTypePieChart.data.labels = k;
|
||||
$("#query-types-pie .overlay").hide();
|
||||
queryTypePieChart.update();
|
||||
queryTypePieChart.chart.config.options.cutoutPercentage = 50;
|
||||
queryTypePieChart.update();
|
||||
// Don't use rotation animation for further updates
|
||||
@@ -352,7 +369,7 @@ function updateClientsOverTime() {
|
||||
var timestamps = data.over_time[0];
|
||||
var plotdata = data.over_time[1];
|
||||
var labels = [];
|
||||
var key, i, j;
|
||||
var key;
|
||||
|
||||
for (key in data.clients) {
|
||||
if (Object.prototype.hasOwnProperty.call(data.clients, key)) {
|
||||
@@ -363,19 +380,15 @@ function updateClientsOverTime() {
|
||||
|
||||
// Remove possibly already existing data
|
||||
clientsChart.data.labels = [];
|
||||
clientsChart.data.datasets[0].data = [];
|
||||
for (i = 1; i < clientsChart.data.datasets.length; i++) {
|
||||
clientsChart.data.datasets[i].data = [];
|
||||
}
|
||||
clientsChart.data.datasets = [];
|
||||
|
||||
// Collect values and colors, and labels
|
||||
clientsChart.data.datasets[0].backgroundColor = THEME_COLORS[0];
|
||||
clientsChart.data.datasets[0].pointRadius = 0;
|
||||
clientsChart.data.datasets[0].pointHitRadius = 5;
|
||||
clientsChart.data.datasets[0].pointHoverRadius = 5;
|
||||
clientsChart.data.datasets[0].label = labels[0];
|
||||
var numClients = 0;
|
||||
if (plotdata.length > 0) {
|
||||
numClients = plotdata[0].length;
|
||||
}
|
||||
|
||||
for (i = clientsChart.data.datasets.length; plotdata.length && i < plotdata[0].length; i++) {
|
||||
for (var i = 0; i < numClients; i++) {
|
||||
clientsChart.data.datasets.push({
|
||||
data: [],
|
||||
// If we ran out of colors, make a random one
|
||||
@@ -392,7 +405,7 @@ function updateClientsOverTime() {
|
||||
}
|
||||
|
||||
// Add data for each dataset that is available
|
||||
for (j in timestamps) {
|
||||
for (var j in timestamps) {
|
||||
if (!Object.prototype.hasOwnProperty.call(timestamps, j)) {
|
||||
continue;
|
||||
}
|
||||
@@ -403,7 +416,7 @@ function updateClientsOverTime() {
|
||||
}
|
||||
}
|
||||
|
||||
var d = new Date(1000 * parseInt(timestamps[j]));
|
||||
var d = new Date(1000 * parseInt(timestamps[j], 10));
|
||||
clientsChart.data.labels.push(d);
|
||||
}
|
||||
|
||||
@@ -462,7 +475,6 @@ function updateForwardDestinationsPie() {
|
||||
forwardDestinationPieChart.data.datasets[0] = dd;
|
||||
// and push it at once
|
||||
$("#forward-destinations-pie .overlay").hide();
|
||||
forwardDestinationPieChart.update();
|
||||
forwardDestinationPieChart.chart.config.options.cutoutPercentage = 50;
|
||||
forwardDestinationPieChart.update();
|
||||
// Don't use rotation animation for further updates
|
||||
@@ -779,8 +791,6 @@ $(function () {
|
||||
// Pull in data via AJAX
|
||||
updateSummaryData();
|
||||
|
||||
var blockedColor = $(".queries-blocked").css("background-color");
|
||||
var permittedColor = $(".queries-permitted").css("background-color");
|
||||
var gridColor = $(".graphs-grid").css("background-color");
|
||||
var ticksColor = $(".graphs-ticks").css("color");
|
||||
var ctx = document.getElementById("queryOverTimeChart").getContext("2d");
|
||||
@@ -788,30 +798,7 @@ $(function () {
|
||||
type: utils.getGraphType(),
|
||||
data: {
|
||||
labels: [],
|
||||
datasets: [
|
||||
{
|
||||
label: "Blocked DNS Queries",
|
||||
fill: true,
|
||||
backgroundColor: blockedColor,
|
||||
borderColor: blockedColor,
|
||||
pointBorderColor: blockedColor,
|
||||
pointRadius: 1,
|
||||
pointHoverRadius: 5,
|
||||
data: [],
|
||||
pointHitRadius: 5
|
||||
},
|
||||
{
|
||||
label: "Permitted DNS Queries",
|
||||
fill: true,
|
||||
backgroundColor: permittedColor,
|
||||
borderColor: permittedColor,
|
||||
pointBorderColor: permittedColor,
|
||||
pointRadius: 1,
|
||||
pointHoverRadius: 5,
|
||||
data: [],
|
||||
pointHitRadius: 5
|
||||
}
|
||||
]
|
||||
datasets: [{ data: [] }]
|
||||
},
|
||||
options: {
|
||||
tooltips: {
|
||||
@@ -833,8 +820,8 @@ $(function () {
|
||||
label: function (tooltipItems, data) {
|
||||
if (tooltipItems.datasetIndex === 0) {
|
||||
var percentage = 0;
|
||||
var permitted = parseInt(data.datasets[1].data[tooltipItems.index]);
|
||||
var blocked = parseInt(data.datasets[0].data[tooltipItems.index]);
|
||||
var permitted = parseInt(data.datasets[1].data[tooltipItems.index], 10);
|
||||
var blocked = parseInt(data.datasets[0].data[tooltipItems.index], 10);
|
||||
var total = permitted + blocked;
|
||||
if (total > 0) {
|
||||
percentage = (100 * blocked) / total;
|
||||
|
||||
@@ -57,6 +57,22 @@ function renderMessage(data, type, row) {
|
||||
"</pre> to get the group configuration for this client."
|
||||
);
|
||||
|
||||
case "HOSTNAME":
|
||||
var hint = new Array(row.blob2 + row.message.length + 3).join(" ");
|
||||
return (
|
||||
"Hostname contains invalid character <code>" +
|
||||
decodeURIComponent(escape(row.blob1))[row.blob2] +
|
||||
"</code>:<pre>" +
|
||||
hint +
|
||||
"↓\n" +
|
||||
row.message +
|
||||
": " +
|
||||
decodeURIComponent(escape(row.blob1)) +
|
||||
"\n" +
|
||||
hint +
|
||||
"↑</pre>"
|
||||
);
|
||||
|
||||
default:
|
||||
return "Unknown message type<pre>" + JSON.stringify(row) + "</pre>";
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
/* global moment:false, utils:false */
|
||||
/* global utils:false */
|
||||
|
||||
var tableApi;
|
||||
|
||||
@@ -70,7 +70,7 @@ $(function () {
|
||||
rowCallback: function (row, data) {
|
||||
var color;
|
||||
var iconClasses;
|
||||
var lastQuery = parseInt(data.lastQuery);
|
||||
var lastQuery = parseInt(data.lastQuery, 10);
|
||||
var diff = getTimestamp() - lastQuery;
|
||||
var networkRecent = $(".network-recent").css("background-color");
|
||||
var networkOld = $(".network-old").css("background-color");
|
||||
@@ -161,7 +161,7 @@ $(function () {
|
||||
width: "8%",
|
||||
render: function (data, type) {
|
||||
if (type === "display") {
|
||||
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
|
||||
return utils.datetime(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -172,7 +172,7 @@ $(function () {
|
||||
width: "8%",
|
||||
render: function (data, type) {
|
||||
if (type === "display") {
|
||||
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
|
||||
return utils.datetime(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -258,7 +258,8 @@ $(function () {
|
||||
isCNAME = true;
|
||||
break;
|
||||
default:
|
||||
fieldtext = "Unknown (" + data[4] + ")";
|
||||
colorClass = false;
|
||||
fieldtext = "Unknown (" + parseInt(data[4], 10) + ")";
|
||||
buttontext = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ $("#btnSearchExact").on("click", function () {
|
||||
|
||||
// Wrap form-group's buttons to next line when viewed on a small screen
|
||||
$(window).on("resize", function () {
|
||||
if ($(window).width() < 991) {
|
||||
if ($(window).width() < 992) {
|
||||
$(".form-group.input-group").removeClass("input-group").addClass("input-group-block");
|
||||
$(".form-group.input-group-block > input").css("margin-bottom", "5px");
|
||||
$(".form-group.input-group-block > .input-group-btn")
|
||||
|
||||
@@ -149,11 +149,11 @@ function loadCacheInfo() {
|
||||
}
|
||||
|
||||
// Fill table with obtained values
|
||||
$("#cache-size").text(parseInt(data.cacheinfo["cache-size"]));
|
||||
$("#cache-inserted").text(parseInt(data.cacheinfo["cache-inserted"]));
|
||||
$("#cache-size").text(parseInt(data.cacheinfo["cache-size"], 10));
|
||||
$("#cache-inserted").text(parseInt(data.cacheinfo["cache-inserted"], 10));
|
||||
|
||||
// Highlight early cache removals when present
|
||||
var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"]);
|
||||
var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"], 10);
|
||||
$("#cache-live-freed").text(cachelivefreed);
|
||||
if (cachelivefreed > 0) {
|
||||
$("#cache-live-freed").parent("tr").addClass("lookatme");
|
||||
|
||||
@@ -41,37 +41,6 @@ function JSON_error($message = null)
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
function space_aware_explode($input)
|
||||
{
|
||||
$ret = array();
|
||||
$quoted = false;
|
||||
$pos = 0;
|
||||
|
||||
// Loop over input string
|
||||
for ($i = 0; $i < strlen($input); $i++)
|
||||
{
|
||||
// Get current character
|
||||
$c = $input[$i];
|
||||
|
||||
// If current character is a space (or comma) and we're outside
|
||||
// of a quoted region, we accept this character as separator
|
||||
if (($c == ' ' || $c == ',') && !$quoted) {
|
||||
$ret[] = str_replace('"', '', substr($input, $pos, $i - $pos));
|
||||
$pos = $i+1;
|
||||
}
|
||||
elseif($c == '"' && !$quoted)
|
||||
$quoted = true; // Quotation begins
|
||||
elseif($c == '"' && $quoted)
|
||||
$quoted = false; // Quotation ends here
|
||||
}
|
||||
// Get last element of the string
|
||||
if ($pos > 0) {
|
||||
$ret[] = substr($input, $pos);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'get_groups') {
|
||||
// List all available groups
|
||||
try {
|
||||
@@ -89,7 +58,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
} elseif ($_POST['action'] == 'add_group') {
|
||||
// Add new group
|
||||
try {
|
||||
$names = space_aware_explode(trim($_POST['name']));
|
||||
$names = str_getcsv(trim($_POST['name']), ' ');
|
||||
$total = count($names);
|
||||
$added = 0;
|
||||
$stmt = $db->prepare('INSERT INTO "group" (name,description) VALUES (:name,:desc)');
|
||||
@@ -97,7 +66,12 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':desc', $_POST['desc'], SQLITE3_TEXT)) {
|
||||
$desc = $_POST['desc'];
|
||||
if (strlen($desc) === 0) {
|
||||
// Store NULL in database for empty descriptions
|
||||
$desc = null;
|
||||
}
|
||||
if (!$stmt->bindValue(':desc', $desc, SQLITE3_TEXT)) {
|
||||
throw new Exception('While binding desc: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
@@ -137,7 +111,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
}
|
||||
|
||||
$desc = $_POST['desc'];
|
||||
if (strlen($desc) == 0) {
|
||||
if (strlen($desc) === 0) {
|
||||
// Store NULL in database for empty descriptions
|
||||
$desc = null;
|
||||
}
|
||||
@@ -290,7 +264,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
}
|
||||
|
||||
$comment = $_POST['comment'];
|
||||
if (strlen($comment) == 0) {
|
||||
if (strlen($comment) === 0) {
|
||||
// Store NULL in database for empty comments
|
||||
$comment = null;
|
||||
}
|
||||
@@ -320,7 +294,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
}
|
||||
|
||||
$comment = $_POST['comment'];
|
||||
if (strlen($comment) == 0) {
|
||||
if (strlen($comment) === 0) {
|
||||
// Store NULL in database for empty comments
|
||||
$comment = null;
|
||||
}
|
||||
@@ -480,6 +454,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
// Add new domain
|
||||
try {
|
||||
$domains = explode(' ', trim($_POST['domain']));
|
||||
$before = intval($db->querySingle("SELECT COUNT(*) FROM domainlist;"));
|
||||
$total = count($domains);
|
||||
$added = 0;
|
||||
$stmt = $db->prepare('REPLACE INTO domainlist (domain,type,comment) VALUES (:domain,:type,:comment)');
|
||||
@@ -499,7 +474,12 @@ if ($_POST['action'] == 'get_groups') {
|
||||
throw new Exception('While binding type: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':comment', $_POST['comment'], SQLITE3_TEXT)) {
|
||||
$comment = $_POST['comment'];
|
||||
if (strlen($comment) === 0) {
|
||||
// Store NULL in database for empty comments
|
||||
$comment = null;
|
||||
}
|
||||
if (!$stmt->bindValue(':comment', $comment, SQLITE3_TEXT)) {
|
||||
throw new Exception('While binding comment: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
@@ -556,8 +536,23 @@ if ($_POST['action'] == 'get_groups') {
|
||||
$added++;
|
||||
}
|
||||
|
||||
$after = intval($db->querySingle("SELECT COUNT(*) FROM domainlist;"));
|
||||
$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();
|
||||
JSON_success($msg);
|
||||
} catch (\Exception $ex) {
|
||||
JSON_error($ex->getMessage());
|
||||
}
|
||||
@@ -579,7 +574,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
}
|
||||
|
||||
$comment = $_POST['comment'];
|
||||
if (strlen($comment) == 0) {
|
||||
if (strlen($comment) === 0) {
|
||||
// Store NULL in database for empty comments
|
||||
$comment = null;
|
||||
}
|
||||
@@ -751,12 +746,17 @@ if ($_POST['action'] == 'get_groups') {
|
||||
$total = count($addresses);
|
||||
$added = 0;
|
||||
|
||||
$stmt = $db->prepare('INSERT INTO adlist (address,comment) VALUES (:address,:comment)');
|
||||
$stmt = $db->prepare('INSERT OR IGNORE INTO adlist (address,comment) VALUES (:address,:comment)');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':comment', $_POST['comment'], SQLITE3_TEXT)) {
|
||||
$comment = $_POST['comment'];
|
||||
if (strlen($comment) === 0) {
|
||||
// Store NULL in database for empty comments
|
||||
$comment = null;
|
||||
}
|
||||
if (!$stmt->bindValue(':comment', $comment, SQLITE3_TEXT)) {
|
||||
throw new Exception('While binding comment: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
}
|
||||
|
||||
$comment = $_POST['comment'];
|
||||
if (strlen($comment) == 0) {
|
||||
if (strlen($comment) === 0) {
|
||||
// Store NULL in database for empty comments
|
||||
$comment = null;
|
||||
}
|
||||
@@ -896,5 +896,4 @@ if ($_POST['action'] == 'get_groups') {
|
||||
// Reload lists in pihole-FTL after having added something
|
||||
if ($reload) {
|
||||
$output = pihole_execute('restartdns reload-lists');
|
||||
echo implode("\n", $output);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
{
|
||||
// $output could be either 4-5 digits or 2-3, and we only divide by 1000 if it's 4-5
|
||||
// ex. 39007 vs 39
|
||||
$celsius = intVal($output);
|
||||
$celsius = intval($output);
|
||||
|
||||
// If celsius is greater than 1 degree and is in the 4-5 digit format
|
||||
if($celsius > 1000) {
|
||||
@@ -90,7 +90,7 @@
|
||||
if(count($expl) == 2)
|
||||
{
|
||||
// remove " kB" from the end of the string and make it an integer
|
||||
$meminfo[$expl[0]] = intVal(substr($expl[1],0, -3));
|
||||
$meminfo[$expl[0]] = intval(substr($expl[1],0, -3));
|
||||
}
|
||||
}
|
||||
$memory_used = $meminfo["MemTotal"]-$meminfo["MemFree"]-$meminfo["Buffers"]-$meminfo["Cached"];
|
||||
@@ -162,7 +162,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://api.github.com; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; base-uri 'none'; child-src 'self'; form-action 'self'; frame-src 'self'; font-src 'self'; connect-src 'self'; img-src 'self'; manifest-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'">
|
||||
<!-- Usually browsers proactively perform domain name resolution on links that the user may choose to follow. We disable DNS prefetching here -->
|
||||
<meta http-equiv="x-dns-prefetch-control" content="off">
|
||||
<meta http-equiv="cache-control" content="max-age=60,private">
|
||||
@@ -419,7 +419,7 @@ if($auth) {
|
||||
</li>
|
||||
<li class="treeview<?php if($scriptname === "db_queries.php" || $scriptname === "db_lists.php" || $scriptname === "db_graph.php"){ ?> active<?php } ?>">
|
||||
<a href="#">
|
||||
<i class="fa fa-clock"></i> <span>Long term data</span>
|
||||
<i class="fa fa-clock"></i> <span>Long-term data</span>
|
||||
<span class="pull-right-container">
|
||||
<i class="fa fa-angle-left pull-right"></i>
|
||||
</span>
|
||||
|
||||
Vendored
+5
-8
File diff suppressed because one or more lines are too long
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
/*! iCheck v2.0.0 rc1 - http://git.io/arlzeA, (c) Damir Sultanov - http://fronteed.com */
|
||||
(function(r,x,m){r.ichecked||(r.ichecked=function(){m=r.jQuery||r.Zepto;var A={autoInit:!0,autoAjax:!1,tap:!0,checkboxClass:"icheckbox",radioClass:"iradio",checkedClass:"checked",disabledClass:"disabled",indeterminateClass:"indeterminate",hoverClass:"hover",callbacks:{ifCreated:!1},classes:{base:"icheck",div:"#-item",area:"#-area-",input:"#-input",label:"#-label"}};r.icheck=m.extend(A,r.icheck);var l=r.navigator.userAgent,ca=/MSIE [5-8]/.test(l)||9>x.documentMode,D=/Opera Mini/.test(l),E=A.classes.base,
|
||||
O=A.classes.div.replace("#",E),da=A.classes.area.replace("#",E),P=A.classes.input.replace("#",E),Q=A.classes.label.replace("#",E);delete A.classes;var ea={},p={},la=new RegExp(E+"\\[(.*?)\\]"),I=function(a,c,e){a&&(c=la.exec(a))&&p[c[1]]&&(e=c[1]);return e},fa=r.getComputedStyle,X=r.PointerEvent||r.MSPointerEvent,y="ontouchend"in r,F=/mobile|tablet|phone|ip(ad|od)|android|silk|webos/i.test(l),l=["mouse","down","up","over","out"],u=r.PointerEvent?["pointer",l[1],l[2],l[3],l[4]]:["MSPointer","Down",
|
||||
"Up","Over","Out"],R=["touch","start","end"],S=y&&F||X,T=S?y?R[0]+R[1]:u[0]+u[3]:l[0]+l[3],Y=S?y?R[0]+R[2]:u[0]+u[4]:l[0]+l[4],M=S?y?!1:u[0]+u[1]:l[0]+l[1],Z=S?y?!1:u[0]+u[2]:l[0]+l[2],l=D?"":T+".i "+Y+".i ",u=!D&&M?M+".i "+Z+".i":"",J,U,ga=!1!==A.areaStyle?'position:absolute;display:block;content:"";top:#;bottom:#;left:#;right:#;':0,V=function(a,c,e){J||(J=x.createElement("style"),(x.head||x.getElementsByTagName("head")[0]).appendChild(J),r.createPopup||J.appendChild(x.createTextNode("")),U=J.sheet||
|
||||
J.styleSheet);c||(c="div."+(e?da+e+":after":O+" input."+P));a=a.replace(/!/g," !important");U.addRule?U.addRule(c,a,0):U.insertRule(c+"{"+a+"}",0)};V("position:absolute!;display:block!;outline:none!;"+(A.debug?"":"opacity:0!;z-index:-99!;clip:rect(0 0 0 0)!;"));(y&&F||D)&&V("cursor:pointer!;","label."+Q+",div."+O);V("display:none!","iframe.icheck-frame");var G=function(a,c,e,b,f,d,k){if(b=a.className)return f=" "+b+" ",1===e?d=c:0===e?k=c:(d=c[0],k=c[1]),d&&0>f.indexOf(" "+d+" ")&&(f+=d+" "),k&&~f.indexOf(" "+
|
||||
k+" ")&&(f=f.replace(" "+k+" "," ")),f=f.replace(/^\s+|\s+$/g,""),f!==b&&(a.className=f),f},ha=function(a,c,e,b,f,d){p[c]&&(b=p[c],f=b.className,d=m(K(a,"div",f)),d.length&&(m(a).removeClass(P+" "+f).attr("style",b.style),m("label."+b.esc).removeClass(Q+" "+f),m(d).replaceWith(m(a)),e&&N(a,c,e)),p[c]=!1)},ia=function(a,c,e,b,f){e=[];for(b=a.length;b--;)if(c=a[b],c.type)~"input[type=checkbox],input[type=radio]".indexOf(c.type)&&e.push(c);else for(c=m(c).find("input[type=checkbox],input[type=radio]"),
|
||||
f=c.length;f--;)e.push(c[f]);return e},K=function(a,c,e,b){for(;a&&9!==a.nodeType;)if((a=a.parentNode)&&a.tagName==c.toUpperCase()&&~a.className.indexOf(e)){b=a;break}return b},N=function(a,c,e){e="if"+e;if(p[c].callbacks&&!1!==p[c].callbacks[e]&&(m(a).trigger(e),"function"==typeof p[c].callbacks[e]))p[c].callbacks[e](a,p[c])},ja=function(a,c,e,b){a=ia(a);for(var f=a.length;f--;){var d=a[f],k=d.attributes,l={},g=k.length,h,n,u={},y={},t,q=d.id,w=d.className,z,D=d.type,aa=m.cache?m.cache[d[m.expando]]:
|
||||
0,B=I(w),L,v,C="",H=!1;v=[];for(var F=r.FastClick?" needsclick":"";g--;)h=k[g].name,n=k[g].value,~h.indexOf("data-")&&(u[h.substr(5)]=n),"style"==h&&(z=n),l[h]=n;aa&&aa.data&&(u=m.extend(u,aa.data));for(t in u){n=u[t];if("true"==n||"false"==n)n="true"==n;y[t.replace(/checkbox|radio|class|id|label/g,function(a,b){return 0===b?a:a.charAt(0).toUpperCase()+a.slice(1)})]=n}k=m.extend({},A,r.icheck,y,c);g=k.handle;"checkbox"!==g&&"radio"!==g&&(g="input[type=checkbox],input[type=radio]");if(!1!==k.init&&
|
||||
~g.indexOf(D)){for(B&&ha(d,B);!p[B];)if(B=Math.random().toString(36).substr(2,5),!p[B]){L=E+"["+B+"]";break}delete k.autoInit;delete k.autoAjax;k.style=z||"";k.className=L;k.esc=L.replace(/(\[|\])/g,"\\$1");p[B]=k;if(g=K(d,"label",""))!g.htmlFor&&q&&(g.htmlFor=q),v.push(g);if(q)for(h=m('label[for="'+q+'"]');h.length--;)q=h[h.length],q!==g&&v.push(q);for(n=v.length;n--;)q=v[n],h=q.className,h=(g=I(h))?G(q,E+"["+g+"]",0):(h?h+" ":"")+Q,q.className=h+" "+L+F;v=x.createElement("div");if(k.inherit)for(q=
|
||||
k.inherit.split(/\s*,\s*/),h=q.length;h--;)g=q[h],void 0!==l[g]&&("class"==g?C+=l[g]+" ":v.setAttribute(g,"id"==g?E+"-"+l[g]:l[g]));C+=k[D+"Class"];C+=" "+O+" "+L;k.area&&ga&&(H=(""+k.area).replace(/%|px|em|\+|-/g,"")|0)&&(ea[H]||(V(ga.replace(/#/g,"-"+H+"%"),!1,H),ea[H]=!0),C+=" "+da+H);v.className=C+F;d.className=(w?w+" ":"")+P+" "+L;d.parentNode.replaceChild(v,d);v.appendChild(d);k.insert&&m(v).append(k.insert);H&&(l=fa?fa(v,null).getPropertyValue("position"):v.currentStyle.position,"static"==
|
||||
l&&(v.style.position="relative"));W(d,v,B,"updated",!0,!1,e);p[B].done=!0;b||N(d,B,"Created")}}},W=function(a,c,e,b,f,d,k){var m=p[e],g={},h={};g.checked=[a.checked,"Checked","Unchecked"];d&&!k||"click"===b||(g.disabled=[a.disabled,"Disabled","Enabled"],g.indeterminate=["true"==a.getAttribute("indeterminate")||!!a.indeterminate,"Indeterminate","Determinate"]);"updated"==b||"click"==b?(h.checked=d?!g.checked[0]:g.checked[0],d&&!k||"click"===b||(h.disabled=g.disabled[0],h.indeterminate=g.indeterminate[0])):
|
||||
"checked"==b||"unchecked"==b?h.checked="checked"==b:"disabled"==b||"enabled"==b?h.disabled="disabled"==b:"indeterminate"==b||"determinate"==b?h.indeterminate="determinate"!==b:h.checked=!g.checked[0];ka(a,c,g,h,e,m,b,f,d,k)},ka=function(a,c,e,b,f,d,k,l,g,h,n){var r=a.type,u="radio"==r?"Radio":"Checkbox",t,q,w,z,y,x,B,A,v,C;c||(c=K(a,"div",d.className));if(c){for(t in b)if(q=b[t],e[t][0]!==q&&"updated"!==k&&"click"!==k&&(a[t]=q),h&&(q?a.setAttribute(t,t):a.removeAttribute(t)),d[t]!==q){d[t]=q;v=!0;
|
||||
if("checked"==t&&(C=!0,!n&&q&&(p[f].done||h)&&"radio"==r&&a.name))for(z=K(a,"form",""),w='input[name="'+a.name+'"]',w=z&&!h?m(z).find(w):m(w),z=w.length;z--;)y=w[z],x=I(y.className),a!==y&&p[x]&&p[x].checked&&(B={checked:[!0,"Checked","Unchecked"]},A={checked:!1},ka(y,!1,B,A,x,p[x],"updated",l,g,h,!0));w=[d[t+"Class"],d[t+u+"Class"],d[e[t][1]+"Class"],d[e[t][1]+u+"Class"],d[t+"LabelClass"]];z=[w[3]||w[2],w[1]||w[0]];q&&z.reverse();G(c,z);if(d.mirror&&w[4])for(z=m("label."+d.esc);z.length--;)G(z[z.length],
|
||||
w[4],q?1:0);l&&!n||N(a,f,e[t][q?1:2])}if(!l||n)v&&N(a,f,"Changed"),C&&N(a,f,"Toggled");d.cursor&&!F&&(d.disabled||d.pointer?d.disabled&&d.pointer&&(c.style.cursor="default",d.pointer=!1):(c.style.cursor="pointer",d.pointer=!0));p[f]=d}};m.fn.icheck=function(a,c){if(/^(checked|unchecked|indeterminate|determinate|disabled|enabled|updated|toggle|destroy|data|styler)$/.test(a))for(var e=ia(this),b=e.length;b--;){var f=e[b],d=I(f.className);if(d){if("data"==a)return p[d];if("styler"==a)return K(f,"div",
|
||||
p[d].className);"destroy"==a?ha(f,d,"Destroyed"):W(f,!1,d,a);"function"==typeof c&&c(f)}}else"object"!=typeof a&&a||ja(this,a||{});return this};var ba;m(x).on("click.i "+l+u,"label."+Q+",div."+O,function(a){var c=this,e=I(c.className);if(e){var b=a.type,f=p[e],d=f.esc,e="DIV"==c.tagName,k,l,g,h,n=[["label",f.activeLabelClass,f.hoverLabelClass],["div",f.activeClass,f.hoverClass]];e&&n.reverse();if(b==M||b==Z){n[0][1]&&G(c,n[0][1],b==M?1:0);if(f.mirror&&n[1][1])for(g=m(n[1][0]+"."+d);g.length--;)G(g[g.length],
|
||||
n[1][1],b==M?1:0);e&&b==Z&&f.tap&&F&&X&&!D&&(h=!0)}else if(b==T||b==Y){n[0][2]&&G(c,n[0][2],b==T?1:0);if(f.mirror&&n[1][2])for(g=m(n[1][0]+"."+d);g.length--;)G(g[g.length],n[1][2],b==T?1:0);e&&b==Y&&f.tap&&F&&y&&!D&&(h=!0)}else e&&(F&&(y||X)&&f.tap&&!D||(h=!0));h&&setTimeout(function(){l=a.currentTarget||{};"LABEL"!==l.tagName&&(!f.change||100<+new Date-f.change)&&(k=m(c).find("input."+d).click(),(ca||D)&&k.change())},2)}}).on("click.i change.i focusin.i focusout.i keyup.i keydown.i","input."+P,function(a){var c=
|
||||
I(this.className);if(c){var e=a.type,b=p[c],f=b.esc,d="click"==e?!1:K(this,"div",b.className);if("click"==e)p[c].change=+new Date,a.stopPropagation();else if("change"==e)d&&!this.disabled&&W(this,d,c,"click");else if(~e.indexOf("focus")){if(a=[b.focusClass,b.focusLabelClass],a[0]&&d&&G(d,a[0],"focusin"==e?1:0),b.mirror&&a[1])for(b=m("label."+f);b.length--;)G(b[b.length],a[1],"focusin"==e?1:0)}else d&&!this.disabled&&("keyup"==e?(("checkbox"==this.type&&32==a.keyCode&&b.keydown||"radio"==this.type&&
|
||||
!this.checked)&&W(this,d,c,"click",!1,!0),p[c].keydown=!1,p[ba]&&(p[ba].keydown=!1)):(ba=c,p[c].keydown=!0))}}).ready(function(){r.icheck.autoInit&&m("."+E).icheck();if(r.jQuery){var a=x.body||x.getElementsByTagName("body")[0];m.ajaxSetup({converters:{"text html":function(c){if(r.icheck.autoAjax&&a){var e=x.createElement("iframe"),b;ca||(e.style="display:none");e.className="iframe.icheck-frame";e.src="about:blank";a.appendChild(e);b=e.contentDocument?e.contentDocument:e.contentWindow.document;b.open();
|
||||
b.write(c);b.close();a.removeChild(e);b=m(b);ja(b.find("."+E),{},!0);b=b[0];c=(b.body||b.getElementsByTagName("body")[0]).innerHTML}return c}}})}})},"function"==typeof define&&define.amd?define("icheck",[r.jQuery?"jquery":"zepto"],r.ichecked):r.ichecked())})(window,document);
|
||||
Vendored
+2
-4
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user