Diff for /loncom/publisher/loncleanup.pm between versions 1.1 and 1.3

version 1.1, 2005/05/28 01:32:33 version 1.3, 2005/05/28 18:53:50
Line 208  sub symbolfontreplace { Line 208  sub symbolfontreplace {
 }  }
   
 sub htmlclean {  sub htmlclean {
     my ($raw,$full)=@_;      my ($raw,$full,$blocklinefeed,$blockemptytags,$blocklowercasing,$blockdesymboling)=@_;
 # Take care of CRLF etc  # Take care of CRLF etc
       unless ($blocklinefeed) {
     $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs;   $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs;
     $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs;   $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs;
     $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs;   $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs;
     $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs;   $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs;
       }
 # Generate empty tags, remove wrong end tags  # Generate empty tags, remove wrong end tags
     $raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis;      unless ($blockemptytags) {
     $raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis;   $raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis;
     unless ($full) {   $raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis;
        $raw=~s/\<[\/]*(body|head|html)\>//gis;   unless ($full) {
       $raw=~s/\<[\/]*(body|head|html)\>//gis;
    }
     }      }
 # Make standard tags lowercase  # Make standard tags lowercase
     foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',      unless ($blocklowercasing) {
              'table','tr','td','th','p','br','hr','img','embed','font',   foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',
              'a','strong','center','title','basefont','li','ol','ul',   'table','tr','td','th','p','br','hr','img','embed','font',
              'input','select','form','option','script','pre') {   'a','strong','center','title','basefont','li','ol','ul',
  $raw=~s/\<$_\s*\>/\<$_\>/gis;   'input','select','form','option','script','pre') {
         $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;      $raw=~s/\<$_\s*\>/\<$_\>/gis;
         $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;      $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;
       $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;
    }
       }
   # Replace <font face="symbol">
       unless ($blockdesymboling) {
    $raw=&symbolfontreplace($raw);
     }      }
     return $raw;      return $raw;
 }  }
   
 sub phaseone {  sub phaseone {
       my ($r,$fn,$uname,$udom)=@_;
 }  }
   
 sub phasetwo {  sub phasetwo {
       my ($r,$fn,$uname,$udom)=@_;
   }
   
   sub phasethree {
       my ($r,$fn,$uname,$udom)=@_;
 }  }
   
 # ---------------------------------------------------------------- Main Handler  # ---------------------------------------------------------------- Main Handler
 sub handler {  sub handler {
   
   my $r=shift;      my $r=shift;
   
   
 # Get query string for limited number of parameters  # Get query string for limited number of parameters
   
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
   ['filename']);      ['filename']);
   
       if ($env{'form.filename'}) {
    $fn=$env{'form.filename'};
    $fn=~s/^http\:\/\/[^\/]+//;
       } else {
    $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
          ' unspecified filename for cleanup', $r->filename); 
    return HTTP_NOT_FOUND;
       }
   
   if ($env{'form.filename'}) {      unless ($fn) { 
       $fn=$env{'form.filename'};   $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
       $fn=~s/^http\:\/\/[^\/]+//;         ' trying to cleanup non-existing file', $r->filename); 
   } else {   return HTTP_NOT_FOUND;
      $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.      } 
          ' unspecified filename for cleanup', $r->filename);   
      return HTTP_NOT_FOUND;  
   }  
   
   unless ($fn) {   
      $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.  
          ' trying to cleanup non-existing file', $r->filename);   
      return HTTP_NOT_FOUND;  
   }   
   
 # ----------------------------------------------------------- Start page output  # ----------------------------------------------------------- Start page output
   my $uname;      my $uname;
   my $udom;      my $udom;
   
   ($uname,$udom)=      ($uname,$udom)=
     &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));   &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
   unless (($uname) && ($udom)) {      unless (($uname) && ($udom)) {
      $r->log_reason($uname.' at '.$udom.   $r->log_reason($uname.' at '.$udom.
          ' trying to cleanup file '.$env{'form.filename'}.         ' trying to cleanup file '.$env{'form.filename'}.
          ' ('.$fn.') - not authorized',          ' ('.$fn.') - not authorized', 
          $r->filename);          $r->filename); 
      return HTTP_NOT_ACCEPTABLE;   return HTTP_NOT_ACCEPTABLE;
   }      }
   
   $fn=~s/\/\~(\w+)//;      $fn=~s/\/\~(\w+)//;
   
   &Apache::loncommon::content_type($r,'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>');
   
   $r->print(&Apache::loncommon::bodytag('Cleanup XML Document'));      $r->print(&Apache::loncommon::bodytag('Cleanup XML Document'));
   
   if ($env{'form.phase'} eq 'two') {      if ($env{'form.phase'} eq 'three') {
       &phasetwo($r,$fn,$uname,$udom);   &phasethree($r,$fn,$uname,$udom);
   } else {      } elsif ($env{'form.phase'} eq 'two') {
       &phaseone($r,$fn,$uname,$udom);   &phasetwo($r,$fn,$uname,$udom);
   }      } else {
    &phaseone($r,$fn,$uname,$udom);
       }
   
   $r->print('</body></html>');      $r->print('</body></html>');
   return OK;        return OK;  
 }  }
   
 1;  1;

Removed from v.1.1  
changed lines
  Added in v.1.3


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