version 1.132, 2010/02/08 13:28:40
|
version 1.133, 2010/03/03 17:00:01
|
Line 121 sub handler {
|
Line 121 sub handler {
|
|
|
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
my $domain = &Apache::lonnet::default_login_domain(); |
my $domain = &Apache::lonnet::default_login_domain(); |
my %domconfhash = &Apache::loncommon::get_domainconf($domain); |
|
if ($lonhost ne '') { |
if ($lonhost ne '') { |
my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost}; |
my $redirect = &check_loginvia($domain,$lonhost); |
if (($loginvia ne '') && ($loginvia ne $lonhost)) { |
if ($redirect) { |
if (&Apache::lonnet::hostname($loginvia) ne '') { |
$r->print($redirect); |
$r->print(&redirect_page($loginvia)); |
return OK; |
return OK; |
} |
} |
|
} |
|
} |
} |
|
|
if (($env{'form.domain'}) && |
if (($env{'form.domain'}) && |
Line 529 ENDDOCUMENT
|
Line 526 ENDDOCUMENT
|
return OK; |
return OK; |
} |
} |
|
|
|
sub check_loginvia { |
|
my ($domain,$lonhost) = @_; |
|
if ($domain eq '' || $lonhost 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 = $ENV{'REMOTE_ADDR'}; |
|
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 '') { |
|
$output = &redirect_page($newhost,$path); |
|
} |
|
} |
|
} |
|
} |
|
return $output; |
|
} |
|
|
sub redirect_page { |
sub redirect_page { |
my ($desthost) = @_; |
my ($desthost,$path) = @_; |
my $protocol = $Apache::lonnet::protocol{$desthost}; |
my $protocol = $Apache::lonnet::protocol{$desthost}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).'/'; |
unless ($path =~ m{^/}) { |
|
$path = '/'.$path; |
|
} |
|
my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path; |
if ($env{'form.firsturl'} ne '') { |
if ($env{'form.firsturl'} ne '') { |
$url .='?firsturl='.$env{'form.firsturl'}; |
$url .='?firsturl='.$env{'form.firsturl'}; |
} |
} |