--- loncom/cgi/loncgi.pm 2005/04/05 20:43:27 1.2 +++ loncom/cgi/loncgi.pm 2006/09/19 21:36:31 1.8 @@ -1,7 +1,7 @@ # # LON-CAPA helpers for cgi-bin scripts # -# $Id: loncgi.pm,v 1.2 2005/04/05 20:43:27 albertel Exp $ +# $Id: loncgi.pm,v 1.8 2006/09/19 21:36:31 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,16 +52,14 @@ package LONCAPA::loncgi; use strict; use warnings FATAL=>'all'; no warnings 'uninitialized'; -use vars qw(%env); +use lib '/home/httpd/lib/perl/'; use CGI(); use CGI::Cookie(); use Fcntl qw(:flock); +use LONCAPA; use LONCAPA::Configuration(); -require Exporter; - -our @ISA = qw (Exporter); -our @EXPORT = qw(%env); +use GDBM_File; my $lonidsdir; @@ -81,7 +79,7 @@ BEGIN { Inputs: none Returns: 1 if the user has a LON-CAPA cookie 0 if not. -Loads the users environment into the %ENV hash if the cookie is correct. +Loads the users environment into the %env hash if the cookie is correct. =cut @@ -134,7 +132,7 @@ sub check_cookie { =item transfer_profile_to_env -Load the users environment into the %ENV hash. +Load the users environment into the %env hash. Inputs: $handle, the name of the users LON-CAPA cookie. @@ -146,27 +144,19 @@ Returns: undef ############################################# sub transfer_profile_to_env { my ($handle)=@_; - my @profile; - { - open(IDFILE, "<$lonidsdir/$handle.id"); - flock(IDFILE,LOCK_SH); - @profile=; - close(IDFILE); - } - foreach my $envrow (@profile) { - chomp($envrow); - my ($envname,$envvalue)=split(/=/,$envrow); - $ENV{$envname} = $envvalue; - $env{$envname} = $envvalue; + if (tie(my %disk_env,'GDBM_File',"$lonidsdir/$handle.id",&GDBM_READER(), + 0640)) { + %Apache::lonnet::env = %disk_env; + untie(%disk_env); } - $ENV{'user.environment'} = "$lonidsdir/$handle.id"; - $env{'user.environment'} = "$lonidsdir/$handle.id"; + $Apache::lonnet::env{'user.environment'} = "$lonidsdir/$handle.id"; return undef; } ############################################# ############################################# + =pod =back