Log.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. ###
  3. # @name Log Module
  4. # @author Tobias Reich
  5. # @copyright 2014 by Tobias Reich
  6. ###
  7. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  8. class Log extends Module {
  9. public static function notice($database, $function, $line, $text = '') {
  10. return Log::text($database, 'notice', $function, $line, $text);
  11. }
  12. public static function warning($database, $function, $line, $text = '') {
  13. return Log::text($database, 'warning', $function, $line, $text);
  14. }
  15. public static function error($database, $function, $line, $text = '') {
  16. return Log::text($database, 'error', $function, $line, $text);
  17. }
  18. public static function text($database, $type, $function, $line, $text = '') {
  19. # Check dependencies
  20. Module::dependencies(isset($database, $type, $function, $line, $text));
  21. # Get time
  22. $sysstamp = time();
  23. # Escape
  24. $type = mysqli_real_escape_string($database, $type);
  25. $function = mysqli_real_escape_string($database, $function);
  26. $line = mysqli_real_escape_string($database, $line);
  27. $text = mysqli_real_escape_string($database, $text);
  28. # Save in database
  29. $query = "INSERT INTO lychee_log (time, type, function, line, text) VALUES ('$sysstamp', '$type', '$function', '$line', '$text');";
  30. $result = $database->query($query);
  31. if (!$result) return false;
  32. return true;
  33. }
  34. }
  35. ?>