tame1 has asked for the wisdom of the Perl Monks concerning the following question:
I followed a small tutorial and was able to modify my Apache to
write accesses to one certain directory into a database, by makeing a
Apache::MyAccess.pm.
Everything is fine, accept one small thing: I cannot seem to grab the environment variable REMOTE_USER no matter what method I use.
I know for a fact that it is set, as I had to enter a username/pass combo just to access the directory I am logging.
Here is the code I am using:
Can anyone tell me why the $query->remote_user() is failing? The other three fields get written to the database just fine. Only the remote_user is always blank.
What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"
Everything is fine, accept one small thing: I cannot seem to grab the environment variable REMOTE_USER no matter what method I use.
I know for a fact that it is set, as I had to enter a username/pass combo just to access the directory I am logging.
Here is the code I am using:
package Apache::TaartsLog; use CGI qw(:cgi); use Apache (); use Apache::Constants qw(:common &OPT_EXECCGI &REDIRECT); use DBI; my $query = new CGI(); $dbh = DBI->connect("dbi:mysql:taarts","jrobiso2","") || die "$DBI::er +rstr: $!\n"; sub handler { my $r = shift; # @_[0] contains a reference to # the current request handler my ($request); my ($hostname); # Returns a blessed reference if ($r->main) { # unless this is the main request $orig = $r->main; } else { $orig = $r; } $hostname = $orig->get_remote_host; $request = $orig->filename; $user = $query->remote_user(); # this apparently fails. unless (($request =~ /jpg/) || ($request =~ /gif/)) { $dbh->do("insert into logs (host,request,time_stamp,cdsid) +VALUES ('$hostname','$request',NOW(),'$user')"); } } END { undef($dbh); } 1;
Can anyone tell me why the $query->remote_user() is failing? The other three fields get written to the database just fine. Only the remote_user is always blank.
What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Apache Modules
by larryl (Monk) on Mar 13, 2001 at 00:32 UTC | |
by tame1 (Pilgrim) on Mar 13, 2001 at 00:42 UTC | |
by larryl (Monk) on Mar 13, 2001 at 00:51 UTC | |
by tame1 (Pilgrim) on Mar 13, 2001 at 01:02 UTC | |
by btrott (Parson) on Mar 13, 2001 at 00:43 UTC | |
Re: Apache Modules
by larryl (Monk) on Mar 13, 2001 at 00:21 UTC | |
Re: Apache Modules
by LunaticLeo (Scribe) on Mar 14, 2001 at 01:40 UTC |
Back to
Seekers of Perl Wisdom