Diff for /loncom/auth/lonauth.pm between versions 1.111 and 1.147

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


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