mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-24 07:30:10 +01:00
syslog()
This commit is contained in:
parent
a37a14a398
commit
3e28328dc9
@ -75,6 +75,9 @@
|
|||||||
// This keeps the script from querying the database and causing strain when not needed.
|
// This keeps the script from querying the database and causing strain when not needed.
|
||||||
$config['has_installed'] = '.installed';
|
$config['has_installed'] = '.installed';
|
||||||
|
|
||||||
|
// Use syslog() for logging all error messages and unauthorized login attempts.
|
||||||
|
$config['syslog'] = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ====================
|
* ====================
|
||||||
* Database settings
|
* Database settings
|
||||||
|
@ -61,10 +61,15 @@
|
|||||||
'bottom' => '<div class="boardlist bottom">' . $body . '</div>'
|
'bottom' => '<div class="boardlist bottom">' . $body . '</div>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function error($message) {
|
function error($message, $priority = true) {
|
||||||
global $board, $mod, $config;
|
global $board, $mod, $config;
|
||||||
|
|
||||||
|
if($config['syslog'] && $priority !== false) {
|
||||||
|
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant.
|
||||||
|
_syslog($priority !== true ? $priority : LOG_NOTICE, $message);
|
||||||
|
}
|
||||||
|
|
||||||
if(defined('STDIN')) {
|
if(defined('STDIN')) {
|
||||||
// Running from CLI
|
// Running from CLI
|
||||||
die('Error: ' . $message . "\n");
|
die('Error: ' . $message . "\n");
|
||||||
|
@ -124,14 +124,24 @@
|
|||||||
_textdomain('tinyboard');
|
_textdomain('tinyboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($config['syslog'])
|
||||||
|
openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); // open a connection to sysem logger
|
||||||
|
|
||||||
if($config['recaptcha'])
|
if($config['recaptcha'])
|
||||||
require_once 'inc/contrib/recaptcha/recaptchalib.php';
|
require_once 'inc/contrib/recaptcha/recaptchalib.php';
|
||||||
if($config['cache']['enabled'])
|
if($config['cache']['enabled'])
|
||||||
require_once 'inc/cache.php';
|
require_once 'inc/cache.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
function basic_error_function_because_the_other_isnt_loaded_yet($message) {
|
function basic_error_function_because_the_other_isnt_loaded_yet($message, $priority = true) {
|
||||||
if(function_exists('sql_close')) sql_close();
|
global $config;
|
||||||
|
|
||||||
|
if($config['syslog'] && $priority !== false) {
|
||||||
|
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant.
|
||||||
|
_syslog($priority !== true ? $priority : LOG_NOTICE, $message);
|
||||||
|
}
|
||||||
|
|
||||||
// Yes, this is horrible.
|
// Yes, this is horrible.
|
||||||
die('<!DOCTYPE html><html><head><title>Error</title>' .
|
die('<!DOCTYPE html><html><head><title>Error</title>' .
|
||||||
'<style type="text/css">' .
|
'<style type="text/css">' .
|
||||||
@ -147,14 +157,18 @@
|
|||||||
if($error = error_get_last()) {
|
if($error = error_get_last()) {
|
||||||
if($error['type'] == E_ERROR) {
|
if($error['type'] == E_ERROR) {
|
||||||
if(function_exists('error')) {
|
if(function_exists('error')) {
|
||||||
error('Caught fatal error: ' . $error['message'] . ' in <strong>' . $error['file'] . '</strong> on line ' . $error['line']);
|
error('Caught fatal error: ' . $error['message'] . ' in <strong>' . $error['file'] . '</strong> on line ' . $error['line'], LOG_ERR);
|
||||||
} else {
|
} else {
|
||||||
basic_error_function_because_the_other_isnt_loaded_yet('Caught fatal error: ' . $error['message'] . ' in ' . $error['file'] . ' on line ' . $error['line']);
|
basic_error_function_because_the_other_isnt_loaded_yet('Caught fatal error: ' . $error['message'] . ' in ' . $error['file'] . ' on line ' . $error['line'], LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _syslog($priority, $message) {
|
||||||
|
syslog($priority, $message . ' - client: ' . $_SERVER['REMOTE_ADDR'] . ', request: "' . $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . '"');
|
||||||
|
}
|
||||||
|
|
||||||
function loadThemeConfig($_theme) {
|
function loadThemeConfig($_theme) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
4
mod.php
4
mod.php
@ -36,8 +36,10 @@
|
|||||||
) loginForm($config['error']['invalid'], $_POST['username'], '?' . $query);
|
) loginForm($config['error']['invalid'], $_POST['username'], '?' . $query);
|
||||||
|
|
||||||
|
|
||||||
if(!login($_POST['username'], $_POST['password']))
|
if(!login($_POST['username'], $_POST['password'])) {
|
||||||
|
_syslog(LOG_WARNING, 'Unauthorized login attempt!');
|
||||||
loginForm($config['error']['invalid'], $_POST['username'], '?' . $query);
|
loginForm($config['error']['invalid'], $_POST['username'], '?' . $query);
|
||||||
|
}
|
||||||
|
|
||||||
modLog("Logged in.");
|
modLog("Logged in.");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user