diff --git a/README.md b/README.md
index 6e225856..c9770800 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
Pi-hole Admin Dashboard
============
+[](https://www.codacy.com/app/Pi-hole/AdminLTE?utm_source=github.com&utm_medium=referral&utm_content=pi-hole/AdminLTE&utm_campaign=badger)
[](https://gitter.im/pi-hole/AdminLTE?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
diff --git a/list.php b/list.php
index 9d030936..da146258 100644
--- a/list.php
+++ b/list.php
@@ -51,7 +51,7 @@ function getFullName() {
| " + url +
" | " + data.top_sources[domain] + " | -1)
{
- key = key.substr(0, key.indexOf("|"));
+ var idx = key.indexOf("|");
+ key = key.substr(0, idx)+" ("+key.substr(idx+1, key.length-idx)+")";
}
forwardDestinationChart.data.labels.push(key);
});
@@ -291,7 +295,7 @@ $(document).ready(function() {
enabled: true,
mode: "x-axis",
callbacks: {
- title(tooltipItem, data) {
+ title: function(tooltipItem, data) {
var label = tooltipItem[0].xLabel;
var time = label.match(/(\d?\d):?(\d?\d?)/);
var h = parseInt(time[1], 10);
@@ -300,7 +304,7 @@ $(document).ready(function() {
var to = padNumber(h)+":"+padNumber(m+9)+":59";
return "Queries from "+from+" to "+to;
},
- label(tooltipItems, data) {
+ label: function(tooltipItems, data) {
if(tooltipItems.datasetIndex === 1)
{
var percentage = 0.0;
diff --git a/scripts/pi-hole/js/list.js b/scripts/pi-hole/js/list.js
index ea9e5f44..12da6bcf 100644
--- a/scripts/pi-hole/js/list.js
+++ b/scripts/pi-hole/js/list.js
@@ -126,6 +126,7 @@ function add(arg) {
var alInfo = $("#alInfo");
var alSuccess = $("#alSuccess");
var alFailure = $("#alFailure");
+ var err = $("#err");
alInfo.show();
alSuccess.hide();
alFailure.hide();
@@ -137,10 +138,11 @@ function add(arg) {
if (response.indexOf("not a valid argument") >= 0 ||
response.indexOf("is not a valid domain") >= 0) {
alFailure.show();
- alFailure.delay(1000).fadeOut(2000, function() {
+ err.html(response);
+ alFailure.delay(4000).fadeOut(2000, function() {
alFailure.hide();
});
- alInfo.delay(1000).fadeOut(2000, function() {
+ alInfo.delay(4000).fadeOut(2000, function() {
alInfo.hide();
});
} else {
diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js
index 64be7586..428006c7 100644
--- a/scripts/pi-hole/js/queries.js
+++ b/scripts/pi-hole/js/queries.js
@@ -69,6 +69,17 @@ function add(domain,list) {
}
});
}
+function handleAjaxError( xhr, textStatus, error ) {
+ if ( textStatus === "timeout" ) {
+ alert( "The server took too long to send the data." );
+ }
+ else {
+ alert( "An error occured while loading the data. Presumably your log is too large to be processed." );
+ }
+ $("#all-queries_processing").hide();
+ tableApi.clear();
+ tableApi.draw();
+}
$(document).ready(function() {
var status;
@@ -94,11 +105,11 @@ $(document).ready(function() {
status = data[4];
if (status.substr(0,2) === "Pi") {
$(row).css("color","red");
- $("td:eq(5)", row).html( " " );
+ $("td:eq(5)", row).html( " " );
}
else{
$(row).css("color","green");
- $("td:eq(5)", row).html( " " );
+ $("td:eq(5)", row).html( " " );
}
},
@@ -106,8 +117,9 @@ $(document).ready(function() {
"<'row'<'col-sm-4'l><'col-sm-8'p>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
- "ajax": APIstring,
+ "ajax": {"url": APIstring, "error": handleAjaxError },
"autoWidth" : false,
+ "processing": true,
"order" : [[0, "desc"]],
"columns": [
{ "width" : "20%", "type": "date" },
diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js
index e7e613ea..27620f5a 100644
--- a/scripts/pi-hole/js/settings.js
+++ b/scripts/pi-hole/js/settings.js
@@ -55,6 +55,7 @@ $(".confirm-flushlogs").confirm({
$("#DHCPchk").click(function() {
$("input.DHCPgroup").prop("disabled", !this.checked);
+ $("#dhcpnotice").prop("hidden", !this.checked).addClass("lookatme");
});
var leasetable;
diff --git a/scripts/pi-hole/php/auth.php b/scripts/pi-hole/php/auth.php
index f6757ffa..188b47b6 100644
--- a/scripts/pi-hole/php/auth.php
+++ b/scripts/pi-hole/php/auth.php
@@ -35,7 +35,11 @@ function check_cors() {
// to validate that the client is authorized, only unauthorized.
$server_host = $_SERVER['HTTP_HOST'];
- // If HTTP_HOST contains a non-standard port (!= 80) we have to strip the port
+ // Use parse_url if HTTP_HOST contains a colon (:) to get the host name
+ // e.g.
+ // https://pi.hole
+ // pi.hole:8080
+ // However, we don't use parse_url(...) if there is no colon, since it will fail for e.g. "pi.hole"
if(strpos($server_host, ":"))
{
$server_host = parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST);
@@ -48,7 +52,7 @@ function check_cors() {
if(isset($_SERVER['HTTP_ORIGIN'])) {
$server_origin = $_SERVER['HTTP_ORIGIN'];
- // If HTTP_ORIGIN contains a non-standard port (!= 80) we have to strip the port
+ // Detect colon in $_SERVER['HTTP_ORIGIN'] (see comment above)
if(strpos($server_origin, ":"))
{
$server_origin = parse_url($_SERVER['HTTP_ORIGIN'], PHP_URL_HOST);
@@ -99,14 +103,19 @@ function check_csrf($token) {
function check_domain() {
if(isset($_POST['domain'])){
- $validDomain = is_valid_domain_name($_POST['domain']);
- if(!$validDomain){
- log_and_die($_POST['domain']. ' is not a valid domain');
+ $domains = explode(" ",$_POST['domain']);
+ foreach($domains as $domain)
+ {
+ $validDomain = is_valid_domain_name($domain);
+ if(!$validDomain){
+ log_and_die(htmlspecialchars($domain. ' is not a valid domain'));
+ }
}
}
}
function list_verify($type) {
+ global $pwhash, $wrongpassword;
if(!isset($_POST['domain']) || !isset($_POST['list']) || !(isset($_POST['pw']) || isset($_POST['token']))) {
log_and_die("Missing POST variables");
}
@@ -121,11 +130,11 @@ function list_verify($type) {
require("password.php");
if(strlen($pwhash) == 0)
{
- log_and_die("No password set - ${type}listing with password not supported");
+ log_and_die("No password set - ".htmlspecialchars($type)."listing with password not supported");
}
elseif($wrongpassword)
{
- log_and_die("Wrong password - ${type}listing of ${_POST['domain']} not permitted");
+ log_and_die("Wrong password - ".htmlspecialchars($type)."listing of ${_POST['domain']} not permitted");
}
}
else
diff --git a/scripts/pi-hole/php/data.php b/scripts/pi-hole/php/data.php
index 8dd827d6..fdb6135f 100644
--- a/scripts/pi-hole/php/data.php
+++ b/scripts/pi-hole/php/data.php
@@ -679,14 +679,12 @@
$byTimeAds[$time] = 1;
}
}
- else
- {
- if (isset($byTimeDomains[$time])) {
- $byTimeDomains[$time]++;
- }
- else {
- $byTimeDomains[$time] = 1;
- }
+
+ if (isset($byTimeDomains[$time])) {
+ $byTimeDomains[$time]++;
+ }
+ else {
+ $byTimeDomains[$time] = 1;
}
}
return [$byTimeDomains,$byTimeAds];
@@ -721,14 +719,12 @@
$byTimeAds[$time] = 1;
}
}
- else
- {
- if (isset($byTimeDomains[$time])) {
- $byTimeDomains[$time]++;
- }
- else {
- $byTimeDomains[$time] = 1;
- }
+
+ if (isset($byTimeDomains[$time])) {
+ $byTimeDomains[$time]++;
+ }
+ else {
+ $byTimeDomains[$time] = 1;
}
}
return [$byTimeDomains,$byTimeAds];
diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php
index c889ab24..e554d76a 100644
--- a/scripts/pi-hole/php/header.php
+++ b/scripts/pi-hole/php/header.php
@@ -83,15 +83,16 @@
$memory_usage = -1;
}
+ if($auth) {
+ // For session timer
+ $maxlifetime = ini_get("session.gc_maxlifetime");
- // For session timer
- $maxlifetime = ini_get("session.gc_maxlifetime");
-
- // Generate CSRF token
- if(empty($_SESSION['token'])) {
- $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
+ // Generate CSRF token
+ if(empty($_SESSION['token'])) {
+ $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
+ }
+ $token = $_SESSION['token'];
}
- $token = $_SESSION['token'];
if(isset($setupVars['WEBUIBOXEDLAYOUT']))
{
@@ -171,7 +172,7 @@
-
+
@@ -249,25 +250,25 @@
- 
+
@@ -442,7 +443,7 @@
// Show Logout button if $auth is set and authorization is required
if(strlen($pwhash) > 0) { ?>
-
+
Logout
diff --git a/scripts/pi-hole/php/loginpage.php b/scripts/pi-hole/php/loginpage.php
index a0366dfb..beba3c87 100644
--- a/scripts/pi-hole/php/loginpage.php
+++ b/scripts/pi-hole/php/loginpage.php
@@ -13,13 +13,19 @@
@@ -93,6 +104,17 @@
0 && $piHoleIPv6 != "unknown")
+ {
+ if(substr($piHoleIPv6, 0, 4) != "fe80")
+ {
+ $usingipv6 = true;
+ }
+ }
+
if(isset($setupVars["DHCP_ACTIVE"]))
{
if($setupVars["DHCP_ACTIVE"] == 1)
@@ -107,12 +129,29 @@
$DHCPstart = $setupVars["DHCP_START"];
$DHCPend = $setupVars["DHCP_END"];
$DHCProuter = $setupVars["DHCP_ROUTER"];
- $DHCPleasetime = $setupVars["DHCP_LEASETIME"];
- if(strlen($DHCPleasetime) < 1)
+ // This setting has been added later, we have to check if it exists
+ if(isset($setupVars["DHCP_LEASETIME"]))
+ {
+ $DHCPleasetime = $setupVars["DHCP_LEASETIME"];
+ if(strlen($DHCPleasetime) < 1)
+ {
+ // Fallback if empty string
+ $DHCPleasetime = 24;
+ }
+ }
+ else
{
- // Fallback if it was not set before
$DHCPleasetime = 24;
}
+ if(isset($setupVars["DHCP_IPv6"]))
+ {
+ $DHCPIPv6 = $setupVars["DHCP_IPv6"];
+ }
+ else
+ {
+ $DHCPIPv6 = $usingipv6;
+ }
+
}
else
{
@@ -130,6 +169,7 @@
$DHCProuter = "";
}
$DHCPleasetime = 24;
+ $DHCPIPv6 = $usingipv6;
}
if(isset($setupVars["PIHOLE_DOMAIN"])){
$piHoleDomain = $setupVars["PIHOLE_DOMAIN"];
@@ -143,8 +183,13 @@
|