[LON-CAPA-cvs] cvs: loncom / lontrans.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 30 Sep 2002 20:32:45 -0000


albertel		Mon Sep 30 16:32:45 2002 EDT

  Modified files:              
    /loncom	lontrans.pm 
  Log:
  - so many half assed fixes for the fact that APache doesn't do proper evaluation of the ~ for non Unix based lon-capa users could have been avoided by doin this in the first place.
  
  - Any way should make a god $r->filename for all users under all conditions, this ostensibly fixes BUG#812 (but maybe others)
  
  
Index: loncom/lontrans.pm
diff -u loncom/lontrans.pm:1.2 loncom/lontrans.pm:1.3
--- loncom/lontrans.pm:1.2	Thu Aug  8 09:45:21 2002
+++ loncom/lontrans.pm	Mon Sep 30 16:32:45 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for User Files
 #
-# $Id: lontrans.pm,v 1.2 2002/08/08 13:45:21 www Exp $
+# $Id: lontrans.pm,v 1.3 2002/09/30 20:32:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,15 +41,22 @@
     $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
     my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
     return $proname;
-} 
+}
 
 
 sub handler {
     my $r = shift;
-    unless ($r->uri=~/^\/uploaded\//) { return DECLINED; }
-    my ($dum1,$dum2,$udom,$uname,$ufile)=split(/\//,$r->uri);
-    $ufile=~s/^[\~\.]+//;
-    $r->filename(&propath($udom,$uname).'/userfiles/'.$ufile);
+    if ($r->uri=~m|^/uploaded/|) {
+	my ($dum1,$dum2,$udom,$uname,$ufile)=split(/\//,$r->uri);
+	$ufile=~s/^[\~\.]+//;
+	$r->filename(&propath($udom,$uname).'/userfiles/'.$ufile);
+    } elsif ($r->uri=~m|^/~|) {	
+	#internal authentication, needs fixup.
+	my $fn = $r->uri(); # non users do not get the full path request
+	                 # through SCRIPT_FILENAME
+	$fn=~s|^/~(\w+)|/home/$1/public_html|;
+	$r->filename($fn);
+    } else { return DECLINED; }
 }
 
 1;