mirror of
https://github.com/pi-hole/web.git
synced 2026-07-18 12:12:09 +01:00
Add colors to debug log
- Add function and CSS to show colorful debug log - Adjusts to #output element Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -8,7 +8,7 @@ header('Cache-Control: no-cache');
|
||||
require "password.php";
|
||||
require "auth.php";
|
||||
|
||||
if(!$auth) {
|
||||
if (!$auth) {
|
||||
die("Unauthorized");
|
||||
}
|
||||
|
||||
@@ -18,22 +18,43 @@ $token = isset($_GET["token"]) ? $_GET["token"] : "";
|
||||
check_csrf($token);
|
||||
|
||||
function echoEvent($datatext) {
|
||||
$data = htmlspecialchars($datatext);
|
||||
$ANSIcolors = array(
|
||||
chr(27)."[1;91m" => '<span class="log-red">',
|
||||
chr(27)."[1;32m" => '<span class="log-green">',
|
||||
chr(27)."[1;33m" => '<span class="log-yellow">',
|
||||
chr(27)."[1;34m" => '<span class="log-blue">',
|
||||
chr(27)."[1;35m" => '<span class="log-purple">',
|
||||
chr(27)."[1;36m" => '<span class="log-cyan">',
|
||||
|
||||
if(!isset($_GET["IE"]))
|
||||
echo "data: ".implode("\ndata: ", explode("\n", $data))."\n\n";
|
||||
else
|
||||
echo $data;
|
||||
chr(27)."[90m" => '<span class="log-gray">',
|
||||
chr(27)."[91m" => '<span class="log-red">',
|
||||
chr(27)."[32m" => '<span class="log-green">',
|
||||
chr(27)."[33m" => '<span class="log-yellow">',
|
||||
chr(27)."[94m" => '<span class="log-blue">',
|
||||
chr(27)."[95m" => '<span class="log-purple">',
|
||||
chr(27)."[96m" => '<span class="log-cyan">',
|
||||
|
||||
chr(27)."[1m" => '<span class="text-bold">',
|
||||
chr(27)."[4m" => '<span class="text-underline">',
|
||||
|
||||
chr(27)."[0m" => '</span>',
|
||||
);
|
||||
|
||||
$data = str_replace(array_keys($ANSIcolors), $ANSIcolors, htmlspecialchars($datatext));
|
||||
|
||||
if (!isset($_GET["IE"])) {
|
||||
echo "data: ".implode("\ndata: ", explode("\n", $data))."\n\n";
|
||||
} else {
|
||||
echo $data;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET["upload"]))
|
||||
{
|
||||
$proc = popen("sudo pihole -d -a -w", "r");
|
||||
}
|
||||
else
|
||||
{
|
||||
$proc = popen("sudo pihole -d -w", "r");
|
||||
if (isset($_GET["upload"])) {
|
||||
$proc = popen("sudo pihole -d -a -w", "r");
|
||||
} else {
|
||||
$proc = popen("sudo pihole -d -w", "r");
|
||||
}
|
||||
|
||||
while (!feof($proc)) {
|
||||
echoEvent(fread($proc, 4096));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user