Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.257 and 1.260

version 1.257, 2002/07/30 21:20:27 version 1.260, 2002/08/02 21:11:55
Line 712  sub ssi { Line 712  sub ssi {
   
 sub tokenwrapper {  sub tokenwrapper {
     my $uri=shift;      my $uri=shift;
     my $token=&reply('tmpput:'.&escape($uri),$perlvar{'lonHostID'});      $uri=~s/^http\:\/\/([^\/]+)//;
     return $uri.(($uri=~/\?/)?'&':'?').      $uri=~s/^\///;
  'token='.$token.'&server='.$perlvar{'lonHostID'};      $ENV{'user.environment'}=~/\/([^\/]+)\.id/;
       my $token=$1;
       if ($uri=~/^uploaded\/([^\/]+)\/([^\/]+)\/([^\/]+)(\?\.*)*$/) {
    &appenv('userfile.'.$1.'/'.$2.'/'.$3 => $ENV{'request.course.id'});
           return 'http://'.$hostname{ &homeserver($2,$1)}.'/'.$uri.
                  (($uri=~/\?/)?'&':'?').'token='.$token;
       } else {
    return '/adm/notfound.html';
       }
 }  }
           
 # --------------- Take an uploaded file and put it into the userfiles directory  # --------------- Take an uploaded file and put it into the userfiles directory
 # input: name of form element  # input: name of form element, coursedoc=1 means this is for the course
 # output: url of file in userspace  # output: url of file in userspace
   
 sub userfileupload {  sub userfileupload {
     my $formname=shift;      my ($formname,$coursedoc)=@_;
     my $fname=$ENV{'form.'.$formname.'.filename'};      my $fname=$ENV{'form.'.$formname.'.filename'};
     $fname=~s/\\/\//g;      $fname=~s/\\/\//g;
     $fname=~s/^.*\/([^\/]+)$/$1/;      $fname=~s/^.*\/([^\/]+)$/$1/;
     unless ($fname) { return 'error: no uploaded file'; }      unless ($fname) { return 'error: no uploaded file'; }
     chop($ENV{'form.'.$formname});      chop($ENV{'form.'.$formname});
     my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/';  # Create the directory if not present
       my $docuname='';
       my $docudom='';
       my $docuhome='';
       if ($coursedoc) {
    $docuname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
    $docudom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
    $docuhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
       } else {
           $docuname=$ENV{'user.name'};
           $docudom=$ENV{'user.domain'};
           $docuhome=$ENV{'user.home'};
       }
       my $path=$docudom.'/'.$docuname.'/';
       my $filepath=$perlvar{'lonDocRoot'};
       my @parts=split(/\//,$filepath.'/userfiles/'.$path);
       my $count;
       for ($count=4;$count<=$#parts;$count++) {
           $filepath.="/$parts[$count]";
           if ((-e $filepath)!=1) {
       mkdir($filepath,0777);
           }
       }
   # Save the file
       {
          my $fh=Apache::File->new('>'.$filepath.'/'.$fname);
          print $fh $ENV{'form.'.$formname};
       }
   # Notify homeserver to grep it
 #  #
 # FIXME: actually save file  # FIXME - this still needs to happen
 #  #
     return 'http;//'.$ENV{'SERVER_NAME'}.$path.$fname;      # Return the URL to it
       return '/uploaded/'.$path.$fname;    
 }  }
   
 # ------------------------------------------------------------------------- Log  # ------------------------------------------------------------------------- Log
Line 2881  sub ireceipt { Line 2918  sub ireceipt {
 }  }
   
 sub receipt {  sub receipt {
     return &ireceipt($ENV{'user.name'},$ENV{'user.domain'},    my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
                      $ENV{'request.course.id'},&symbread());    return &ireceipt($name,$domain,$courseid,$symb);
 }  }
     
 # ------------------------------------------------------------ Serves up a file  # ------------------------------------------------------------ Serves up a file
 # returns either the contents of the file or a -1  # returns either the contents of the file or a -1
 sub getfile {  sub getfile {

Removed from v.1.257  
changed lines
  Added in v.1.260


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>