--- loncom/lonnet/perl/lonnet.pm 2001/08/16 11:25:03 1.149 +++ loncom/lonnet/perl/lonnet.pm 2001/08/16 16:57:31 1.150 @@ -131,7 +131,7 @@ use Apache::File; use LWP::UserAgent(); use HTTP::Headers; use vars -qw(%perlvar %hostname %homecache %spareid %hostdom %libserv %pr %prp %fe %fd $readit %metacache %packagetab); +qw(%perlvar %hostname %homecache %hostip %spareid %hostdom %libserv %pr %prp %fe %fd $readit %metacache %packagetab); use IO::Socket; use GDBM_File; use Apache::Constants qw(:common :http); @@ -661,7 +661,6 @@ sub log { # ----------------------------------------------------------- Check out an item - sub checkout { my ($symb,$tuname,$tudom,$tcrsid)=@_; my $now=time; @@ -677,9 +676,9 @@ sub checkout { $token=~s/^(\d+)\_.*\_(\d+)$/$1\*$2\*$lonhost/; $token=~tr/a-z/A-Z/; - my %infohash=('token' => $token, - 'checktime' => $now, - 'remote' => $ENV{'REMOTE_ADDR'}); + my %infohash=('outtoken' => $token, + 'checkouttime' => $now, + 'outremote' => $ENV{'REMOTE_ADDR'}); unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') { return ''; @@ -696,6 +695,28 @@ sub checkout { sub checkin { my $token=shift; + my $now=time; + my ($ta,$tb,$lonhost)=split(/\*/,$token); + $lonhost=~tr/A-Z/a-z/; + my $dtoken=$ta.'_'.$hostip{$lonhost}.'_'.$tb; + $dtoken=~s/\W/\_/g; + my ($tuname,$tudom,$tcrsid,$symb,$chtim,$rmaddr)= + split(/\&/,&unescape(&reply('tmpget:'.$dtoken,$lonhost))); + + my %infohash=('intoken' => $token, + 'checkintime' => $now, + 'inremote' => $ENV{'REMOTE_ADDR'}); + + unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') { + return ''; + } + + if (&log($tudom,$tuname,&homeserver($tuname,$tudom), + &escape('Checkin - '.$token)) ne 'ok') { + return ''; + } + + return ($symb,$tuname,$tudom,$tcrsid); } # --------------------------------------------- Set Expire Date for Spreadsheet @@ -2230,6 +2251,7 @@ if ($readit ne 'done') { my ($id,$domain,$role,$name,$ip)=split(/:/,$configline); $hostname{$id}=$name; $hostdom{$id}=$domain; + $hostip{$id}=$ip; if ($role eq 'library') { $libserv{$id}=$name; } } }