diff --git a/inc/config.php b/inc/config.php
index 98cf1f73..0de56b20 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -75,6 +75,9 @@
// This keeps the script from querying the database and causing strain when not needed.
$config['has_installed'] = '.installed';
+ // Use syslog() for logging all error messages and unauthorized login attempts.
+ $config['syslog'] = false;
+
/*
* ====================
* Database settings
diff --git a/inc/display.php b/inc/display.php
index 655aaf22..93afd59d 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -61,10 +61,15 @@
'bottom' => '
' . $body . '
'
);
}
-
- function error($message) {
+
+ function error($message, $priority = true) {
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')) {
// Running from CLI
die('Error: ' . $message . "\n");
diff --git a/inc/functions.php b/inc/functions.php
index 602b48ab..f9b16c8a 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -124,14 +124,24 @@
_textdomain('tinyboard');
}
+
+ if($config['syslog'])
+ openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); // open a connection to sysem logger
+
if($config['recaptcha'])
require_once 'inc/contrib/recaptcha/recaptchalib.php';
if($config['cache']['enabled'])
require_once 'inc/cache.php';
}
- function basic_error_function_because_the_other_isnt_loaded_yet($message) {
- if(function_exists('sql_close')) sql_close();
+ function basic_error_function_because_the_other_isnt_loaded_yet($message, $priority = true) {
+ 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.
die('Error' .
'