From faff70eb0715cf47154fbfcf13e473f66f4e6640 Mon Sep 17 00:00:00 2001 From: tracer Date: Tue, 1 Mar 2022 18:17:33 +0100 Subject: [PATCH] colorized the output of check permissions Signed-off-by: tracer --- src/Controller/DomainController.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Controller/DomainController.php b/src/Controller/DomainController.php index 089071e..b53c7a8 100644 --- a/src/Controller/DomainController.php +++ b/src/Controller/DomainController.php @@ -108,7 +108,7 @@ class DomainController echo 'Checking permission:' . PHP_EOL . PHP_EOL; $uid = posix_geteuid(); - print("UID:\t" . COLOR_YELLOW . $uid . PHP_EOL); + echo "UID:\t" . COLOR_YELLOW . $uid . PHP_EOL; $pwuid = posix_getpwuid(user_id: $uid); $name = $pwuid['name']; @@ -122,26 +122,26 @@ class DomainController } - echo 'Checking file: ' . $this->localZoneFile . PHP_EOL; + echo COLOR_DEFAULT . 'Checking ' . COLOR_YELLOW . $this->localZoneFile . PHP_EOL; $localZoneFilePermissions = fileperms(filename: $this->localZoneFile); if ($localZoneFilePermissions & 0x0010) { - echo "\t✅ Group has write access." . PHP_EOL; + echo COLOR_DEFAULT . "\t✅ Group has write access." . PHP_EOL; } else { - echo "\t❌Group needs write permission!" . PHP_EOL; + echo COLOR_RED . "\t❌Group needs write permission!" . PHP_EOL; } - echo "Checking $this->namedConfLocalFile" . PHP_EOL; + echo 'Checking ' . COLOR_YELLOW . $this->namedConfLocalFile . PHP_EOL; if ($namedConfLocal = file_get_contents(filename: $this->namedConfLocalFile)) { if (!str_contains(haystack: $namedConfLocal, needle: $this->localZoneFile)) { - echo "\t❌ $this->localZoneFile needs to be included in $this->namedConfLocalFile . " . PHP_EOL; + echo "\t❌ $this->localZoneFile" . COLOR_RED . ' needs to be included in ' . COLOR_YELLOW . $this->namedConfLocalFile . PHP_EOL; } else { - echo "\t✅ $this->localZoneFile is included in $this->namedConfLocalFile" . PHP_EOL; + echo "\t✅ $this->localZoneFile" . COLOR_DEFAULT . ' is included in ' . COLOR_YELLOW . $this->namedConfLocalFile . PHP_EOL; } } else { echo "\t❌ No access to '$this->namedConfLocalFile' . Please check permissions" . PHP_EOL; } - echo 'Checking directory: ' . $this->localZonesDir . PHP_EOL; + echo COLOR_DEFAULT . 'Checking directory: ' . COLOR_YELLOW . $this->localZonesDir . PHP_EOL; $localZoneDirPermissions = fileperms(filename: $this->localZonesDir); if ($localZoneDirPermissions & 0x0010) { echo "\t✅ Group has write access." . PHP_EOL;