Diff for /loncom/publisher/loncfile.pm between versions 1.31 and 1.35

version 1.31, 2003/06/19 20:49:13 version 1.35, 2003/08/01 20:32:05
Line 92  use Apache::Constants qw(:common :http : Line 92  use Apache::Constants qw(:common :http :
 use Apache::loncacc;  use Apache::loncacc;
 use Apache::Log ();  use Apache::Log ();
 use Apache::lonnet;  use Apache::lonnet;
   use Apache::loncommon();
   
 my $DEBUG=0;  my $DEBUG=0;
 my $r; # Needs to be global for some stuff RF.  my $r; # Needs to be global for some stuff RF.
Line 172  Global References Line 173  Global References
 sub URLToPath {  sub URLToPath {
   my $Url = shift;    my $Url = shift;
   &Debug($r, "UrlToPath got: $Url");    &Debug($r, "UrlToPath got: $Url");
   $Url=~ s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;  
   $Url=~ s/^http\:\/\/[^\/]+//;    $Url=~ s/^http\:\/\/[^\/]+//;
     $Url=~ s/^\///;
     $Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//;
   &Debug($r, "Returning $Url \n");    &Debug($r, "Returning $Url \n");
   return $Url;    return $Url;
 }  }
Line 387  sub checksuffix { Line 389  sub checksuffix {
     }      }
     return $result;      return $result;
 }  }
   
   sub cleanDest {
       my ($request,$dest)=@_;
       #remove bad characters
       if  ($dest=~/[\#\?&]/) {
    $request->print("<p><font color=\"red\">Invalid characters in requested name have been removed.</font></p>");
    $dest=~s/[\#\?&]//g;
       }
       return $dest;
   }
   
 =pod  =pod
   
 =item CloseForm1($request, $user, $file)  =item CloseForm1($request, $user, $file)
Line 778  sub NewFile1 { Line 791  sub NewFile1 {
  }   }
     }      }
   
     #remove bad characters  
     if  ($newfilename=~/[\#\?&]/) {  
  $request->print("<p><font color=\"red\">Invalid characters in requested filename have been removed.</font></p>");  
  $newfilename=~s/[\#\?&]//g;  
     }  
   
     my $fullpath = $dir.'/'.$newfilename;      my $fullpath = $dir.'/'.$newfilename;
   
     &Debug($request, "Full path is : ".$fullpath);      &Debug($request, "Full path is : ".$fullpath);
Line 842  sub phaseone { Line 849  sub phaseone {
       
   #  my $conspace=ConstructionPathFromRelative($uname, $fn);    #  my $conspace=ConstructionPathFromRelative($uname, $fn);
       
       $ENV{'form.newfilename'}=&cleanDest($r,$ENV{'form.newfilename'});
   
   $r->print('<form action="/adm/cfile" method="post">'.    $r->print('<form action="/adm/cfile" method="post">'.
     '<input type="hidden" name="filename" value="/~'.$uname.$fn.'" />'.      '<input type="hidden" name="filename" value="/~'.$uname.$fn.'" />'.
     '<input type="hidden" name="phase" value="two" />'.      '<input type="hidden" name="phase" value="two" />'.
Line 872  sub phaseone { Line 880  sub phaseone {
     $ENV{'form.action'} eq 'newproblemfile' ||      $ENV{'form.action'} eq 'newproblemfile' ||
             $ENV{'form.action'} eq 'newpagefile' ||              $ENV{'form.action'} eq 'newpagefile' ||
             $ENV{'form.action'} eq 'newsequencefile' ||              $ENV{'form.action'} eq 'newsequencefile' ||
               $ENV{'form.action'} eq 'newrightsfile' ||
               $ENV{'form.action'} eq 'newstyfile' ||
             $ENV{'form.action'} eq 'Select Action') {              $ENV{'form.action'} eq 'Select Action') {
       if($ENV{'form.newfilename'}) {        if($ENV{'form.newfilename'}) {
   my $newfilename = $ENV{'form.newfilename'};    my $newfilename = $ENV{'form.newfilename'};
Line 1232  sub handler { Line 1242  sub handler {
   
   if ($ENV{'form.filename'}) {    if ($ENV{'form.filename'}) {
       $fn=&Apache::lonnet::unescape($ENV{'form.filename'});        $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
       &Debug($r, "loncfile::handler - raw url: $fn");        $fn=&URLToPath($fn);
 #      $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;  
 #      $fn=~s/^http\:\/\/[^\/]+//;  
       $fn=URLToPath($fn);  
       &Debug($r, "loncfile::handler - doctored url: $fn");  
   
   } else {    } else {
       &Debug($r, "loncfile::handler - no form.filename");        &Debug($r, "loncfile::handler - no form.filename");
      $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.       $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
Line 1276  sub handler { Line 1281  sub handler {
   
   $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');    $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
   
   $r->print(    $r->print(&Apache::loncommon::bodytag('File Operation'));
    '<body bgcolor="#FFFFFF"><img align="right" src="/adm/lonIcons/lonlogos.gif" />');  
   
       
   $r->print('<h1>Construction Space <tt>'.$fn.'</tt></h1>');    $r->print('<h1>Construction Space <tt>'.$fn.'</tt></h1>');
Line 1303  sub handler { Line 1307  sub handler {
    $ENV{'form.action'} eq 'newproblemfile' ||     $ENV{'form.action'} eq 'newproblemfile' ||
            $ENV{'form.action'} eq 'newpagefile' ||             $ENV{'form.action'} eq 'newpagefile' ||
            $ENV{'form.action'} eq 'newsequencefile' ||             $ENV{'form.action'} eq 'newsequencefile' ||
      $ENV{'form.action'} eq 'newrightsfile' ||
      $ENV{'form.action'} eq 'newstyfile' ||
            $ENV{'form.action'} eq 'Select Action' ) {             $ENV{'form.action'} eq 'Select Action' ) {
       $r->print('<h3>New Resource</h3>');        $r->print('<h3>New Resource</h3>');
   } else {    } else {

Removed from v.1.31  
changed lines
  Added in v.1.35


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