[LON-CAPA-cvs] cvs: loncom /cgi takeoffline.pl
raeburn
raeburn at source.lon-capa.org
Wed Jan 21 10:12:03 EST 2015
raeburn Wed Jan 21 15:12:03 2015 EDT
Modified files:
/loncom/cgi takeoffline.pl
Log:
- Bug 6767
- In case where a specific destination is chosen when server is "offline"
the destination in the meta refresh needs to be the hostname not the
destination server's lonhostID.
- xhtml now satisfies w3c validation
- eliminate deprecated <font> tags.
-------------- next part --------------
Index: loncom/cgi/takeoffline.pl
diff -u loncom/cgi/takeoffline.pl:1.7 loncom/cgi/takeoffline.pl:1.8
--- loncom/cgi/takeoffline.pl:1.7 Mon Mar 22 20:11:15 2010
+++ loncom/cgi/takeoffline.pl Wed Jan 21 15:12:03 2015
@@ -2,7 +2,7 @@
$|=1;
# Take machine offline, reroute traffic
#
-# $Id: takeoffline.pl,v 1.7 2010/03/22 20:11:15 droeschl Exp $
+# $Id: takeoffline.pl,v 1.8 2015/01/21 15:12:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,6 +31,7 @@
use lib '/home/httpd/lib/perl/';
use Apache::lonlocal;
use Apache::loncommon;
+use Apache::lonnet;
use LONCAPA::loncgi;
use LONCAPA::lonauthcgi;
@@ -61,6 +62,7 @@
} else {
my $js = <<ENDJS;
<script type="text/javascript">
+// <![CDATA[
function setphase(form) {
var subaction = '/cgi-bin/takeoffline.pl?phase=two';
@@ -68,6 +70,7 @@
form.submit();
}
+// ]]>
</script>
ENDJS
print &Apache::loncommon::start_page('Take Offline',$js);
@@ -78,7 +81,6 @@
}
sub phaseone {
-# print '<html><body bgcolor="#FFFFFF">
print '<h2>'.&Apache::lonlocal::mt('Take Offline').'</h2>';
my ($is_dc, at okmachines,%servers);
my @poss_domains = &Apache::lonnet::current_machine_domains();
@@ -98,14 +100,14 @@
}
my $ip = $ENV{'REMOTE_ADDR'};
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:").
+ 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>'.
'<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></p>';
+ '<li>'.&mt('A page which announces that this LON-CAPA server is offline.').'</li></ul>';
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:").'<ul>'.
+ print '<p>'.&mt("In common with other Domain Status pages the 'take online' script is accessible from certain IP addresses:").'</p><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("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><p><hr /></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 />';
if ($ip eq '127.0.0.1') {
print '<div class="LC_info">'.&mt('You are accessing this page from the loopback device.').'</div>';
} elsif (!@okmachines) {
@@ -119,7 +121,7 @@
if ($ENV{'QUERY_STRING'}) {
($otherserver,$domain)=split(/\&/,$ENV{'QUERY_STRING'});
}
- print '<p><hr /></p><p><form method="post" name="takeoffline" onSubmit="javascript:setphase(this);">';
+ print '<hr /><form method="post" name="takeoffline" onsubmit="javascript:setphase(this);" action="">';
my $options;
if ($domain) {
@@ -129,11 +131,10 @@
next if ($hostid eq $lonhost);
my $selchk = '';
if ($otherserver eq $hostid) {
- $selchk = 'selected="selected"';
+ $selchk = ' selected="selected"';
}
$options .=
- "<option value=\"$hostid&$domain\" $selchk>"."\n".
- "$hostid ".&mt('Domain: [_1], Hostname: [_2]',$domain,$servers{$domain}{$hostid}).'</option>'."\n";
+ "<option value=\"$hostid&$domain\"$selchk>$servers{$domain}{$hostid}</option>\n";
}
}
}
@@ -147,11 +148,10 @@
$allhosts{$hostid} = 1;
my $selchk = '';
if ($otherserver eq $hostid) {
- $selchk = 'selected="selected"';
+ $selchk = ' selected="selected"';
}
- $options .=
- "<option value=\"$hostid&$dom\" $selchk>".
- $hostid.'</option>';
+ $options .=
+ "<option value=\"$hostid&$dom\"$selchk>$servers{$dom}{$hostid}</option>\n";
}
}
}
@@ -171,10 +171,11 @@
my ($reroute) = @_;
print '<h2>'.&Apache::lonlocal::mt('Take Offline').'</h2>';
my $statusmsg;
- if ($reroute) {
+ if ($reroute ne '') {
my ($otherserver,$domain)=split(/\&/,$reroute);
- if (&reroute($otherserver,$domain)) {
- print &Apache::lonlocal::mt('Rerouting to [_1]',$otherserver);
+ my $otherhostname = &reroute($otherserver,$domain);
+ if ($otherhostname ne '') {
+ print &Apache::lonlocal::mt('Rerouting to [_1]',$otherhostname);
$statusmsg = "status=rerouting&server=$otherserver&domain=$domain&time=".time.
"by=$Apache::lonnet::env{'user.name'}:$Apache::lonnet::env{'user.domain'}";
}
@@ -205,22 +206,30 @@
sub reroute {
my ($otherserver,$domain) = @_;
- if (open (OUT,'>/home/httpd/html/index.html')) {
- print OUT (<<ENDNEWINDEX);
-<html>
+ my $otherhostname = &Apache::lonnet::hostname($otherserver);
+ my $protocol = $Apache::lonnet::protocol{$otherserver};
+ $protocol = 'http' if ($protocol ne 'https');
+ 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>
<title>Welcome to the LearningOnline Network with CAPA</title>
- <meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://$otherserver/adm/login?domain=$domain">
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+ <meta http-equiv="refresh" content="0.5; url=$protocol://$otherhostname/adm/login?domain=$domain">
+ <meta http-equiv="pragma" content="no-cache" />
</head>
- <body style="background-color:"#004400"; margin: 0px;">
- <img src="/adm/lonIcons/header.gif" />
-<p><font color="#FFFFFF">Connecting to
-<a href="http://$otherserver/adm/login?domain=$domain"><font color="#FFFFFF">http://$otherserver/</font></a></font></p>
+ <body style="background-color:#004400; margin: 0px;">
+ <img src="/adm/lonIcons/header.gif" alt="loncapa banner" />
+<p style="color:#ffffff">Connecting to
+<a href="$protocol://$otherhostname/adm/login?domain=$domain" style="color:#ffffff">$protocol://$otherhostname/</a></p>
</body>
</html>
ENDNEWINDEX
- close(OUT);
- return 'ok';
+ close(OUT);
+ return $otherhostname;
+ }
}
return;
}
More information about the LON-CAPA-cvs
mailing list