Diff for /loncom/cgi/decompress.pl between versions 1.4 and 1.8

version 1.4, 2003/10/20 22:38:28 version 1.8, 2003/11/19 15:07:25
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
   }
   else
   {
       print "Content-type: text/html\n\n";
       if(! $ENV{'cgi.file'} || ! $ENV{'cgi.dir'})
       {
           print <<END;
           <html><body>Bad Enviroment!</body></html>
   END
       }
       else
       {
           print <<END;
    <html><body><b>Output of decompress:</b><br /><br />
 END  END
 } else {          chdir $ENV{'cgi.dir'};
     $url = $ENV{'HTTP_REFERER'};          if ($ENV{'cgi.file'} =~ m|zip|)
     $url =~ m|/{2}|;          {
     $url = $'; #' stupid emacs              open(OUTPUT, "unzip $ENV{'cgi.file'} 2> /dev/null |");
     $url =~ m|/{1}|;              while (<OUTPUT>)
     $referer = $`;              {
     if($referer ne $ENV{'SERVER_NAME'}) {                  print "$_<br />";
  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>";              close(TRACE);
     } else {          }
  $url = $'; #' stupid emacs          elsif ($ENV{'cgi.file'} =~ m|tar.gz|)
  $url =~ m|$ENV{'user.name'}/{1}|;          {
  $url = $'; #' stupid emacs              open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
  $url =~ m|\?{1}|;              while (<OUTPUT>)
  $url = $`;              {
  $path ="/home/$ENV{'user.name'}/public_html/";                  print "$_<br />";
  $back_path = "";              }
  while($url =~ m|/|) {              close(TRACE);
     $path .= $`;          }
     $back_path .= $`;          elsif ($ENV{'cgi.file'} =~ m|tar.bz2|)
     $path .= "/";          {
     $back_path .= "/";              open(OUTPUT, "tar -jxpvf $ENV{'cgi.file'} 2> /dev/null |");
     $url = $'; #' stupid emacs              while (<OUTPUT>)
  }              {
  chdir $path;                  print "$_<br />";
  $filename=$url;              }
  if      ($url =~ m|zip|) {              close(TRACE);
     system "unzip -qq $filename &> /dev/null";          }
  } elsif ($url =~ m|tar.gz|) {          elsif ($ENV{'cgi.file'} =~ m|bz2|)
     system "tar -zxpvf $filename &> /dev/null";          {
  } elsif ($url =~ m|tar.bz2|){              open(OUTPUT, "bunzip2 $ENV{'cgi.file'} 2> /dev/null |");
     system "tar -jxpvf $filename &> /dev/null";              while (<OUTPUT>)
  } elsif ($url =~ m|bz2|){              {
     system "bunzip2 $filename &> /dev/null";                  print "$_<br />";
  } elsif ($url =~ m|tgz|){              }
     system "tar -zxpvf $filename &> /dev/null";              close(TRACE);
  } elsif ($url =~ m|gz|){          }
     system "gunzip $filename &> /dev/null";          elsif ($ENV{'cgi.file'} =~ m|tgz|)
  } elsif ($url =~ m|tar|){          {
     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.4  
changed lines
  Added in v.1.8


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