2014-05-19 16:40:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
###
|
2015-03-29 16:56:08 +00:00
|
|
|
# @name Display Log Plugin
|
|
|
|
# @author Tobias Reich
|
|
|
|
# @copyright 2015 by Tobias Reich
|
2014-05-19 16:40:33 +00:00
|
|
|
# @description This file queries the database for log messages and displays them if present.
|
|
|
|
###
|
|
|
|
|
|
|
|
# Location
|
|
|
|
$lychee = __DIR__ . '/../../';
|
|
|
|
|
|
|
|
# Load requirements
|
|
|
|
require($lychee . 'php/define.php');
|
|
|
|
require($lychee . 'php/autoload.php');
|
|
|
|
require($lychee . 'php/modules/misc.php');
|
|
|
|
|
|
|
|
# Set content
|
|
|
|
header('content-type: text/plain');
|
|
|
|
|
|
|
|
# Load config
|
|
|
|
if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error 001: Configuration not found. Please install Lychee first.');
|
|
|
|
require(LYCHEE_CONFIG_FILE);
|
|
|
|
|
2014-08-29 22:01:42 +00:00
|
|
|
# Define the table prefix
|
2014-09-04 19:22:58 +00:00
|
|
|
if (!isset($dbTablePrefix)) $dbTablePrefix = '';
|
2014-08-29 22:01:42 +00:00
|
|
|
defineTablePrefix($dbTablePrefix);
|
|
|
|
|
2014-05-19 16:40:33 +00:00
|
|
|
# Declare
|
|
|
|
$result = '';
|
|
|
|
|
|
|
|
# Database
|
|
|
|
$database = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);
|
|
|
|
|
2014-05-21 09:39:36 +00:00
|
|
|
if (mysqli_connect_errno()!=0) {
|
2014-05-19 16:40:33 +00:00
|
|
|
echo 'Error 100: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '' . PHP_EOL;
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Result
|
2014-08-30 05:22:44 +00:00
|
|
|
$query = Database::prepare($database, "SELECT FROM_UNIXTIME(time), type, function, line, text FROM ?", array(LYCHEE_TABLE_LOG));
|
2014-08-29 22:01:42 +00:00
|
|
|
$result = $database->query($query);
|
2014-05-19 16:40:33 +00:00
|
|
|
|
|
|
|
# Output
|
2014-08-29 22:01:42 +00:00
|
|
|
if ($result->num_rows===0) {
|
|
|
|
|
2014-05-19 16:40:33 +00:00
|
|
|
echo('Everything looks fine, Lychee has not reported any problems!' . PHP_EOL . PHP_EOL);
|
2014-08-29 22:01:42 +00:00
|
|
|
|
2014-05-19 16:40:33 +00:00
|
|
|
} else {
|
2014-08-29 22:01:42 +00:00
|
|
|
|
|
|
|
while($row = $result->fetch_row()) {
|
2014-05-19 16:40:33 +00:00
|
|
|
|
|
|
|
# Encode result before printing
|
2014-05-21 09:39:36 +00:00
|
|
|
$row = array_map("htmlentities", $row);
|
2014-05-19 16:40:33 +00:00
|
|
|
|
|
|
|
# Format: time TZ - type - function(line) - text
|
2014-05-21 09:39:36 +00:00
|
|
|
printf ("%s %s - %s - %s (%s) \t- %s\n", $row[0], date_default_timezone_get(), $row[1], $row[2], $row[3], $row[4]);
|
2014-08-29 22:01:42 +00:00
|
|
|
|
2014-05-19 16:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|