version 1.87, 2007/01/14 02:00:04
|
version 1.183, 2021/05/03 15:27:44
|
Line 1
|
Line 1
|
# The LearningOnline Network |
# The LearningOnline Network
|
# Login Screen |
# Login Screen
|
# |
#
|
# $Id$ |
# $Id$
|
# |
#
|
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees
|
# |
#
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
|
# |
#
|
# LON-CAPA is free software; you can redistribute it and/or modify |
# LON-CAPA is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 2 of the License, or |
# the Free Software Foundation; either version 2 of the License, or
|
# (at your option) any later version. |
# (at your option) any later version.
|
# |
#
|
# LON-CAPA is distributed in the hope that it will be useful, |
# LON-CAPA is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details. |
# GNU General Public License for more details.
|
# |
#
|
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License
|
# along with LON-CAPA; if not, write to the Free Software |
# along with LON-CAPA; if not, write to the Free Software
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# |
#
|
# /home/httpd/html/adm/gpl.txt |
# /home/httpd/html/adm/gpl.txt
|
# |
#
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/
|
# |
#
|
|
|
package Apache::lonlogin; |
package Apache::lonlogin;
|
|
|
use strict; |
use strict;
|
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common);
|
use CGI::Cookie(); |
use Apache::File ();
|
use Apache::File (); |
use Apache::lonnet;
|
use Apache::lonnet; |
use Apache::loncommon();
|
use Apache::loncommon(); |
use Apache::lonauth();
|
use Apache::lonauth(); |
use Apache::lonlocal;
|
use Apache::lonlocal; |
use Apache::migrateuser();
|
use Apache::migrateuser(); |
use lib '/home/httpd/lib/perl/';
|
use lib '/home/httpd/lib/perl/'; |
use LONCAPA qw(:DEFAULT :match);
|
use LONCAPA; |
use CGI::Cookie();
|
|
|
sub handler { |
sub handler {
|
my $r = shift; |
my $r = shift;
|
|
|
&Apache::loncommon::get_unprocessed_cgi |
&Apache::loncommon::get_unprocessed_cgi
|
(join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'}, |
(join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
|
$ENV{'REDIRECT_QUERY_STRING'}), |
$ENV{'REDIRECT_QUERY_STRING'}),
|
['interface','username','domain','firsturl','localpath','localres', |
['interface','username','domain','firsturl','localpath','localres',
|
'token']); |
'token','role','symb','iptoken','btoken','ltoken','linkkey']);
|
|
if (!defined($env{'form.firsturl'})) {
|
# -- check if they are a migrating user |
&Apache::lonacc::get_posted_cgi($r,['firsturl']);
|
if (defined($env{'form.token'})) { |
}
|
return &Apache::migrateuser::handler($r); |
if (!defined($env{'form.firsturl'})) {
|
} |
if ($ENV{'REDIRECT_URL'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) {
|
|
$env{'form.firsturl'} = $ENV{'REDIRECT_URL'};
|
&Apache::loncommon::no_cache($r); |
}
|
&Apache::lonlocal::get_language_handle($r); |
}
|
&Apache::loncommon::content_type($r,'text/html'); |
if (($env{'form.firsturl'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) &&
|
$r->send_http_header; |
(!$env{'form.ltoken'}) && (!$env{'form.linkkey'})) {
|
return OK if $r->header_only; |
&Apache::lonacc::get_posted_cgi($r,['linkkey']);
|
|
}
|
|
|
# Are we re-routing? |
# -- check if they are a migrating user
|
if (-e '/home/httpd/html/lon-status/reroute.txt') { |
if (defined($env{'form.token'})) {
|
&Apache::lonauth::reroute($r); |
return &Apache::migrateuser::handler($r);
|
return OK; |
}
|
} |
|
|
# For "public user" - remove any exising "public" cookie, as user really wants to log-in
|
|
my ($handle,$lonidsdir,$expirepub,$userdom);
|
# -------------------------------- Prevent users from attempting to login twice |
$lonidsdir=$r->dir_config('lonIDsDir');
|
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
unless ($r->header_only) {
|
my $lonid=$cookies{'lonID'}; |
$handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
|
my $cookie; |
if ($handle ne '') {
|
if ($lonid) { |
if ($handle=~/^publicuser\_/) {
|
my $handle=&LONCAPA::clean_handle($lonid->value); |
unlink($r->dir_config('lonIDsDir')."/$handle.id");
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
undef($handle);
|
if (-e "$lonidsdir/$handle.id") { |
undef($userdom);
|
# Is there an existing token file? |
$expirepub = 1;
|
if ($handle=~/^publicuser\_/) { |
}
|
# For "public user" - remove it, we apparently really want to login |
}
|
unlink("$lonidsdir/$handle.id"); |
}
|
} elsif ($handle ne '') { |
|
# Indeed, a valid token is found |
&Apache::loncommon::no_cache($r);
|
my $start_page = |
&Apache::lonlocal::get_language_handle($r);
|
&Apache::loncommon::start_page('Already logged in'); |
&Apache::loncommon::content_type($r,'text/html');
|
my $end_page = |
if ($expirepub) {
|
&Apache::loncommon::end_page(); |
my $c = new CGI::Cookie(-name => 'lonPubID',
|
$r->print(<<ENDFAILED); |
-value => '',
|
$start_page |
-expires => '-10y',);
|
<h1>You are already logged in</h1> |
$r->header_out('Set-cookie' => $c);
|
<p>Please either <a href="/adm/roles">continue the current session</a> or |
} elsif (($handle eq '') && ($userdom ne '')) {
|
<a href="/adm/logout">logout</a>.</p> |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
|
<p> |
foreach my $name (keys(%cookies)) {
|
<a href="/adm/loginproblems.html">Problems?</a></p> |
next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
|
$end_page |
my $c = new CGI::Cookie(-name => $name,
|
ENDFAILED |
-value => '',
|
return OK; |
-expires => '-10y',);
|
} |
$r->headers_out->add('Set-cookie' => $c);
|
} |
}
|
} |
}
|
|
$r->send_http_header;
|
# ---------------------------------------------------- No valid token, continue |
return OK if $r->header_only;
|
|
|
# ---------------------------- Not possible to really login to domain "public" |
|
if ($env{'form.domain'} eq 'public') { |
# Are we re-routing?
|
$env{'form.domain'}=''; |
my $londocroot = $r->dir_config('lonDocRoot');
|
$env{'form.username'}=''; |
if (-e "$londocroot/lon-status/reroute.txt") {
|
} |
&Apache::lonauth::reroute($r);
|
# ----------------------------------------------------------- Process Interface |
return OK;
|
$env{'form.interface'}=~s/\W//g; |
}
|
|
|
my $textbrowsers=$r->dir_config('lonTextBrowsers'); |
my $lonhost = $r->dir_config('lonHostID');
|
my $httpbrowser=$ENV{"HTTP_USER_AGENT"}; |
$env{'form.firsturl'} =~ s/(`)/'/g;
|
|
|
foreach (split(/\:/,$textbrowsers)) { |
# Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
|
if ($httpbrowser=~/$_/i) { |
|
$env{'form.interface'}='textual'; |
my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r,1);
|
} |
if ($found_server) {
|
} |
my $hostname = &Apache::lonnet::hostname($found_server);
|
|
if ($hostname ne '') {
|
my $fullgraph=($env{'form.interface'} ne 'textual'); |
my $protocol = $Apache::lonnet::protocol{$found_server};
|
my $port_to_use=$r->dir_config('lonhttpdPort'); |
$protocol = 'http' if ($protocol ne 'https');
|
if (!defined($port_to_use)) { |
my $dest = '/adm/roles';
|
$port_to_use='8080'; |
if ($env{'form.firsturl'} ne '') {
|
} |
$dest = $env{'form.firsturl'};
|
my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use. |
}
|
$r->dir_config('lonIconsURL'); |
my %info = (
|
my $domain = &Apache::lonnet::default_login_domain(); |
balcookie => $lonhost.':'.$balancer_cookie,
|
if (($env{'form.domain'}) && |
);
|
($Apache::lonnet::domaindescription{$env{'form.domain'}})) { |
if ($env{'form.ltoken'}) {
|
$domain=$env{'form.domain'}; |
my %link_info = &Apache::lonnet::tmpget($env{'form.ltoken'});
|
} |
if ($link_info{'linkprot'}) {
|
my $role = $r->dir_config('lonRole'); |
$info{'linkprot'} = $link_info{'linkprot'};
|
my $loadlim = $r->dir_config('lonLoadLim'); |
}
|
my $lonhost = $r->dir_config('lonHostID'); |
&Apache::lonnet::tmpdel($env{'form.ltoken'});
|
my $tabdir = $r->dir_config('lonTabDir'); |
delete($env{'form.ltoken'});
|
my $include = $r->dir_config('lonIncludes'); |
} elsif ($env{'form.linkkey'}) {
|
my $expire = $r->dir_config('lonExpire'); |
$info{'linkkey'} = $env{'form.linkkey'};
|
my $version = $r->dir_config('lonVersion'); |
delete($env{'form.linkkey'});
|
my $host_name = $Apache::lonnet::hostname{$lonhost}; |
}
|
|
my $balancer_token = &Apache::lonnet::tmpput(\%info,$found_server);
|
# --------------------------------------------- Default values for login fields |
if ($balancer_token) {
|
|
$dest .= (($dest=~/\?/)?'&;':'?') . 'btoken='.$balancer_token;
|
my $authusername=($env{'form.username'}?$env{'form.username'}:''); |
}
|
my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain); |
unless ($found_server eq $lonhost) {
|
|
my $alias = &Apache::lonnet::use_proxy_alias($r,$found_server);
|
# ---------------------------------------------------------- Determine own load |
$hostname = $alias if ($alias ne '');
|
my $loadavg; |
}
|
{ |
my $url = $protocol.'://'.$hostname.$dest;
|
my $loadfile=Apache::File->new('/proc/loadavg'); |
my $start_page =
|
$loadavg=<$loadfile>; |
&Apache::loncommon::start_page('Switching Server ...',undef,
|
} |
{'redirect' => [0,$url],});
|
$loadavg =~ s/\s.*//g; |
my $end_page = &Apache::loncommon::end_page();
|
my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim); |
$r->print($start_page.$end_page);
|
my $userloadpercent=&Apache::lonnet::userload(); |
return OK;
|
|
}
|
# ------------------------------------------------------- Do the load balancing |
}
|
my $otherserver= &Apache::lonnet::absolute_url($host_name); |
|
my $firsturl= |
#
|
($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'}); |
# Check if a LON-CAPA load balancer sent user here because user's browser sent
|
# ---------------------------------------- Are we access server and overloaded? |
# it a balancer cookie for an active session on this server.
|
if (($role eq 'access') && |
#
|
(($userloadpercent>100.0)||($loadpercent>100.0))) { |
|
my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); |
my ($balcookie,$linkprot,$linkkey);
|
if ($unloaded) { $otherserver=$unloaded; } |
if ($env{'form.btoken'}) {
|
} |
my %info = &Apache::lonnet::tmpget($env{'form.btoken'});
|
|
$balcookie = $info{'balcookie'};
|
# ----------------------------------------------------------- Get announcements |
if ($balcookie) {
|
my $announcements=&Apache::lonnet::getannounce(); |
if ($info{'linkprot'}) {
|
# -------------------------------------------------------- Set login parameters |
$linkprot = $info{'linkprot'};
|
|
} elsif ($info{'linkkey'}) {
|
my @hexstr=('0','1','2','3','4','5','6','7', |
$linkkey = $info{'linkkey'};
|
'8','9','a','b','c','d','e','f'); |
}
|
my $lkey=''; |
}
|
for (0..7) { |
&Apache::lonnet::tmpdel($env{'form.btoken'});
|
$lkey.=$hexstr[rand(15)]; |
delete($env{'form.btoken'});
|
} |
}
|
|
|
my $ukey=''; |
#
|
for (0..7) { |
# If browser sent an old cookie for which the session file had been removed
|
$ukey.=$hexstr[rand(15)]; |
# check if configuration for user's domain has a portal URL set. If so
|
} |
# switch user's log-in to the portal.
|
|
#
|
my $lextkey=hex($lkey); |
|
if ($lextkey>2147483647) { $lextkey-=4294967296; } |
if (($handle eq '') && ($userdom ne '')) {
|
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);
|
my $uextkey=hex($ukey); |
if ($domdefaults{'portal_def'} =~ /^https?\:/) {
|
if ($uextkey>2147483647) { $uextkey-=4294967296; } |
my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
|
|
{'redirect' => [0,$domdefaults{'portal_def'}],});
|
# -------------------------------------------------------- Store away log token |
my $end_page = &Apache::loncommon::end_page();
|
my $logtoken=Apache::lonnet::reply( |
$r->print($start_page.$end_page);
|
'tmpput:'.$ukey.$lkey.'&'.$firsturl, |
return OK;
|
$lonhost); |
}
|
|
}
|
# ------------------- If we cannot talk to ourselves, we are in serious trouble |
|
|
# -------------------------------- Prevent users from attempting to login twice
|
if ($logtoken eq 'con_lost') { |
if ($handle ne '') {
|
my $spares=''; |
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
|
my $last; |
my $start_page =
|
foreach my $hostid (sort |
&Apache::loncommon::start_page('Already logged in');
|
{ |
my $end_page =
|
$Apache::lonnet::hostname{$a} cmp |
&Apache::loncommon::end_page();
|
$Apache::lonnet::hostname{$b}; |
my $dest = '/adm/roles';
|
} |
if ($env{'form.firsturl'} ne '') {
|
keys(%Apache::lonnet::spareid)) { |
$dest = $env{'form.firsturl'};
|
next if ($hostid eq $lonhost); |
}
|
next if ($last eq $Apache::lonnet::hostname{$hostid}); |
if (($env{'form.ltoken'}) || ($linkprot)) {
|
$spares.='<br /><font size="+1"><a href="http://'. |
unless ($linkprot) {
|
$Apache::lonnet::hostname{$hostid}. |
my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});
|
'/adm/login?domain='.$authdomain.'">'. |
$linkprot = $info{'linkprot'};
|
$Apache::lonnet::hostname{$hostid}.'</a>'. |
my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'});
|
' (preferred)</font>'.$/; |
delete($env{'form.ltoken'});
|
$last=$Apache::lonnet::hostname{$hostid}; |
}
|
} |
if ($linkprot) {
|
$spares.= '<br />'; |
my ($linkprotector,$deeplink) = split(/:/,$linkprot,2);
|
foreach my $hostid (sort |
if ($env{'user.linkprotector'}) {
|
{ |
my @protectors = split(/,/,$env{'user.linkprotector'});
|
$Apache::lonnet::hostname{$a} cmp |
unless (grep(/^\Q$linkprotector\E$/,@protectors)) {
|
$Apache::lonnet::hostname{$b}; |
push(@protectors,$linkprotector);
|
} |
@protectors = sort { $a <=> $b } @protectors;
|
keys(%Apache::lonnet::hostname)) { |
&Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});
|
next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid}); |
}
|
next if ($last eq $Apache::lonnet::hostname{$hostid}); |
} else {
|
$spares.='<br /><a href="http://'. |
&Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });
|
$Apache::lonnet::hostname{$hostid}. |
}
|
'/adm/login?domain='.$authdomain.'">'. |
if ($env{'user.linkproturi'}) {
|
$Apache::lonnet::hostname{$hostid}.'</a>'; |
my @proturis = split(/,/,$env{'user.linkproturi'});
|
$last=$Apache::lonnet::hostname{$hostid}; |
unless (grep(/^\Q$deeplink\E$/,@proturis)) {
|
} |
push(@proturis,$deeplink);
|
$r->print(<<ENDTROUBLE); |
@proturis = sort @proturis;
|
<html> |
&Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});
|
<head><title>The LearningOnline Network with CAPA</title></head> |
}
|
<body bgcolor="#FFFFFF"> |
} else {
|
<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" /> |
&Apache::lonnet::appenv({'user.linkproturi' => $deeplink});
|
<h3>This LON-CAPA server is temporarily not available for login</h3> |
}
|
<p>Please attempt to login to one of the following servers:</p>$spares |
}
|
</body> |
} elsif (($env{'form.linkkey'}) || ($linkkey)) {
|
</html> |
if ($env{'form.firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
|
ENDTROUBLE |
if ($linkkey eq '') {
|
return OK; |
$linkkey = $env{'form.linkkey'};
|
} |
}
|
|
if ($env{'user.deeplinkkey'}) {
|
# ----------------------------------------------- Apparently we are in business |
my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
|
|
unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
|
my $domainlogo=&Apache::loncommon::domainlogo($domain); |
push(@linkkeys,$linkkey);
|
|
&Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});
|
# --------------------------------------------------- Print login screen header |
}
|
$r->print(<<ENDHEADER); |
} else {
|
<html> |
&Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
|
<head> |
}
|
<meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" /> |
my $deeplink = $env{'form.firsturl'};
|
<title>The LearningOnline Network with CAPA Login</title> |
if ($env{'user.keyedlinkuri'}) {
|
</head> |
my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
|
ENDHEADER |
unless (grep(/^\Q$deeplink\E$/,@keyeduris)) {
|
# ---------------------------------------------------- Serve out DES JavaScript |
push(@keyeduris,$deeplink);
|
{ |
&Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
|
my $jsh=Apache::File->new($include."/londes.js"); |
}
|
$r->print(<$jsh>); |
} else {
|
} |
&Apache::lonnet::appenv({'user.keyedlinkuri' => $deeplink});
|
|
}
|
# ----------------------------------------------------------- Front page design |
}
|
my $pgbg= |
}
|
($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF'); |
$r->print(
|
my $font= |
$start_page
|
($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000'); |
.'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
|
my $link= |
.'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
|
($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF'); |
'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
|
my $vlink= |
.$end_page
|
($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF'); |
);
|
my $alink=&Apache::loncommon::designparm('login.alink',$domain); |
return OK;
|
my $mainbg= |
}
|
($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF'); |
|
my $sidebg= |
# ---------------------------------------------------- No valid token, continue
|
($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF'); |
|
my $logo=&Apache::loncommon::designparm('login.logo',$domain); |
# ---------------------------- Not possible to really login to domain "public"
|
my $img=&Apache::loncommon::designparm('login.img',$domain); |
if ($env{'form.domain'} eq 'public') {
|
|
$env{'form.domain'}='';
|
# ----------------------------------------------------------------------- Texts |
$env{'form.username'}='';
|
|
}
|
my %lt=&Apache::lonlocal::texthash( |
|
'un' => 'Username', |
# ------ Is this page requested because /adm/migrateuser detected an IP change?
|
'pw' => 'Password', |
my %sessiondata;
|
'dom' => 'Domain', |
if ($env{'form.iptoken'}) {
|
'perc' => 'percent', |
%sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
|
'load' => 'Load', |
unless ($sessiondata{'sessionserver'}) {
|
'userload' => 'User Load', |
my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
|
'about' => 'About LON-CAPA', |
delete($env{'form.iptoken'});
|
'access' => 'Accessibility Options', |
}
|
'catalog' => 'Course Catalog', |
}
|
'auth' => 'userauthentication.gif', |
# ----------------------------------------------------------- Process Interface
|
'log' => 'Log in', |
$env{'form.interface'}=~s/\W//g;
|
'help' => 'Log-in Help', |
|
'serv' => 'Server', |
(undef,undef,undef,undef,undef,undef,my $clientmobile) =
|
'helpdesk' => 'Contact Helpdesk', |
&Apache::loncommon::decode_user_agent();
|
'forgotpw' => 'Forgot password?'); |
|
# -------------------------------------------------- Change password field name |
my $iconpath=
|
my $now=time; |
&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
my $forgotpw = &forgotpwdisplay(%lt); |
|
my $loginhelp = &loginhelpdisplay(%lt); |
my $domain = &Apache::lonnet::default_login_domain();
|
# ---------------------------------------------------------- Serve rest of page |
my $defdom = $domain;
|
$r->print(<<ENDSCRIPT); |
if ($lonhost ne '') {
|
|
unless ($sessiondata{'sessionserver'}) {
|
<body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink" |
my $redirect = &check_loginvia($domain,$lonhost,$lonidsdir,$balcookie,$linkprot);
|
topmargin=0 leftmargin=0 marginwidth=0 marginheight=0> |
if ($redirect) {
|
|
$r->print($redirect);
|
<script language="JavaScript"> |
return OK;
|
function send() |
}
|
{ |
}
|
this.document.server.elements.uname.value |
}
|
=this.document.client.elements.uname.value; |
|
|
if (($sessiondata{'domain'}) &&
|
this.document.server.elements.udom.value |
(&Apache::lonnet::domain($sessiondata{'domain'},'description'))) {
|
=this.document.client.elements.udom.value; |
$domain=$sessiondata{'domain'};
|
|
} elsif (($env{'form.domain'}) &&
|
this.document.server.elements.imagesuppress.value |
(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
|
=this.document.client.elements.imagesuppress.checked; |
$domain=$env{'form.domain'};
|
|
}
|
this.document.server.elements.embedsuppress.value |
|
=this.document.client.elements.embedsuppress.checked; |
my $role = $r->dir_config('lonRole');
|
|
my $loadlim = $r->dir_config('lonLoadLim');
|
this.document.server.elements.appletsuppress.value |
my $uloadlim= $r->dir_config('lonUserLoadLim');
|
=this.document.client.elements.appletsuppress.checked; |
my $servadm = $r->dir_config('lonAdmEMail');
|
|
my $tabdir = $r->dir_config('lonTabDir');
|
this.document.server.elements.fontenhance.value |
my $include = $r->dir_config('lonIncludes');
|
=this.document.client.elements.fontenhance.checked; |
my $expire = $r->dir_config('lonExpire');
|
|
my $version = $r->dir_config('lonVersion');
|
this.document.server.elements.blackwhite.value |
my $host_name = &Apache::lonnet::hostname($lonhost);
|
=this.document.client.elements.blackwhite.checked; |
|
|
# --------------------------------------------- Default values for login fields
|
this.document.server.elements.remember.value |
|
=this.document.client.elements.remember.checked; |
my ($authusername,$authdomain);
|
|
if ($sessiondata{'username'}) {
|
uextkey=this.document.client.elements.uextkey.value; |
$authusername=$sessiondata{'username'};
|
lextkey=this.document.client.elements.lextkey.value; |
} else {
|
initkeys(); |
$env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
|
|
$authusername=($env{'form.username'}?$env{'form.username'}:'');
|
this.document.server.elements.upass0.value |
}
|
=crypted(this.document.client.elements.upass$now.value.substr(0,15)); |
if ($sessiondata{'domain'}) {
|
this.document.server.elements.upass1.value |
$authdomain=$sessiondata{'domain'};
|
=crypted(this.document.client.elements.upass$now.value.substr(15,15)); |
} else {
|
this.document.server.elements.upass2.value |
$env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
|
=crypted(this.document.client.elements.upass$now.value.substr(30,15)); |
$authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
|
|
}
|
this.document.client.elements.uname.value=''; |
|
this.document.client.elements.upass$now.value=''; |
# ---------------------------------------------------------- Determine own load
|
|
my $loadavg;
|
this.document.server.submit(); |
{
|
return false; |
my $loadfile=Apache::File->new('/proc/loadavg');
|
} |
$loadavg=<$loadfile>;
|
</script> |
}
|
ENDSCRIPT |
$loadavg =~ s/\s.*//g;
|
|
|
if ($fullgraph) { |
my ($loadpercent,$userloadpercent);
|
$r->print( |
if ($loadlim) {
|
'<table width="100%" cellpadding=0 cellspacing=0 border=0>'); |
$loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
|
} |
}
|
|
if ($uloadlim) {
|
$r->print(<<ENDSERVERFORM); |
$userloadpercent=&Apache::lonnet::userload();
|
<form name="server" action="$otherserver/adm/authenticate" method="post" target="_top"> |
}
|
<input type="hidden" name="logtoken" value="$logtoken" /> |
|
<input type="hidden" name="serverid" value="$lonhost" /> |
my $firsturl=
|
<input type="hidden" name="interface" value="$env{'form.interface'}" /> |
($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
|
<input type="hidden" name="uname" value="" /> |
|
<input type="hidden" name="upass0" value="" /> |
# ----------------------------------------------------------- Get announcements
|
<input type="hidden" name="upass1" value="" /> |
my $announcements=&Apache::lonnet::getannounce();
|
<input type="hidden" name="upass2" value="" /> |
# -------------------------------------------------------- Set login parameters
|
<input type="hidden" name="udom" value="" /> |
|
<input type="hidden" name="imagesuppress" value="" /> |
my @hexstr=('0','1','2','3','4','5','6','7',
|
<input type="hidden" name="appletsuppress" value="" /> |
'8','9','a','b','c','d','e','f');
|
<input type="hidden" name="embedsuppress" value="" /> |
my $lkey='';
|
<input type="hidden" name="fontenhance" value="" /> |
for (0..7) {
|
<input type="hidden" name="blackwhite" value="" /> |
$lkey.=$hexstr[rand(15)];
|
<input type="hidden" name="remember" value="" /> |
}
|
<input type="hidden" name="localpath" value="$env{'form.localpath'}" /> |
|
<input type="hidden" name="localres" value="$env{'form.localres'}" /> |
my $ukey='';
|
</form> |
for (0..7) {
|
ENDSERVERFORM |
$ukey.=$hexstr[rand(15)];
|
if ($fullgraph) { $r->print(<<ENDTOP); |
}
|
<!-- The LON-CAPA Header --> |
|
<tr> |
my $lextkey=hex($lkey);
|
|
if ($lextkey>2147483647) { $lextkey-=4294967296; }
|
<!-- Row 1 Columns 2-4 --> |
|
<td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td> |
my $uextkey=hex($ukey);
|
</tr> |
if ($uextkey>2147483647) { $uextkey-=4294967296; }
|
|
|
<!-- The gray bar that starts the two table frames --> |
# -------------------------------------------------------- Store away log token
|
<tr> |
my $tokenextras;
|
|
if ($env{'form.role'}) {
|
<!-- Row 2 Column 1 --> |
$tokenextras = '&role='.&escape($env{'form.role'});
|
<td width=182 height=27 bgcolor="$sidebg"> </td> |
}
|
|
if ($env{'form.symb'}) {
|
<!-- Row 2 Column 2 --> |
if (!$tokenextras) {
|
<td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td> |
$tokenextras = '&';
|
|
}
|
<!-- Row 2 Column 3 --> |
$tokenextras .= '&symb='.&escape($env{'form.symb'});
|
<td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td> |
}
|
|
if ($env{'form.iptoken'}) {
|
<!-- Row 2 Column 4 --> |
if (!$tokenextras) {
|
<td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td> |
$tokenextras = '&&';
|
</tr> |
}
|
<tr> |
$tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
|
|
}
|
<!-- A cell that will hold the 'access', 'about', and 'catalog' links --> |
if ($env{'form.ltoken'}) {
|
<!-- Row 3 Column 1 --> |
my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});
|
<td valign="top" height="60" align="left" bgcolor="$sidebg"> |
&Apache::lonnet::tmpdel($env{'form.ltoken'});
|
<table cellpadding="0" cellspacing="2" border="0"> |
delete($env{'form.ltoken'});
|
<tr> |
if ($info{'linkprot'}) {
|
<td> </td> |
if (!$tokenextras) {
|
<td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td> |
$tokenextras = '&&&';
|
</tr> |
}
|
<tr> |
$tokenextras .= '&linkprot='.&escape($info{'linkprot'});
|
<td> </td> |
}
|
<td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td> |
} elsif ($env{'form.linkkey'}) {
|
</tr> |
if (!$tokenextras) {
|
<tr> |
$tokenextras = '&&&';
|
<td> </td> |
}
|
<td><a href="/adm/coursecatalog"><b>$lt{'catalog'}</b></a></td> |
$tokenextras .= '&linkkey='.&escape($env{'form.linkkey'});
|
</tr> |
}
|
<tr> |
my $logtoken=Apache::lonnet::reply(
|
<td colspan="2"> </td> |
'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
|
</tr> |
$lonhost);
|
</table> |
|
</td> |
# -- If we cannot talk to ourselves, or hostID does not map to a hostname
|
<!-- The shaded space between the two main columns --> |
# we are in serious trouble
|
<!-- Row 3 Column 2 --> |
|
<td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td> |
if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
|
|
if ($logtoken eq 'no_such_host') {
|
<!-- The right main column holding the large LON-CAPA logo--> |
&Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
|
<!-- Rows 3-4 Column 3 --> |
}
|
<td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg"> |
my $spares='';
|
<center> |
my (@sparehosts,%spareservers);
|
<img src="$logo" alt="" /> |
my $sparesref = &Apache::lonnet::this_host_spares($defdom);
|
</center> |
if (ref($sparesref) eq 'HASH') {
|
</td> |
foreach my $key (keys(%{$sparesref})) {
|
|
if (ref($sparesref->{$key}) eq 'ARRAY') {
|
<!-- Row 3 Column 4 --> |
my @sorted = sort { &Apache::lonnet::hostname($a) cmp
|
<td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td> |
&Apache::lonnet::hostname($b);
|
</tr> |
} @{$sparesref->{$key}};
|
<tr> |
if (@sorted) {
|
|
if ($key eq 'primary') {
|
<!-- The entry form --> |
unshift(@sparehosts,@sorted);
|
<!-- Row 4 Column 1 --> |
} elsif ($key eq 'default') {
|
<td align="center" valign="middle" bgcolor="$sidebg"> |
push(@sparehosts,@sorted);
|
ENDTOP |
}
|
} else { |
}
|
$r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>'.$announcements); |
}
|
} |
}
|
$r->print('<form name="client" onsubmit="return(send())">'); |
}
|
unless ($fullgraph) { |
foreach my $hostid (@sparehosts) {
|
$r->print(<<ENDACCESSOPTIONS); |
next if ($hostid eq $lonhost);
|
<h3>Select Accessibility Options</h3> |
my $hostname = &Apache::lonnet::hostname($hostid);
|
<label><input type="checkbox" name="imagesuppress" /> Suppress rendering of images</label><br /> |
next if (($hostname eq '') || ($spareservers{$hostname}));
|
<label><input type="checkbox" name="appletsuppress" /> Suppress Java applets</label><br /> |
$spareservers{$hostname} = 1;
|
<label><input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia</label><br /> |
my $protocol = $Apache::lonnet::protocol{$hostid};
|
<label><input type="checkbox" name="fontenhance" /> Increase font size</label><br /> |
$protocol = 'http' if ($protocol ne 'https');
|
<label><input type="checkbox" name="blackwhite" /> Switch to black and white mode</label><br /> |
$spares.='<br /><span style="font-size: larger;"><a href="'.$protocol.'://'.
|
<input type="checkbox" name="remember" /> Remember these settings for next login<hr /> |
$hostname.
|
ENDACCESSOPTIONS |
'/adm/login?domain='.$authdomain.'">'.
|
} else { |
$hostname.'</a>'.
|
$r->print(<<ENDNOOPT); |
' '.&mt('(preferred)').'</span>'.$/;
|
<input type="hidden" name="imagesuppress" value="" /> |
}
|
<input type="hidden" name="embedsuppress" value="" /> |
if ($spares) {
|
<input type="hidden" name="appletsuppress" value="" /> |
$spares.= '<br />';
|
<input type="hidden" name="fontenhance" value="" /> |
}
|
<input type="hidden" name="blackwhite" value="" /> |
my %all_hostnames = &Apache::lonnet::all_hostnames();
|
<input type="hidden" name="remember" value="" /> |
foreach my $hostid (sort
|
ENDNOOPT |
{
|
} |
&Apache::lonnet::hostname($a) cmp
|
$r->print(<<ENDLOGIN); |
&Apache::lonnet::hostname($b);
|
<input type="hidden" name="lextkey" value="$lextkey"> |
}
|
<input type="hidden" name="uextkey" value="$uextkey"> |
keys(%all_hostnames)) {
|
|
next if ($hostid eq $lonhost);
|
<!-- Start the sub-table for text and input alignment --> |
my $hostname = &Apache::lonnet::hostname($hostid);
|
<table border=0 cellspacing=0 cellpadding=0> |
next if (($hostname eq '') || ($spareservers{$hostname}));
|
<tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr> |
$spareservers{$hostname} = 1;
|
<tr> |
my $protocol = $Apache::lonnet::protocol{$hostid};
|
<td bgcolor="$mainbg"><br /><font size=-1><b> $lt{'un'}:</b></font></td> |
$protocol = 'http' if ($protocol ne 'https');
|
<td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td> |
$spares.='<br /><a href="'.$protocol.'://'.
|
</tr> |
$hostname.
|
<tr> |
'/adm/login?domain='.$authdomain.'">'.
|
<td bgcolor="$mainbg"><font size=-1><b> $lt{'pw'}:</b></font></td> |
$hostname.'</a>';
|
<td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td> |
}
|
</tr> |
$r->print(
|
<tr> |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
<td bgcolor="$mainbg"><font size=-1><b> $lt{'dom'}:</b></font></td> |
.'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
|
<td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td> |
.'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>'
|
</tr> |
.&mt('The LearningOnline Network with CAPA')
|
<tr> |
.'</title></head>'
|
<td bgcolor="$mainbg"> </td> |
.'<body bgcolor="#FFFFFF">'
|
<td bgcolor="$mainbg" valign="bottom" align="center"> |
.'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
|
<br /> |
.'<img src="/adm/lonKaputt/lonlogo_broken.gif" alt="broken icon" align="right" />'
|
<input type="submit" value="$lt{'log'}" /> |
.'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
|
</td> |
if ($spares) {
|
</tr> |
$r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
|
<tr> |
.'</p>'
|
<td bgcolor="$mainbg" valign="bottom" align="left" colspan="2"> |
.$spares);
|
$loginhelp |
}
|
$forgotpw |
$r->print('</body>'
|
</td> |
.'</html>'
|
</tr> |
);
|
</table> |
return OK;
|
<!-- End sub-table --> |
}
|
</form> |
|
ENDLOGIN |
# ----------------------------------------------- Apparently we are in business
|
if ($fullgraph) { |
$servadm=~s/\,/\<br \/\>/g;
|
my $helpdeskscript; |
|
my $contactblock = &contactdisplay(\%lt,$version,$authdomain,\$helpdeskscript); |
# ----------------------------------------------------------- Front page design
|
$r->print(<<ENDDOCUMENT); |
my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
|
</td> |
my $font=&Apache::loncommon::designparm('login.font',$domain);
|
|
my $link=&Apache::loncommon::designparm('login.link',$domain);
|
<!-- Row 4 Column 2 --> |
my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
|
<td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td> |
my $alink=&Apache::loncommon::designparm('login.alink',$domain);
|
|
my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
|
<!-- Row 4 Column 3 --> |
my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
|
<td bgcolor="$mainbg">$announcements</td> |
my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
|
|
my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
|
<!-- Row 4 Column 4 --> |
my $logo=&Apache::loncommon::designparm('login.logo',$domain);
|
<td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td> |
my $img=&Apache::loncommon::designparm('login.img',$domain);
|
</tr> |
my $domainlogo=&Apache::loncommon::domainlogo($domain);
|
<tr> |
my $showbanner = 1;
|
|
my $showmainlogo = 1;
|
<!-- Row 5 Column 1 --> |
if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
|
<td bgcolor="$sidebg" valign="middle" align="left"> |
$showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
|
<br /> |
}
|
<table border=0 cellspacing=0 cellpadding=0> |
if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
|
<tr> |
$showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
|
<td bgcolor="$sidebg" align="left" valign="top"> |
}
|
<small><b> $lt{'dom'}: </b></small> |
my $showadminmail;
|
</td> |
my @possdoms = &Apache::lonnet::current_machine_domains();
|
<td bgcolor="$sidebg" align="left" valign="top"> |
if (grep(/^\Q$domain\E$/,@possdoms)) {
|
<small><tt> $domain</tt></small> |
$showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
|
</td> |
}
|
</tr> |
my $showcoursecat =
|
<tr> |
&Apache::loncommon::designparm('login.coursecatalog',$domain);
|
<td bgcolor="$sidebg" align="left" valign="top"> |
my $shownewuserlink =
|
<small><b> $lt{'serv'}: </b></small> |
&Apache::loncommon::designparm('login.newuser',$domain);
|
</td> |
my $showhelpdesk =
|
<td bgcolor="$sidebg" align="left" valign="top"> |
&Apache::loncommon::designparm('login.helpdesk',$domain);
|
<small><tt> $lonhost ($role)</tt></small> |
my $now=time;
|
</td> |
my $js = (<<ENDSCRIPT);
|
</tr> |
|
<tr> |
<script type="text/javascript" language="JavaScript">
|
<td bgcolor="$sidebg" align="left" valign="top"> |
// <![CDATA[
|
<small><b> $lt{'load'}: </b></small> |
function send()
|
</td> |
{
|
<td bgcolor="$sidebg" align="left" valign="top"> |
this.document.server.elements.uname.value
|
<small><tt> $loadpercent $lt{'perc'}</tt></small> |
=this.document.client.elements.uname.value;
|
</td> |
|
</tr> |
this.document.server.elements.udom.value
|
<tr> |
=this.document.client.elements.udom.value;
|
<td bgcolor="$sidebg" align="left" valign="top"> |
|
<small><b> $lt{'userload'}: </b></small> |
uextkey=this.document.client.elements.uextkey.value;
|
</td> |
lextkey=this.document.client.elements.lextkey.value;
|
<td bgcolor="$sidebg" align="left" valign="top"> |
initkeys();
|
<small><tt> $userloadpercent $lt{'perc'}</tt></small> |
|
</td> |
if(this.document.server.action.substr(0,5) === 'http:'){
|
</tr> |
this.document.server.elements.upass0.value
|
</table> |
=getCrypted(this.document.client.elements.upass$now.value);
|
<br /> |
} else {
|
$contactblock |
this.document.server.elements.upass0.value
|
</td> |
=this.document.client.elements.upass$now.value;
|
|
}
|
<!-- Row 5 Column 2 --> |
|
<td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td> |
this.document.client.elements.uname.value='';
|
|
this.document.client.elements.upass$now.value='';
|
<!-- Row 5 Column 3 --> |
|
<td width="100%" valign="bottom" bgcolor="$mainbg"> |
this.document.server.submit();
|
$domainlogo |
return false;
|
</td> |
}
|
|
|
<!-- Row 5 Column 4 --> |
function enableInput() {
|
<td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td> |
this.document.client.elements.upass$now.removeAttribute("readOnly");
|
</tr> |
this.document.client.elements.uname.removeAttribute("readOnly");
|
<tr> |
this.document.client.elements.udom.removeAttribute("readOnly");
|
|
return;
|
<!-- Row 6 Column 1 --> |
}
|
<td bgcolor="$sidebg"> </td> |
|
|
// ]]>
|
<!-- Row 6 Column 2 --> |
</script>
|
<td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td> |
|
|
ENDSCRIPT
|
<!-- Row 6 Column 3 --> |
|
<td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td> |
# --------------------------------------------------- Print login screen header
|
|
|
<!-- Row 6 Column 4 --> |
my %add_entries = (
|
<td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td> |
bgcolor => "$mainbg",
|
</tr> |
text => "$font",
|
</table> |
link => "$link",
|
|
vlink => "$vlink",
|
<script type="text/javascript"> |
alink => "$alink",
|
// the if prevents the script error if the browser can not handle this |
onload => 'javascript:enableInput();',);
|
if ( document.client.uname ) { document.client.uname.focus(); } |
|
</script> |
my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
|
$helpdeskscript |
@hosts = &Apache::lonnet::current_machine_ids();
|
|
$lonhost_in_use = $lonhost;
|
ENDDOCUMENT |
if (@hosts > 1) {
|
} |
foreach my $hostid (@hosts) {
|
$r->print('</body></html>'); |
if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
|
return OK; |
$lonhost_in_use = $hostid;
|
} |
last;
|
|
}
|
sub contactdisplay { |
}
|
my ($lt,$version,$authdomain,$helpdeskscript) = @_; |
}
|
my $contactblock; |
%defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
|
my $showhelpdesk = 0; |
$headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
|
my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
$headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
|
if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) { |
if ($headextra) {
|
$showhelpdesk = 1; |
my $omitextra;
|
} |
if ($headextra_exempt ne '') {
|
if ($showhelpdesk) { |
my @exempt = split(',',$headextra_exempt);
|
$contactblock .= '<b> <a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />'; |
my $ip = &Apache::lonnet::get_requestor_ip();
|
my $thisurl = &escape('/adm/login'); |
if (grep(/^\Q$ip\E$/,@exempt)) {
|
$$helpdeskscript = <<"ENDSCRIPT"; |
$omitextra = 1;
|
<script type="text/javascript"> |
}
|
function helpdesk() { |
}
|
var codedom = document.client.udom.value; |
unless ($omitextra) {
|
if (codedom == '') { |
my $confname = $defdom.'-domainconfig';
|
codedom = "$authdomain"; |
if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
|
} |
my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
|
var querystr = "origurl=$thisurl&codedom="+codedom; |
unless ($extra eq '-1') {
|
document.location.href = "/adm/helpdesk?"+querystr; |
$js .= "\n".$extra."\n";
|
return; |
}
|
} |
}
|
</script> |
}
|
ENDSCRIPT |
}
|
} |
|
$contactblock .= <<"ENDBLOCK"; |
$r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
|
$version |
{ 'redirect' => [$expire,'/adm/roles'],
|
ENDBLOCK |
'add_entries' => \%add_entries,
|
return $contactblock; |
'only_body' => 1,}));
|
} |
|
|
# ----------------------------------------------------------------------- Texts
|
sub forgotpwdisplay { |
|
my (%lt) = @_; |
my %lt=&Apache::lonlocal::texthash(
|
my $prompt_for_resetpw = 1; |
'un' => 'Username',
|
if ($prompt_for_resetpw) { |
'pw' => 'Password',
|
return '<br /> <a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a></b><br /><br />'; |
'dom' => 'Domain',
|
} |
'perc' => 'percent',
|
return; |
'load' => 'Server Load',
|
} |
'userload' => 'User Load',
|
|
'catalog' => 'Course/Community Catalog',
|
sub loginhelpdisplay { |
'log' => 'Log in',
|
my (%lt) = @_; |
'help' => 'Log-in Help',
|
my $login_help = 1; |
'serv' => 'Server',
|
if ($login_help) { |
'servadm' => 'Server Administration',
|
return ' <a href="/adm/loginproblems.html">'.$lt{'help'}.'</a></b>'; |
'helpdesk' => 'Contact Helpdesk',
|
} |
'forgotpw' => 'Forgot password?',
|
return; |
'newuser' => 'New User?',
|
} |
);
|
|
# -------------------------------------------------- Change password field name
|
1; |
|
__END__ |
my $forgotpw = &forgotpwdisplay(%lt);
|
|
$forgotpw .= '<br />' if $forgotpw;
|
|
my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
|
|
if ($loginhelp) {
|
|
$loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
|
|
}
|
|
|
|
# ---------------------------------------------------- Serve out DES JavaScript
|
|
{
|
|
my $jsh=Apache::File->new($include."/londes.js");
|
|
$r->print(<$jsh>);
|
|
}
|
|
# ---------------------------------------------------------- Serve rest of page
|
|
|
|
$r->print(
|
|
'<div class="LC_Box"'
|
|
.' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
|
|
);
|
|
|
|
$r->print(<<ENDSERVERFORM);
|
|
<form name="server" action="/adm/authenticate" method="post" target="_top">
|
|
<input type="hidden" name="logtoken" value="$logtoken" />
|
|
<input type="hidden" name="serverid" value="$lonhost" />
|
|
<input type="hidden" name="uname" value="" />
|
|
<input type="hidden" name="upass0" value="" />
|
|
<input type="hidden" name="udom" value="" />
|
|
<input type="hidden" name="localpath" value="$env{'form.localpath'}" />
|
|
<input type="hidden" name="localres" value="$env{'form.localres'}" />
|
|
</form>
|
|
ENDSERVERFORM
|
|
my $coursecatalog;
|
|
if (($showcoursecat eq '') || ($showcoursecat)) {
|
|
$coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
|
|
}
|
|
my $newuserlink;
|
|
if ($shownewuserlink) {
|
|
$newuserlink = &newuser_link($lt{'newuser'}).'<br />';
|
|
}
|
|
my $logintitle =
|
|
'<h2 class="LC_hcell"'
|
|
.' style="background:'.$loginbox_header_bgcol.';'
|
|
.' color:'.$loginbox_header_textcol.'">'
|
|
.$lt{'log'}
|
|
.'</h2>';
|
|
|
|
my $noscript_warning='<noscript><span class="LC_warning"><b>'
|
|
.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
|
|
.'</b></span></noscript>';
|
|
my $helpdeskscript;
|
|
my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
|
|
$authdomain,\$helpdeskscript,
|
|
$showhelpdesk,\@possdoms);
|
|
|
|
my $mobileargs;
|
|
if ($clientmobile) {
|
|
$mobileargs = 'autocapitalize="off" autocorrect="off"';
|
|
}
|
|
my $loginform=(<<LFORM);
|
|
<form name="client" action="" onsubmit="return(send())">
|
|
<input type="hidden" name="lextkey" value="$lextkey" />
|
|
<input type="hidden" name="uextkey" value="$uextkey" />
|
|
<b><label for="uname">$lt{'un'}</label>:</b><br />
|
|
<input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
|
|
<b><label for="upass$now">$lt{'pw'}</label>:</b><br />
|
|
<input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
|
|
<b><label for="udom">$lt{'dom'}</label>:</b><br />
|
|
<input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
|
|
<input type="submit" value="$lt{'log'}" />
|
|
</form>
|
|
LFORM
|
|
|
|
if ($showbanner) {
|
|
$r->print(<<HEADER);
|
|
<!-- The LON-CAPA Header -->
|
|
<div style="background:$pgbg;margin:0;width:100%;">
|
|
<img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
|
|
</div>
|
|
HEADER
|
|
}
|
|
$r->print(<<ENDTOP);
|
|
<div style="float:left;margin-top:0;">
|
|
<div class="LC_Box" style="background:$loginbox_bg;">
|
|
$logintitle
|
|
$loginform
|
|
$noscript_warning
|
|
</div>
|
|
|
|
<div class="LC_Box" style="padding-top: 10px;">
|
|
$loginhelp
|
|
$forgotpw
|
|
$contactblock
|
|
$newuserlink
|
|
$coursecatalog
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
ENDTOP
|
|
if ($showmainlogo) {
|
|
$r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
|
|
}
|
|
$r->print(<<ENDTOP);
|
|
$announcements
|
|
</div>
|
|
<hr style="clear:both;" />
|
|
ENDTOP
|
|
my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
|
|
$domainrow = <<"END";
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<small><b>$lt{'dom'}: </b></small>
|
|
</td>
|
|
<td align="left" valign="top">
|
|
<small><tt> $domain</tt></small>
|
|
</td>
|
|
</tr>
|
|
END
|
|
$serverrow = <<"END";
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<small><b>$lt{'serv'}: </b></small>
|
|
</td>
|
|
<td align="left" valign="top">
|
|
<small><tt> $lonhost ($role)</tt></small>
|
|
</td>
|
|
</tr>
|
|
END
|
|
if ($loadlim) {
|
|
$loadrow = <<"END";
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<small><b>$lt{'load'}: </b></small>
|
|
</td>
|
|
<td align="left" valign="top">
|
|
<small><tt> $loadpercent $lt{'perc'}</tt></small>
|
|
</td>
|
|
</tr>
|
|
END
|
|
}
|
|
if ($uloadlim) {
|
|
$userloadrow = <<"END";
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<small><b>$lt{'userload'}: </b></small>
|
|
</td>
|
|
<td align="left" valign="top">
|
|
<small><tt> $userloadpercent $lt{'perc'}</tt></small>
|
|
</td>
|
|
</tr>
|
|
END
|
|
}
|
|
if (($version ne '') && ($version ne '<!-- VERSION -->')) {
|
|
$versionrow = <<"END";
|
|
<tr>
|
|
<td colspan="2" align="left">
|
|
<small>$version</small>
|
|
</td>
|
|
</tr>
|
|
END
|
|
}
|
|
|
|
$r->print(<<ENDDOCUMENT);
|
|
<div style="float: left;">
|
|
<table border="0" cellspacing="0" cellpadding="0">
|
|
$domainrow
|
|
$serverrow
|
|
$loadrow
|
|
$userloadrow
|
|
$versionrow
|
|
</table>
|
|
</div>
|
|
<div style="float: right;">
|
|
$domainlogo
|
|
</div>
|
|
<br style="clear:both;" />
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
// <![CDATA[
|
|
// the if prevents the script error if the browser can not handle this
|
|
if ( document.client.uname ) { document.client.uname.focus(); }
|
|
// ]]>
|
|
</script>
|
|
$helpdeskscript
|
|
|
|
ENDDOCUMENT
|
|
my %endargs = ( 'noredirectlink' => 1, );
|
|
$r->print(&Apache::loncommon::end_page(\%endargs));
|
|
return OK;
|
|
}
|
|
|
|
sub check_loginvia {
|
|
my ($domain,$lonhost,$lonidsdir,$balcookie,$linkprot) = @_;
|
|
if ($domain eq '' || $lonhost eq '' || $lonidsdir eq '') {
|
|
return;
|
|
}
|
|
my %domconfhash = &Apache::loncommon::get_domainconf($domain);
|
|
my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
|
|
my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
|
|
my $output;
|
|
if ($loginvia ne '') {
|
|
my $noredirect;
|
|
my $ip = &Apache::lonnet::get_requestor_ip();
|
|
if ($ip eq '127.0.0.1') {
|
|
$noredirect = 1;
|
|
} else {
|
|
if ($loginvia_exempt ne '') {
|
|
my @exempt = split(',',$loginvia_exempt);
|
|
if (grep(/^\Q$ip\E$/,@exempt)) {
|
|
$noredirect = 1;
|
|
}
|
|
}
|
|
}
|
|
unless ($noredirect) {
|
|
my ($newhost,$path);
|
|
if ($loginvia =~ /:/) {
|
|
($newhost,$path) = split(':',$loginvia);
|
|
} else {
|
|
$newhost = $loginvia;
|
|
}
|
|
if ($newhost ne $lonhost) {
|
|
if (&Apache::lonnet::hostname($newhost) ne '') {
|
|
if ($balcookie) {
|
|
my ($balancer,$cookie) = split(/:/,$balcookie);
|
|
if ($cookie =~ /^($match_domain)_($match_username)_([a-f0-9]+)$/) {
|
|
my ($udom,$uname,$cookieid) = ($1,$2,$3);
|
|
unless (&Apache::lonnet::delbalcookie($cookie,$balancer) eq 'ok') {
|
|
if ((-d $lonidsdir) && (opendir(my $dh,$lonidsdir))) {
|
|
while (my $filename=readdir($dh)) {
|
|
if ($filename=~/^(\Q$uname\E_\d+_\Q$udom\E_$match_lonid)\.id$/) {
|
|
my $handle = $1;
|
|
my %hash =
|
|
&Apache::lonnet::get_sessionfile_vars($handle,$lonidsdir,
|
|
['request.balancercookie',
|
|
'user.linkedenv']);
|
|
if ($hash{'request.balancercookie'} eq "$balancer:$cookieid") {
|
|
if (unlink("$lonidsdir/$filename")) {
|
|
if (($hash{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&
|
|
(-l "$lonidsdir/$hash{'user.linkedenv'}.id") &&
|
|
(readlink("$lonidsdir/$hash{'user.linkedenv'}.id") eq "$lonidsdir/$filename")) {
|
|
unlink("$lonidsdir/$hash{'user.linkedenv'}.id");
|
|
}
|
|
}
|
|
}
|
|
last;
|
|
}
|
|
}
|
|
closedir($dh);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$output = &redirect_page($newhost,$path,$linkprot);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
sub redirect_page {
|
|
my ($desthost,$path,$linkprot) = @_;
|
|
my $hostname = &Apache::lonnet::hostname($desthost);
|
|
my $protocol = $Apache::lonnet::protocol{$desthost};
|
|
$protocol = 'http' if ($protocol ne 'https');
|
|
unless ($path =~ m{^/}) {
|
|
$path = '/'.$path;
|
|
}
|
|
my $url = $protocol.'://'.$hostname.$path;
|
|
if ($env{'form.firsturl'} ne '') {
|
|
$url .='?firsturl='.$env{'form.firsturl'};
|
|
}
|
|
if ($linkprot) {
|
|
my $ltoken = &Apache::lonnet::tmpput({linkprot => $linkprot},$desthost);
|
|
if ($ltoken) {
|
|
$url .= (($url =~ /\?/) ? '&' : '?').'ltoken='.$ltoken;
|
|
}
|
|
}
|
|
my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
|
|
{'redirect' => [0,$url],});
|
|
my $end_page = &Apache::loncommon::end_page();
|
|
return $start_page.$end_page;
|
|
}
|
|
|
|
sub contactdisplay {
|
|
my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
|
|
$possdoms) = @_;
|
|
my $contactblock;
|
|
my $origmail;
|
|
if (ref($possdoms) eq 'ARRAY') {
|
|
if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
|
|
$origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
|
|
}
|
|
}
|
|
my $requestmail =
|
|
&Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
|
|
$authdomain,$origmail);
|
|
unless ($showhelpdesk eq '0') {
|
|
if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
|
|
$showhelpdesk = 1;
|
|
} else {
|
|
$showhelpdesk = 0;
|
|
}
|
|
}
|
|
if ($servadm && $showadminmail) {
|
|
$contactblock .= $$lt{'servadm'}.':<br />'.
|
|
'<tt>'.$servadm.'</tt><br />';
|
|
}
|
|
if ($showhelpdesk) {
|
|
$contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
|
|
my $thisurl = &escape('/adm/login');
|
|
$$helpdeskscript = <<"ENDSCRIPT";
|
|
<script type="text/javascript">
|
|
// <![CDATA[
|
|
function helpdesk() {
|
|
var possdom = document.client.udom.value;
|
|
var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
|
|
if (codedom == '') {
|
|
codedom = "$authdomain";
|
|
}
|
|
var querystr = "origurl=$thisurl&codedom="+codedom;
|
|
document.location.href = "/adm/helpdesk?"+querystr;
|
|
return;
|
|
}
|
|
// ]]>
|
|
</script>
|
|
ENDSCRIPT
|
|
}
|
|
return $contactblock;
|
|
}
|
|
|
|
sub forgotpwdisplay {
|
|
my (%lt) = @_;
|
|
my $prompt_for_resetpw = 1;
|
|
if ($prompt_for_resetpw) {
|
|
return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
|
|
}
|
|
return;
|
|
}
|
|
|
|
sub coursecatalog_link {
|
|
my ($linkname) = @_;
|
|
return <<"END";
|
|
<a href="/adm/coursecatalog">$linkname</a>
|
|
END
|
|
}
|
|
|
|
sub newuser_link {
|
|
my ($linkname) = @_;
|
|
return '<a href="/adm/createaccount">'.$linkname.'</a>';
|
|
}
|
|
|
|
1;
|
|
__END__
|