Files
web/php/queryads.php
2016-11-22 15:23:30 +01:00

36 lines
733 B
PHP

<?php
// Test if domain is set
if(isset($_GET["domain"]))
{
// Remove illegal characters
$url = filter_var($_GET["domain"], FILTER_SANITIZE_URL);
if(!filter_var("http://".$url, FILTER_VALIDATE_URL ) === true)
{
die("Invalid domain!");
}
}
else
{
die("No domain provided");
}
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";
}
// echoEvent("***START***");
$proc = popen("sudo pihole -q ".$url, 'r');
while (!feof($proc)) {
echoEvent(fread($proc, 4096));
}
// echoEvent("***END***");
?>