Annotation of loncom/cgi/decompress.pl, revision 1.1

1.1     ! taceyjo1    1: #!/usr/bin/perl
        !             2: #
        !             3: # 
        !             4: # Copyright Michigan State University Board of Trustees
        !             5: #
        !             6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !             7: #
        !             8: # LON-CAPA is free software; you can redistribute it and/or modify
        !             9: # it under the terms of the GNU General Public License as published by
        !            10: # the Free Software Foundation; either version 2 of the License, or
        !            11: # (at your option) any later version.
        !            12: #
        !            13: # LON-CAPA is distributed in the hope that it will be useful,
        !            14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            16: # GNU General Public License for more details.
        !            17: #
        !            18: # You should have received a copy of the GNU General Public License
        !            19: # along with LON-CAPA; if not, write to the Free Software
        !            20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            21: #
        !            22: # /home/httpd/cgi-bin/decompress.pl
        !            23: #
        !            24: # http://www.lon-capa.org/
        !            25: #
        !            26: # The LearningOnline Network with CAPA
        !            27: #
        !            28: # A CGI script that decompresses compressed files for mass uploading into
        !            29: # construction space
        !            30: ####
        !            31: use lib '/home/httpd/lib/perl';
        !            32: use LONCAPA::Configuration;
        !            33: use LONCAPA::loncgi();
        !            34: 
        !            35: if(! &LONCAPA::loncgi::check_cookie_and_load_env()){
        !            36: 	print "Content-type: text/html\n\n";
        !            37: 	 print <<END;
        !            38: 	 NO COOKIE!
        !            39: END
        !            40: }
        !            41: else
        !            42: {
        !            43: 	$url = $ENV{'HTTP_REFERER'};
        !            44: 	$url =~ m|/{2}|;
        !            45: 	$url = $';
        !            46: 	$url =~ m|/{1}|;
        !            47: 	$referer = $`;
        !            48: 	if($referer ne $ENV{'SERVER_NAME'})
        !            49: 	{	print "Content-type: text/html\n\n";
        !            50: 		print "You are trying something that is not allowed, go to the real homeserver and try again";
        !            51: 	}
        !            52: 	else
        !            53: 	{
        !            54: 		$url = $';	
        !            55: 		$url =~ m|$ENV{'user.name'}/{1}|;
        !            56: 		$url = $';
        !            57: 		$url =~ m|\?{1}|;
        !            58: 		$url = $`;
        !            59: 		$path ="/home/$ENV{'user.name'}/public_html/";
        !            60: 		$back_path = "";
        !            61: 		while($url =~ m|/|)
        !            62: 		{
        !            63: 			$path .= $`;
        !            64: 			$back_path .= $`;
        !            65: 			$path .= "/";
        !            66: 			$back_path .= "/";
        !            67: 			$url = $';
        !            68: 		}
        !            69: 		chdir $path;
        !            70: 		$filename=$url;
        !            71: 		if($url =~ m|zip|){system "unzip -qq $filename &> /dev/null";}
        !            72: 		elsif($url =~ m|tar.gz|){system "tar -zxpvf $filename &> /dev/null";}
        !            73: 		elsif($url =~ m|tar.bz2|){system "tar -jxpvf $filename &> /dev/null";}
        !            74: 		elsif($url =~ m|bz2|){system "bunzip2 $filename &> /dev/null";}
        !            75: 		elsif($url =~ m|tgz|){system "tar -zxpvf $filename &> /dev/null";}
        !            76: 		elsif($url =~ m|gz|){system "gunzip $filename &> /dev/null";}
        !            77: 		elsif($url =~ m|tar|){system "tar -xpvf $filename &> /dev/null";}
        !            78: 	}
        !            79: 	
        !            80: }
        !            81: print "Content-type: text/html\n\n";
        !            82: print '<META http-equiv="refresh" content="0; URL=';
        !            83: print "http://$ENV{'SERVER_NAME'}/priv/$ENV{'user.name'}/$back_path"; print '" target=_top>';

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