Merge branch 'devel' into auth

Conflicts:
	header.php
This commit is contained in:
DL6ER
2016-11-23 18:02:40 +01:00
9 changed files with 320 additions and 5 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ groups:
- devel
required: 2
teams:
- dashboard
- approvers
master:
approve_by_comment:
+27 -1
View File
@@ -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 @@
<link rel="icon" type="image/png" sizes="96x96" href="img/logo.svg">
<meta name="msapplication-TileColor" content="#367fa9">
<meta name="msapplication-TileImage" content="img/logo.svg">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome-4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
@@ -246,7 +260,13 @@
<!-- Run gravity.sh -->
<li>
<a href="gravity.php">
<i class="fa fa-arrow-circle-down"></i> <span>Update lists</span>
<i class="fa fa-arrow-circle-down"></i> <span>Update Lists</span>
</a>
</li>
<!-- Query adlists -->
<li>
<a href="queryads.php">
<i class="fa fa-search"></i> <span>Query adlists</span>
</a>
</li>
<!-- Toggle -->
@@ -284,6 +304,12 @@
<i class="fa fa-paypal"></i> <span>Donate</span>
</a>
</li>
<!-- Help -->
<li>
<a href="help.php">
<i class="fa fa-question-circle"></i> <span>Help</span>
</a>
</li>
</ul>
</section>
<!-- /.sidebar -->
+121
View File
@@ -0,0 +1,121 @@
<?php
require "header.php";
?>
<div class="row">
<div class="col-md-12">
<h1>Help center</h1>
<h2>Header</h2>
<h4>Top left: Status display</h4>
<p>Shows different status messages:</p>
<ul>
<li>Status: Current status of the Pi-hole - Active (<i class="fa fa-circle" style="color:#7FFF00"></i>), Offline (<i class="fa fa-circle" style="color:#FF0000"></i>), or Starting (<i class="fa fa-circle" style="color:#ff9900"></i>)</li>
<li>Temp: Current CPU temperature
<?php
if($temperatureunit != "F"){
?>
(switch unit to <a href="help.php?tempunit=fahrenheit">Fahrenheit</a>)
<?php
}
else
{
?>
(switch unit to <a href="help.php?tempunit=celsius">Celsius</a>)
<?php
}
?></li>
<li>Load: load averages for the last minute, 5 minutes and 15 minutes, respectively. A load average of 1 reflects the full workload of a single processor on the system. We show a red icon if the current load exceeds the number of available processors on this machine (which is <?php echo $nproc; ?>)</li>
<li>Memory usage: Shows the percentage of memory actually blocked by applications. We show a red icon if the memory usage exceeds 75%</li>
</ul>
<h4>Top right: About</h4>
<ul>
<li>GitHub: Link to the Pi-hole repository</li>
<li>Details: Link to Jacob Salmela's blog with some more details, describing also the concept of the Pi-hole</li>
<li>Updates: Link to list of releases</li>
<li>Update notifications: If updates are available, a link will be shown here.</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Main page</h2>
<p>On the main page, you can see various Pi-hole statistics:</p>
<ul>
<li>Summary: A summary of statistics showing how many total DNS queries have been blocked today, what percentage of DNS queries have been blocked, and how many domains are in the compiled ad list. This summary is updated every 10 seconds.</li>
<li>Queries over time: Graph showing DNS queries (total and blocked) over 10 minute time intervals. More information can be acquired by hovering over the lines.</li>
<li>Query Types: Identifies the types of processed queries:
<ul>
<li>A: address lookup (most commonly used to map hostnames to an IPv4 address of the host)</li>
<li>AAAA: address lookup (most commonly used to map hostnames to an IPv6 address of the host)</li>
<li>PTR: most common use is for implementing reverse DNS lookups</li>
<li>SRV: Service locator (often used by XMPP, SIP, and LDAP)</li>
<li>and others</li>
</ul>
</li>
<li>Query Types: Shows to which upstream DNS the permitted requests have been forwarded to.</li>
<li>Top Domains: Ranking of requested sites by number of DNS lookups.</li>
<li>Top Advertisers: Ranking of requested advertisements by number of DNS lookups.</li>
<li>Top Clients: Ranking of how many DNS requests each client has made on the local network.</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Query Log</h2>
<p>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.</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>White- / Blacklist</h2>
<p>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 <em>not</em> supported.</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Update Lists</h2>
<p>Runs the command <pre>sudo pihole -g</pre> and prints the result transparently to the web UI. The gravity.sh script will update the list of ad-serving domains</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Disable / Enable</h2>
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)
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Donate</h2>
Keep in mind that Pi-hole is free. If you like Pi-hole, please consider a small donation to help support its development
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Help (this page)</h2>
Shows information about what is happening behind the scenes and what can be done with this web user interface (web UI)
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Footer</h2>
Shows the currently installed Pi-hole and Web Interface version. If an update is available, this will be indicated here
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Emergency help</h2>
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 <a href="#" id="flush">FLUSH</a>. Note that your statistics will be reset and you lose the statistics up to this point.
</div>
</div>
<?php
// Web based flushing of pi-hole log file
if (isset($_GET["flush"]))
{
exec("sudo pihole -f");
}
require "footer.php";
?>
<script src="js/pihole/help.js"></script>
+7
View File
@@ -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!
}
});
+34 -3
View File
@@ -237,11 +237,28 @@ function updateQueryTypes() {
});
}
// Credit: http://stackoverflow.com/questions/1787322/htmlspecialchars-equivalent-in-javascript/4835406#4835406
function escapeHtml(text) {
var map = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
"\"": "&quot;",
"\'": "&#039;"
};
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('<tr> <td>' + domain +
// Sanitize domain
domain = escapeHtml(domain);
var url = "<a href=\"queries.php?client="+domain+"\">"+domain+"</a>";
clienttable.append("<tr> <td>" + url +
'</td> <td>' + data.top_sources[domain] + '</td> <td> <div class="progress progress-sm"> <div class="progress-bar progress-bar-blue" style="width: ' +
data.top_sources[domain] / data.dns_queries_today * 100 + '%"></div> </div> </td> </tr> ');
}
@@ -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('<tr> <td>' + domain +
// Sanitize domain
domain = escapeHtml(domain);
if(domain !== "pi.hole")
{
url = "<a href=\"queries.php?domain="+domain+"\">"+domain+"</a>";
}
else
{
url = domain;
}
domaintable.append("<tr> <td>" + url +
'</td> <td>' + data.top_queries[domain] + '</td> <td> <div class="progress progress-sm"> <div class="progress-bar progress-bar-green" style="width: ' +
data.top_queries[domain] / data.dns_queries_today * 100 + '%"></div> </div> </td> </tr> ');
}
for (domain in data.top_ads) {
adtable.append('<tr> <td>' + domain +
// Sanitize domain
domain = escapeHtml(domain);
url = "<a href=\"queries.php?domain="+domain+"\">"+domain+"</a>";
adtable.append("<tr> <td>" + url +
'</td> <td>' + data.top_ads[domain] + '</td> <td> <div class="progress progress-sm"> <div class="progress-bar progress-bar-yellow" style="width: ' +
data.top_ads[domain] / data.ads_blocked_today * 100 + '%"></div> </div> </td> </tr> ');
}
+28
View File
@@ -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() {
+38
View File
@@ -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();
});
+41
View File
@@ -0,0 +1,41 @@
<?php
ob_end_flush();
ini_set("output_buffering", "0");
ob_implicit_flush(true);
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
function echoEvent($datatext) {
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
}
// Credit: http://stackoverflow.com/a/4694816/2087442
function is_valid_domain_name($domain_name)
{
return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) //valid chars check
&& preg_match("/^.{1,253}$/", $domain_name) //overall length check
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name) ); //length of each label
}
// Test if domain is set
if(isset($_GET["domain"]))
{
// Is this a valid domain?
$url = $_GET["domain"];
if(!is_valid_domain_name($url))
{
echoEvent("Invalid domain!");
die();
}
}
else
{
echoEvent("No domain provided");
die();
}
$proc = popen("sudo pihole -q ".$url, 'r');
while (!feof($proc)) {
echoEvent(fread($proc, 4096));
}
?>
+23
View File
@@ -0,0 +1,23 @@
<?php
require "header.php";
?>
<!-- Title -->
<div class="page-header">
<h1>Find Ad Domain In Lists</h1>
</div>
<!-- Domain Input -->
<div class="form-group input-group">
<input id="domain" type="text" class="form-control" placeholder="Domain to look for (example.com or sub.example.com)">
<span class="input-group-btn">
<button id="btnSearch" class="btn btn-default" type="button">Search</button>
</span>
</div>
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
<?php
require "footer.php";
?>
<script src="js/pihole/queryads.js"></script>