diff --git a/.pullapprove.yml b/.pullapprove.yml index d0b883e9..8bd8f0a2 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -25,7 +25,7 @@ groups: - devel required: 2 teams: - - dashboard + - approvers master: approve_by_comment: diff --git a/header.php b/header.php index 313253e5..436f0997 100644 --- a/header.php +++ b/header.php @@ -11,6 +11,19 @@ header("location:$refer"); } + // Web based change of temperature unit + if (isset($_GET['tempunit'])) + { + if($_GET['tempunit'] == "fahrenheit") + { + exec('sudo pihole -a -f'); + } + else + { + exec('sudo pihole -a -c'); + } + } + $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp | cut -c1-2`))"; $output = shell_exec($cmd); $celsius = str_replace(array("\r\n","\r","\n"),"", $output); @@ -53,6 +66,7 @@ + @@ -246,7 +260,13 @@
  • - Update lists + Update Lists + +
  • + +
  • + + Query adlists
  • @@ -284,6 +304,12 @@ Donate + +
  • + + Help + +
  • diff --git a/help.php b/help.php new file mode 100644 index 00000000..8c416647 --- /dev/null +++ b/help.php @@ -0,0 +1,121 @@ + + +
    +
    +

    Help center

    +

    Header

    +

    Top left: Status display

    +

    Shows different status messages:

    + +

    Top right: About

    + +
    +
    +
    +
    +

    Main page

    +

    On the main page, you can see various Pi-hole statistics:

    + +
    +
    +
    +
    +

    Query Log

    +

    Shows the recent queries by parsing Pi-hole's log. It is possible to search through the whole list by using the "Search" input field. If the status is reported as "OK", then the DNS request has been permitted. Otherwise ("Pi-holed") it has been blocked. By clicking on the buttons under "Action" the corresponding domains can quickly be added to the white-/blacklist. The status of the action will be reported on this page.

    +
    +
    +
    +
    +

    White- / Blacklist

    +

    Add or remove domains (or subdomains) from the white-/blacklist. If a domain is added to e.g. the whitelist, any possible entry of the same domain will be automatically removed from the blacklist and vice versa. Adding wildcards using the web UI is currently not supported.

    +
    +
    +
    +
    +

    Update Lists

    +

    Runs the command

    sudo pihole -g
    and prints the result transparently to the web UI. The gravity.sh script will update the list of ad-serving domains

    +
    +
    +
    +
    +

    Disable / Enable

    + Disables/enables Pi-Hole blocking completely. You may have to wait a few minutes for the changes to reach all of your devices. The change will be reflected by a changed status (top left) +
    +
    +
    +
    +

    Donate

    + Keep in mind that Pi-hole is free. If you like Pi-hole, please consider a small donation to help support its development +
    +
    +
    +
    +

    Help (this page)

    + Shows information about what is happening behind the scenes and what can be done with this web user interface (web UI) +
    +
    +
    +
    +

    Footer

    + Shows the currently installed Pi-hole and Web Interface version. If an update is available, this will be indicated here +
    +
    +
    +
    +

    Emergency help

    + In case the web UI does not work properly anymore (i.e. timeout errors or diagrams not showing up) you can try to flush the Pi-hole config file by clicking FLUSH. Note that your statistics will be reset and you lose the statistics up to this point. +
    +
    + + + + diff --git a/js/pihole/help.js b/js/pihole/help.js new file mode 100644 index 00000000..086759a0 --- /dev/null +++ b/js/pihole/help.js @@ -0,0 +1,7 @@ +$( "#flush" ).click(function() { + if (confirm("Are you sure you want to flush the Pi-hole log file?")) { + document.location.href="help.php?flush"; + } else { + // Do nothing! + } +}); diff --git a/js/pihole/index.js b/js/pihole/index.js index ffc022c5..5588c24b 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -237,11 +237,28 @@ function updateQueryTypes() { }); } +// Credit: http://stackoverflow.com/questions/1787322/htmlspecialchars-equivalent-in-javascript/4835406#4835406 +function escapeHtml(text) { + var map = { + "&": "&", + "<": "<", + ">": ">", + "\"": """, + "\'": "'" + }; + + return text.replace(/[&<>"']/g, function(m) { return map[m]; }); +} + function updateTopClientsChart() { $.getJSON("api.php?summaryRaw&getQuerySources", function(data) { var clienttable = $('#client-frequency').find('tbody:last'); + var domain; for (domain in data.top_sources) { - clienttable.append(' ' + domain + + // Sanitize domain + domain = escapeHtml(domain); + var url = ""+domain+""; + clienttable.append(" " + url + ' ' + data.top_sources[domain] + '
    '); } @@ -277,14 +294,28 @@ function updateTopLists() { $.getJSON("api.php?summaryRaw&topItems", function(data) { var domaintable = $('#domain-frequency').find('tbody:last'); var adtable = $('#ad-frequency').find('tbody:last'); + var url, domain; for (domain in data.top_queries) { - domaintable.append(' ' + domain + + // Sanitize domain + domain = escapeHtml(domain); + if(domain !== "pi.hole") + { + url = ""+domain+""; + } + else + { + url = domain; + } + domaintable.append(" " + url + ' ' + data.top_queries[domain] + '
    '); } for (domain in data.top_ads) { - adtable.append(' ' + domain + + // Sanitize domain + domain = escapeHtml(domain); + url = ""+domain+""; + adtable.append(" " + url + ' ' + data.top_ads[domain] + '
    '); } diff --git a/js/pihole/queries.js b/js/pihole/queries.js index cbb76c70..c8225ab2 100644 --- a/js/pihole/queries.js +++ b/js/pihole/queries.js @@ -1,3 +1,14 @@ +var tableApi; + +function escapeRegex(text) { + var map = { + "(": "\\(", + ")": "\\)", + ".": "\\.", + }; + return text.replace(/[().]/g, function(m) { return map[m]; }); +} + $(document).ready(function() { tableApi = $('#all-queries').DataTable( { "rowCallback": function( row, data, index ){ @@ -40,6 +51,23 @@ $(document).ready(function() { add(data[2],"black"); } } ); + + // Do we want to filter queries? + var GETDict = {}; + location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1];}); + if("client" in GETDict) + { + // Search in third column (zero indexed) + // Use regular expression to only show exact matches, i.e. + // don't show 192.168.0.100 when searching for 192.168.0.1 + // true = use regex, false = don't use smart search + tableApi.column(3).search("^"+escapeRegex(GETDict["client"])+"$",true,false); + } + if("domain" in GETDict) + { + // Search in second column (zero indexed) + tableApi.column(2).search("^"+escapeRegex(GETDict["domain"])+"$",true,false); + } } ); function refreshData() { diff --git a/js/pihole/queryads.js b/js/pihole/queryads.js new file mode 100644 index 00000000..26061d42 --- /dev/null +++ b/js/pihole/queryads.js @@ -0,0 +1,38 @@ +function eventsource() { + var ta = $("#output"); + var domain = $("#domain"); + if(domain.val().length === 0) + { + return; + } + var source = new EventSource("php/queryads.php?domain="+domain.val()); + + // Reset and show field + ta.empty(); + ta.show(); + + source.addEventListener("message", function(e) { + ta.append(e.data); + }, false); + + // Will be called when script has finished + source.addEventListener("error", function(e) { + source.close(); + }, false); +} + +// $(function(){ +// eventsourcetest(); +// }); + +// Handle enter button +$(document).keypress(function(e) { + if(e.which === 13 && $("#domain").is(":focus")) { + // Enter was pressed, and the input has focus + eventsource(); + } +}); +// Handle button +$("#btnSearch").on("click", function() { + eventsource(); +}); diff --git a/php/queryads.php b/php/queryads.php new file mode 100644 index 00000000..eedb4a22 --- /dev/null +++ b/php/queryads.php @@ -0,0 +1,41 @@ + diff --git a/queryads.php b/queryads.php new file mode 100644 index 00000000..4392c01f --- /dev/null +++ b/queryads.php @@ -0,0 +1,23 @@ + + + + +
    + + + + +
    + + + + + + +