Move flush_exec to function file

This commit is contained in:
John Crisp
2021-03-18 12:55:12 +01:00
parent 5f6b7b0cb7
commit 4e0b95ace9

View File

@@ -305,3 +305,27 @@ function getOSInformation()
return null; 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", "<br>\n", $line);
$line = '';
flush();
} elseif (strlen($line) > $line_length) {
print $line."<br>\n";
$line = '';
flush();
}
}
print $line."<br>\n";
flush();
return;
}