version 1.84, 2006/11/15 00:53:48
|
version 1.97, 2007/10/09 16:27:08
|
Line 30 package Apache::lonlogin;
|
Line 30 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(); |
Line 40 use Apache::migrateuser();
|
Line 39 use Apache::migrateuser();
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA; |
use LONCAPA; |
|
|
|
|
sub additional_machine_domains { |
|
my @domains; |
|
open(my $fh,"<".$Apache::lonnet::perlvar{'lonTabDir'}.'/expected_domains.tab'); |
|
while( my $line = <$fh>) { |
|
$line =~ s/\s//g; |
|
push(@domains,$line); |
|
} |
|
return @domains; |
|
} |
|
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
Line 80 sub handler {
|
Line 68 sub handler {
|
|
|
|
|
# -------------------------------- Prevent users from attempting to login twice |
# -------------------------------- Prevent users from attempting to login twice |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
my $handle = &Apache::lonnet::check_for_valid_session($r); |
my $lonid=$cookies{'lonID'}; |
if ($handle=~/^publicuser\_/) { |
my $cookie; |
|
if ($lonid) { |
|
my $handle=$lonid->value; |
|
$handle=~s/\W//g; |
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
|
if (-e "$lonidsdir/$handle.id") { |
|
# Is there an existing token file? |
|
if ($handle=~/^publicuser\_/) { |
|
# For "public user" - remove it, we apparently really want to login |
# For "public user" - remove it, we apparently really want to login |
unlink("$lonidsdir/$handle.id"); |
unlink($r->dir_config('lonIDsDir')."/$handle.id"); |
} elsif ($handle ne '') { |
} elsif ($handle ne '') { |
# Indeed, a valid token is found |
# Indeed, a valid token is found |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Already logged in'); |
&Apache::loncommon::start_page('Already logged in'); |
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
$r->print(<<ENDFAILED); |
$r->print(<<ENDFAILED); |
$start_page |
$start_page |
<h1>You are already logged in</h1> |
<h1>You are already logged in</h1> |
<p>Please either <a href="/adm/roles">continue the current session</a> or |
<p>Please either <a href="/adm/roles">continue the current session</a> or |
Line 107 $start_page
|
Line 87 $start_page
|
<a href="/adm/loginproblems.html">Problems?</a></p> |
<a href="/adm/loginproblems.html">Problems?</a></p> |
$end_page |
$end_page |
ENDFAILED |
ENDFAILED |
return OK; |
return OK; |
} |
|
} |
|
} |
} |
|
|
# ---------------------------------------------------- No valid token, continue |
# ---------------------------------------------------- No valid token, continue |
Line 132 ENDFAILED
|
Line 110 ENDFAILED
|
} |
} |
|
|
my $fullgraph=($env{'form.interface'} ne 'textual'); |
my $fullgraph=($env{'form.interface'} ne 'textual'); |
my $port_to_use=$r->dir_config('lonhttpdPort'); |
|
if (!defined($port_to_use)) { |
my $iconpath= |
$port_to_use='8080'; |
&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
} |
|
my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use. |
my $domain = &Apache::lonnet::default_login_domain(); |
$r->dir_config('lonIconsURL'); |
|
my $domain = $r->dir_config('lonDefDomain'); |
|
my $testdomain=(split(/\./,$ENV{'HTTP_HOST'}))[0]; |
|
foreach my $posdom (&Apache::lonnet::current_machine_domains(), |
|
&additional_machine_domains()) { |
|
if (lc($posdom) eq lc($testdomain)) { $domain=$posdom; } |
|
} |
|
if (($env{'form.domain'}) && |
if (($env{'form.domain'}) && |
($Apache::lonnet::domaindescription{$env{'form.domain'}})) { |
(&Apache::lonnet::domain($env{'form.domain'},'description'))) { |
$domain=$env{'form.domain'}; |
$domain=$env{'form.domain'}; |
} |
} |
my $role = $r->dir_config('lonRole'); |
my $role = $r->dir_config('lonRole'); |
my $loadlim = $r->dir_config('lonLoadLim'); |
my $loadlim = $r->dir_config('lonLoadLim'); |
|
my $servadm = $r->dir_config('lonAdmEMail'); |
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
my $tabdir = $r->dir_config('lonTabDir'); |
my $tabdir = $r->dir_config('lonTabDir'); |
my $include = $r->dir_config('lonIncludes'); |
my $include = $r->dir_config('lonIncludes'); |
my $expire = $r->dir_config('lonExpire'); |
my $expire = $r->dir_config('lonExpire'); |
my $version = $r->dir_config('lonVersion'); |
my $version = $r->dir_config('lonVersion'); |
my $host_name = $Apache::lonnet::hostname{$lonhost}; |
my $host_name = &Apache::lonnet::hostname($lonhost); |
|
|
# --------------------------------------------- Default values for login fields |
# --------------------------------------------- Default values for login fields |
|
|
Line 176 ENDFAILED
|
Line 148 ENDFAILED
|
my $otherserver= &Apache::lonnet::absolute_url($host_name); |
my $otherserver= &Apache::lonnet::absolute_url($host_name); |
my $firsturl= |
my $firsturl= |
($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'}); |
($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'}); |
# ---------------------------------------- Are we access server and overloaded? |
# ---------------------------------------------------------- Are we overloaded? |
if (($role eq 'access') && |
if ((($userloadpercent>100.0)||($loadpercent>100.0))) { |
(($userloadpercent>100.0)||($loadpercent>100.0))) { |
|
my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); |
my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); |
if ($unloaded) { $otherserver=$unloaded; } |
if ($unloaded) { $otherserver=$unloaded; } |
} |
} |
Line 217 ENDFAILED
|
Line 188 ENDFAILED
|
my $last; |
my $last; |
foreach my $hostid (sort |
foreach my $hostid (sort |
{ |
{ |
$Apache::lonnet::hostname{$a} cmp |
&Apache::lonnet::hostname($a) cmp |
$Apache::lonnet::hostname{$b}; |
&Apache::lonnet::hostname($b); |
} |
} |
keys(%Apache::lonnet::spareid)) { |
keys(%Apache::lonnet::spareid)) { |
next if ($hostid eq $lonhost); |
next if ($hostid eq $lonhost); |
next if ($last eq $Apache::lonnet::hostname{$hostid}); |
my $hostname = &Apache::lonnet::hostname($hostid); |
|
next if ($last eq $hostname); |
$spares.='<br /><font size="+1"><a href="http://'. |
$spares.='<br /><font size="+1"><a href="http://'. |
$Apache::lonnet::hostname{$hostid}. |
$hostname. |
'/adm/login?domain='.$authdomain.'">'. |
'/adm/login?domain='.$authdomain.'">'. |
$Apache::lonnet::hostname{$hostid}.'</a>'. |
$hostname.'</a>'. |
' (preferred)</font>'.$/; |
' (preferred)</font>'.$/; |
$last=$Apache::lonnet::hostname{$hostid}; |
$last=$hostname; |
} |
} |
$spares.= '<br />'; |
$spares.= '<br />'; |
|
my %all_hostnames = &Apache::lonnet::all_hostnames(); |
foreach my $hostid (sort |
foreach my $hostid (sort |
{ |
{ |
$Apache::lonnet::hostname{$a} cmp |
&Apache::lonnet::hostname($a) cmp |
$Apache::lonnet::hostname{$b}; |
&Apache::lonnet::hostname($b); |
} |
} |
keys(%Apache::lonnet::hostname)) { |
keys(%all_hostnames)) { |
next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid}); |
next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid}); |
next if ($last eq $Apache::lonnet::hostname{$hostid}); |
my $hostname = &Apache::lonnet::hostname($hostid); |
|
next if ($last eq $hostname); |
$spares.='<br /><a href="http://'. |
$spares.='<br /><a href="http://'. |
$Apache::lonnet::hostname{$hostid}. |
$hostname. |
'/adm/login?domain='.$authdomain.'">'. |
'/adm/login?domain='.$authdomain.'">'. |
$Apache::lonnet::hostname{$hostid}.'</a>'; |
$hostname.'</a>'; |
$last=$Apache::lonnet::hostname{$hostid}; |
$last=$hostname; |
} |
} |
$r->print(<<ENDTROUBLE); |
$r->print(<<ENDTROUBLE); |
<html> |
<html> |
Line 259 ENDTROUBLE
|
Line 233 ENDTROUBLE
|
} |
} |
|
|
# ----------------------------------------------- Apparently we are in business |
# ----------------------------------------------- Apparently we are in business |
|
$servadm=~s/\,/\<br \/\>/g; |
my $domainlogo=&Apache::loncommon::domainlogo($domain); |
|
|
|
# --------------------------------------------------- Print login screen header |
# --------------------------------------------------- Print login screen header |
$r->print(<<ENDHEADER); |
$r->print(<<ENDHEADER); |
Line 292 ENDHEADER
|
Line 265 ENDHEADER
|
($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF'); |
($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF'); |
my $logo=&Apache::loncommon::designparm('login.logo',$domain); |
my $logo=&Apache::loncommon::designparm('login.logo',$domain); |
my $img=&Apache::loncommon::designparm('login.img',$domain); |
my $img=&Apache::loncommon::designparm('login.img',$domain); |
|
my $domainlogo=&Apache::loncommon::domainlogo($domain); |
|
my $showadminmail=&Apache::loncommon::designparm('login.adminmail', $domain); |
|
my $showcoursecat = |
|
&Apache::loncommon::designparm('login.coursecatalog',$domain); |
|
|
|
|
# ----------------------------------------------------------------------- Texts |
# ----------------------------------------------------------------------- Texts |
|
|
Line 309 my %lt=&Apache::lonlocal::texthash(
|
Line 287 my %lt=&Apache::lonlocal::texthash(
|
'log' => 'Log in', |
'log' => 'Log in', |
'help' => 'Log-in Help', |
'help' => 'Log-in Help', |
'serv' => 'Server', |
'serv' => 'Server', |
|
'servadm' => 'Server Administration', |
'helpdesk' => 'Contact Helpdesk', |
'helpdesk' => 'Contact Helpdesk', |
'forgotpw' => 'Forgot password?'); |
'forgotpw' => 'Forgot password?'); |
# -------------------------------------------------- Change password field name |
# -------------------------------------------------- Change password field name |
Line 393 ENDSCRIPT
|
Line 372 ENDSCRIPT
|
<input type="hidden" name="localres" value="$env{'form.localres'}" /> |
<input type="hidden" name="localres" value="$env{'form.localres'}" /> |
</form> |
</form> |
ENDSERVERFORM |
ENDSERVERFORM |
|
my $coursecatalog; |
|
if (($showcoursecat eq '') || ($showcoursecat)) { |
|
$coursecatalog = &coursecatalog_link($lt{'catalog'}); |
|
} |
if ($fullgraph) { $r->print(<<ENDTOP); |
if ($fullgraph) { $r->print(<<ENDTOP); |
<!-- The LON-CAPA Header --> |
<!-- The LON-CAPA Header --> |
<tr> |
<tr> |
Line 420 ENDSERVERFORM
|
Line 403 ENDSERVERFORM
|
|
|
<!-- A cell that will hold the 'access', 'about', and 'catalog' links --> |
<!-- A cell that will hold the 'access', 'about', and 'catalog' links --> |
<!-- Row 3 Column 1 --> |
<!-- Row 3 Column 1 --> |
<td valign="top" height=60 align="left" bgcolor="$sidebg"> |
<td valign="top" height="60" align="left" bgcolor="$sidebg"> |
<table cellpadding="0" cellspacing="2" border="0"> |
<table cellpadding="0" cellspacing="2" border="0"> |
<tr> |
<tr> |
<td> </td> |
<td> </td> |
<td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td> |
<td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td> |
</tr> |
</tr> |
<tr> |
<tr> |
<td> </td> |
<td> </td> |
<td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td> |
<td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td> |
</tr> |
</tr>$coursecatalog |
<tr> |
<tr> |
<td> </td> |
|
<td><a href="/adm/coursecatalog"><b>$lt{'catalog'}</b></a></td> |
|
</tr> |
|
<tr> |
|
<td colspan="2"> </td> |
<td colspan="2"> </td> |
</tr> |
</tr> |
</table> |
</table> |
|
</td> |
<!-- The shaded space between the two main columns --> |
<!-- The shaded space between the two main columns --> |
<!-- Row 3 Column 2 --> |
<!-- Row 3 Column 2 --> |
<td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td> |
<td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td> |
Line 491 ENDNOOPT
|
Line 471 ENDNOOPT
|
<table border=0 cellspacing=0 cellpadding=0> |
<table border=0 cellspacing=0 cellpadding=0> |
<tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr> |
<tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr> |
<tr> |
<tr> |
<td bgcolor="$mainbg"><br /><font size=-1><b> $lt{'un'}:</b></font></td> |
<td bgcolor="$mainbg"><br /><font size=-1><b> <label for="uname">$lt{'un'}</label>:</b></font></td> |
<td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td> |
<td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td> |
</tr> |
</tr> |
<tr> |
<tr> |
<td bgcolor="$mainbg"><font size=-1><b> $lt{'pw'}:</b></font></td> |
<td bgcolor="$mainbg"><font size=-1><b> <label for="upass$now">$lt{'pw'}</label>:</b></font></td> |
<td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td> |
<td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td> |
</tr> |
</tr> |
<tr> |
<tr> |
<td bgcolor="$mainbg"><font size=-1><b> $lt{'dom'}:</b></font></td> |
<td bgcolor="$mainbg"><font size=-1><b> <label for="udom">$lt{'dom'}</label>:</b></font></td> |
<td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td> |
<td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td> |
</tr> |
</tr> |
<tr> |
<tr> |
Line 521 ENDNOOPT
|
Line 501 ENDNOOPT
|
ENDLOGIN |
ENDLOGIN |
if ($fullgraph) { |
if ($fullgraph) { |
my $helpdeskscript; |
my $helpdeskscript; |
my $contactblock = &contactdisplay(\%lt,$version,$authdomain,\$helpdeskscript); |
my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail, |
|
$version,$authdomain,\$helpdeskscript); |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
</td> |
</td> |
|
|
Line 617 ENDDOCUMENT
|
Line 598 ENDDOCUMENT
|
} |
} |
|
|
sub contactdisplay { |
sub contactdisplay { |
my ($lt,$version,$authdomain,$helpdeskscript) = @_; |
my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_; |
my $contactblock; |
my $contactblock; |
my $showhelpdesk = 0; |
my $showhelpdesk = 0; |
my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; |
if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) { |
if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) { |
$showhelpdesk = 1; |
$showhelpdesk = 1; |
} |
} |
|
if ($servadm && $showadminmail) { |
|
$contactblock .= '<b> '.$$lt{'servadm'}.':</b><br />'. |
|
'<tt> '.$servadm.'</tt><br /> <br />'; |
|
} |
if ($showhelpdesk) { |
if ($showhelpdesk) { |
$contactblock .= '<b> <a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />'; |
$contactblock .= '<b> <a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />'; |
my $thisurl = &escape('/adm/login'); |
my $thisurl = &escape('/adm/login'); |
Line 665 sub loginhelpdisplay {
|
Line 650 sub loginhelpdisplay {
|
return; |
return; |
} |
} |
|
|
|
sub coursecatalog_link { |
|
my ($linkname) = @_; |
|
return <<"END"; |
|
<tr> |
|
<td> </td> |
|
<td><a href="/adm/coursecatalog"><b>$linkname</b></a></td> |
|
</tr> |
|
END |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |