File:  [LON-CAPA] / loncom / cgi / decompress.pl
Revision 1.12: download - view: text, annotated - select for diffs
Wed Jun 9 19:04:47 2004 UTC (19 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, HEAD
- large number of roles would blow up the system call. (BUG#3044)

    1: #!/usr/bin/perl
    2: #
    3: #
    4: # Copyright Michigan State University Board of Trustees
    5: # $Id
    6: #
    7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: #
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/cgi-bin/decompress.pl
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: # The LearningOnline Network with CAPA
   28: #
   29: # A CGI script that decompresses compressed files for mass uploading into
   30: # construction space
   31: ####
   32: use strict;
   33: use lib '/home/httpd/lib/perl';
   34: use LONCAPA::loncgi ();
   35: my %origENV=%ENV;
   36: if(! &LONCAPA::loncgi::check_cookie_and_load_env()) {
   37:     print "Content-type: text/html\n\n";
   38:     print <<END;
   39:     <html><body>NO COOKIE!</body></html>
   40: END
   41: } else {
   42:     print "Content-type: text/html\n\n";
   43:     my $file=$ENV{'cgi.file'};
   44:     my $dir=$ENV{'cgi.dir'}; 
   45:     %ENV=%origENV;
   46:     if(! $file || ! $dir) {
   47:         print <<END;
   48:         <html><body>Bad Enviroment!</body></html>
   49: END
   50:     } else {
   51:         print <<END;
   52: 	<html><body><b>Output of decompress:</b><br /><br />
   53: END
   54:         chdir $dir;
   55:         if ($file =~ m|zip|) {
   56:             open(OUTPUT, "unzip $file 2> /dev/null |");
   57:             while (<OUTPUT>) {
   58:                 print "$_<br />";
   59:             }
   60:             close(OUTPUT);
   61:         } elsif ($file =~ m|tar.gz|) {
   62:             open(OUTPUT, "tar -zxpvf $file 2> /dev/null |");
   63:             while (<OUTPUT>) {
   64:                 print "$_<br />";
   65:             }
   66:             close(OUTPUT);
   67:         } elsif ($file =~ m|tar.bz2|) {
   68:             open(OUTPUT, "tar -jxpvf $file 2> /dev/null |");
   69:             while (<OUTPUT>) {
   70:                 print "$_<br />";
   71:             }
   72:             close(OUTPUT);
   73:         } elsif ($file =~ m|bz2|) {
   74:             open(OUTPUT, "bunzip2 $file 2> /dev/null |");
   75:             while (<OUTPUT>) {
   76:                 print "$_<br />";
   77:             }
   78:             close(OUTPUT);
   79:         } elsif ($file =~ m|tgz|) {
   80:             open(OUTPUT, "tar -zxpvf $file 2> /dev/null |");
   81:             while (<OUTPUT>) {
   82:                 print "$_<br />";
   83:             }
   84:             close(OUTPUT);
   85:         } elsif ($file =~ m|gz|) {
   86:             open(OUTPUT, "gunzip $file 2> /dev/null |");
   87:             while (<OUTPUT>) {
   88:                 print "$_<br />";
   89:             }
   90:             close(OUTPUT);
   91:         } elsif ($file =~ m|tar|) {
   92:             open(OUTPUT, "tar -xpvf $file 2> /dev/null |");
   93:             while (<OUTPUT>) {
   94:                 print "$_<br />";
   95:             }
   96:             close(OUTPUT);
   97:         } else {
   98:             print "There has been an error in determining the file type of $file, please check name";
   99:         }
  100:         print "<br /><b>Decompress complete!</b><br /></body></html>";
  101:     }
  102: }
  103: 

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