From 4e0b95ace90bc6a48d3aeb925028a2d02b50207d Mon Sep 17 00:00:00 2001 From: John Crisp Date: Thu, 18 Mar 2021 12:55:12 +0100 Subject: [PATCH] Move flush_exec to function file --- include/my_functions.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/my_functions.php b/include/my_functions.php index f49953c..21a906d 100644 --- a/include/my_functions.php +++ b/include/my_functions.php @@ -305,3 +305,27 @@ function getOSInformation() return null; } } + +# Used in setup +function flush_exec($command, $line_length = 200) +{ + $handle = popen("$command 2>&1", 'r'); + + $line = ''; + while (! feof($handle)) { + $chr = fread($handle, 1); + $line .= $chr; + if ($chr == "\n") { + print str_replace("\n", "
\n", $line); + $line = ''; + flush(); + } elseif (strlen($line) > $line_length) { + print $line."
\n"; + $line = ''; + flush(); + } + } + print $line."
\n"; + flush(); + return; +}