mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Adding more detailed description to the function
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -21,20 +21,20 @@ header('Cache-Control: no-cache');
|
||||
|
||||
function echoEvent($datatext)
|
||||
{
|
||||
// Detect ${OVER} and replace it with something we can safely transmit
|
||||
// "pihole -g" command uses an escape sequence to allow overwriting lines = ${OVER}
|
||||
// The ${OVER} sequence is a Carriage Return ("\r") followed by "ESC+[+K" ("\e[K")
|
||||
// This allows every line (including progress and error messages) to be shown on the page
|
||||
|
||||
// Replace "\r\e[K" ("CR+ESC+[" generated by gravity.sh) with "<------"
|
||||
// Replace ${OVER} with something we can safely transmit and use on the javascript code
|
||||
$datatext = str_replace("\r\e[K", '<------', $datatext);
|
||||
|
||||
// Replace "\r" generated by "pihole-FTL gravity parseList" command
|
||||
$datatext = str_replace("\r", '<------', $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 the "<------" string is in the middle of the line we remove everything before it
|
||||
// Example: "Pending: String to replace<------Done: String has been replaced"
|
||||
// After replacing: "<------Done: String has been replaced"
|
||||
if ($pos !== false && $pos !== 0) {
|
||||
$datatext = substr($datatext, $pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user