2
0

serverLog.class.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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, 'fatal') !== false) {
  7. echo '<div class="error">' . $_log . '</div>';
  8. } elseif (stripos($_log, 'warn') !== false OR stripos($_log, 'alert') !== false) {
  9. echo '<div class="warning">' . $_log . '</div>';
  10. } elseif (stripos($_log, 'notice') !== false) {
  11. echo '<div class="notice">' . $_log . '</div>';
  12. } else {
  13. echo '<div class="grey">' . $_log . '</div>';
  14. }
  15. }
  16. public static function filtreLog(string $_log){
  17. $log = self::hidePassword($_log);
  18. self::printLog($log);
  19. }
  20. private static function ifFolderWww(string $_log){
  21. return (stripos($_log, DOCUMENT_ROOT) !== false) ? TRUE : FALSE;
  22. }
  23. private static function ifFolderDomain(string $_log){
  24. return (stripos($_log, DOMAIN_CMS) !== false) ? TRUE : FALSE;
  25. }
  26. private static function ifGeneral(string $_log){
  27. return (stripos($_log, "/var/www/") == FALSE AND stripos($_log, "https://") == FALSE) ? TRUE : FALSE;
  28. }
  29. private static function hidePassword($input) {
  30. return preg_replace("/('password'\s*=>\s*)'[^']*'/", "$1'####'", $input);
  31. }
  32. }