Diff for /loncom/cgi/decompress.pl between versions 1.4 and 1.5

version 1.4, 2003/10/20 22:38:28 version 1.5, 2003/11/17 23:12:12
Line 31 Line 31
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
 use LONCAPA::Configuration;  use LONCAPA::Configuration;
 use LONCAPA::loncgi();  use LONCAPA::loncgi();
   use Apache::lonnet;
   
 if(! &LONCAPA::loncgi::check_cookie_and_load_env()){  if(! &LONCAPA::loncgi::check_cookie_and_load_env()){
     print "Content-type: text/html\n\n";      print "Content-type: text/html\n\n";
Line 38  if(! &LONCAPA::loncgi::check_cookie_and_ Line 39  if(! &LONCAPA::loncgi::check_cookie_and_
  <html><body>NO COOKIE!</body></html>   <html><body>NO COOKIE!</body></html>
 END  END
 } else {  } else {
     $url = $ENV{'HTTP_REFERER'};      print "Content-type: text/html\n\n";
     $url =~ m|/{2}|;  print "<html><head></head><body>";
     $url = $'; #' stupid emacs  print "$ENV{'cgi.path'}";
     $url =~ m|/{1}|;  print "<br>$ENV{'cgi.file'}";
     $referer = $`;  print "<br>$ENV{'user.name'}<br>";
     if($referer ne $ENV{'SERVER_NAME'}) {  $path = $ENV{'cgi.path'};
  print "Content-type: text/html\n\n";  $path =~ m|/{1}|;
  print "<html><body>You are trying something that is not allowed, go to the real homeserver and try again</body></html>";  $path = $'; #' stupid emacs
     } else {  $path =~ m|/{1}|;
  $url = $'; #' stupid emacs  $path = $';
  $url =~ m|$ENV{'user.name'}/{1}|;  $username = $`; #Hmm, can't use the enviroment for this, if you are a co-author.. so we work around it.
  $url = $'; #' stupid emacs  $path2 = "/home/$username/public_html/";
  $url =~ m|\?{1}|;  $path2 .=$path;
  $url = $`;  $back_path = "";
  $path ="/home/$ENV{'user.name'}/public_html/";   while($path =~ m|/|) {
  $back_path = "";  
  while($url =~ m|/|) {  
     $path .= $`;  
     $back_path .= $`;      $back_path .= $`;
     $path .= "/";  
     $back_path .= "/";      $back_path .= "/";
     $url = $'; #' stupid emacs      $path = $'; #' stupid emacs
  }   }
  chdir $path;  $path = "/home/$username/public_html";
  $filename=$url;  $path .= '/';
  if      ($url =~ m|zip|) {  $path .= $back_path;
     system "unzip -qq $filename &> /dev/null";  print "<br>path: $path<br>";
  } elsif ($url =~ m|tar.gz|) {  print "back_path: $back_path <br>";
     system "tar -zxpvf $filename &> /dev/null";  print "path2: $path2 <br>";
  } elsif ($url =~ m|tar.bz2|){  print "$path2<br>";
     system "tar -jxpvf $filename &> /dev/null";  if ( -r $path2){
  } elsif ($url =~ m|bz2|){  print "Good read access is allowed";
     system "bunzip2 $filename &> /dev/null";  print "<br><br>";
  } elsif ($url =~ m|tgz|){  $right = $ENV{'request.role'};
     system "tar -zxpvf $filename &> /dev/null";  $right =~ m|\.|;
  } elsif ($url =~ m|gz|){  $right = $`;
     system "gunzip $filename &> /dev/null";  $filename = $ENV{'cgi.file'};
  } elsif ($url =~ m|tar|){  if($right eq "ca" || $right eq "au") {
     system "tar -xpvf $filename &> /dev/null";  chdir $path;
   if      ($filename =~ m|zip|) {
       system "unzip -qq $path2 &> /dev/null";
    } elsif ($filename =~ m|tar.gz|) {
       system "tar -zxpvf $path2 &> /dev/null";
    } elsif ($filename =~ m|tar.bz2|){
      system "tar -jxpvf $path2 &> /dev/null";
    } elsif ($filename =~ m|bz2|){
       system "bunzip2 $path2 &> /dev/null";
    } elsif ($filename =~ m|tgz|){
       system "tar -zxpvf $path2 &> /dev/null";
    } elsif ($filename =~ m|gz|){
       system "gunzip $path2 &> /dev/null";
    } elsif ($filename =~ m|tar|){
       system "tar -xpvf $path2 &> /dev/null";
  }   }
     }  } 
   else {print "You don't have proper privledges";}
 }  }
 print "Content-type: text/html\n\n";  else { print "Read access not allowed!"; }
 print '<html><head>';  
 print '<meta http-equiv="refresh" content="0; URL=';  print '<meta http-equiv="refresh" content="0; URL=';
 print "http://$ENV{'SERVER_NAME'}/~$ENV{'user.name'}/$back_path"; print '" />';  print "http://$ENV{'SERVER_NAME'}/~$username'}/$back_path"; print '" />';
 print '</head></html>';  print '</body></html>';
   &Apache::lonnet::delenv(cgi.file);
   &Apache::lonnet::delenv(cgi.path);
   }

Removed from v.1.4  
changed lines
  Added in v.1.5


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