Diff for /loncom/auth/lonauth.pm between versions 1.121.2.11 and 1.141

version 1.121.2.11, 2014/05/04 15:16:10 version 1.141, 2016/12/05 00:51:43
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # User Authentication Module  # User Authentication Module
 #  #
 # $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::lonauth;  package Apache::lonauth;
   
 use strict;  use strict;
 use LONCAPA;  use LONCAPA qw(:DEFAULT :match);
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use CGI qw(:standard);  use CGI qw(:standard);
 use DynaLoader; # for Crypt::DES version  use DynaLoader; # for Crypt::DES version
 use Crypt::DES;  use Crypt::DES;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::lonmenu();  use Apache::lonmenu();
 use Apache::createaccount;  use Apache::createaccount;
 use Fcntl qw(:flock);  use Fcntl qw(:flock);
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::File();  use Apache::File();
 use HTML::Entities;  use HTML::Entities;
     
 # ------------------------------------------------------------ Successful login  # ------------------------------------------------------------ Successful login
 sub success {  sub success {
     my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,      my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
  $form) = @_;   $form) = @_;
   
 # ------------------------------------------------------------ Get cookie ready  # ------------------------------------------------------------ Get cookie ready
     my $cookie =      my $cookie =
  &Apache::loncommon::init_user_environment($r, $username, $domain,   &Apache::loncommon::init_user_environment($r, $username, $domain,
   $authhost, $form,    $authhost, $form,
   {'extra_env' => $extra_env,});    {'extra_env' => $extra_env,});
   
     my $public=($username eq 'public' && $domain eq 'public');      my $public=($username eq 'public' && $domain eq 'public');
   
     if ($public or $lowerurl eq 'noredirect') { return $cookie; }      if ($public or $lowerurl eq 'noredirect') { return $cookie; }
   
 # -------------------------------------------------------------------- Log this  # -------------------------------------------------------------------- Log this
   
     &Apache::lonnet::log($domain,$username,$authhost,      &Apache::lonnet::log($domain,$username,$authhost,
                          "Login $ENV{'REMOTE_ADDR'}");                           "Login $ENV{'REMOTE_ADDR'}");
   
 # ------------------------------------------------- Check for critical messages  # ------------------------------------------------- Check for critical messages
   
     my @what=&Apache::lonnet::dump('critical',$domain,$username);      my @what=&Apache::lonnet::dump('critical',$domain,$username);
     if ($what[0]) {      if ($what[0]) {
  if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {   if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
     $lowerurl='/adm/email?critical=display';      $lowerurl='/adm/email?critical=display';
         }          }
     }      }
   
 # ------------------------------------------------------------ Get cookie ready  # ------------------------------------------------------------ Get cookie ready
     $cookie="lonID=$cookie; path=/";      $cookie="lonID=$cookie; path=/";
 # -------------------------------------------------------- Menu script and info  # -------------------------------------------------------- Menu script and info
     my $destination = $lowerurl;      my $destination = $lowerurl;
   
     if (defined($form->{role})) {      if (defined($form->{role})) {
         my $envkey = 'user.role.'.$form->{role};          my $envkey = 'user.role.'.$form->{role};
         my $now=time;          my $now=time;
         my $then=$env{'user.login.time'};          my $then=$env{'user.login.time'};
         my $refresh=$env{'user.refresh.time'};          my $refresh=$env{'user.refresh.time'};
         my $update=$env{'user.update.time'};          my $update=$env{'user.update.time'};
         if (!$update) {          if (!$update) {
             $update = $then;              $update = $then;
         }          }
         if (exists($env{$envkey})) {          if (exists($env{$envkey})) {
             my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);              my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);
             &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,              &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
                                          \$trolecode,\$tstatus,\$tstart,\$tend);                                           \$trolecode,\$tstatus,\$tstart,\$tend);
             if ($tstatus eq 'is') {              if ($tstatus eq 'is') {
                 $destination  .= ($destination =~ /\?/) ? '&' : '?';                  $destination  .= ($destination =~ /\?/) ? '&' : '?';
                 my $newrole = &HTML::Entities::encode($form->{role},'"<>&');                  my $newrole = &HTML::Entities::encode($form->{role},'"<>&');
                 $destination .= 'selectrole=1&'.$newrole.'=1';                  $destination .= 'selectrole=1&'.$newrole.'=1';
             }              }
         }          }
     }      }
     if (defined($form->{symb})) {      if (defined($form->{symb})) {
         my $destsymb = $form->{symb};          my $destsymb = $form->{symb};
         $destination  .= ($destination =~ /\?/) ? '&' : '?';          $destination  .= ($destination =~ /\?/) ? '&' : '?';
         if ($destsymb =~ /___/) {          if ($destsymb =~ /___/) {
             # FIXME Need to deal with encrypted symbs and urls as needed.              # FIXME Need to deal with encrypted symbs and urls as needed.
             my ($map,$resid,$desturl)=split(/___/,$destsymb);              my ($map,$resid,$desturl)=split(/___/,$destsymb);
             unless ($desturl=~/^(adm|editupload|public)/) {              $desturl = &Apache::lonnet::clutter($desturl);
                 $desturl = &Apache::lonnet::clutter($desturl);              $desturl = &HTML::Entities::encode($desturl,'"<>&');
             }              $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
             $desturl = &HTML::Entities::encode($desturl,'"<>&');              $destination .= 'destinationurl='.$desturl.
             $destsymb = &HTML::Entities::encode($destsymb,'"<>&');                              '&destsymb='.$destsymb;
             $destination .= 'destinationurl='.$desturl.          } else {
                             '&destsymb='.$destsymb;              $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
         } else {              $destination .= 'destinationurl='.$destsymb;
             $destsymb = &HTML::Entities::encode($destsymb,'"<>&');          }
             $destination .= 'destinationurl='.$destsymb;      }
         }      if ($destination =~ m{^/adm/roles}) {
     }          $destination  .= ($destination =~ /\?/) ? '&' : '?';
     if ($destination =~ m{^/adm/roles}) {          $destination .= 'source=login';
         $destination  .= ($destination =~ /\?/) ? '&' : '?';      }
         $destination .= 'source=login';  
     }      my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');
       my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
     my $windowinfo=&Apache::lonmenu::open($env{'browser.os'});      my $brcrum = [{'href' => '',
     my $startupremote=&Apache::lonmenu::startupremote($destination);                     'text' => 'Successful Login'},];
     my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl);      my $args = {'bread_crumbs' => $brcrum,};
     my $setflags=&Apache::lonmenu::setflags();      unless ((defined($form->{role})) || (defined($form->{symb}))) {
     my $maincall=&Apache::lonmenu::maincall();          my $update=$env{'user.update.time'};
     my $brcrum = [{'href' => '',          if (!$update) {
                    'text' => 'Successful Login'},];              $update = $env{'user.login.time'};
     my $start_page=&Apache::loncommon::start_page('Successful Login',          }
                                                   $startupremote,          my %roles_in_env;
                                                   {'no_inline_link' => 1,          my $showcount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
                                                    'bread_crumbs' => $brcrum,});          if ($showcount == 1) {
     my $end_page  =&Apache::loncommon::end_page();              foreach my $rolecode (keys(%roles_in_env)) {
                   my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
     my $continuelink;                  if ($cid) {
     if ($env{'environment.remote'} eq 'off') {                      my %coursedescription =
  $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';                          &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
     }                      if ($coursedescription{'type'} eq 'Placement') {
 # ------------------------------------------------- Output for successful login                          $args->{'crstype'} = 'Placement';
                       }
     &Apache::loncommon::content_type($r,'text/html');                      last;
     $r->header_out('Set-cookie' => $cookie);                  }
     $r->send_http_header;              }
           }
     my %lt=&Apache::lonlocal::texthash(      }
        'wel' => 'Welcome',      my $start_page=&Apache::loncommon::start_page('Successful Login',
        'pro' => 'Login problems?',                                                    $header,$args);
        );      my $end_page  =&Apache::loncommon::end_page();
     my $loginhelp = &loginhelpdisplay($domain);  
     if ($loginhelp) {   my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';
         $loginhelp = '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';  # ------------------------------------------------- Output for successful login
     }  
       &Apache::loncommon::content_type($r,'text/html');
     my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');       $r->header_out('Set-cookie' => $cookie);
     $r->print(<<ENDSUCCESS);      $r->send_http_header;
 $start_page  
 $setflags      my %lt=&Apache::lonlocal::texthash(
 $windowinfo         'wel' => 'Welcome',
 <h1>$lt{'wel'}</h1>         'pro' => 'Login problems?',
 $welcome         );
 $loginhelp      my $loginhelp = &loginhelpdisplay($domain);
 $remoteinfo      if ($loginhelp) {
 $maincall          $loginhelp = '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
 $continuelink      }
 $end_page  
 ENDSUCCESS      my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
     return;      $r->print(<<ENDSUCCESS);
 }  $start_page
   $windowinfo
 # --------------------------------------------------------------- Failed login!  <h1>$lt{'wel'}</h1>
   $welcome
 sub failed {  $loginhelp
     my ($r,$message,$form) = @_;  $continuelink
     (undef,undef,undef,my $clientmathml,my $clientunicode) =  $end_page
         &Apache::loncommon::decode_user_agent();  ENDSUCCESS
     my $args = {};      return;
     if ($clientunicode && !$clientmathml) {  }
         $args = {'browser.unicode' => 1};  
     }  # --------------------------------------------------------------- Failed login!
   
     my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);  sub failed {
     my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});      my ($r,$message,$form) = @_;
     my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});      (undef,undef,undef,my $clientmathml,my $clientunicode) =
     if (&Apache::lonnet::domain($udom,'description') eq '') {          &Apache::loncommon::decode_user_agent();
         undef($udom);      my $args = {};
     }      if ($clientunicode && !$clientmathml) {
     my $retry = '/adm/login';          $args = {'browser.unicode' => 1};
     if ($uname eq $form->{'uname'}) {      }
         $retry .= '?username='.$uname;  
     }      my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);
     if ($udom) {      my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});
         $retry .= (($retry=~/\?/)?'&amp;':'?').'domain='.$udom;      my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});
     }      if (&Apache::lonnet::domain($udom,'description') eq '') {
     if (exists($form->{role})) {          undef($udom);
         my $role = &Apache::loncommon::cleanup_html($form->{role});      }
         if ($role ne '') {      my $retry = '/adm/login';
             $retry .= (($retry=~/\?/)?'&amp;':'?').'role='.$role;      if ($uname eq $form->{'uname'}) {
         }          $retry .= '?username='.$uname;
     }      }
     if (exists($form->{symb})) {      if ($udom) {
         my $symb = &Apache::loncommon::cleanup_html($form->{symb});          $retry .= (($retry=~/\?/)?'&amp;':'?').'domain='.$udom;
         if ($symb ne '') {      }
             $retry .= (($retry=~/\?/)?'&amp;':'?').'symb='.$symb;      if (exists($form->{role})) {
         }          my $role = &Apache::loncommon::cleanup_html($form->{role});
     }          if ($role ne '') {
     my $end_page = &Apache::loncommon::end_page();              $retry .= (($retry=~/\?/)?'&amp;':'?').'role='.$role;
     &Apache::loncommon::content_type($r,'text/html');          }
     $r->send_http_header;      }
     my @actions =      if (exists($form->{symb})) {
          (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));          my $symb = &Apache::loncommon::cleanup_html($form->{symb});
     my $loginhelp = &loginhelpdisplay($udom);          if ($symb ne '') {
     if ($loginhelp) {              $retry .= (($retry=~/\?/)?'&amp;':'?').'symb='.$symb;
         push(@actions, '<a href="'.$loginhelp.'">'.&mt('Login problems?').'</a>');          }
     }      }
     #FIXME: link to helpdesk might be added here      my $end_page = &Apache::loncommon::end_page();
       &Apache::loncommon::content_type($r,'text/html');
     $r->print(      $r->send_http_header;
        $start_page      my @actions =
       .'<h2>'.&mt('Sorry ...').'</h2>'           (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
       .&Apache::lonhtmlcommon::confirm_success(&mt($message),1).'<br /><br />'      my $loginhelp = &loginhelpdisplay($udom);
       .&Apache::lonhtmlcommon::actionbox(\@actions)      if ($loginhelp) {
       .$end_page          push(@actions, '<a href="'.$loginhelp.'">'.&mt('Login problems?').'</a>');
     );      }
  }      #FIXME: link to helpdesk might be added here
   
 # ------------------------------------------------------------------ Rerouting!      $r->print(
          $start_page
 sub reroute {        .'<h2>'.&mt('Sorry ...').'</h2>'
     my ($r) = @_;        .&Apache::lonhtmlcommon::confirm_success(&mt($message),1).'<br /><br />'
     &Apache::loncommon::content_type($r,'text/html');        .&Apache::lonhtmlcommon::actionbox(\@actions)
     $r->send_http_header;        .$end_page
     my $msg='<b>'.&mt('Sorry ...').'</b><br />'      );
            .&mt('Please [_1]log in again[_2].');   }
     &Apache::loncommon::simple_error_page($r,'Rerouting',$msg,{'no_auto_mt_msg' => 1});  
 }  # ------------------------------------------------------------------ Rerouting!
   
 # ---------------------------------------------------------------- Main handler  sub reroute {
       my ($r) = @_;
 sub handler {      &Apache::loncommon::content_type($r,'text/html');
     my $r = shift;      $r->send_http_header;
     my $londocroot = $r->dir_config('lonDocRoot');      my $msg='<b>'.&mt('Sorry ...').'</b><br />'
     my $form;             .&mt('Please [_1]log in again[_2].');
 # Are we re-routing?      &Apache::loncommon::simple_error_page($r,'Rerouting',$msg,{'no_auto_mt_msg' => 1});
     if (-e "$londocroot/lon-status/reroute.txt") {  }
  &reroute($r);  
  return OK;  # ---------------------------------------------------------------- Main handler
     }  
   sub handler {
     &Apache::lonlocal::get_language_handle($r);      my $r = shift;
       my $londocroot = $r->dir_config('lonDocRoot');
 # -------------------------------- Prevent users from attempting to login twice  # Are we re-routing?
     my $handle = &Apache::lonnet::check_for_valid_session($r);      if (-e "$londocroot/lon-status/reroute.txt") {
     if ($handle ne '') {   &reroute($r);
         my $lonidsdir=$r->dir_config('lonIDsDir');   return OK;
         if ($handle=~/^publicuser\_/) {      }
 # For "public user" - remove it, we apparently really want to login  
             unlink($r->dir_config('lonIDsDir')."/$handle.id");      &Apache::lonlocal::get_language_handle($r);
         } else {  
 # Indeed, a valid token is found  # -------------------------------- Prevent users from attempting to login twice
             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);      my $handle = &Apache::lonnet::check_for_valid_session($r);
     &Apache::loncommon::content_type($r,'text/html');      if ($handle ne '') {
     $r->send_http_header;          my $lonidsdir=$r->dir_config('lonIDsDir');
     my $start_page =           if ($handle=~/^publicuser\_/) {
         &Apache::loncommon::start_page('Already logged in');  # For "public user" - remove it, we apparently really want to login
     my $end_page =               unlink($r->dir_config('lonIDsDir')."/$handle.id");
         &Apache::loncommon::end_page();          } else {
             my $dest = '/adm/roles';  # Indeed, a valid token is found
             if ($env{'form.firsturl'} ne '') {              &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
                 $dest = $env{'form.firsturl'};      &Apache::loncommon::content_type($r,'text/html');
             }      $r->send_http_header;
             $r->print(      my $start_page =
                $start_page          &Apache::loncommon::start_page('Already logged in');
               .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'      my $end_page =
               .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'          &Apache::loncommon::end_page();
                     ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')              my $dest = '/adm/roles';
               .'</p>'              if ($env{'form.firsturl'} ne '') {
               .$end_page                  $dest = $env{'form.firsturl'};
             );              }
             return OK;              $r->print(
         }                 $start_page
     }                .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
                 .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'
 # ---------------------------------------------------- No valid token, continue                      ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')
                 .'</p>'
                 .$end_page
     my $buffer;              );
     if ($r->header_in('Content-length') > 0) {              return OK;
  $r->read($buffer,$r->header_in('Content-length'),0);          }
     }      }
     my %form;  
     foreach my $pair (split(/&/,$buffer)) {  # ---------------------------------------------------- No valid token, continue
        my ($name,$value) = split(/=/,$pair);  
        $value =~ tr/+/ /;  
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;      my $buffer;
        $form{$name}=$value;      if ($r->header_in('Content-length') > 0) {
     }   $r->read($buffer,$r->header_in('Content-length'),0);
       }
     if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {      my %form;
  &failed($r,'Username, password and domain need to be specified.',      foreach my $pair (split(/&/,$buffer)) {
  \%form);         my ($name,$value) = split(/=/,$pair);
         return OK;         $value =~ tr/+/ /;
     }         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
          $form{$name}=$value;
 # split user logging in and "su"-user      }
   
     ($form{'uname'},$form{'suname'})=split(/\:/,$form{'uname'});      if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {
     $form{'uname'} = &LONCAPA::clean_username($form{'uname'});   &failed($r,'Username, password and domain need to be specified.',
     $form{'suname'}= &LONCAPA::clean_username($form{'suname'});   \%form);
     $form{'udom'}  = &LONCAPA::clean_domain(  $form{'udom'});          return OK;
       }
     my $role   = $r->dir_config('lonRole');  
     my $domain = $r->dir_config('lonDefDomain');  # split user logging in and "su"-user
     my $prodir = $r->dir_config('lonUsersDir');  
     my $contact_name = &mt('LON-CAPA helpdesk');      ($form{'uname'},$form{'suname'})=split(/\:/,$form{'uname'});
       $form{'uname'} = &LONCAPA::clean_username($form{'uname'});
 # ---------------------------------------- Get the information from login token      $form{'suname'}= &LONCAPA::clean_username($form{'suname'});
       $form{'udom'}  = &LONCAPA::clean_domain(  $form{'udom'});
     my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},  
                                       $form{'serverid'});      my $role   = $r->dir_config('lonRole');
       my $domain = $r->dir_config('lonDefDomain');
     my %sessiondata;      my $prodir = $r->dir_config('lonUsersDir');
     if ($form{'iptoken'}) {      my $contact_name = &mt('LON-CAPA helpdesk');
         %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});  
         my $delete = &Apache::lonnet::tmpdel($form{'iptoken'});  # ---------------------------------------- Get the information from login token
     }  
       my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
     if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||                                         $form{'serverid'});
         ($tmpinfo eq 'no_such_host')) {  
  &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);      if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
         return OK;          ($tmpinfo eq 'no_such_host')) {
     } else {   &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);
  my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},          return OK;
    $form{'serverid'});      } else {
         if ( $reply ne 'ok' ) {   my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},
             &failed($r,'Session could not be opened.',\%form);     $form{'serverid'});
     &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");          if ( $reply ne 'ok' ) {
     return OK;              &failed($r,'Session could not be opened.',\%form);
  }      &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");
     }      return OK;
    }
     if (!&Apache::lonnet::domain($form{'udom'})) {      }
         &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);  
         return OK;      if (!&Apache::lonnet::domain($form{'udom'})) {
     }          &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);
           return OK;
     my ($key,$firsturl,$rolestr,$symbstr)=split(/&/,$tmpinfo);      }
     if ($rolestr) {  
         $rolestr = &unescape($rolestr);      my ($key,$firsturl,$rolestr,$symbstr,$iptokenstr)=split(/&/,$tmpinfo);
     }      if ($rolestr) {
     if ($symbstr) {          $rolestr = &unescape($rolestr);
         $symbstr= &unescape($symbstr);      }
     }      if ($symbstr) {
     if ($rolestr =~ /^role=/) {          $symbstr= &unescape($symbstr);
         (undef,$form{'role'}) = split('=',$rolestr);      }
     }      if ($iptokenstr) {
     if ($symbstr =~ /^symb=/) {           $iptokenstr = &unescape($iptokenstr);
         (undef,$form{'symb'}) = split('=',$symbstr);      }
     }      if ($rolestr =~ /^role=/) {
           (undef,$form{'role'}) = split('=',$rolestr);
     my $keybin=pack("H16",$key);      }
       if ($symbstr =~ /^symb=/) {
     my $cipher;          (undef,$form{'symb'}) = split('=',$symbstr);
     if ($Crypt::DES::VERSION>=2.03) {      }
  $cipher=new Crypt::DES $keybin;      if ($iptokenstr =~ /^iptoken=/) {
     }          (undef,$form{'iptoken'}) = split('=',$iptokenstr);
     else {      }
  $cipher=new DES $keybin;  
     }      my $upass = $ENV{HTTPS} ? $form{'upass0'}
     my $upass='';          : &Apache::loncommon::des_decrypt($key,$form{'upass0'});
     for (my $i=0;$i<=2;$i++) {  
  my $chunk=  # ---------------------------------------------------------------- Authenticate
     $cipher->decrypt(unpack("a8",pack("H16",substr($form{'upass'.$i},0,16))));  
       my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
  $chunk.=      my ($cancreate,$statustocreate) =
     $cipher->decrypt(unpack("a8",pack("H16",substr($form{'upass'.$i},16,16))));          &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});
       my $defaultauth;
  $chunk=substr($chunk,1,ord(substr($chunk,0,1)));      if (ref($cancreate) eq 'ARRAY') {
  $upass.=$chunk;          if (grep(/^login$/,@{$cancreate})) {
     }              $defaultauth = 1;
           }
 # ---------------------------------------------------------------- Authenticate      }
       my $clientcancheckhost = 1;
     my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});      my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
     my ($cancreate,$statustocreate) =                                                $form{'udom'},$defaultauth,
         &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});                                                $clientcancheckhost);
     my $defaultauth;     
     if (ref($cancreate) eq 'ARRAY') {  # --------------------------------------------------------------------- Failed?
         if (grep(/^login$/,@{$cancreate})) {  
             $defaultauth = 1;      if ($authhost eq 'no_host') {
         }   &failed($r,'Username and/or password could not be authenticated.',
     }   \%form);
     my $clientcancheckhost = 1;          return OK;
     my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,      } elsif ($authhost eq 'no_account_on_host') {
                                               $form{'udom'},$defaultauth,          if ($defaultauth) {
                                               $clientcancheckhost);              my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
                   unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
 # --------------------------------------------------------------------- Failed?                  return OK;
               }
     if ($authhost eq 'no_host') {              my $start_page =
  &failed($r,'Username and/or password could not be authenticated.',                  &Apache::loncommon::start_page('Create a user account in LON-CAPA');
  \%form);              my $lonhost = $r->dir_config('lonHostID');
         return OK;              my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
     } elsif ($authhost eq 'no_account_on_host') {              my $contacts =
         if ($defaultauth) {                  &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
             my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');                                                          $form{'udom'},$origmail);
             unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {              my ($contact_email) = split(',',$contacts);
                 return OK;              my $output =
             }                  &Apache::createaccount::username_check($form{'uname'},$form{'udom'},
             my $start_page =                                                          $domdesc,'',$lonhost,
                 &Apache::loncommon::start_page('Create a user account in LON-CAPA',                                                         $contact_email,$contact_name,
                                                '',{'no_inline_link'   => 1,});                                                         undef,$statustocreate);
             my $lonhost = $r->dir_config('lonHostID');              &Apache::loncommon::content_type($r,'text/html');
             my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};              $r->send_http_header;
             my $contacts =               &Apache::createaccount::print_header($r,$start_page);
                 &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',              $r->print('<h3>'.&mt('Account creation').'</h3>'.
                                                         $form{'udom'},$origmail);                        &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.
             my ($contact_email) = split(',',$contacts);                         $output.&Apache::loncommon::end_page());
             my $output =               return OK;
                 &Apache::createaccount::username_check($form{'uname'},$form{'udom'},          } else {
                                                        $domdesc,'',$lonhost,              &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);
                                                        $contact_email,$contact_name,              return OK;
                                                        undef,$statustocreate);          }
             &Apache::loncommon::content_type($r,'text/html');      }
             $r->send_http_header;  
             &Apache::createaccount::print_header($r,$start_page);      if (($firsturl eq '') ||
             $r->print('<h3>'.&mt('Account creation').'</h3>'.   ($firsturl=~/^\/adm\/(logout|remote)/)) {
                       &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.   $firsturl='/adm/roles';
                       $output.&Apache::loncommon::end_page());      }
             return OK;  
         } else {      my $hosthere;
             &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);      if ($form{'iptoken'}) {
             return OK;          my %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});
         }          my $delete = &Apache::lonnet::tmpdel($form{'iptoken'});
     }          if (($sessiondata{'domain'} eq $form{'udom'}) &&
               ($sessiondata{'username'} eq $form{'uname'})) {
     if (($firsturl eq '') ||               $hosthere = 1;
  ($firsturl=~/^\/adm\/(logout|remote)/)) {          }
  $firsturl='/adm/roles';      }
     }  
   # --------------------------------- Are we attempting to login as somebody else?
     my $hosthere;      if ($form{'suname'}) {
     if ($form{'iptoken'}) {  # ------------ see if the original user has enough privileges to pull this stunt
         if (($sessiondata{'domain'} eq $form{'udom'}) &&   if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'})) {
             ($sessiondata{'username'} eq $form{'uname'})) {  # ---------------------------------------------------- see if the su-user exists
             $hosthere = 1;      unless (&Apache::lonnet::homeserver($form{'suname'},$form{'udom'})
         }   eq 'no_host') {
     }   &Apache::lonnet::logthis(&Apache::lonnet::homeserver($form{'suname'},$form{'udom'}));
   # ------------------------------ see if the su-user is not too highly privileged
 # --------------------------------- Are we attempting to login as somebody else?   unless (&Apache::lonnet::privileged($form{'suname'},$form{'udom'})) {
     if ($form{'suname'}) {  # -------------------------------------------------------- actually switch users
 # ------------ see if the original user has enough privileges to pull this stunt      &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.$form{'udom'}.
  if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'})) {   ' logging in as '.$form{'suname'});
 # ---------------------------------------------------- see if the su-user exists      $form{'uname'}=$form{'suname'};
     unless (&Apache::lonnet::homeserver($form{'suname'},$form{'udom'})   } else {
  eq 'no_host') {      &Apache::lonnet::logthis('Attempted switch user to privileged user');
  &Apache::lonnet::logthis(&Apache::lonnet::homeserver($form{'suname'},$form{'udom'}));   }
 # ------------------------------ see if the su-user is not too highly privileged      }
  unless (&Apache::lonnet::privileged($form{'suname'},$form{'udom'})) {   } else {
 # -------------------------------------------------------- actually switch users      &Apache::lonnet::logthis('Non-privileged user attempting switch user');
     &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.$form{'udom'}.   }
  ' logging in as '.$form{'suname'});      }
     $form{'uname'}=$form{'suname'};  
  } else {      my ($is_balancer,$otherserver);
     &Apache::lonnet::logthis('Attempted switch user to privileged user');  
  }      unless ($hosthere) {
     }          ($is_balancer,$otherserver) =
  } else {              &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'},'login');
     &Apache::lonnet::logthis('Non-privileged user attempting switch user');          if ($is_balancer) {
  }              if ($otherserver eq '') {
     }                  my $lowest_load;
                   ($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($form{'udom'});
     my ($is_balancer,$otherserver);                  if ($lowest_load > 100) {
                       $otherserver = &Apache::lonnet::spareserver($lowest_load,$lowest_load,1,$form{'udom'});
     unless ($hosthere) {                  }
         ($is_balancer,$otherserver) =              }
             &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'});              if ($otherserver ne '') {
     }                  my @hosts = &Apache::lonnet::current_machine_ids();
                   if (grep(/^\Q$otherserver\E$/,@hosts)) {
     if ($is_balancer) {                      $hosthere = $otherserver;
         if (!$otherserver) {                   }
             ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});              }
         }          }
         if ($otherserver) {      }
             &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,  
                      \%form);      if (($is_balancer) && (!$hosthere)) {
             my $switchto = '/adm/switchserver?otherserver='.$otherserver;          if ($otherserver) {
             if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {              &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
                 $switchto .= '&origurl='.$firsturl;                       \%form);
             }              my $switchto = '/adm/switchserver?otherserver='.$otherserver;
             if ($form{'role'}) {              if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
                 $switchto .= '&role='.$form{'role'};                  $switchto .= '&origurl='.$firsturl;
             }              }
             if ($form{'symb'}) {              if ($form{'role'}) {
                 $switchto .= '&symb='.$form{'symb'};                  $switchto .= '&role='.$form{'role'};
             }              }
             $r->internal_redirect($switchto);              if ($form{'symb'}) {
         } else {                  $switchto .= '&symb='.$form{'symb'};
             $r->print(&noswitch());              }
         }              $r->internal_redirect($switchto);
         return OK;          } else {
     } else {              $r->print(&noswitch());
         if (!&check_can_host($r,\%form,$authhost)) {          }
             my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});          return OK;
             if ($otherserver) {      } else {
                 &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,          if (!&check_can_host($r,\%form,$authhost)) {
                          \%form);              my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
                 my $switchto = '/adm/switchserver?otherserver='.$otherserver;              if ($otherserver) {
                 if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {                  &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
                     $switchto .= '&origurl='.$firsturl;                           \%form);
                 }                  my $switchto = '/adm/switchserver?otherserver='.$otherserver;
                 if ($form{'role'}) {                  if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
                     $switchto .= '&role='.$form{'role'};                      $switchto .= '&origurl='.$firsturl;
                 }                  }
                 if ($form{'symb'}) {                  if ($form{'role'}) {
                     $switchto .= '&symb='.$form{'symb'};                      $switchto .= '&role='.$form{'role'};
                 }                  }
                 $r->internal_redirect($switchto);                  if ($form{'symb'}) {
             } else {                      $switchto .= '&symb='.$form{'symb'};
                 $r->print(&noswitch());                  }
             }                  $r->internal_redirect($switchto);
             return OK;              } else {
         }                  $r->print(&noswitch());
               }
 # ------------------------------------------------------- Do the load balancing              return OK;
           }
 # ---------------------------------------------------------- Determine own load  
         my $loadlim = $r->dir_config('lonLoadLim');  # ------------------------------------------------------- Do the load balancing
         my $loadavg;  
         {  # ---------------------------------------------------------- Determine own load
             my $loadfile=Apache::File->new('/proc/loadavg');          my $loadlim = $r->dir_config('lonLoadLim');
             $loadavg=<$loadfile>;          my $loadavg;
         }          {
         $loadavg =~ s/\s.*//g;              my $loadfile=Apache::File->new('/proc/loadavg');
         my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);              $loadavg=<$loadfile>;
         my $userloadpercent=&Apache::lonnet::userload();          }
           $loadavg =~ s/\s.*//g;
 # ---------------------------------------------------------- Are we overloaded?          my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
         if ((($userloadpercent>100.0)||($loadpercent>100.0))) {          my $userloadpercent=&Apache::lonnet::userload();
             my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'});  
             if (!$unloaded) {  # ---------------------------------------------------------- Are we overloaded?
                 ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});          if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
             }              my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'});
             if ($unloaded) {              if (!$unloaded) {
                 &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',                  ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});
                          undef,\%form);              }
                 $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);              if ($unloaded) {
                 return OK;                  &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',
             }                           undef,\%form);
         }                  $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);
         &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,                  return OK;
                  \%form);              }
         return OK;          }
     }          if (($is_balancer) && ($hosthere)) {
 }              $form{'noloadbalance'} = $hosthere;
           }
 sub check_can_host {          &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,
     my ($r,$form,$authhost,$domdesc) = @_;                   \%form);
     return unless (ref($form) eq 'HASH');          return OK;
     my $canhost = 1;      }
     my $lonhost = $r->dir_config('lonHostID');  }
     my $udom = $form->{'udom'};  
     my @intdoms;  sub check_can_host {
     my $internet_names = &Apache::lonnet::get_internet_names($lonhost);      my ($r,$form,$authhost,$domdesc) = @_;
     if (ref($internet_names) eq 'ARRAY') {      return unless (ref($form) eq 'HASH');
         @intdoms = @{$internet_names};      my $canhost = 1;
     }      my $lonhost = $r->dir_config('lonHostID');
     my $uprimary_id = &Apache::lonnet::domain($udom,'primary');      my $udom = $form->{'udom'};
     my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);      my @intdoms;
     unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {      my $internet_names = &Apache::lonnet::get_internet_names($lonhost);
         my $machine_dom = &Apache::lonnet::host_domain($lonhost);      if (ref($internet_names) eq 'ARRAY') {
         my $hostname = &Apache::lonnet::hostname($lonhost);          @intdoms = @{$internet_names};
         my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);      }
         my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);      my $uprimary_id = &Apache::lonnet::domain($udom,'primary');
         my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);      my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
         my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);      unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {
         my $loncaparev;          my $machine_dom = &Apache::lonnet::host_domain($lonhost);
         if ($authhost eq 'no_account_on_host') {          my $hostname = &Apache::lonnet::hostname($lonhost);
             $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);          my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);
         } else {          my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
             $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);          my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
         }          my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);
         $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,          my $loncaparev;
                                                      $udomdefaults{'remotesessions'},          if ($authhost eq 'no_account_on_host') {
                                                      $defdomdefaults{'hostedsessions'});              $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);
     }          } else {
     unless ($canhost) {              $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);
         if ($authhost eq 'no_account_on_host') {          }
             my $checkloginvia = 1;          $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,
             my ($login_host,$hostname) =                                                        $udomdefaults{'remotesessions'},
                 &Apache::lonnet::choose_server($udom,$checkloginvia);                                                       $defdomdefaults{'hostedsessions'});
             &Apache::loncommon::content_type($r,'text/html');      }
             $r->send_http_header;      unless ($canhost) {
             if ($login_host ne '') {          if ($authhost eq 'no_account_on_host') {
                 my $protocol = $Apache::lonnet::protocol{$login_host};              my $checkloginvia = 1;
                 $protocol = 'http' if ($protocol ne 'https');              my ($login_host,$hostname) =
                 my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';                  &Apache::lonnet::choose_server($udom,$checkloginvia);
                 $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').              &Apache::loncommon::content_type($r,'text/html');
                           '<h3>'.&mt('Account creation').'</h3>'.              $r->send_http_header;
                           &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.              if ($login_host ne '') {
                           '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.                  my $protocol = $Apache::lonnet::protocol{$login_host};
                           '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').                  $protocol = 'http' if ($protocol ne 'https');
                           &Apache::loncommon::end_page());                  my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';
             } else {                  $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').
                 $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').                            '<h3>'.&mt('Account creation').'</h3>'.
                           '<h3>'.&mt('Account creation unavailable').'</h3>'.                            &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
                           &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.                            '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.
                           '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.                            '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').
                           &Apache::loncommon::end_page());                            &Apache::loncommon::end_page());
             }              } else {
         } else {                  $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').
             &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,                            '<h3>'.&mt('Account creation unavailable').'</h3>'.
                      $form);                            &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
             my ($otherserver) = &Apache::lonnet::choose_server($udom);                            '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.
             $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);                            &Apache::loncommon::end_page());
         }              }
     }          } else {
     return $canhost;              &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,
 }                       $form);
               my ($otherserver) = &Apache::lonnet::choose_server($udom);
 sub noswitch {              $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);
     my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').          }
                  '<h3>'.&mt('Session unavailable').'</h3>'.      }
                  &mt('This LON-CAPA server is unable to host your session.').'<br />'.      return $canhost;
                  '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.  }
                  &Apache::loncommon::end_page();  
     return $result;  sub noswitch {
 }      my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').
                    '<h3>'.&mt('Session unavailable').'</h3>'.
 sub loginhelpdisplay {                   &mt('This LON-CAPA server is unable to host your session.').'<br />'.
     my ($authdomain) = @_;                   '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.
     my $login_help = 1;                   &Apache::loncommon::end_page();
     my $lang = &Apache::lonlocal::current_language();      return $result;
     if ($login_help) {  }
         my $dom = $authdomain;  
         if ($dom eq '') {  sub loginhelpdisplay {
             $dom = &Apache::lonnet::default_login_domain();      my ($authdomain) = @_;
         }      my $login_help = 1;
         my %domconfhash = &Apache::loncommon::get_domainconf($dom);      my $lang = &Apache::lonlocal::current_language();
         my $loginhelp_url;      if ($login_help) {
         if ($lang) {          my $dom = $authdomain;
             $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};          if ($dom eq '') {
             if ($loginhelp_url ne '') {              $dom = &Apache::lonnet::default_login_domain();
                 return $loginhelp_url;          }
             }          my %domconfhash = &Apache::loncommon::get_domainconf($dom);
         }          my $loginhelp_url;
         $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};          if ($lang) {
         if ($loginhelp_url ne '') {              $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};
             return $loginhelp_url;              if ($loginhelp_url ne '') {
         } else {                  return $loginhelp_url;
             return '/adm/loginproblems.html';              }
         }          }
     }          $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};
     return;          if ($loginhelp_url ne '') {
 }              return $loginhelp_url;
           } else {
 1;              return '/adm/loginproblems.html';
 __END__          }
       }
       return;
   }
   
   1;
   __END__
   
   

Removed from v.1.121.2.11  
changed lines
  Added in v.1.141


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>