Annotation of loncom/cgi/decompress.pl, revision 1.8
1.1 taceyjo1 1: #!/usr/bin/perl
2: #
1.7 taceyjo1 3: #
1.1 taceyjo1 4: # Copyright Michigan State University Board of Trustees
1.8 ! 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.7 taceyjo1 32: use strict;
1.1 taceyjo1 33: use lib '/home/httpd/lib/perl';
1.7 taceyjo1 34: use LONCAPA::loncgi ();
35: if(! &LONCAPA::loncgi::check_cookie_and_load_env())
36: {
1.3 albertel 37: print "Content-type: text/html\n\n";
38: print <<END;
1.7 taceyjo1 39: <html><body>NO COOKIE!</body></html>
1.3 albertel 40: END
1.5 taceyjo1 41: }
1.7 taceyjo1 42: else
43: {
44: print "Content-type: text/html\n\n";
45: if(! $ENV{'cgi.file'} || ! $ENV{'cgi.dir'})
46: {
47: print <<END;
48: <html><body>Bad Enviroment!</body></html>
49: END
50: }
51: else
52: {
53: print <<END;
54: <html><body><b>Output of decompress:</b><br /><br />
55: END
56: chdir $ENV{'cgi.dir'};
57: if ($ENV{'cgi.file'} =~ m|zip|)
58: {
59: open(OUTPUT, "unzip $ENV{'cgi.file'} 2> /dev/null |");
60: while (<OUTPUT>)
61: {
62: print "$_<br />";
63: }
64: close(TRACE);
65: }
66: elsif ($ENV{'cgi.file'} =~ m|tar.gz|)
67: {
68: open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
69: while (<OUTPUT>)
70: {
71: print "$_<br />";
72: }
73: close(TRACE);
74: }
75: elsif ($ENV{'cgi.file'} =~ m|tar.bz2|)
76: {
77: open(OUTPUT, "tar -jxpvf $ENV{'cgi.file'} 2> /dev/null |");
78: while (<OUTPUT>)
79: {
80: print "$_<br />";
81: }
82: close(TRACE);
83: }
84: elsif ($ENV{'cgi.file'} =~ m|bz2|)
85: {
86: open(OUTPUT, "bunzip2 $ENV{'cgi.file'} 2> /dev/null |");
87: while (<OUTPUT>)
88: {
89: print "$_<br />";
90: }
91: close(TRACE);
92: }
93: elsif ($ENV{'cgi.file'} =~ m|tgz|)
94: {
95: open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
96: while (<OUTPUT>)
97: {
98: print "$_<br />";
99: }
100: close(TRACE);
101: }
102: elsif ($ENV{'cgi.file'} =~ m|gz|)
103: {
104: open(OUTPUT, "gunzip $ENV{'cgi.file'} 2> /dev/null |");
105: while (<OUTPUT>)
106: {
107: print "$_<br />";
108: }
109: close(TRACE);
110: }
111: elsif ($ENV{'cgi.file'} =~ m|tar|)
112: {
113: open(OUTPUT, "tar -xpvf $ENV{'cgi.file'} 2> /dev/null |");
114: while (<OUTPUT>)
115: {
116: print "$_<br />";
117: }
118: close(TRACE);
119: }
120: else
121: {
122: print "There has been an error in determining the file type of $ENV{'cgi.file'}, please check name";
123: }
124: print "<br /><b>Decompress complete!</b><br /></body></html>";
125: }
126: }
127:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>