');
+ if ($saml_landing) {
+ $ssoauthstyle = 'inline-block';
+ $stdauthformstyle = 'none';
+ $logintype = $samlssotext;
+ my $ssologin = '/adm/sso';
+ if ($samlssourl ne '') {
+ $ssologin = $samlssourl;
+ }
+ if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
+ my $querystring;
+ if ($env{'form.firsturl'} ne '') {
+ $querystring = 'origurl=';
+ if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
+ $querystring .= &uri_escape_utf8($env{'form.firsturl'});
+ } else {
+ $querystring .= &uri_escape($env{'form.firsturl'});
+ }
+ $querystring = &HTML::Entities::encode($querystring,"'");
+ }
+ if ($env{'form.ltoken'} ne '') {
+ $querystring .= (($querystring eq '')?'':'&') . 'ltoken='.
+ &HTML::Entities::encode(&uri_escape($env{'form.ltoken'}));
+ } elsif ($env{'form.linkkey'}) {
+ $querystring .= (($querystring eq '')?'':'&') . 'linkkey='.
+ &HTML::Entities::encode(&uri_escape($env{'form.linkkey'}));
+ }
+ if ($querystring ne '') {
+ $ssologin .= (($ssologin=~/\?/)?'&':'?') . $querystring;
+ }
+ } elsif ($logtoken ne '') {
+ $ssologin .= (($ssologin=~/\?/)?'&':'?') . 'logtoken='.$logtoken;
+ }
+ my $ssohref;
+ if ($samlssoimg ne '') {
+ $ssohref = '

';
+ } else {
+ $ssohref = '
'.$samlssotext.'';
+ }
+ if (($env{'form.saml'} eq 'no') ||
+ (($env{'form.username'} ne '') && ($env{'form.domain'} ne ''))) {
+ $ssoauthstyle = 'none';
+ $stdauthformstyle = 'inline-block';
+ $logintype = $samlnonsso;
+ }
+ $r->print(<
+Log-in type:
+$logintype
+$lt{'change'}
+
+
+
+$ssohref
+$noscript_warning
+
+
+$loginhelp
+$contactblock
+$coursecatalog
+
+
+ENDSAML
+ } else {
+ if ($env{'form.ltoken'}) {
+ &Apache::lonnet::tmpdel($env{'form.ltoken'});
+ delete($env{'form.ltoken'});
+ }
+ }
+
+ $r->print(<
$logintitle
$loginform
@@ -742,8 +910,8 @@ HEADER
-'."\n");
if ($showmainlogo) {
$r->print('

'."\n");
}
@@ -838,7 +1006,7 @@ ENDDOCUMENT
}
sub check_loginvia {
- my ($domain,$lonhost,$lonidsdir,$balcookie,$linkprot) = @_;
+ my ($domain,$lonhost,$lonidsdir,$balcookie) = @_;
if ($domain eq '' || $lonhost eq '' || $lonidsdir eq '') {
return;
}
@@ -848,7 +1016,7 @@ sub check_loginvia {
my $output;
if ($loginvia ne '') {
my $noredirect;
- my $ip = $ENV{'REMOTE_ADDR'};
+ my $ip = &Apache::lonnet::get_requestor_ip();
if ($ip eq '127.0.0.1') {
$noredirect = 1;
} else {
@@ -898,7 +1066,7 @@ sub check_loginvia {
}
}
}
- $output = &redirect_page($newhost,$path,$linkprot);
+ $output = &redirect_page($newhost,$path);
}
}
}
@@ -907,7 +1075,7 @@ sub check_loginvia {
}
sub redirect_page {
- my ($desthost,$path,$linkprot) = @_;
+ my ($desthost,$path) = @_;
my $hostname = &Apache::lonnet::hostname($desthost);
my $protocol = $Apache::lonnet::protocol{$desthost};
$protocol = 'http' if ($protocol ne 'https');
@@ -916,12 +1084,26 @@ sub redirect_page {
}
my $url = $protocol.'://'.$hostname.$path;
if ($env{'form.firsturl'} ne '') {
- $url .='?firsturl='.$env{'form.firsturl'};
+ my $querystring;
+ if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
+ $querystring = &uri_escape_utf8($env{'form.firsturl'});
+ } else {
+ $querystring = &uri_escape($env{'form.firsturl'});
+ }
+ $querystring = &HTML::Entities::encode($querystring,"'");
+ $url .='?firsturl='.$querystring;
}
- if ($linkprot) {
- my $ltoken = &Apache::lonnet::tmpput({linkprot => $linkprot},$desthost);
- if ($ltoken) {
- $url .= (($url =~ /\?/) ? '&' : '?').'ltoken='.$ltoken;
+ if (($env{'form.ltoken'}) || ($env{'form.linkkey'} ne '')) {
+ my %link_info;
+ if ($env{'form.ltoken'}) {
+ $link_info{'ltoken'} = $env{'form.ltoken'};
+ } elsif ($env{'form.linkkey'} ne '') {
+ $link_info{'linkkey'} = $env{'form.linkkey'};
+ }
+ my $token = &Apache::lonnet::tmpput(\%link_info,$desthost,'link');
+ unless (($token eq 'con_lost') || ($token eq 'refused') ||
+ ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {
+ $url .= (($url=~/\?/)?'&':'?') . 'ttoken='.$token;
}
}
my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
@@ -998,5 +1180,19 @@ sub newuser_link {
return '
'.$linkname.'';
}
+sub decode_token {
+ my ($info) = @_;
+ my ($firsturl,@rest)=split(/\&/,$info);
+ my %form;
+ if ($firsturl ne '') {
+ $form{'firsturl'} = &unescape($firsturl);
+ }
+ foreach my $item (@rest) {
+ my ($key,$value) = split(/=/,$item);
+ $form{$key} = &unescape($value);
+ }
+ return %form;
+}
+
1;
__END__