Diff for /loncom/publisher/lonupload.pm between versions 1.11 and 1.16

version 1.11, 2002/08/05 02:22:56 version 1.16, 2003/06/23 21:56:31
Line 1 Line 1
   
 # The LearningOnline Network with CAPA  # The LearningOnline Network with CAPA
 # Handler to upload files into construction space  # Handler to upload files into construction space
 #  #
Line 43 Line 44
 #  #
 # 04/05,04/09,05/25,06/23,06/24,08/22 Gerd Kortemeyer  # 04/05,04/09,05/25,06/23,06/24,08/22 Gerd Kortemeyer
 # 11/29 Matthew Hall  # 11/29 Matthew Hall
 # 12/16 Scott Harrison  
 #  #
 ###  ###
   
Line 52  package Apache::lonupload; Line 52  package Apache::lonupload;
 use strict;  use strict;
 use Apache::File;  use Apache::File;
 use File::Copy;  use File::Copy;
   use File::Basename;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;  use Apache::loncacc;
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::Log();
   use Apache::lonnet;
   use HTML::Entities();
   
   my $DEBUG=0;
   
   sub Debug {
     
     # Marshall the parameters.
     
     my $r       = shift;
     my $log     = $r->log;
     my $message = shift;
     
     # Put out the indicated message butonly if DEBUG is false.
     
     if ($DEBUG) {
       $log->debug($message);
     }
   }
   
 sub upfile_store {  sub upfile_store {
     my $r=shift;      my $r=shift;
Line 86  sub phaseone { Line 107  sub phaseone {
     $fn=~s/^\///;      $fn=~s/^\///;
     $fn=~s/(\/)+/\//g;      $fn=~s/(\/)+/\//g;
   
   #    Fn is the full path to the destination filename.
   #    
   
       &Debug($r, "Filename for upload: $fn");
     if (($fn) && ($fn!~/\/$/)) {      if (($fn) && ($fn!~/\/$/)) {
       $r->print(        $r->print(
  '<form action=/adm/upload method=post>'.   '<form action=/adm/upload method=post>'.
Line 123  sub phaseone { Line 148  sub phaseone {
   
 sub phasetwo {  sub phasetwo {
    my ($r,$fn,$uname,$udom)=@_;     my ($r,$fn,$uname,$udom)=@_;
    if ($fn=~/^\/priv\/$uname\//) {      &Debug($r, "Filename is ".$fn);
      if ($fn=~/^\/priv\/$uname\//) {
       &Debug($r, "Filename after priv substitution: ".$fn);
     my $tfn=$fn;      my $tfn=$fn;
     $tfn=~s/^\/(\~|priv)\/(\w+)//;      $tfn=~s/^\/(\~|priv)\/(\w+)//;
       &Debug($r, "Filename for tfn = ".$tfn);
     my $target='/home/'.$uname.'/public_html'.$tfn;      my $target='/home/'.$uname.'/public_html'.$tfn;
       &Debug($r, "target -> ".$target);
   #     target is the full filesystem path of the destination file.
       my $base = &File::Basename::basename($fn);
       my $path = &File::Basename::dirname($fn);
       $base    = &HTML::Entities::encode($base);
       my $url  = $path."/".$base; 
       &Debug($r, "URL is now ".$url);
     my $datatoken=$ENV{'form.datatoken'};      my $datatoken=$ENV{'form.datatoken'};
     if (($fn) && ($datatoken)) {      if (($fn) && ($datatoken)) {
  if ((-e $target) && ($ENV{'form.override'} ne 'Yes')) {   if ((-e $target) && ($ENV{'form.override'} ne 'Yes')) {
Line 134  sub phasetwo { Line 169  sub phasetwo {
  '<form action=/adm/upload method=post>'.   '<form action=/adm/upload method=post>'.
  'File <tt>'.$fn.'</tt> exists. Overwrite? '.   'File <tt>'.$fn.'</tt> exists. Overwrite? '.
  '<input type=hidden name=phase value=two>'.   '<input type=hidden name=phase value=two>'.
  '<input type=hidden name=filename value="'.$fn.'">'.   '<input type=hidden name=filename value="'."$url".'">'.
  '<input type=hidden name=datatoken value="'.$datatoken.'">'.   '<input type=hidden name=datatoken value="'.$datatoken.'">'.
  '<input type=submit name=override value="Yes"></form>');   '<input type=submit name=override value="Yes"></form>');
        } else {         } else {
Line 158  sub phasetwo { Line 193  sub phasetwo {
    } elsif (copy($source,$target)) {     } elsif (copy($source,$target)) {
        chmod(0660, $target); # Set permissions to rw-rw---.         chmod(0660, $target); # Set permissions to rw-rw---.
       $r->print('File copied.');        $r->print('File copied.');
               $r->print('<p><font size=+2><a href="'.$fn.                $r->print('<p><font size=+2><a href="'.$url.
                         '">View file</a></font>');                          '">View file</a></font>');
                 $r->print('<p><font size=+2><a href="'.$path.
                           '">Back to Directory</a></font>');
    } else {     } else {
               $r->print('Failed to copy: '.$!);                $r->print('Failed to copy: '.$!);
    }     }

Removed from v.1.11  
changed lines
  Added in v.1.16


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