Diff for /loncom/publisher/lonupload.pm between versions 1.19 and 1.20

version 1.19, 2003/08/04 18:22:55 version 1.20, 2003/09/22 15:39:53
Line 40  use Apache::loncommon(); Line 40  use Apache::loncommon();
 use Apache::Log();  use Apache::Log();
 use Apache::lonnet;  use Apache::lonnet;
 use HTML::Entities();  use HTML::Entities();
   use Apache::lonlocal;
   
 my $DEBUG=0;  my $DEBUG=0;
   
Line 98  sub phaseone { Line 99  sub phaseone {
  '<input type=hidden name=phase value=two>'.   '<input type=hidden name=phase value=two>'.
  '<input type=hidden name=datatoken value="'.&upfile_store.'">'.   '<input type=hidden name=datatoken value="'.&upfile_store.'">'.
  '<input type=hidden name=uploaduname value="'.$uname.'">'.   '<input type=hidden name=uploaduname value="'.$uname.'">'.
  'Store uploaded file as '.   &mt('Store uploaded file as ').
  '<input type=text size=50 name=filename value="'.$fn.'"><br>'.   '<input type=text size=50 name=filename value="'.$fn.'"><br>'.
  '<input type=submit value="Store"></form>');   '<input type=submit value="'.&mt('Store').'"></form>');
       # Check for bad extension and warn user        # Check for bad extension and warn user
       if ($fn=~/\.(\w+)$/ &&         if ($fn=~/\.(\w+)$/ && 
   (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {    (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
   $r->print(    $r->print(
  '<font color=red>'.   '<font color=red>'.
  'The extension on this file, "'.$1.   &mt('The extension on this file,').' "'.$1.
  '", is reserved internally by LON-CAPA. <br \>'.   '"'.&mt(', is reserved internally by LON-CAPA.').' <br \>'.
  'Please change the extension.'.   &mt('Please change the extension.').
  '</font>');   '</font>');
       } elsif($fn=~/\.(\w+)$/ &&         } elsif($fn=~/\.(\w+)$/ && 
       !defined(&Apache::loncommon::fileembstyle($1))) {        !defined(&Apache::loncommon::fileembstyle($1))) {
   $r->print(    $r->print(
  '<font color=red>'.   '<font color=red>'.
  'The extension on this file, "'.$1.   &mt('The extension on this file,').' "'.$1.
  '", is not recognized by LON-CAPA. <br \>'.   '"'.&mt(', is not recognized by LON-CAPA.').' <br \>'.
  'Please change the extension.'.   &mt('Please change the extension.').
  '</font>');   '</font>');
       }        }
   } else {    } else {
       $r->print('<font color=red>Illegal filename.</font>');        $r->print('<font color=red>'.&mt('Illegal filename.').'</font>');
   }    }
  } else {   } else {
      $r->print('<font color=red>No upload file specified.</font>');       $r->print('<font color=red>'.&mt('No upload file specified.').'</font>');
  }   }
 }  }
   
Line 147  sub phasetwo { Line 148  sub phasetwo {
  if ((-e $target) && ($ENV{'form.override'} ne 'Yes')) {   if ((-e $target) && ($ENV{'form.override'} ne 'Yes')) {
            $r->print(             $r->print(
  '<form action=/adm/upload method=post>'.   '<form action=/adm/upload method=post>'.
  'File <tt>'.$fn.'</tt> exists. Overwrite? '.   &mt('File').' <tt>'.$fn.'</tt> '.&mt('exists. Overwrite?').' '.
  '<input type=hidden name=phase value=two>'.   '<input type=hidden name=phase value=two>'.
  '<input type=hidden name=filename value="'."$url".'">'.   '<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="'.&mt('Yes').'"></form>');
        } else {         } else {
            my $source=$r->dir_config('lonDaemons').             my $source=$r->dir_config('lonDaemons').
                              '/tmp/'.$datatoken.'.tmp';                               '/tmp/'.$datatoken.'.tmp';
Line 159  sub phasetwo { Line 160  sub phasetwo {
    if ($fn=~/\.(\w+)$/ &&      if ($fn=~/\.(\w+)$/ && 
        (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {         (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
        $r->print(         $r->print(
  'File <tt>'.$fn.'</tt> could not be copied.<br />'.   &mt('File').' <tt>'.$fn.'</tt> '.&mt('could not be copied.').'<br />'.
  '<font color=red>'.   '<font color=red>'.
  'The extension on this file is reserved internally by LON-CAPA.'.   &mt('The extension on this file is reserved internally by LON-CAPA.').
  '</font>');   '</font>');
               $r->print('<p><font size=+2><a href="'.$path.                $r->print('<p><font size=+2><a href="'.$path.
                         '">Back to Directory</a></font>');                          '">'.&mt('Back to Directory').'</a></font>');
    } elsif ($fn=~/\.(\w+)$/ &&      } elsif ($fn=~/\.(\w+)$/ && 
     !defined(&Apache::loncommon::fileembstyle($1))) {      !defined(&Apache::loncommon::fileembstyle($1))) {
        $r->print(         $r->print(
  'File <tt>'.$fn.'</tt> could not be copied.<br />'.   &mt('File').' <tt>'.$fn.'</tt> '.&mt('could not be copied.').'<br />'.
  '<font color=red>'.   '<font color=red>'.
  'The extension on this file is not recognized by LON-CAPA.'.   &mt('The extension on this file is not recognized by LON-CAPA.').
  '</font>');   '</font>');
        $r->print('<p><font size=+2><a href="'.$path.         $r->print('<p><font size=+2><a href="'.$path.
                         '">Back to Directory</a></font>');                          '">'.&mt('Back to Directory').'</a></font>');
    } elsif (-d $target) {     } elsif (-d $target) {
        $r->print(         $r->print(
  'File <tt>'.$fn.'</tt> could not be copied.<br />'.   'File <tt>'.$fn.'</tt> could not be copied.<br />'.
  '<font color=red>'.   '<font color=red>'.
  'The target is an existing directory.'.   &mt('The target is an existing directory.').
  '</font>');   '</font>');
        $r->print('<p><font size=+2><a href="'.$path.         $r->print('<p><font size=+2><a href="'.$path.
                         '">Back to Directory</a></font>');                          '">'.&mt('Back to Directory').'</a></font>');
    } 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(&mt('File copied.'));
               $r->print('<p><font size=+2><a href="'.$url.                $r->print('<p><font size=+2><a href="'.$url.
                         '">View file</a></font>');                          '">'.&mt('View file').'</a></font>');
               $r->print('<p><font size=+2><a href="'.$path.                $r->print('<p><font size=+2><a href="'.$path.
                         '">Back to Directory</a></font>');                          '">'.&mt('Back to Directory').'</a></font>');
    } else {     } else {
               $r->print('Failed to copy: '.$!);                $r->print('Failed to copy: '.$!);
               $r->print('<p><font size=+2><a href="'.$path.                $r->print('<p><font size=+2><a href="'.$path.
                         '">Back to Directory</a></font>');                          '">'.&mt('Back to Directory').'</a></font>');
    }     }
        }         }
     } else {      } else {
        $r->print(         $r->print(
    '<font size=+1 color=red>Please use browser "Back" button and pick a filename</font><p>');     '<font size=+1 color=red>'.
   &mt('Please use browser "Back" button and pick a filename').'</font><p>');
     }      }
   } else {    } else {
     $r->print(      $r->print(
    '<font size=+1 color=red>Please use browser "Back" button and pick a filename</font><p>');     '<font size=+1 color=red>'.&mt('Please use browser "Back" button and pick a filename').'</font><p>');
   }    }
 }  }
   
Line 248  sub handler { Line 250  sub handler {
 # ----------------------------------------------------------- Start page output  # ----------------------------------------------------------- Start page output
   
   
   $r->content_type('text/html');    &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;    $r->send_http_header;
   
   $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');    $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
Line 256  sub handler { Line 258  sub handler {
   $r->print(&Apache::loncommon::bodytag('Upload file to Construction Space'));    $r->print(&Apache::loncommon::bodytag('Upload file to Construction Space'));
       
   if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
           $r->print('<h3><font color=red>Co-Author: '.$uname.' at '.$udom.            $r->print('<h3><font color=red>'&mt('Co-Author').': '.$uname.
   &mt(' at ').$udom.
                '</font></h3>');                 '</font></h3>');
   }    }
   

Removed from v.1.19  
changed lines
  Added in v.1.20


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