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

version 1.5, 2003/11/17 23:12:12 version 1.10, 2003/11/19 20:03:39
Line 1 Line 1
 #!/usr/bin/perl  #!/usr/bin/perl
 #  #
 #   #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
   # $Id
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
 #  #
Line 28 Line 29
 # A CGI script that decompresses compressed files for mass uploading into  # A CGI script that decompresses compressed files for mass uploading into
 # construction space  # construction space
 ####  ####
   use strict;
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
 use LONCAPA::Configuration;  use LONCAPA::loncgi ();
 use LONCAPA::loncgi();  if(! &LONCAPA::loncgi::check_cookie_and_load_env()) {
 use Apache::lonnet;  
   
 if(! &LONCAPA::loncgi::check_cookie_and_load_env()){  
     print "Content-type: text/html\n\n";      print "Content-type: text/html\n\n";
     print <<END;      print <<END;
  <html><body>NO COOKIE!</body></html>      <html><body>NO COOKIE!</body></html>
 END  END
 } else {  } else {
     print "Content-type: text/html\n\n";      print "Content-type: text/html\n\n";
 print "<html><head></head><body>";      if(! $ENV{'cgi.file'} || ! $ENV{'cgi.dir'}) {
 print "$ENV{'cgi.path'}";          print <<END;
 print "<br>$ENV{'cgi.file'}";          <html><body>Bad Enviroment!</body></html>
 print "<br>$ENV{'user.name'}<br>";  END
 $path = $ENV{'cgi.path'};      } else {
 $path =~ m|/{1}|;          print <<END;
 $path = $'; #' stupid emacs   <html><body><b>Output of decompress:</b><br /><br />
 $path =~ m|/{1}|;  END
 $path = $';          chdir $ENV{'cgi.dir'};
 $username = $`; #Hmm, can't use the enviroment for this, if you are a co-author.. so we work around it.          if ($ENV{'cgi.file'} =~ m|zip|) {
 $path2 = "/home/$username/public_html/";              open(OUTPUT, "unzip $ENV{'cgi.file'} 2> /dev/null |");
 $path2 .=$path;              while (<OUTPUT>) {
 $back_path = "";                  print "$_<br />";
  while($path =~ m|/|) {              }
     $back_path .= $`;              close(OUTPUT);
     $back_path .= "/";          } elsif ($ENV{'cgi.file'} =~ m|tar.gz|) {
     $path = $'; #' stupid emacs              open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
  }              while (<OUTPUT>) {
 $path = "/home/$username/public_html";                  print "$_<br />";
 $path .= '/';              }
 $path .= $back_path;              close(OUTPUT);
 print "<br>path: $path<br>";          } elsif ($ENV{'cgi.file'} =~ m|tar.bz2|) {
 print "back_path: $back_path <br>";              open(OUTPUT, "tar -jxpvf $ENV{'cgi.file'} 2> /dev/null |");
 print "path2: $path2 <br>";              while (<OUTPUT>) {
 print "$path2<br>";                  print "$_<br />";
 if ( -r $path2){              }
 print "Good read access is allowed";              close(OUTPUT);
 print "<br><br>";          } elsif ($ENV{'cgi.file'} =~ m|bz2|) {
 $right = $ENV{'request.role'};              open(OUTPUT, "bunzip2 $ENV{'cgi.file'} 2> /dev/null |");
 $right =~ m|\.|;              while (<OUTPUT>) {
 $right = $`;                  print "$_<br />";
 $filename = $ENV{'cgi.file'};              }
 if($right eq "ca" || $right eq "au") {              close(OUTPUT);
 chdir $path;          } elsif ($ENV{'cgi.file'} =~ m|tgz|) {
 if      ($filename =~ m|zip|) {              open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
     system "unzip -qq $path2 &> /dev/null";              while (<OUTPUT>) {
  } elsif ($filename =~ m|tar.gz|) {                  print "$_<br />";
     system "tar -zxpvf $path2 &> /dev/null";              }
  } elsif ($filename =~ m|tar.bz2|){              close(OUTPUT);
    system "tar -jxpvf $path2 &> /dev/null";          } elsif ($ENV{'cgi.file'} =~ m|gz|) {
  } elsif ($filename =~ m|bz2|){              open(OUTPUT, "gunzip $ENV{'cgi.file'} 2> /dev/null |");
     system "bunzip2 $path2 &> /dev/null";              while (<OUTPUT>) {
  } elsif ($filename =~ m|tgz|){                  print "$_<br />";
     system "tar -zxpvf $path2 &> /dev/null";              }
  } elsif ($filename =~ m|gz|){              close(OUTPUT);
     system "gunzip $path2 &> /dev/null";          } elsif ($ENV{'cgi.file'} =~ m|tar|) {
  } elsif ($filename =~ m|tar|){              open(OUTPUT, "tar -xpvf $ENV{'cgi.file'} 2> /dev/null |");
     system "tar -xpvf $path2 &> /dev/null";              while (<OUTPUT>) {
  }                  print "$_<br />";
 }               }
 else {print "You don't have proper privledges";}              close(OUTPUT);
 }          } else {
 else { print "Read access not allowed!"; }              print "There has been an error in determining the file type of $ENV{'cgi.file'}, please check name";
 print '<meta http-equiv="refresh" content="0; URL=';          }
 print "http://$ENV{'SERVER_NAME'}/~$username'}/$back_path"; print '" />';          print "<br /><b>Decompress complete!</b><br /></body></html>";
 print '</body></html>';      }
 &Apache::lonnet::delenv(cgi.file);  
 &Apache::lonnet::delenv(cgi.path);  
 }  }
   

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


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