[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm /interface loncommon.pm rat lonambiguous.pm lonpageflip.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 18 Aug 2006 20:24:56 -0000


albertel		Fri Aug 18 16:24:56 2006 EDT

  Modified files:              
    /rat	lonambiguous.pm lonpageflip.pm 
    /loncom/auth	lonlogin.pm 
    /loncom/interface	loncommon.pm 
  Log:
  - move to using a sub as more location are going to need fixing.
  - navigation thorugh a course with https:// works
  
  
Index: rat/lonambiguous.pm
diff -u rat/lonambiguous.pm:1.19 rat/lonambiguous.pm:1.20
--- rat/lonambiguous.pm:1.19	Sun Mar 19 18:09:07 2006
+++ rat/lonambiguous.pm	Fri Aug 18 16:24:53 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to resolve ambiguous file locations
 #
-# $Id: lonambiguous.pm,v 1.19 2006/03/19 23:09:07 albertel Exp $
+# $Id: lonambiguous.pm,v 1.20 2006/08/18 20:24:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -95,7 +95,7 @@
 				           $resurl => [$resurl,$resid]);
                  untie(%bighash);
                  $r->header_out(Location => 
-                                'http://'.$ENV{'HTTP_HOST'}.$resurl);
+				&Apache::loncommon::absolute_url().$resurl);
                  return REDIRECT;
              }
 	  }
@@ -134,7 +134,7 @@
 # ----------------------------------- Okay, this should have appeared on a page
 	   &Apache::loncommon::content_type($r,'text/html');
            $r->header_out(Location => 
-			  'http://'.$ENV{'HTTP_HOST'}.
+			  &Apache::loncommon::absolute_url().
 			  &Apache::lonnet::clutter($page));
            return REDIRECT;
        } else {
@@ -146,7 +146,8 @@
 # ------------------------------------Encrypted requests go straight to navmaps
    if ($env{'request.enc'}) {
        &Apache::loncommon::content_type($r,'text/html');
-       $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.'/adm/navmaps');
+       $r->header_out(Location => 
+		      &Apache::loncommon::absolute_url().'/adm/navmaps');
        return REDIRECT;
    }
 # ------------------------------------------------ Would be standalone resource
@@ -178,9 +179,9 @@
 		my $mapurl=$bighash{'map_id_'.(split(/\./,$id))[0]};
 		my $symb=&make_symb($id);
 		&Apache::loncommon::content_type($r,'text/html');
-		&Apache::lonnet::logthis('http://'.$ENV{'HTTP_HOST'}.$resurl.'?symb='.$symb);
 		$r->header_out(Location => 
-			   'http://'.$ENV{'HTTP_HOST'}.$resurl.'?symb='.$symb);
+			       &Apache::loncommon::absolute_url().
+			       $resurl.'?symb='.$symb);
 		return REDIRECT;
 	    }
             if ($#possibilities>0) {
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.69 rat/lonpageflip.pm:1.70
--- rat/lonpageflip.pm:1.69	Tue May 30 15:47:40 2006
+++ rat/lonpageflip.pm	Fri Aug 18 16:24:53 2006
@@ -2,7 +2,7 @@
 #
 # Page flip handler
 #
-# $Id: lonpageflip.pm,v 1.69 2006/05/30 19:47:40 www Exp $
+# $Id: lonpageflip.pm,v 1.70 2006/08/18 20:24:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
 use LONCAPA;
 use Apache::Constants qw(:common :http REDIRECT);
 use Apache::lonnet;
+use Apache::loncommon();
 use HTML::TokeParser;
 use GDBM_File;
 
@@ -256,7 +257,7 @@
 	  my $furl=&first_accessible_resource();
 	  &Apache::loncommon::content_type($r,'text/html');
 	  $r->header_out(Location => 
-			 'http://'.$ENV{'HTTP_HOST'}.$furl);
+			 &Apache::loncommon::absolute_url().$furl);
 	     
 	  return REDIRECT;
       }
@@ -290,7 +291,7 @@
 	 } else {
 	     &Apache::loncommon::content_type($r,'text/html');
 	     $r->header_out(Location => 
-			    'http://'.$ENV{'HTTP_HOST'}.$newloc);
+			    &Apache::loncommon::absolute_url().$newloc);
 	     
 	     return REDIRECT;
 	 }
@@ -313,7 +314,8 @@
 	     if ($direction eq 'return') {
 		 &Apache::loncommon::content_type($r,'text/html');
 		 $r->header_out(Location => 
-				'http://'.$ENV{'HTTP_HOST'}.'/adm/noidea.html');
+				&Apache::loncommon::absolute_url().
+				'/adm/noidea.html');
 		 return REDIRECT;
 	     } else {
 		 &navlaunch($r);
@@ -415,7 +417,7 @@
 		  }
 
 		  &Apache::loncommon::content_type($r,'text/html');
-		  my $url='http://'.$ENV{'HTTP_HOST'}.$redirecturl;
+		  my $url=&Apache::loncommon::absolute_url().$redirecturl;
 		  $url = &add_get_param($url, { 'symb' => $redirectsymb});
                   $r->header_out(Location => $url);
                   return REDIRECT;
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.77 loncom/auth/lonlogin.pm:1.78
--- loncom/auth/lonlogin.pm:1.77	Fri Aug 18 13:44:44 2006
+++ loncom/auth/lonlogin.pm	Fri Aug 18 16:24:53 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.77 2006/08/18 17:44:44 albertel Exp $
+# $Id: lonlogin.pm,v 1.78 2006/08/18 20:24:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -163,8 +163,7 @@
     my $userloadpercent=&Apache::lonnet::userload();
 
 # ------------------------------------------------------- Do the load balancing
-    my $otherserver=
-	($ENV{'SERVER_PORT'} == 443?'https://':'HTTP://').$host_name;
+    my $otherserver= &Apache::loncommon::absolute_url($host_name);
     my $firsturl=
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
 # ---------------------------------------- Are we access server and overloaded?
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.445 loncom/interface/loncommon.pm:1.446
--- loncom/interface/loncommon.pm:1.445	Thu Aug 17 18:35:52 2006
+++ loncom/interface/loncommon.pm	Fri Aug 18 16:24:54 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.445 2006/08/17 22:35:52 albertel Exp $
+# $Id: loncommon.pm,v 1.446 2006/08/18 20:24:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5921,6 +5921,15 @@
     return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;
 }
 
+sub absolute_url {
+    my ($host_name) = @_;
+    my $protocol = ($ENV{'SERVER_PORT'} == 443?'https://':'http://');
+    if ($host_name eq '') {
+	$host_name = $ENV{'SERVER_NAME'};
+    }
+    return $protocol.$host_name;
+}
+
 sub connection_aborted {
     my ($r)=@_;
     $r->print(" ");$r->rflush();