Diff for /loncom/cgi/decompress.pl between versions 1.2 and 1.15

version 1.2, 2003/10/18 17:42:45 version 1.15, 2005/11/03 20:36:58
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()){  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;
  NO COOKIE!      <html><body>NO COOKIE!</body></html>
 END  END
 }  } else {
 else      print "Content-type: text/html\n\n";
 {      my $file=$Apache::lonnet::env{'cgi.file'};
  $url = $ENV{'HTTP_REFERER'};      my $dir=$Apache::lonnet::env{'cgi.dir'}; 
  $url =~ m|/{2}|;      if(! $file || ! $dir) {
  $url = $';          print(<<END);
  $url =~ m|/{1}|;          <html><body>Bad Enviroment!</body></html>
  $referer = $`;  END
  if($referer ne $ENV{'SERVER_NAME'})      } else {
  { print "Content-type: text/html\n\n";          print(<<END);
  print "You are trying something that is not allowed, go to the real homeserver and try again";   <html><body><p><b>Output of decompress:</b></p>
  }  END
  else          chdir($dir);
  {   my @cmd;
  $url = $';          if ($file =~ m|\.zip$|) {
  $url =~ m|$ENV{'user.name'}/{1}|;              @cmd = ("/usr/bin/unzip","-o");
  $url = $';          } elsif ($file =~ m|\.tar\.gz$|) {
  $url =~ m|\?{1}|;              @cmd = ("/usr/bin/tar","-zxpvf");
  $url = $`;          } elsif ($file =~ m|\.tar\.bz2$|) {
  $path ="/home/$ENV{'user.name'}/public_html/";              @cmd = ("/usr/bin/tar","-jxpvf");
  $back_path = "";          } elsif ($file =~ m|\.bz2$|) {
  while($url =~ m|/|)              @cmd = ("/usr/bin/bunzip2");
  {          } elsif ($file =~ m|\.tgz$|) {
  $path .= $`;              @cmd = ("/usr/bin/tar","-zxpvf");
  $back_path .= $`;          } elsif ($file =~ m|\.gz$|) {
  $path .= "/";      @cmd = ("/usr/bin/gunzip");
  $back_path .= "/";          } elsif ($file =~ m|\.tar$|) {
  $url = $';              @cmd = ("/usr/bin/tar","-xpvf");
  }          } else {
  chdir $path;              print("There has been an error in determining the file type of $file, please check name");
  $filename=$url;          }
  if($url =~ m|zip|){system "unzip -qq $filename &> /dev/null";}   if (@cmd) {
  elsif($url =~ m|tar.gz|){system "tar -zxpvf $filename &> /dev/null";}      undef($!);
  elsif($url =~ m|tar.bz2|){system "tar -jxpvf $filename &> /dev/null";}      undef($@);
  elsif($url =~ m|bz2|){system "bunzip2 $filename &> /dev/null";}      open(OUTPUT,"-|", @cmd, $file);
  elsif($url =~ m|tgz|){system "tar -zxpvf $filename &> /dev/null";}      while (<OUTPUT>) { print "$_<br />"; }
  elsif($url =~ m|gz|){system "gunzip $filename &> /dev/null";}      close(OUTPUT);
  elsif($url =~ m|tar|){system "tar -xpvf $filename &> /dev/null";}      print("<p><b>Decompress complete.</b></p>");
       if ($! || $@) {
    print("<p><b>An error occurred</b></p><p>$!</p><p>$@</p>");
       }
       print("</body></html>");
  }   }
       }
 }  }
 print "Content-type: text/html\n\n";  
 print '<META http-equiv="refresh" content="0; URL=';  
 print "http://$ENV{'SERVER_NAME'}/~$ENV{'user.name'}/$back_path"; print '" >';   
   
   

Removed from v.1.2  
changed lines
  Added in v.1.15


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