serverLog.class.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. class serverLog {
  3. public static function printLog(string $_log){
  4. if (stripos($_log, 'error') !== false) {
  5. echo '<div class="error">' . $_log . '</div>';
  6. } elseif (stripos($_log, 'warn') !== false) {
  7. echo '<div class="warning">' . $_log . '</div>';
  8. } elseif (stripos($_log, 'notice') !== false) {
  9. echo '<div class="notice">' . $_log . '</div>';
  10. } else {
  11. echo '<div>' . $_log . '</div>';
  12. }
  13. }
  14. public static function filtreLog(string $_log){
  15. if(self::ifFolderWww($_log)){
  16. self::printLog($_log);
  17. } elseif(self::ifFolderDomain($_log)){
  18. self::printLog($_log);
  19. } elseif(self::ifGeneral($_log)){
  20. self::printLog($_log);
  21. }
  22. }
  23. private static function ifFolderWww(string $_log){
  24. return (stripos($_log, DOCUMENT_ROOT) !== false) ? TRUE : FALSE;
  25. }
  26. private static function ifFolderDomain(string $_log){
  27. return (stripos($_log, DOMAIN_CMS) !== false) ? TRUE : FALSE;
  28. }
  29. private static function ifGeneral(string $_log){
  30. return (stripos($_log, "/var/www/") == FALSE AND stripos($_log, "https://") == FALSE) ? TRUE : FALSE;
  31. }
  32. }