mirror of
https://github.com/pi-hole/web.git
synced 2026-04-25 03:10:18 +01:00
@@ -7,33 +7,34 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require "password.php";
|
||||
require 'password.php';
|
||||
|
||||
if(!$auth) die("Not authorized");
|
||||
if (!$auth) {
|
||||
exit('Not authorized');
|
||||
}
|
||||
|
||||
ob_end_flush();
|
||||
ini_set("output_buffering", "0");
|
||||
ini_set('output_buffering', '0');
|
||||
ob_implicit_flush(true);
|
||||
header('Content-Type: text/event-stream');
|
||||
header('Cache-Control: no-cache');
|
||||
|
||||
function echoEvent($datatext) {
|
||||
function echoEvent($datatext)
|
||||
{
|
||||
// Detect ${OVER} and replace it with something we can safely transmit
|
||||
$datatext = str_replace("\r[K","<------",$datatext);
|
||||
$pos = strpos($datatext,"<------");
|
||||
$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)
|
||||
{
|
||||
if (false !== $pos && 0 !== $pos) {
|
||||
$datatext = substr($datatext, $pos);
|
||||
}
|
||||
echo "data: ".implode("\ndata: ", explode("\n",$datatext))."\n\n";
|
||||
echo 'data: '.implode("\ndata: ", explode("\n", $datatext))."\n\n";
|
||||
}
|
||||
|
||||
$proc = popen("sudo pihole -g", 'r');
|
||||
$proc = popen('sudo pihole -g', 'r');
|
||||
while (!feof($proc)) {
|
||||
echoEvent(fread($proc, 4096));
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user