mirror of
https://github.com/pi-hole/web.git
synced 2026-02-20 18:00:04 +00:00
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
/* Pi-hole: A black hole for Internet advertisements
|
|
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
* Network-wide ad blocking via your own hardware.
|
|
*
|
|
* This file is copyright under the latest version of the EUPL.
|
|
* Please see LICENSE file for your rights under this license. */
|
|
|
|
while (ob_get_level() > 0) {
|
|
ob_end_flush();
|
|
}
|
|
require_once("func.php");
|
|
ini_set("output_buffering", "0");
|
|
ob_implicit_flush(true);
|
|
header('Content-Type: text/event-stream');
|
|
header('Cache-Control: no-cache');
|
|
|
|
function echoEvent($datatext) {
|
|
if(!isset($_GET["IE"]))
|
|
echo "data:".implode("\ndata:", explode("\n", $datatext))."\n\n";
|
|
else
|
|
echo $datatext;
|
|
}
|
|
|
|
// Test if domain is set
|
|
if(isset($_GET["domain"]))
|
|
{
|
|
// Is this a valid domain?
|
|
$url = idn_to_ascii($_GET["domain"]);
|
|
if(!validDomain($url))
|
|
{
|
|
echoEvent("$url is an invalid domain!");
|
|
die();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echoEvent("No domain provided");
|
|
die();
|
|
}
|
|
|
|
if(isset($_GET["exact"]))
|
|
{
|
|
$exact = "-exact";
|
|
}
|
|
elseif(isset($_GET["bp"]))
|
|
{
|
|
$exact = "-bp";
|
|
}
|
|
else
|
|
{
|
|
$exact = "";
|
|
}
|
|
|
|
$proc = popen("sudo pihole -q -adlist ".$url." ".$exact, 'r');
|
|
while (!feof($proc)) {
|
|
echoEvent(fread($proc, 4096));
|
|
}
|
|
?>
|