mirror of
https://github.com/pi-hole/web.git
synced 2026-04-25 11:19:59 +01:00
Detect ${OVER} and mirror its effect properly on the web interface
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -16,15 +16,22 @@ header('Content-Type: text/event-stream');
|
||||
header('Cache-Control: no-cache');
|
||||
|
||||
function echoEvent($datatext) {
|
||||
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
|
||||
// Detect ${OVER} and replace it with something we can safely transmit
|
||||
$datatext = str_replace("\r[K","<------",$datatext);
|
||||
$pos = strpos($datatext,"<------");
|
||||
// Detect if the ${OVER} line is within this line, e.g.
|
||||
// "Pending: String to replace${OVER}Done: String has been replaced"
|
||||
// If this is the case, we have to remove everything before ${OVER}
|
||||
// and return only the text thereafter
|
||||
if($pos !== false && $pos !== 0)
|
||||
{
|
||||
$datatext = substr($datatext, $pos);
|
||||
}
|
||||
echo "data: ".implode("\ndata: ", explode("\n",$datatext))."\n\n";
|
||||
}
|
||||
|
||||
// echoEvent("***START***");
|
||||
|
||||
$proc = popen("sudo pihole -g", 'r');
|
||||
while (!feof($proc)) {
|
||||
echoEvent(fread($proc, 4096));
|
||||
}
|
||||
|
||||
// echoEvent("***END***");
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user