Log.php 847 B

12345678910111213141516171819202122232425262728293031323334353637
  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 error($database, $function, $line, $text = '') {
  10. # Check dependencies
  11. Module::dependencies(isset($database, $function, $line, $text));
  12. # Get time
  13. $sysstamp = time();
  14. # Escape
  15. $function = mysqli_real_escape_string($database, $function);
  16. $line = mysqli_real_escape_string($database, $line);
  17. $text = mysqli_real_escape_string($database, $text);
  18. # Save in database
  19. $query = "INSERT INTO lychee_log (time, type, function, line, text) VALUES ('$sysstamp', 'error', '$function', '$line', '$text');";
  20. $result = $database->query($query);
  21. if (!$result) return false;
  22. return $database->insert_id;
  23. }
  24. }
  25. ?>