Diff for /loncom/cgi/takeoffline.pl between versions 1.6.12.1 and 1.7

version 1.6.12.1, 2015/03/11 03:33:22 version 1.7, 2010/03/22 20:11:15
Line 31  use strict; Line 31  use strict;
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonnet;  
 use LONCAPA::loncgi;  use LONCAPA::loncgi;
 use LONCAPA::lonauthcgi;  use LONCAPA::lonauthcgi;
   
Line 57  sub main { Line 56  sub main {
   
     if ($ENV{'QUERY_STRING'} =~ /^phase\=two\&?(.*)$/) {      if ($ENV{'QUERY_STRING'} =~ /^phase\=two\&?(.*)$/) {
         my $reroute = $1;          my $reroute = $1;
         print &Apache::loncommon::start_page('Take Offline','',          print &Apache::loncommon::start_page('Take Offline');
                                              {'no_inline_link'   => 1,});  
         &phasetwo($reroute);          &phasetwo($reroute);
     } else {      } else {
         my $js = <<ENDJS;          my $js = <<ENDJS;
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  
   
 function setphase(form) {  function setphase(form) {
     var subaction = '/cgi-bin/takeoffline.pl?phase=two';      var subaction = '/cgi-bin/takeoffline.pl?phase=two';
Line 71  function setphase(form) { Line 68  function setphase(form) {
     form.submit();      form.submit();
 }  }
   
 // ]]>  
 </script>  </script>
 ENDJS  ENDJS
         print &Apache::loncommon::start_page('Take Offline',$js,          print &Apache::loncommon::start_page('Take Offline',$js);
                                              {'no_inline_link'   => 1,});  
         &phaseone();          &phaseone();
     }      }
     print &Apache::loncommon::end_page();      print &Apache::loncommon::end_page();
Line 83  ENDJS Line 78  ENDJS
 }  }
   
 sub phaseone {  sub phaseone {
   #    print '<html><body bgcolor="#FFFFFF">
     print '<h2>'.&Apache::lonlocal::mt('Take Offline').'</h2>';      print '<h2>'.&Apache::lonlocal::mt('Take Offline').'</h2>';
     my ($is_dc,@okmachines,%servers);      my ($is_dc,@okmachines,%servers);
     my @poss_domains = &Apache::lonnet::current_machine_domains();      my @poss_domains = &Apache::lonnet::current_machine_domains();
Line 102  sub phaseone { Line 98  sub phaseone {
     }      }
     my $ip = $ENV{'REMOTE_ADDR'};      my $ip = $ENV{'REMOTE_ADDR'};
     my $lonhost = $Apache::lonnet::perlvar{'lonHostID'};      my $lonhost = $Apache::lonnet::perlvar{'lonHostID'};
     print '<p>'.&mt("When a LON-CAPA server is 'taken offline' using this utility, the standard log-in page will be replaced with one of the following:").'</p>'.      print '<p>'.&mt("When a LON-CAPA server is 'taken offline' using this utility, the standard log-in page will be replaced with one of the following:").
           '<ul><li>'.&mt('A page which automatically performs a redirect to another server in your domain - the server must be specified below.').'</li>'.            '<ul><li>'.&mt('A page which automatically performs a redirect to another server in your domain - the server must be specified below.').'</li>'.
               '<li>'.&mt('A page which announces that this LON-CAPA server is offline.').'</li></ul>';                '<li>'.&mt('A page which announces that this LON-CAPA server is offline.').'</li></ul></p>';
     print '<p>'.&mt("Once a server is offline, the [_1]'take online'[_2] utility can be used to reverse this, but you should verify that you will still be able to access that script once the server is in an offline state.",'<a href="/cgi-bin/takeonline.pl">','</a>').'</p>';      print '<p>'.&mt("Once a server is offline, the [_1]'take online'[_2] utility can be used to reverse this, but you should verify that you will still be able to access that script once the server is in an offline state.",'<a href="/cgi-bin/takeonline.pl">','</a>').'</p>';
     print '<p>'.&mt("In common with other Domain Status pages the 'take online' script is accessible from certain IP addresses:").'</p><ul>'.      print '<p>'.&mt("In common with other Domain Status pages the 'take online' script is accessible from certain IP addresses:").'<ul>'.
           '<li>'.&mt('The loopback device - 127.0.0.1 (localhost) - for times when you are web browsing from the server itself.').'</li>'.            '<li>'.&mt('The loopback device - 127.0.0.1 (localhost) - for times when you are web browsing from the server itself.').'</li>'.
           '<li>'.&mt("Specified IP addresses set via the configuration for [_1]Access to Server Status Pages[_2] for domain(s) hosted on the server.",'<a href="/adm/domainprefs?phase=display&amp;actions=serverstatuses">','</a>').'</li></ul><p>'.            '<li>'.&mt("Specified IP addresses set via the configuration for [_1]Access to Server Status Pages[_2] for domain(s) hosted on the server.",'<a href="/adm/domainprefs?phase=display&actions=serverstatuses">','</a>').'</li></ul><p>'.
           &mt("Once the server is offline you will not be able to log-in directly to select a Domain Coordinator role to use the 'Take online' script, unless IP-based controls provide your access.").'<br />'.&mt("However, you will be able to log-in to a different server in the LON-CAPA network, select a Domain Coordinator role in this server's domain, and then use: [_1] to migrate you session to this machine.","<br /><tt>/adm/switchserver?otherserver=$lonhost</tt>").'<br /></p><hr />';            &mt("Once the server is offline you will not be able to log-in directly to select a Domain Coordinator role to use the 'Take online' script, unless IP-based controls provide your access.").'<br />'.&mt("However, you will be able to log-in to a different server in the LON-CAPA network, select a Domain Coordinator role in this server's domain, and then use: [_1] to migrate you session to this machine.","<br /><tt>/adm/switchserver?otherserver=$lonhost</tt>").'<br /></p><p><hr /></p>';
     if ($ip eq '127.0.0.1') {      if ($ip eq '127.0.0.1') {
         print '<div class="LC_info">'.&mt('You are accessing this page from the loopback device.').'</div>';          print '<div class="LC_info">'.&mt('You are accessing this page from the loopback device.').'</div>';
     } elsif (!@okmachines) {      } elsif (!@okmachines) {
Line 123  sub phaseone { Line 119  sub phaseone {
     if ($ENV{'QUERY_STRING'}) {      if ($ENV{'QUERY_STRING'}) {
         ($otherserver,$domain)=split(/\&/,$ENV{'QUERY_STRING'});          ($otherserver,$domain)=split(/\&/,$ENV{'QUERY_STRING'});
     }      }
     print '<hr /><form method="post" name="takeoffline" onsubmit="javascript:setphase(this);" action="">';      print '<p><hr /></p><p><form method="post" name="takeoffline" onSubmit="javascript:setphase(this);">';
   
     my $options;      my $options;
     if ($domain) {      if ($domain) {
Line 133  sub phaseone { Line 129  sub phaseone {
                     next if ($hostid eq $lonhost);                      next if ($hostid eq $lonhost);
                     my $selchk = '';                      my $selchk = '';
                     if ($otherserver eq $hostid) {                      if ($otherserver eq $hostid) {
                         $selchk = ' selected="selected"';                          $selchk = 'selected="selected"';
                     }                      }
                     $options .=                      $options .=
                         "<option value=\"$hostid&amp;$domain\"$selchk>$servers{$domain}{$hostid}</option>\n";     "<option value=\"$hostid&$domain\" $selchk>"."\n".
      "$hostid ".&mt('Domain: [_1], Hostname: [_2]',$domain,$servers{$domain}{$hostid}).'</option>'."\n";
                 }                  }
             }              }
         }          }
Line 150  sub phaseone { Line 147  sub phaseone {
                 $allhosts{$hostid} = 1;                  $allhosts{$hostid} = 1;
                 my $selchk = '';                  my $selchk = '';
                 if ($otherserver eq $hostid) {                  if ($otherserver eq $hostid) {
                     $selchk = ' selected="selected"';                      $selchk = 'selected="selected"';
                 }                  }
                 $options .=                  $options .=  
                     "<option value=\"$hostid&amp;$dom\"$selchk>$servers{$dom}{$hostid}</option>\n";                 "<option value=\"$hostid&$dom\" $selchk>".
                  $hostid.'</option>';
             }              }
         }          }
     }      }
Line 173  sub phasetwo { Line 171  sub phasetwo {
     my ($reroute) = @_;      my ($reroute) = @_;
     print '<h2>'.&Apache::lonlocal::mt('Take Offline').'</h2>';      print '<h2>'.&Apache::lonlocal::mt('Take Offline').'</h2>';
     my $statusmsg;      my $statusmsg;
     if ($reroute ne '') {      if ($reroute) {
         my ($otherserver,$domain)=split(/\&/,$reroute);          my ($otherserver,$domain)=split(/\&/,$reroute);
         my $otherhostname = &reroute($otherserver,$domain);          if (&reroute($otherserver,$domain)) {
         if ($otherhostname ne '') {              print &Apache::lonlocal::mt('Rerouting to [_1]',$otherserver);
             print &Apache::lonlocal::mt('Rerouting to [_1]',$otherhostname);  
             $statusmsg = "status=rerouting&server=$otherserver&domain=$domain&time=".time.              $statusmsg = "status=rerouting&server=$otherserver&domain=$domain&time=".time.
                          "by=$Apache::lonnet::env{'user.name'}:$Apache::lonnet::env{'user.domain'}";                           "by=$Apache::lonnet::env{'user.name'}:$Apache::lonnet::env{'user.domain'}";
         }          }
Line 208  sub dead { Line 205  sub dead {
   
 sub reroute {  sub reroute {
     my ($otherserver,$domain) = @_;      my ($otherserver,$domain) = @_;
     my $otherhostname = &Apache::lonnet::hostname($otherserver);      if (open (OUT,'>/home/httpd/html/index.html')) {
     my $protocol = $Apache::lonnet::protocol{$otherserver};          print OUT (<<ENDNEWINDEX);
     $protocol = 'http' if ($protocol ne 'https');  <html>
     if ($otherhostname ne '') {  
         if (open (OUT,'>/home/httpd/html/index.html')) {  
             print OUT (<<ENDNEWINDEX);  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
  <head>   <head>
   <title>Welcome to the LearningOnline Network with CAPA</title>    <title>Welcome to the LearningOnline Network with CAPA</title>
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />    <meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://$otherserver/adm/login?domain=$domain">
   <meta http-equiv="refresh" content="0.5; url=$protocol://$otherhostname/adm/login?domain=$domain">  
   <meta http-equiv="pragma" content="no-cache" />  
  </head>   </head>
  <body style="background-color:#004400; margin: 0px;">   <body style="background-color:"#004400"; margin: 0px;">
   <img src="/adm/lonIcons/header.gif" alt="loncapa banner" />    <img src="/adm/lonIcons/header.gif" />
 <p style="color:#ffffff">Connecting to   <p><font color="#FFFFFF">Connecting to
 <a href="$protocol://$otherhostname/adm/login?domain=$domain" style="color:#ffffff">$protocol://$otherhostname/</a></p>  <a href="http://$otherserver/adm/login?domain=$domain"><font color="#FFFFFF">http://$otherserver/</font></a></font></p>
 </body>  </body>
 </html>  </html>
 ENDNEWINDEX  ENDNEWINDEX
             close(OUT);         close(OUT);
             return $otherhostname;         return 'ok';
         }  
     }      }
     return;      return;
 }  }

Removed from v.1.6.12.1  
changed lines
  Added in v.1.7


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