lychee/php/modules/Log.php

37 lines
847 B
PHP
Raw Normal View History

2014-05-06 19:22:56 +00:00
<?php
###
# @name Log Module
# @author Tobias Reich
# @copyright 2014 by Tobias Reich
###
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
class Log extends Module {
public static function error($database, $function, $line, $text = '') {
# Check dependencies
Module::dependencies(isset($database, $function, $line, $text));
# Get time
$sysstamp = time();
# Escape
$function = mysqli_real_escape_string($database, $function);
$line = mysqli_real_escape_string($database, $line);
$text = mysqli_real_escape_string($database, $text);
# Save in database
$query = "INSERT INTO lychee_log (time, type, function, line, text) VALUES ('$sysstamp', 'error', '$function', '$line', '$text');";
$result = $database->query($query);
if (!$result) return false;
return $database->insert_id;
}
}
?>