From b779a67e60e85f3d7218badabaae24ab65afb6e4 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Wed, 9 Oct 2013 15:58:05 +0200 Subject: [PATCH] create sql-error.log file for database errors so support/debugging will be easier Signed-off-by: Michael Kaufmann (d00p) --- lib/classes/database/class.db.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/classes/database/class.db.php b/lib/classes/database/class.db.php index 915f4d9d..2e6193eb 100644 --- a/lib/classes/database/class.db.php +++ b/lib/classes/database/class.db.php @@ -367,7 +367,21 @@ class db openlog("Froxlor", LOG_NDELAY, LOG_USER); syslog(LOG_ERR, $text . "; $md5"); closelog(); - die("We are sorry, but a MySQL - error occurred. The administrator may find more information in syslog with the ID $md5"); + + /** + * log to a file, so we can actually ask people for the error + * (no one seems to find the stuff in the syslog) + */ + $sl_dir = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__))))."/logs/"); + if (!file_exists($sl_dir)) { + @mkdir($sl_dir, 0755); + } + $sl_file = makeCorrectFile($sl_dir."/sql-error.log"); + $sqllog = @fopen($sl_file, 'a'); + @fwrite($sqllog, date('d.m.Y H:i', time())." --- ".$text."\n"); + @fclose($sqllog); + + die("We are sorry, but a MySQL - error occurred. The administrator may find more information in syslog with the ID ".$md5." or in the sql-error.log in the logs/ directory"); } }