Implemented new "pihole -q <domain> -exact" argument in web UI

This commit is contained in:
DL6ER
2016-12-06 13:30:53 +01:00
parent 9fd0f916c5
commit beeea0edfb
2 changed files with 27 additions and 7 deletions

View File

@@ -13,8 +13,14 @@ function eventsource() {
quiet = true;
}
var exact = "";
if(quiet)
{
exact = "exact";
}
var host = window.location.host;
var source = new EventSource("http://"+host+"/admin/php/queryads.php?domain="+domain.val());
var source = new EventSource("http://"+host+"/admin/php/queryads.php?domain="+domain.val()+"&"+exact);
// Reset and show field
ta.empty();
@@ -27,12 +33,17 @@ function eventsource() {
}
else
{
if(e.data.indexOf("results") !== -1 && e.data.indexOf("0 results") === -1)
var lines = e.data.split("\n");
for(var i = 0;i<lines.length;i++)
{
var shortstring = e.data.replace("::: /etc/pihole/","");
// Remove "(x results)"
shortstring = shortstring.replace(/\(.*/,"");
ta.append(shortstring);
if(lines[i].indexOf("results") !== -1 && lines[i].indexOf("0 results") === -1)
{
var shortstring = lines[i].replace("::: /etc/pihole/","");
// Remove "(x results)"
shortstring = shortstring.replace(/\(.*/,"");
ta.append(shortstring+"\n");
// ta.append(e.data);
}
}
}
}, false);

View File

@@ -34,7 +34,16 @@ else
die();
}
$proc = popen("sudo pihole -q ".$url, 'r');
if(isset($_GET["exact"]))
{
$exact = "-exact";
}
else
{
$exact = "";
}
$proc = popen("sudo pihole -q ".$url." ".$exact, 'r');
while (!feof($proc)) {
echoEvent(fread($proc, 4096));
}