Diff for /loncom/cgi/decompress.pl between versions 1.5 and 1.6

version 1.5, 2003/11/17 23:12:12 version 1.6, 2003/11/18 04:07:49
Line 2 Line 2
 #  #
 #   # 
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
   #  
 #  #
 # 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
 ####  ####
   
   #Things still todo, 
   #It has been tabinated
   #Now uses strict! with added feature of making everything very strict!
   #about 50% through rewriting things to use split and join
   #still have a lot of debugging statements that will go away after I get it to work ok(along with all the <br>'s)
   #still have to rewrite the refresh tag to work right, its broken
   #the whole thing is broken right now
   #will rename the variables and reorder most of the script to make it more sane
   #improve the general readability of the whole thing, because unlike C everyone gets to look at it, so it has to be readable
   #will get to it tommorrow night as I have a calc test to "pass" yea, or something like that :0)
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
 use LONCAPA::Configuration;  use LONCAPA::Configuration;
 use LONCAPA::loncgi();  use LONCAPA::loncgi();
 use Apache::lonnet;  use Apache::lonnet;
   use strict; 
   
 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  END
 } else {  } else {my $username;
     print "Content-type: text/html\n\n";      print "Content-type: text/html\n\n";
 print "<html><head></head><body>";   print "<html><head></head><body>";
 print "$ENV{'cgi.path'}";   my $path = $ENV{'cgi.path'};
 print "<br>$ENV{'cgi.file'}";   $path =~ m|/{1}|;
 print "<br>$ENV{'user.name'}<br>";   $path = $'; #' stupid emacs
 $path = $ENV{'cgi.path'};   $path =~ m|/{1}|;
 $path =~ m|/{1}|;   $path = $';
 $path = $'; #' stupid emacs   my (@right) = split(/\./,$ENV{'request.role'});
 $path =~ m|/{1}|;   my $role = shift(@right);
 $path = $';   my $temp = shift(@right);
 $username = $`; #Hmm, can't use the enviroment for this, if you are a co-author.. so we work around it.   my (@left) = split(/\/+/,$temp);;
 $path2 = "/home/$username/public_html/";   shift(@left);
 $path2 .=$path;   shift(@left);
 $back_path = "";   $temp = shift(@left);
    print "temp: $temp";
    my $path2 = "/home/$username/public_html/";
    $path2 .=$path;
    my $back_path = "";
  while($path =~ m|/|) {   while($path =~ m|/|) {
     $back_path .= $`;      $back_path .= $`;
     $back_path .= "/";      $back_path .= "/";
     $path = $'; #' stupid emacs      $path = $'; #' stupid emacs
  }   }
 $path = "/home/$username/public_html";   $path .= '/';
 $path .= '/';   $path .= $back_path;
 $path .= $back_path;   print "<br>path: $path<br>";
 print "<br>path: $path<br>";   print "back_path: $back_path <br>";
 print "back_path: $back_path <br>";   print "path2: $path2 <br>";
 print "path2: $path2 <br>";   print "$path2<br>";
 print "$path2<br>";   if ( -r $path2){
 if ( -r $path2){   print "Good read access is allowed";
 print "Good read access is allowed";   print "<br><br>";
 print "<br><br>";   print "<br><br>right: $role";
 $right = $ENV{'request.role'};   my $filename = $ENV{'cgi.file'};
 $right =~ m|\.|;   if($role eq "ca" || $role eq "au") {
 $right = $`;   chdir $path;
 $filename = $ENV{'cgi.file'};   if      ($filename =~ m|zip|) {
 if($right eq "ca" || $right eq "au") {      system "unzip -qq $path2 &> /dev/null";
 chdir $path;   } elsif ($filename =~ m|tar.gz|) {
 if      ($filename =~ m|zip|) {      system "tar -zxpvf $path2 &> /dev/null";
     system "unzip -qq $path2 &> /dev/null";   } elsif ($filename =~ m|tar.bz2|){
  } elsif ($filename =~ m|tar.gz|) {     system "tar -jxpvf $path2 &> /dev/null";
     system "tar -zxpvf $path2 &> /dev/null";   } elsif ($filename =~ m|bz2|){
  } elsif ($filename =~ m|tar.bz2|){      system "bunzip2 $path2 &> /dev/null";
    system "tar -jxpvf $path2 &> /dev/null";   } elsif ($filename =~ m|tgz|){
  } elsif ($filename =~ m|bz2|){      system "tar -zxpvf $path2 &> /dev/null";
     system "bunzip2 $path2 &> /dev/null";   } elsif ($filename =~ m|gz|){
  } elsif ($filename =~ m|tgz|){      system "gunzip $path2 &> /dev/null";
     system "tar -zxpvf $path2 &> /dev/null";   } elsif ($filename =~ m|tar|){
  } elsif ($filename =~ m|gz|){      system "tar -xpvf $path2 &> /dev/null";
     system "gunzip $path2 &> /dev/null";   }
  } elsif ($filename =~ m|tar|){   } 
     system "tar -xpvf $path2 &> /dev/null";   else {print "You don't have proper privledges";}
  }   }
 }    else { print "Read access not allowed!"; }
 else {print "You don't have proper privledges";}   #print '<meta http-equiv="refresh" content="0; URL=';
 }   #print "http://$ENV{'SERVER_NAME'}/~$username'}/$back_path"; print '" />';
 else { print "Read access not allowed!"; }   print '</body></html>';
 print '<meta http-equiv="refresh" content="0; URL=';   &Apache::lonnet::delenv('cgi.file');
 print "http://$ENV{'SERVER_NAME'}/~$username'}/$back_path"; print '" />';   &Apache::lonnet::delenv('cgi.path');
 print '</body></html>';  
 &Apache::lonnet::delenv(cgi.file);  
 &Apache::lonnet::delenv(cgi.path);  
 }  }

Removed from v.1.5  
changed lines
  Added in v.1.6


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