Annotation of loncom/cgi/decompress.pl, revision 1.7
1.1 taceyjo1 1: #!/usr/bin/perl
2: #
1.7 ! taceyjo1 3: #
1.1 taceyjo1 4: # Copyright Michigan State University Board of Trustees
1.7 ! taceyjo1 5: # $Id:
1.1 taceyjo1 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: ####
1.6 taceyjo1 32:
1.7 ! taceyjo1 33: #Things still todo,
1.6 taceyjo1 34: #It has been tabinated
35: #Now uses strict! with added feature of making everything very strict!
36: #about 50% through rewriting things to use split and join
37: #still have a lot of debugging statements that will go away after I get it to work ok(along with all the <br>'s)
38: #still have to rewrite the refresh tag to work right, its broken
39: #the whole thing is broken right now
40: #will rename the variables and reorder most of the script to make it more sane
41: #improve the general readability of the whole thing, because unlike C everyone gets to look at it, so it has to be readable
1.7 ! taceyjo1 42: use strict;
1.1 taceyjo1 43: use lib '/home/httpd/lib/perl';
1.7 ! taceyjo1 44: use LONCAPA::loncgi ();
! 45: if(! &LONCAPA::loncgi::check_cookie_and_load_env())
! 46: {
1.3 albertel 47: print "Content-type: text/html\n\n";
48: print <<END;
1.7 ! taceyjo1 49: <html><body>NO COOKIE!</body></html>
1.3 albertel 50: END
1.5 taceyjo1 51: }
1.7 ! taceyjo1 52: else
! 53: {
! 54: print "Content-type: text/html\n\n";
! 55: if(! $ENV{'cgi.file'} || ! $ENV{'cgi.dir'})
! 56: {
! 57: print <<END;
! 58: <html><body>Bad Enviroment!</body></html>
! 59: END
! 60: }
! 61: else
! 62: {
! 63: print <<END;
! 64: <html><body><b>Output of decompress:</b><br /><br />
! 65: END
! 66: chdir $ENV{'cgi.dir'};
! 67: if ($ENV{'cgi.file'} =~ m|zip|)
! 68: {
! 69: open(OUTPUT, "unzip $ENV{'cgi.file'} 2> /dev/null |");
! 70: while (<OUTPUT>)
! 71: {
! 72: print "$_<br />";
! 73: }
! 74: close(TRACE);
! 75: }
! 76: elsif ($ENV{'cgi.file'} =~ m|tar.gz|)
! 77: {
! 78: open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
! 79: while (<OUTPUT>)
! 80: {
! 81: print "$_<br />";
! 82: }
! 83: close(TRACE);
! 84: }
! 85: elsif ($ENV{'cgi.file'} =~ m|tar.bz2|)
! 86: {
! 87: open(OUTPUT, "tar -jxpvf $ENV{'cgi.file'} 2> /dev/null |");
! 88: while (<OUTPUT>)
! 89: {
! 90: print "$_<br />";
! 91: }
! 92: close(TRACE);
! 93: }
! 94: elsif ($ENV{'cgi.file'} =~ m|bz2|)
! 95: {
! 96: open(OUTPUT, "bunzip2 $ENV{'cgi.file'} 2> /dev/null |");
! 97: while (<OUTPUT>)
! 98: {
! 99: print "$_<br />";
! 100: }
! 101: close(TRACE);
! 102: }
! 103: elsif ($ENV{'cgi.file'} =~ m|tgz|)
! 104: {
! 105: open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
! 106: while (<OUTPUT>)
! 107: {
! 108: print "$_<br />";
! 109: }
! 110: close(TRACE);
! 111: }
! 112: elsif ($ENV{'cgi.file'} =~ m|gz|)
! 113: {
! 114: open(OUTPUT, "gunzip $ENV{'cgi.file'} 2> /dev/null |");
! 115: while (<OUTPUT>)
! 116: {
! 117: print "$_<br />";
! 118: }
! 119: close(TRACE);
! 120: }
! 121: elsif ($ENV{'cgi.file'} =~ m|tar|)
! 122: {
! 123: open(OUTPUT, "tar -xpvf $ENV{'cgi.file'} 2> /dev/null |");
! 124: while (<OUTPUT>)
! 125: {
! 126: print "$_<br />";
! 127: }
! 128: close(TRACE);
! 129: }
! 130: else
! 131: {
! 132: print "There has been an error in determining the file type of $ENV{'cgi.file'}, please check name";
! 133: }
! 134: print "<br /><b>Decompress complete!</b><br /></body></html>";
! 135: }
! 136: }
! 137:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>