Apache log integration -- updated with more options to control what is logged as username. Implemented by Patrick Li.

This commit is contained in:
martinlanghoff 2005-05-17 04:03:48 +00:00
parent 2fa17f9c41
commit 5c5c16bb98
2 changed files with 22 additions and 2 deletions

View File

@ -248,6 +248,14 @@ $CFG->admin = 'admin';
// entry in apache error log indicating the position of the error and the statement
// called. This option will action disregarding error_reporting setting.
// $CFG->dblogerror = true;
//
// The following setting will turn on username logging into Apache log. For full details regarding setting
// up of this function please refer to the install section of the document.
// $CFG->apacheloguser = 0; // Turn this feature off. Default value.
// $CFG->apacheloguser = 1; // Log user id.
// $CFG->apacheloguser = 2; // Log full name in cleaned format. ie, Darth Vader will be displayed as darth_vader.
// $CFG->apacheloguser = 3; // Log username. CAUTION: Use of this value will expose usernames in the Apache log,
// If you are going to publish your log in any cases, this will be a BIG security problem.
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser

View File

@ -411,8 +411,20 @@ global $THEME;
/// Apache log intergration. In apache conf file one can use ${MOODULEUSER}n in
/// LogFormat to get the current logged in username in moodle.
if ($USER && function_exists('apache_note')) {
apache_note('MOODLEUSER', $USER->username);
if ($USER && function_exists('apache_note') && !empty($CFG->apacheloguser)) {
switch ($CFG->apacheloguser) {
case 3:
$logname = clean_filename($USER->username);
break;
case 2:
$logname = clean_filename($USER->firstname." ".$USER->lastname);
break;
case 1:
default:
$logname = $USER->id;
break;
}
apache_note('MOODLEUSER', $logname);
}
/***