diff --git a/config-dist.php b/config-dist.php index 39e270292f5..c5ed8cf10c8 100644 --- a/config-dist.php +++ b/config-dist.php @@ -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 diff --git a/lib/setup.php b/lib/setup.php index af2a774c531..af22b7702d4 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -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); } /***