Diff for /loncom/cgi/decompress.pl between versions 1.3 and 1.9

version 1.3, 2003/10/20 15:51:51 version 1.9, 2003/11/19 20:03:05
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;
  <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}|;      if(! $ENV{'cgi.file'} || ! $ENV{'cgi.dir'}) {
     $url = $'; #' stupid emacs          print <<END;
     $url =~ m|/{1}|;          <html><body>Bad Enviroment!</body></html>
     $referer = $`;  END
     if($referer ne $ENV{'SERVER_NAME'}) {  
  print "Content-type: text/html\n\n";  
  print "<html><body>You are trying something that is not allowed, go to the real homeserver and try again</body></html>";  
     } else {      } else {
  $url = $'; #' stupid emacs          print <<END;
  $url =~ m|$ENV{'user.name'}/{1}|;   <html><body><b>Output of decompress:</b><br /><br />
  $url = $'; #' stupid emacs  END
  $url =~ m|\?{1}|;          chdir $ENV{'cgi.dir'};
  $url = $`;          if ($ENV{'cgi.file'} =~ m|zip|) {
  $path ="/home/$ENV{'user.name'}/public_html/";              open(OUTPUT, "unzip $ENV{'cgi.file'} 2> /dev/null |");
  $back_path = "";              while (<OUTPUT>) {
  while($url =~ m|/|) {                  print "$_<br />";
     $path .= $`;              }
     $back_path .= $`;              close(TRACE);
     $path .= "/";          } elsif ($ENV{'cgi.file'} =~ m|tar.gz|) {
     $back_path .= "/";              open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
     $url = $'; #' stupid emacs              while (<OUTPUT>) {
  }                  print "$_<br />";
  chdir $path;              }
  $filename=$url;              close(TRACE);
  if      ($url =~ m|zip|) {          } elsif ($ENV{'cgi.file'} =~ m|tar.bz2|) {
     system "unzip -qq $filename &> /dev/null";              open(OUTPUT, "tar -jxpvf $ENV{'cgi.file'} 2> /dev/null |");
  } elsif ($url =~ m|tar.gz|) {              while (<OUTPUT>) {
     system "tar -zxpvf $filename &> /dev/null";                  print "$_<br />";
  } elsif ($url =~ m|tar.bz2|){              }
     system "tar -jxpvf $filename &> /dev/null";              close(TRACE);
  } elsif ($url =~ m|bz2|){          } elsif ($ENV{'cgi.file'} =~ m|bz2|) {
     system "bunzip2 $filename &> /dev/null";              open(OUTPUT, "bunzip2 $ENV{'cgi.file'} 2> /dev/null |");
  } elsif ($url =~ m|tgz|){              while (<OUTPUT>) {
     system "tar -zxpvf $filename &> /dev/null";                  print "$_<br />";
  } elsif ($url =~ m|gz|){              }
     system "gunzip $filename &> /dev/null";              close(TRACE);
  } elsif ($url =~ m|tar|){          } elsif ($ENV{'cgi.file'} =~ m|tgz|) {
     system "tar -xpvf $filename &> /dev/null";              open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
  }              while (<OUTPUT>) {
                   print "$_<br />";
               }
               close(TRACE);
           } elsif ($ENV{'cgi.file'} =~ m|gz|) {
               open(OUTPUT, "gunzip $ENV{'cgi.file'} 2> /dev/null |");
               while (<OUTPUT>) {
                   print "$_<br />";
               }
               close(TRACE);
           } elsif ($ENV{'cgi.file'} =~ m|tar|) {
               open(OUTPUT, "tar -xpvf $ENV{'cgi.file'} 2> /dev/null |");
               while (<OUTPUT>) {
                   print "$_<br />";
               }
               close(TRACE);
           } else {
               print "There has been an error in determining the file type of $ENV{'cgi.file'}, please check name";
           }
           print "<br /><b>Decompress complete!</b><br /></body></html>";
     }      }
 }  }
 print "Content-type: text/html\n\n";  
 print '<html><head>'  
 print '<meta http-equiv="refresh" content="0; URL=';  
 print "http://$ENV{'SERVER_NAME'}/~$ENV{'user.name'}/$back_path"; print '" />';  
 print '</head></html>';  

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


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