mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-07-08 17:24:25 +03:00
Fix logging in cases we don't have a username yet. Also, log more stuff. Closes #104
This commit is contained in:
parent
4b5d4b02c9
commit
b91317046b
2 changed files with 10 additions and 3 deletions
|
@ -128,7 +128,6 @@ function do_db_auth($u, $p) {
|
|||
$db->close();
|
||||
|
||||
if ($userinfo and $userinfo['password'] and (crypt($p, $userinfo['password']) === $userinfo['password'])) {
|
||||
writelog('Succesful login.');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -277,11 +276,15 @@ function clearlogs() {
|
|||
writelog("Logtable truncated.");
|
||||
}
|
||||
|
||||
function writelog($line) {
|
||||
function writelog($line, $user=False) {
|
||||
global $logging;
|
||||
if ($logging !== TRUE)
|
||||
return;
|
||||
|
||||
if ($user === False) {
|
||||
$user = get_sess_user();
|
||||
}
|
||||
|
||||
try {
|
||||
$db = get_db();
|
||||
$q = $db->prepare('CREATE TABLE IF NOT EXISTS logs (
|
||||
|
@ -292,7 +295,7 @@ function writelog($line) {
|
|||
$ret = $q->execute();
|
||||
|
||||
$q = $db->prepare('INSERT INTO logs (user, log) VALUES (:user, :log)');
|
||||
$q->bindValue(':user', get_sess_user(), SQLITE3_TEXT);
|
||||
$q->bindValue(':user', $user, SQLITE3_TEXT);
|
||||
$q->bindValue(':log', $line, SQLITE3_TEXT);
|
||||
$q->execute();
|
||||
$db->close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue