[LON-CAPA-cvs] cvs: loncom /auth lonauth.pm lonlogin.pm /cgi takeoffline.pl takeonline.pl

www lon-capa-cvs@mail.lon-capa.org
Thu, 11 Sep 2003 20:54:12 -0000


www		Thu Sep 11 16:54:12 2003 EDT

  Modified files:              
    /loncom/auth	lonauth.pm lonlogin.pm 
    /loncom/cgi	takeoffline.pl takeonline.pl 
  Log:
  Also have login handlers detect re-reouting.
  
  
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.54 loncom/auth/lonauth.pm:1.55
--- loncom/auth/lonauth.pm:1.54	Thu Jul 17 11:24:46 2003
+++ loncom/auth/lonauth.pm	Thu Sep 11 16:54:11 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.54 2003/07/17 15:24:46 www Exp $
+# $Id: lonauth.pm,v 1.55 2003/09/11 20:54:11 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -236,10 +236,39 @@
 ENDFAILED
 }
 
+# ------------------------------------------------------------------ Rerouting!
+
+sub reroute {
+    my $r=shift;
+    my $bodytag=&Apache::loncommon::bodytag('Rerouting');
+    $r->send_cgi_header(<<ENDRFHEADER);
+Content-type: text/html
+
+ENDRFHEADER
+    $r->print(<<ENDRFAILED);
+<html>
+<head>
+<title>Rerouting Login to the LearningOnline Network with CAPA</title>
+</head>
+<html>
+$bodytag
+<h1>Sorry ...</h1>
+Please <a href="/">log in again</a>.
+</body>
+</html>
+ENDRFAILED
+}
+
 # ---------------------------------------------------------------- Main handler
 
 sub handler {
     my $r = shift;
+
+# Are we re-routing?
+    if (-e '/home/httpd/html/lon-status/reroute.txt') {
+	&reroute($r);
+	return OK;
+    }
 
     my $buffer;
     $r->read($buffer,$r->header_in('Content-length'),0);
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.48 loncom/auth/lonlogin.pm:1.49
--- loncom/auth/lonlogin.pm:1.48	Tue Sep  2 18:28:19 2003
+++ loncom/auth/lonlogin.pm	Thu Sep 11 16:54:11 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.48 2003/09/02 22:28:19 albertel Exp $
+# $Id: lonlogin.pm,v 1.49 2003/09/11 20:54:11 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,6 +40,7 @@
 use Apache::File ();
 use Apache::lonnet();
 use Apache::loncommon();
+use Apache::lonauth();
 
 sub handler {
     my $r = shift;
@@ -48,6 +49,12 @@
     $r->send_http_header;
     return OK if $r->header_only;
 
+
+# Are we re-routing?
+    if (-e '/home/httpd/html/lon-status/reroute.txt') {
+	&Apache::lonauth::reroute($r);
+	return OK;
+    }
 
     &Apache::loncommon::get_unprocessed_cgi
      ($ENV{'QUERY_STRING'}.'&'.$ENV{'request.querystring'},
Index: loncom/cgi/takeoffline.pl
diff -u loncom/cgi/takeoffline.pl:1.1 loncom/cgi/takeoffline.pl:1.2
--- loncom/cgi/takeoffline.pl:1.1	Thu Sep 11 15:47:30 2003
+++ loncom/cgi/takeoffline.pl	Thu Sep 11 16:54:11 2003
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Take machine offline, reroute traffic
 #
-# $Id: takeoffline.pl,v 1.1 2003/09/11 19:47:30 www Exp $
+# $Id: takeoffline.pl,v 1.2 2003/09/11 20:54:11 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,10 +32,13 @@
     print 'No reroute server given, taking completely offline.';
     &dead();
 } else {
-    $otherserver=$ENV{'QUERY_STRING'};
+    ($otherserver,$domain)=split(/\&/,$ENV{'QUERY_STRING'});
     print 'Rerouting to '.$otherserver;
     &reroute();
 }
+open (STATUS,'>/home/httpd/html/lon-status/reroute.txt');
+print STATUS "status=rerouting&server=$otherserver&domain=$domain&time=".time."\n";
+close(STATUS);
 
 print "</body></html>";
 
@@ -51,12 +54,12 @@
 <html>
  <head>
   <title>Welcome to the LearningOnline Network with CAPA</title>
-  <meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://$otherserver/adm/roles">
+  <meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://$otherserver/adm/login?domain=$domain">
  </head>
  <body bgcolor="#004400" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
   <img src="/adm/lonIcons/header.gif" />
 <p><font color="#FFFFFF">Connecting to
-<a href="http://$otherserver/adm/roles"><font color="#FFFFFF">http://$otherserver/</font></a></font></p>
+<a href="http://$otherserver/adm/login?domain=$domain"><font color="#FFFFFF">http://$otherserver/</font></a></font></p>
 </body>
 </html>
 ENDNEWINDEX
Index: loncom/cgi/takeonline.pl
diff -u loncom/cgi/takeonline.pl:1.1 loncom/cgi/takeonline.pl:1.2
--- loncom/cgi/takeonline.pl:1.1	Thu Sep 11 15:47:30 2003
+++ loncom/cgi/takeonline.pl	Thu Sep 11 16:54:11 2003
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Take machine online
 #
-# $Id: takeonline.pl,v 1.1 2003/09/11 19:47:30 www Exp $
+# $Id: takeonline.pl,v 1.2 2003/09/11 20:54:11 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -28,5 +28,6 @@
 
 print "Content-type: text/html\n\n".
       "<html><body bgcolor=#FFFFFF><h1>Take Online</h1>";
-system('mv /home/httpd/html/origindex.html /home/httpd/html/index.html');
+system('cp /home/httpd/html/origindex.html /home/httpd/html/index.html');
+system('rm /home/httpd/html/lon-status/reroute.txt');
 print "</body></html>";