Diff for /loncom/publisher/lonpublisher.pm between versions 1.267 and 1.268

version 1.267, 2010/06/02 19:09:42 version 1.268, 2011/10/22 15:16:20
Line 2087  sub handler { Line 2087  sub handler {
 # -------------------------------------------------------------- Check filename  # -------------------------------------------------------------- Check filename
   
     my $fn=&unescape($env{'form.filename'});      my $fn=&unescape($env{'form.filename'});
       ($cuname,$cudom)=&Apache::loncacc::constructaccess($fn);
   # ----------------------------------------------------- Do we have permissions?
        unless (($cuname) && ($cudom)) {
          $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
                         ' trying to publish file '.$env{'form.filename'}.
                         ' - not authorized', 
                         $r->filename); 
          return HTTP_NOT_ACCEPTABLE;
        }
   # ----------------------------------------------------------------- Get docroot
       $docroot=$r->dir_config('lonDocRoot');
   
     ($cuname,$cudom)=  
  &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));  
   
 # special publication: default.meta file  # special publication: default.meta file
     if ($fn=~/\/default.meta$/) {      if ($fn=~/\/default.meta$/) {
  return &defaultmetapublish($r,$fn,$cuname,$cudom);    return &defaultmetapublish($r,$fn,$cuname,$cudom); 
     }      }
     $fn=~s/\.meta$//;      $fn=~s/\.meta$//;
     
   # sanity test on the filename 
    
     unless ($fn) {       unless ($fn) { 
  $r->log_reason($cuname.' at '.$cudom.   $r->log_reason($cuname.' at '.$cudom.
        ' trying to publish empty filename', $r->filename);          ' trying to publish empty filename', $r->filename); 
  return HTTP_NOT_FOUND;   return HTTP_NOT_FOUND;
     }       } 
   
     unless (($cuname) && ($cudom)) {      unless (-e $docroot.$fn) { 
  $r->log_reason($cuname.' at '.$cudom.  
        ' trying to publish file '.$env{'form.filename'}.  
        ' ('.$fn.') - not authorized',   
        $r->filename);   
  return HTTP_NOT_ACCEPTABLE;  
     }  
   
     my $home=&Apache::lonnet::homeserver($cuname,$cudom);  
     my $allowed=0;  
     my @ids=&Apache::lonnet::current_machine_ids();  
     foreach my $id (@ids) { if ($id eq $home) { $allowed = 1; }  }  
     unless ($allowed) {  
  $r->log_reason($cuname.' at '.$cudom.  
        ' trying to publish file '.$env{'form.filename'}.  
        ' ('.$fn.') - not homeserver ('.$home.')',   
        $r->filename);   
  return HTTP_NOT_ACCEPTABLE;  
     }  
   
     $fn=~s{^http://[^/]+}{};  
     $fn=~s{^/~($match_username)}{/home/$1/public_html};  
   
     my $targetdir='';  
     $docroot=$r->dir_config('lonDocRoot');   
     if ($1 ne $cuname) {  
  $r->log_reason($cuname.' at '.$cudom.  
        ' trying to publish unowned file '.  
        $env{'form.filename'}.' ('.$fn.')',   
        $r->filename);   
  return HTTP_NOT_ACCEPTABLE;  
     } else {  
  $targetdir=$docroot.'/res/'.$cudom;  
     }  
                                    
     
     unless (-e $fn) {   
  $r->log_reason($cuname.' at '.$cudom.   $r->log_reason($cuname.' at '.$cudom.
        ' trying to publish non-existing file '.         ' trying to publish non-existing file '.
        $env{'form.filename'}.' ('.$fn.')',          $env{'form.filename'}.' ('.$fn.')', 
Line 2194  sub handler { Line 2169  sub handler {
                   &Apache::loncommon::CSTR_pageheader()) # FIXME crumbs broken?                    &Apache::loncommon::CSTR_pageheader()) # FIXME crumbs broken?
     );      );
   
       my $thisdisfn=&HTML::Entities::encode($fn,'<>&"');
     my $thisfn=$fn;      my $thistarget=$fn;
       $thistarget=~s/^\/priv\//\/res\//;
     my $thistarget=$thisfn;      my $thisdistarget=&HTML::Entities::encode($thistarget,'<>&"');
         
     $thistarget=~s/^\/home/$targetdir/;  
     $thistarget=~s/\/public\_html//;  
   
     my $thisdistarget=$thistarget;  
     $thisdistarget=~s/^\Q$docroot\E//;  
   
     my $thisdisfn=$thisfn;  
     $thisdisfn=~s/^\/home\/\Q$cuname\E\/public_html\///;  
   
     if ($fn=~/\/$/) {      if ($fn=~/\/$/) {
 # -------------------------------------------------------- This is a directory  # -------------------------------------------------------- This is a directory
  &publishdirectory($r,$fn,$thisdisfn);   &publishdirectory($r,$fn,$thisdisfn);
  $r->print('<hr /><a href="/priv/'   $r->print('<hr /><a href="'.$thisdisfn.'">'.&mt('Return to Directory').'</a>');
   .$cuname.'/'.$thisdisfn  
   .'">'.&mt('Return to Directory').'</a>');  
   
   
     } else {      } else {
 # ---------------------- Evaluate individual file, and then output information.  # ---------------------- Evaluate individual file, and then output information.
  $thisfn=~/\.(\w+)$/;   $fn=~/\.(\w+)$/;
  my $thistype=$1;   my $thistype=$1;
  my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);   my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
         if ($thistype eq 'page') {  $thisembstyle = 'rat'; }          if ($thistype eq 'page') {  $thisembstyle = 'rat'; }
Line 2242  sub handler { Line 2204  sub handler {
                  .'<tt>'                   .'<tt>'
                  );                   );
  $r->print(<<ENDCAPTION);   $r->print(<<ENDCAPTION);
 <a href='javascript:void(window.open("/~$cuname/$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>  <a href='javascript:void(window.open("$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>
 $thisdisfn</a>  $thisdisfn</a>
 ENDCAPTION  ENDCAPTION
         $r->print('</tt>'          $r->print('</tt>'
Line 2265  ENDCAPTION Line 2227  ENDCAPTION
             $r->print(&Apache::lonhtmlcommon::row_closure()              $r->print(&Apache::lonhtmlcommon::row_closure()
                      .&Apache::lonhtmlcommon::row_title(&mt('Diffs')));                       .&Apache::lonhtmlcommon::row_title(&mt('Diffs')));
     $r->print(<<ENDDIFF);      $r->print(<<ENDDIFF);
 <a href='javascript:void(window.open("/adm/diff?filename=/~$cuname/$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>  <a href='javascript:void(window.open("/adm/diff?filename=$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>
 ENDDIFF  ENDDIFF
             $r->print(&mt('Diffs with Current Version').'</a>');              $r->print(&mt('Diffs with Current Version').'</a>');
  }   }
Line 2274  ENDDIFF Line 2236  ENDDIFF
                  .&Apache::lonhtmlcommon::end_pick_box()                   .&Apache::lonhtmlcommon::end_pick_box()
                  );                   );
       
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.  # ---------------------- Publishing from $fn to $thistarget with $thisembstyle.
   
  unless ($env{'form.phase'} eq 'two') {   unless ($env{'form.phase'} eq 'two') {
 # ---------------------------------------------------------- Parse for problems  # ---------------------------------------------------------- Parse for problems
     my ($warningcount,$errorcount);      my ($warningcount,$errorcount);
     if ($thisembstyle eq 'ssi') {      if ($thisembstyle eq 'ssi') {
  ($warningcount,$errorcount)=&checkonthis($r,$thisfn);   ($warningcount,$errorcount)=&checkonthis($r,$fn);
     }      }
     unless ($errorcount) {      unless ($errorcount) {
  my ($outstring,$error)=   my ($outstring,$error)=
     &publish($thisfn,$thistarget,$thisembstyle);      &publish($fn,$thistarget,$thisembstyle);
  $r->print($outstring);   $r->print($outstring);
     } else {      } else {
  $r->print('<h3 class="LC_error">'.   $r->print('<h3 class="LC_error">'.
Line 2292  ENDDIFF Line 2254  ENDDIFF
   '</h3>');    '</h3>');
     }      }
  } else {   } else {
     &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget);       &phasetwo($r,$fn,$thistarget,$thisembstyle,$thisdistarget); 
  }   }
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());

Removed from v.1.267  
changed lines
  Added in v.1.268


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