From 5c5c16bb98ea1905b4d92cd2d044b83c3226d3b7 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Tue, 17 May 2005 04:03:48 +0000 Subject: [PATCH] Apache log integration -- updated with more options to control what is logged as username. Implemented by Patrick Li. --- config-dist.php | 8 ++++++++ lib/setup.php | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) 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); } /***