version 1.45, 2003/05/06 21:45:25
|
version 1.48, 2003/09/20 17:44:22
|
Line 44 use Apache::Constants qw(:common :http :
|
Line 44 use Apache::Constants qw(:common :http :
|
use Apache::File; |
use Apache::File; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
|
use Apache::lonlocal; |
use CGI::Cookie(); |
use CGI::Cookie(); |
use Fcntl qw(:flock); |
use Fcntl qw(:flock); |
|
|
Line 59 sub handler {
|
Line 60 sub handler {
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
|
|
# ------------------------------------------- Transfer profile into environment |
# ------------------------------------------------------ Initialize Environment |
|
|
|
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); |
|
|
|
# --------------------------------------------------------- Initialize Language |
|
|
|
&Apache::lonlocal::get_language_handle($r); |
|
|
|
# -------------------------------------------------------------- Resource State |
|
|
my @profile; |
|
{ |
|
my $idf=Apache::File->new("$lonidsdir/$handle.id"); |
|
flock($idf,LOCK_SH); |
|
@profile=<$idf>; |
|
$idf->close(); |
|
} |
|
my $envi; |
|
for ($envi=0;$envi<=$#profile;$envi++) { |
|
chomp($profile[$envi]); |
|
my ($envname,$envvalue)=split(/=/,$profile[$envi]); |
|
$ENV{$envname} = $envvalue; |
|
} |
|
$ENV{'user.environment'} = "$lonidsdir/$handle.id"; |
|
if ($requrl=~/^\/res\//) { |
if ($requrl=~/^\/res\//) { |
$ENV{'request.state'} = "published"; |
$ENV{'request.state'} = "published"; |
} else { |
} else { |
Line 84 sub handler {
|
Line 79 sub handler {
|
|
|
# -------------------------------------------------------- Load POST parameters |
# -------------------------------------------------------- Load POST parameters |
|
|
|
&Apache::loncommon::get_posted_cgi($r); |
|
|
my $buffer; |
|
|
|
$r->read($buffer,$r->header_in('Content-length'),0); |
|
unless ($buffer=~/^(\-+\w+)\s+Content\-Disposition\:\s*form\-data/si) { |
|
my @pairs=split(/&/,$buffer); |
|
my $pair; |
|
foreach $pair (@pairs) { |
|
my ($name,$value) = split(/=/,$pair); |
|
$value =~ tr/+/ /; |
|
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
|
$name =~ tr/+/ /; |
|
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
|
&Apache::loncommon::add_to_env("form.$name",$value); |
|
} |
|
} else { |
|
my $contentsep=$1; |
|
my @lines = split (/\n/,$buffer); |
|
my $name=''; |
|
my $value=''; |
|
my $fname=''; |
|
my $fmime=''; |
|
my $i; |
|
for ($i=0;$i<=$#lines;$i++) { |
|
if ($lines[$i]=~/^$contentsep/) { |
|
if ($name) { |
|
chomp($value); |
|
if ($fname) { |
|
$ENV{"form.$name.filename"}=$fname; |
|
$ENV{"form.$name.mimetype"}=$fmime; |
|
} else { |
|
$value=~s/\s+$//s; |
|
} |
|
&Apache::loncommon::add_to_env("form.$name",$value); |
|
} |
|
if ($i<$#lines) { |
|
$i++; |
|
$lines[$i]=~ |
|
/Content\-Disposition\:\s*form\-data\;\s*name\=\"([^\"]+)\"/i; |
|
$name=$1; |
|
$value=''; |
|
if ($lines[$i]=~/filename\=\"([^\"]+)\"/i) { |
|
$fname=$1; |
|
if |
|
($lines[$i+1]=~/Content\-Type\:\s*([\w\-\/]+)/i) { |
|
$fmime=$1; |
|
$i++; |
|
} else { |
|
$fmime=''; |
|
} |
|
} else { |
|
$fname=''; |
|
$fmime=''; |
|
} |
|
$i++; |
|
} |
|
} else { |
|
$value.=$lines[$i]."\n"; |
|
} |
|
} |
|
} |
|
$ENV{'request.method'}=$ENV{'REQUEST_METHOD'}; |
|
$r->method_number(M_GET); |
|
$r->method('GET'); |
|
$r->headers_in->unset('Content-length'); |
|
|
|
# ---------------------------------------------------------------- Check access |
# ---------------------------------------------------------------- Check access |
|
|