mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Pass "Invalid domain!" error message to user
This commit is contained in:
+17
-19
@@ -1,20 +1,4 @@
|
||||
<?php
|
||||
// Test if domain is set
|
||||
if(isset($_GET["domain"]))
|
||||
{
|
||||
// Remove illegal characters
|
||||
$url = filter_var($_GET["domain"], FILTER_SANITIZE_URL);
|
||||
// Is this a valid domain?
|
||||
if(!filter_var(gethostbyname($url), FILTER_VALIDATE_IP))
|
||||
{
|
||||
die("Invalid domain!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
die("No domain provided");
|
||||
}
|
||||
|
||||
ob_end_flush();
|
||||
ini_set("output_buffering", "0");
|
||||
ob_implicit_flush(true);
|
||||
@@ -25,12 +9,26 @@ function echoEvent($datatext) {
|
||||
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
|
||||
}
|
||||
|
||||
// echoEvent("***START***");
|
||||
// Test if domain is set
|
||||
if(isset($_GET["domain"]))
|
||||
{
|
||||
// Remove illegal characters
|
||||
$url = filter_var($_GET["domain"], FILTER_SANITIZE_URL);
|
||||
// Is this a valid domain?
|
||||
if(!filter_var(gethostbyname($url), FILTER_VALIDATE_IP))
|
||||
{
|
||||
echoEvent("Invalid domain!");
|
||||
die();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echoEvent("No domain provided");
|
||||
die();
|
||||
}
|
||||
|
||||
$proc = popen("sudo pihole -q ".$url, 'r');
|
||||
while (!feof($proc)) {
|
||||
echoEvent(fread($proc, 4096));
|
||||
}
|
||||
|
||||
// echoEvent("***END***");
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user