Skip to content

Commit 5ac9724

Browse files
committed
Deduplicate auth logging
1 parent 8af6fa6 commit 5ac9724

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

interface/lib/app.inc.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ public function log($msg, $priority = 0) {
208208
}
209209
}
210210

211+
public function auth_log($msg) {
212+
$authlog_handle = fopen($this->_conf['ispconfig_log_dir'].'/auth.log', 'a');
213+
fwrite($authlog_handle, $msg . PHP_EOL);
214+
fclose($authlog_handle);
215+
}
216+
211217
/** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
212218
public function error($msg, $next_link = '', $stop = true, $priority = 1) {
213219
//$this->uses("error");

interface/web/login/index.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,6 @@
264264

265265
$app->plugin->raiseEvent('login', $username);
266266

267-
//* Save successfull login message to var
268-
$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s') . ' with session ID ' .session_id();
269-
$authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
270-
fwrite($authlog_handle, $authlog ."\n");
271-
fclose($authlog_handle);
272267

273268
/*
274269
* We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
@@ -321,11 +316,7 @@
321316
if($app->db->errorMessage != '') $error .= '<br />'.$app->db->errorMessage != '';
322317

323318
$app->plugin->raiseEvent('login_failed', $username);
324-
//* Save failed login message to var
325-
$authlog = 'Failed login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s');
326-
$authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
327-
fwrite($authlog_handle, $authlog ."\n");
328-
fclose($authlog_handle);
319+
$app->auth_log('Failed login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s'));
329320
}
330321
}
331322
} else {

0 commit comments

Comments
 (0)