version 1.1, 2003/10/18 17:16:22
|
version 1.5, 2003/11/17 23:12:12
|
Line 31
|
Line 31
|
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; |
|
|
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; |
NO COOKIE! |
<html><body>NO COOKIE!</body></html> |
END |
END |
} |
} else { |
else |
print "Content-type: text/html\n\n"; |
{ |
print "<html><head></head><body>"; |
$url = $ENV{'HTTP_REFERER'}; |
print "$ENV{'cgi.path'}"; |
$url =~ m|/{2}|; |
print "<br>$ENV{'cgi.file'}"; |
$url = $'; |
print "<br>$ENV{'user.name'}<br>"; |
$url =~ m|/{1}|; |
$path = $ENV{'cgi.path'}; |
$referer = $`; |
$path =~ m|/{1}|; |
if($referer ne $ENV{'SERVER_NAME'}) |
$path = $'; #' stupid emacs |
{ print "Content-type: text/html\n\n"; |
$path =~ m|/{1}|; |
print "You are trying something that is not allowed, go to the real homeserver and try again"; |
$path = $'; |
|
$username = $`; #Hmm, can't use the enviroment for this, if you are a co-author.. so we work around it. |
|
$path2 = "/home/$username/public_html/"; |
|
$path2 .=$path; |
|
$back_path = ""; |
|
while($path =~ m|/|) { |
|
$back_path .= $`; |
|
$back_path .= "/"; |
|
$path = $'; #' stupid emacs |
} |
} |
else |
$path = "/home/$username/public_html"; |
{ |
$path .= '/'; |
$url = $'; |
$path .= $back_path; |
$url =~ m|$ENV{'user.name'}/{1}|; |
print "<br>path: $path<br>"; |
$url = $'; |
print "back_path: $back_path <br>"; |
$url =~ m|\?{1}|; |
print "path2: $path2 <br>"; |
$url = $`; |
print "$path2<br>"; |
$path ="/home/$ENV{'user.name'}/public_html/"; |
if ( -r $path2){ |
$back_path = ""; |
print "Good read access is allowed"; |
while($url =~ m|/|) |
print "<br><br>"; |
{ |
$right = $ENV{'request.role'}; |
$path .= $`; |
$right =~ m|\.|; |
$back_path .= $`; |
$right = $`; |
$path .= "/"; |
$filename = $ENV{'cgi.file'}; |
$back_path .= "/"; |
if($right eq "ca" || $right eq "au") { |
$url = $'; |
chdir $path; |
} |
if ($filename =~ m|zip|) { |
chdir $path; |
system "unzip -qq $path2 &> /dev/null"; |
$filename=$url; |
} elsif ($filename =~ m|tar.gz|) { |
if($url =~ m|zip|){system "unzip -qq $filename &> /dev/null";} |
system "tar -zxpvf $path2 &> /dev/null"; |
elsif($url =~ m|tar.gz|){system "tar -zxpvf $filename &> /dev/null";} |
} elsif ($filename =~ m|tar.bz2|){ |
elsif($url =~ m|tar.bz2|){system "tar -jxpvf $filename &> /dev/null";} |
system "tar -jxpvf $path2 &> /dev/null"; |
elsif($url =~ m|bz2|){system "bunzip2 $filename &> /dev/null";} |
} elsif ($filename =~ m|bz2|){ |
elsif($url =~ m|tgz|){system "tar -zxpvf $filename &> /dev/null";} |
system "bunzip2 $path2 &> /dev/null"; |
elsif($url =~ m|gz|){system "gunzip $filename &> /dev/null";} |
} elsif ($filename =~ m|tgz|){ |
elsif($url =~ m|tar|){system "tar -xpvf $filename &> /dev/null";} |
system "tar -zxpvf $path2 &> /dev/null"; |
|
} elsif ($filename =~ m|gz|){ |
|
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!"; } |
|
print '<meta http-equiv="refresh" content="0; URL='; |
|
print "http://$ENV{'SERVER_NAME'}/~$username'}/$back_path"; print '" />'; |
|
print '</body></html>'; |
|
&Apache::lonnet::delenv(cgi.file); |
|
&Apache::lonnet::delenv(cgi.path); |
} |
} |
print "Content-type: text/html\n\n"; |
|
print '<META http-equiv="refresh" content="0; URL='; |
|
print "http://$ENV{'SERVER_NAME'}/priv/$ENV{'user.name'}/$back_path"; print '" target=_top>'; |
|