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

version 1.5, 2003/11/17 23:12:12 version 1.14, 2005/05/25 22:31:51
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();  
 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";
     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>";      my $file=$Apache::lonnet::env{'cgi.file'};
 print "$ENV{'cgi.path'}";      my $dir=$Apache::lonnet::env{'cgi.dir'}; 
 print "<br>$ENV{'cgi.file'}";      if(! $file || ! $dir) {
 print "<br>$ENV{'user.name'}<br>";          print <<END;
 $path = $ENV{'cgi.path'};          <html><body>Bad Enviroment!</body></html>
 $path =~ m|/{1}|;  END
 $path = $'; #' stupid emacs      } else {
 $path =~ m|/{1}|;          print <<END;
 $path = $';   <html><body><b>Output of decompress:</b><br /><br />
 $username = $`; #Hmm, can't use the enviroment for this, if you are a co-author.. so we work around it.  END
 $path2 = "/home/$username/public_html/";          chdir $dir;
 $path2 .=$path;          if ($file =~ m|zip|) {
 $back_path = "";              open(OUTPUT, "unzip $file 2> /dev/null |");
  while($path =~ m|/|) {              while (<OUTPUT>) {
     $back_path .= $`;                  print "$_<br />";
     $back_path .= "/";              }
     $path = $'; #' stupid emacs              close(OUTPUT);
  }          } elsif ($file =~ m|tar.gz|) {
 $path = "/home/$username/public_html";              open(OUTPUT, "tar -zxpvf $file 2> /dev/null |");
 $path .= '/';              while (<OUTPUT>) {
 $path .= $back_path;                  print "$_<br />";
 print "<br>path: $path<br>";              }
 print "back_path: $back_path <br>";              close(OUTPUT);
 print "path2: $path2 <br>";          } elsif ($file =~ m|tar.bz2|) {
 print "$path2<br>";              open(OUTPUT, "tar -jxpvf $file 2> /dev/null |");
 if ( -r $path2){              while (<OUTPUT>) {
 print "Good read access is allowed";                  print "$_<br />";
 print "<br><br>";              }
 $right = $ENV{'request.role'};              close(OUTPUT);
 $right =~ m|\.|;          } elsif ($file =~ m|bz2|) {
 $right = $`;              open(OUTPUT, "bunzip2 $file 2> /dev/null |");
 $filename = $ENV{'cgi.file'};              while (<OUTPUT>) {
 if($right eq "ca" || $right eq "au") {                  print "$_<br />";
 chdir $path;              }
 if      ($filename =~ m|zip|) {              close(OUTPUT);
     system "unzip -qq $path2 &> /dev/null";          } elsif ($file =~ m|tgz|) {
  } elsif ($filename =~ m|tar.gz|) {              open(OUTPUT, "tar -zxpvf $file 2> /dev/null |");
     system "tar -zxpvf $path2 &> /dev/null";              while (<OUTPUT>) {
  } elsif ($filename =~ m|tar.bz2|){                  print "$_<br />";
    system "tar -jxpvf $path2 &> /dev/null";              }
  } elsif ($filename =~ m|bz2|){              close(OUTPUT);
     system "bunzip2 $path2 &> /dev/null";          } elsif ($file =~ m|gz|) {
  } elsif ($filename =~ m|tgz|){              open(OUTPUT, "gunzip $file 2> /dev/null |");
     system "tar -zxpvf $path2 &> /dev/null";              while (<OUTPUT>) {
  } elsif ($filename =~ m|gz|){                  print "$_<br />";
     system "gunzip $path2 &> /dev/null";              }
  } elsif ($filename =~ m|tar|){              close(OUTPUT);
     system "tar -xpvf $path2 &> /dev/null";          } elsif ($file =~ m|tar|) {
  }              open(OUTPUT, "tar -xpvf $file 2> /dev/null |");
 }               while (<OUTPUT>) {
 else {print "You don't have proper privledges";}                  print "$_<br />";
 }              }
 else { print "Read access not allowed!"; }              close(OUTPUT);
 print '<meta http-equiv="refresh" content="0; URL=';          } else {
 print "http://$ENV{'SERVER_NAME'}/~$username'}/$back_path"; print '" />';              print "There has been an error in determining the file type of $file, please check name";
 print '</body></html>';          }
 &Apache::lonnet::delenv(cgi.file);          print "<br /><b>Decompress complete!</b><br /></body></html>";
 &Apache::lonnet::delenv(cgi.path);      }
 }  }
   

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


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