Diff for /loncom/auth/lonauth.pm between versions 1.124 and 1.143

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

Removed from v.1.124  
changed lines
  Added in v.1.143


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