Diff for /loncom/auth/lonlogin.pm between versions 1.155 and 1.170

version 1.155, 2013/01/28 02:00:58 version 1.170, 2017/02/25 19:56:09
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # Login Screen  # Login Screen
 #  #
 # $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::lonlogin;  package Apache::lonlogin;
   
 use strict;  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::File ();  use Apache::File ();
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonauth();  use Apache::lonauth();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::migrateuser();  use Apache::migrateuser();
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA;
    use CGI::Cookie();
 sub handler {   
     my $r = shift;  sub handler {
       my $r = shift;
     &Apache::loncommon::get_unprocessed_cgi  
  (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},      &Apache::loncommon::get_unprocessed_cgi
       $ENV{'REDIRECT_QUERY_STRING'}),   (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
  ['interface','username','domain','firsturl','localpath','localres',        $ENV{'REDIRECT_QUERY_STRING'}),
   'token','role','symb']);   ['interface','username','domain','firsturl','localpath','localres',
     if (!defined($env{'form.firsturl'})) {    'token','role','symb','iptoken']);
         &Apache::lonacc::get_posted_cgi($r,['firsturl']);      if (!defined($env{'form.firsturl'})) {
     }          &Apache::lonacc::get_posted_cgi($r,['firsturl']);
       }
 # -- check if they are a migrating user  
     if (defined($env{'form.token'})) {  # -- check if they are a migrating user
  return &Apache::migrateuser::handler($r);      if (defined($env{'form.token'})) {
     }   return &Apache::migrateuser::handler($r);
       }
     &Apache::loncommon::no_cache($r);  
     &Apache::lonlocal::get_language_handle($r);  # For "public user" - remove any exising "public" cookie, as user really wants to log-in
     &Apache::loncommon::content_type($r,'text/html');      my ($handle,$lonidsdir,$expire);
     $r->send_http_header;      unless ($r->header_only) {
     return OK if $r->header_only;          $handle = &Apache::lonnet::check_for_valid_session($r);
           if ($handle ne '') {
               $lonidsdir=$r->dir_config('lonIDsDir');
 # Are we re-routing?              if ($handle=~/^publicuser\_/) {
     my $londocroot = $r->dir_config('lonDocRoot');                   unlink($r->dir_config('lonIDsDir')."/$handle.id");
     if (-e "$londocroot/lon-status/reroute.txt") {                  undef($handle);
  &Apache::lonauth::reroute($r);                  $expire = 1;
  return OK;              }
     }          }
       }
     $env{'form.firsturl'} =~ s/(`)/'/g;  
       &Apache::loncommon::no_cache($r);
 # -------------------------------- Prevent users from attempting to login twice      &Apache::lonlocal::get_language_handle($r);
     my $handle = &Apache::lonnet::check_for_valid_session($r);      &Apache::loncommon::content_type($r,'text/html');
     if ($handle ne '') {      if ($expire) {
         my $lonidsdir=$r->dir_config('lonIDsDir');          my $c = new CGI::Cookie(-name    => 'lonPubID',
         if ($handle=~/^publicuser\_/) {                                  -value   => '',
 # For "public user" - remove it, we apparently really want to login                                  -expires => '-10y',);
     unlink($r->dir_config('lonIDsDir')."/$handle.id");          $r->header_out('Set-cookie' => $c);
         } else {      }
 # Indeed, a valid token is found      $r->send_http_header;
             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);      return OK if $r->header_only;
     my $start_page =   
         &Apache::loncommon::start_page('Already logged in');  
     my $end_page =   # Are we re-routing?
         &Apache::loncommon::end_page();      my $londocroot = $r->dir_config('lonDocRoot');
             my $dest = '/adm/roles';      if (-e "$londocroot/lon-status/reroute.txt") {
             if ($env{'form.firsturl'} ne '') {   &Apache::lonauth::reroute($r);
                 $dest = $env{'form.firsturl'};    return OK;
             }      }
     $r->print(  
                   $start_page      $env{'form.firsturl'} =~ s/(`)/'/g;
                  .'<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].',  # -------------------------------- Prevent users from attempting to login twice
                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'      if ($handle ne '') {
                  .$end_page          &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
                  );   my $start_page =
             return OK;      &Apache::loncommon::start_page('Already logged in');
         }   my $end_page =
     }      &Apache::loncommon::end_page();
           my $dest = '/adm/roles';
 # ---------------------------------------------------- No valid token, continue          if ($env{'form.firsturl'} ne '') {
               $dest = $env{'form.firsturl'};
  # ---------------------------- Not possible to really login to domain "public"          }
     if ($env{'form.domain'} eq 'public') {   $r->print(
  $env{'form.domain'}='';                    $start_page
  $env{'form.username'}='';                   .'<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].',
 # ----------------------------------------------------------- Process Interface                    '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
     $env{'form.interface'}=~s/\W//g;                   .$end_page
                    );
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};          return OK;
       }
     my $iconpath=   
  &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));  # ---------------------------------------------------- No valid token, continue
   
     my $lonhost = $r->dir_config('lonHostID');  # ---------------------------- Not possible to really login to domain "public"
     my $domain = &Apache::lonnet::default_login_domain();      if ($env{'form.domain'} eq 'public') {
     if ($lonhost ne '') {   $env{'form.domain'}='';
         my $redirect = &check_loginvia($domain,$lonhost);   $env{'form.username'}='';
         if ($redirect) {      }
             $r->print($redirect);  
             return OK;  # ------ Is this page requested because /adm/migrateuser detected an IP change?
         }       my %sessiondata;
     }      if ($env{'form.iptoken'}) {
           %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
     if (($env{'form.domain'}) &&           unless ($sessiondata{'sessionserver'}) {
  (&Apache::lonnet::domain($env{'form.domain'},'description'))) {              my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
  $domain=$env{'form.domain'};              delete($env{'form.iptoken'});
     }          }
     my $role    = $r->dir_config('lonRole');      }
     my $loadlim = $r->dir_config('lonLoadLim');  # ----------------------------------------------------------- Process Interface
     my $uloadlim= $r->dir_config('lonUserLoadLim');      $env{'form.interface'}=~s/\W//g;
     my $servadm = $r->dir_config('lonAdmEMail');  
     my $tabdir  = $r->dir_config('lonTabDir');      (undef,undef,undef,undef,undef,undef,my $clientmobile) =
     my $include = $r->dir_config('lonIncludes');          &Apache::loncommon::decode_user_agent();
     my $expire  = $r->dir_config('lonExpire');  
     my $version = $r->dir_config('lonVersion');      my $iconpath=
     my $host_name = &Apache::lonnet::hostname($lonhost);   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
   
 # --------------------------------------------- Default values for login fields      my $lonhost = $r->dir_config('lonHostID');
       my $domain = &Apache::lonnet::default_login_domain();
     my $authusername=($env{'form.username'}?$env{'form.username'}:'');      my $defdom = $domain;
     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);      if ($lonhost ne '') {
           unless ($sessiondata{'sessionserver'}) {
 # ---------------------------------------------------------- Determine own load              my $redirect = &check_loginvia($domain,$lonhost);
     my $loadavg;              if ($redirect) {
     {                  $r->print($redirect);
  my $loadfile=Apache::File->new('/proc/loadavg');                  return OK;
  $loadavg=<$loadfile>;              }
     }          }
     $loadavg =~ s/\s.*//g;      }
   
     my ($loadpercent,$userloadpercent);      if (($sessiondata{'domain'}) &&
     if ($loadlim) {          (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
         $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);          $domain=$sessiondata{'domain'};
     }      } elsif (($env{'form.domain'}) &&
     if ($uloadlim) {   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
         $userloadpercent=&Apache::lonnet::userload();   $domain=$env{'form.domain'};
     }      }
   
     my $firsturl=      my $role    = $r->dir_config('lonRole');
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});      my $loadlim = $r->dir_config('lonLoadLim');
       my $uloadlim= $r->dir_config('lonUserLoadLim');
 # ----------------------------------------------------------- Get announcements      my $servadm = $r->dir_config('lonAdmEMail');
     my $announcements=&Apache::lonnet::getannounce();      my $tabdir  = $r->dir_config('lonTabDir');
 # -------------------------------------------------------- Set login parameters      my $include = $r->dir_config('lonIncludes');
       my $expire  = $r->dir_config('lonExpire');
     my @hexstr=('0','1','2','3','4','5','6','7',      my $version = $r->dir_config('lonVersion');
                 '8','9','a','b','c','d','e','f');      my $host_name = &Apache::lonnet::hostname($lonhost);
     my $lkey='';  
     for (0..7) {  # --------------------------------------------- Default values for login fields
         $lkey.=$hexstr[rand(15)];     
     }      my ($authusername,$authdomain);
       if ($sessiondata{'username'}) {
     my $ukey='';          $authusername=$sessiondata{'username'};
     for (0..7) {      } else {
         $ukey.=$hexstr[rand(15)];          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
     }          $authusername=($env{'form.username'}?$env{'form.username'}:'');
       }
     my $lextkey=hex($lkey);      if ($sessiondata{'domain'}) {
     if ($lextkey>2147483647) { $lextkey-=4294967296; }          $authdomain=$sessiondata{'domain'};
       } else {
     my $uextkey=hex($ukey);          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
     if ($uextkey>2147483647) { $uextkey-=4294967296; }          $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
       }
 # -------------------------------------------------------- Store away log token  
     my $tokenextras;  # ---------------------------------------------------------- Determine own load
     if ($env{'form.role'}) {      my $loadavg;
         $tokenextras = '&role='.&escape($env{'form.role'});      {
     }   my $loadfile=Apache::File->new('/proc/loadavg');
     if ($env{'form.symb'}) {   $loadavg=<$loadfile>;
         if (!$tokenextras) {      }
             $tokenextras = '&';      $loadavg =~ s/\s.*//g;
         }  
         $tokenextras .= '&symb='.&escape($env{'form.symb'});      my ($loadpercent,$userloadpercent);
     }      if ($loadlim) {
     my $logtoken=Apache::lonnet::reply(          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,      }
        $lonhost);      if ($uloadlim) {
           $userloadpercent=&Apache::lonnet::userload();
 # -- If we cannot talk to ourselves, or hostID does not map to a hostname      }
 #    we are in serious trouble  
       my $firsturl=
     if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
         if ($logtoken eq 'no_such_host') {  
             &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');  # ----------------------------------------------------------- Get announcements
         }      my $announcements=&Apache::lonnet::getannounce();
         my $spares='';  # -------------------------------------------------------- Set login parameters
  my $last;  
         foreach my $hostid (sort      my @hexstr=('0','1','2','3','4','5','6','7',
     {                  '8','9','a','b','c','d','e','f');
  &Apache::lonnet::hostname($a) cmp      my $lkey='';
     &Apache::lonnet::hostname($b);      for (0..7) {
     }          $lkey.=$hexstr[rand(15)];
     keys(%Apache::lonnet::spareid)) {      }
             next if ($hostid eq $lonhost);  
     my $hostname = &Apache::lonnet::hostname($hostid);      my $ukey='';
     next if (($last eq $hostname) || ($hostname eq ''));      for (0..7) {
             $spares.='<br /><font size="+1"><a href="http://'.          $ukey.=$hexstr[rand(15)];
                 $hostname.      }
                 '/adm/login?domain='.$authdomain.'">'.  
                 $hostname.'</a>'.      my $lextkey=hex($lkey);
                 ' '.&mt('(preferred)').'</font>'.$/;      if ($lextkey>2147483647) { $lextkey-=4294967296; }
     $last=$hostname;  
         }      my $uextkey=hex($ukey);
         if ($spares) {      if ($uextkey>2147483647) { $uextkey-=4294967296; }
             $spares.= '<br />';  
         }  # -------------------------------------------------------- Store away log token
         my %all_hostnames = &Apache::lonnet::all_hostnames();      my $tokenextras;
         foreach my $hostid (sort      if ($env{'form.role'}) {
     {          $tokenextras = '&role='.&escape($env{'form.role'});
  &Apache::lonnet::hostname($a) cmp      }
     &Apache::lonnet::hostname($b);      if ($env{'form.symb'}) {
     }          if (!$tokenextras) {
     keys(%all_hostnames)) {              $tokenextras = '&';
             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});          }
             my $hostname = &Apache::lonnet::hostname($hostid);          $tokenextras .= '&symb='.&escape($env{'form.symb'});
             next if (($last eq $hostname) || ($hostname eq ''));      }
             $spares.='<br /><a href="http://'.      if ($env{'form.iptoken'}) {
              $hostname.          if (!$tokenextras) {
              '/adm/login?domain='.$authdomain.'">'.              $tokenextras = '&&';
              $hostname.'</a>';          }
             $last=$hostname;          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
          }      }
          $r->print(      my $logtoken=Apache::lonnet::reply(
    '<html>'         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
   .'<head><title>'         $lonhost);
   .&mt('The LearningOnline Network with CAPA')  
   .'</title></head>'  # -- If we cannot talk to ourselves, or hostID does not map to a hostname
   .'<body bgcolor="#FFFFFF">'  #    we are in serious trouble
   .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'  
   .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'      if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
   .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');          if ($logtoken eq 'no_such_host') {
         if ($spares) {              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
             $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')          }
                      .'</p>'          my $spares='';
                      .$spares);   my $last;
         }          foreach my $hostid (sort
         $r->print('</body>'      {
                  .'</html>'   &Apache::lonnet::hostname($a) cmp
         );      &Apache::lonnet::hostname($b);
         return OK;      }
     }      keys(%Apache::lonnet::spareid)) {
               next if ($hostid eq $lonhost);
 # ----------------------------------------------- Apparently we are in business      my $hostname = &Apache::lonnet::hostname($hostid);
     $servadm=~s/\,/\<br \/\>/g;      next if (($last eq $hostname) || ($hostname eq ''));
               $spares.='<br /><font size="+1"><a href="http://'.
 # ----------------------------------------------------------- Front page design                  $hostname.
     my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);                  '/adm/login?domain='.$authdomain.'">'.
     my $font=&Apache::loncommon::designparm('login.font',$domain);                  $hostname.'</a>'.
     my $link=&Apache::loncommon::designparm('login.link',$domain);                  ' '.&mt('(preferred)').'</font>'.$/;
     my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);      $last=$hostname;
     my $alink=&Apache::loncommon::designparm('login.alink',$domain);          }
     my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);          if ($spares) {
     my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);              $spares.= '<br />';
     my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);          }
     my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);          my %all_hostnames = &Apache::lonnet::all_hostnames();
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);          foreach my $hostid (sort
     my $img=&Apache::loncommon::designparm('login.img',$domain);      {
     my $domainlogo=&Apache::loncommon::domainlogo($domain);   &Apache::lonnet::hostname($a) cmp
     my $showbanner = 1;      &Apache::lonnet::hostname($b);
     my $showmainlogo = 1;      }
     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {      keys(%all_hostnames)) {
         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
     }              my $hostname = &Apache::lonnet::hostname($hostid);
     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {              next if (($last eq $hostname) || ($hostname eq ''));
         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);              $spares.='<br /><a href="http://'.
     }               $hostname.
     my $showadminmail;               '/adm/login?domain='.$authdomain.'">'.
     my @possdoms = &Apache::lonnet::current_machine_domains();               $hostname.'</a>';
     if (grep(/^\Q$domain\E$/,@possdoms)) {              $last=$hostname;
         $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);           }
     }           $r->print(
     my $showcoursecat =     '<html>'
         &Apache::loncommon::designparm('login.coursecatalog',$domain);    .'<head><title>'
     my $shownewuserlink =     .&mt('The LearningOnline Network with CAPA')
         &Apache::loncommon::designparm('login.newuser',$domain);    .'</title></head>'
     my $showhelpdesk =    .'<body bgcolor="#FFFFFF">'
         &Apache::loncommon::designparm('login.helpdesk',$domain);    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
     my $now=time;    .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
     my $js = (<<ENDSCRIPT);    .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
           if ($spares) {
 <script type="text/javascript" language="JavaScript">              $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
 // <![CDATA[                       .'</p>'
 function send()                       .$spares);
 {          }
 this.document.server.elements.uname.value          $r->print('</body>'
 =this.document.client.elements.uname.value;                   .'</html>'
           );
 this.document.server.elements.udom.value          return OK;
 =this.document.client.elements.udom.value;      }
   
 uextkey=this.document.client.elements.uextkey.value;  # ----------------------------------------------- Apparently we are in business
 lextkey=this.document.client.elements.lextkey.value;      $servadm=~s/\,/\<br \/\>/g;
 initkeys();  
   # ----------------------------------------------------------- Front page design
 this.document.server.elements.upass0.value      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
     =crypted(this.document.client.elements.upass$now.value.substr(0,15));      my $font=&Apache::loncommon::designparm('login.font',$domain);
 this.document.server.elements.upass1.value      my $link=&Apache::loncommon::designparm('login.link',$domain);
     =crypted(this.document.client.elements.upass$now.value.substr(15,15));      my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
 this.document.server.elements.upass2.value      my $alink=&Apache::loncommon::designparm('login.alink',$domain);
     =crypted(this.document.client.elements.upass$now.value.substr(30,15));      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
       my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
 this.document.client.elements.uname.value='';      my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
 this.document.client.elements.upass$now.value='';      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
       my $logo=&Apache::loncommon::designparm('login.logo',$domain);
 this.document.server.submit();      my $img=&Apache::loncommon::designparm('login.img',$domain);
 return false;      my $domainlogo=&Apache::loncommon::domainlogo($domain);
 }      my $showbanner = 1;
       my $showmainlogo = 1;
 function enableInput() {      if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
     this.document.client.elements.upass$now.removeAttribute("readOnly");          $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
     this.document.client.elements.uname.removeAttribute("readOnly");      }
     this.document.client.elements.udom.removeAttribute("readOnly");      if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
     return;          $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
 }      }
       my $showadminmail;
 // ]]>      my @possdoms = &Apache::lonnet::current_machine_domains();
 </script>      if (grep(/^\Q$domain\E$/,@possdoms)) {
           $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
 ENDSCRIPT      }
       my $showcoursecat =
 # --------------------------------------------------- Print login screen header          &Apache::loncommon::designparm('login.coursecatalog',$domain);
       my $shownewuserlink =
     my %add_entries = (          &Apache::loncommon::designparm('login.newuser',$domain);
        bgcolor      => "$mainbg",      my $showhelpdesk =
        text         => "$font",          &Apache::loncommon::designparm('login.helpdesk',$domain);
        link         => "$link",      my $now=time;
        vlink        => "$vlink",      my $js = (<<ENDSCRIPT);
        alink        => "$alink",  
                onload       => 'javascript:enableInput();',);  <script type="text/javascript" language="JavaScript">
   // <![CDATA[
     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,  function send()
        { 'redirect'       => [$expire,'/adm/roles'],   {
  'add_entries' => \%add_entries,  this.document.server.elements.uname.value
  'only_body'   => 1,}));  =this.document.client.elements.uname.value;
   
 # ----------------------------------------------------------------------- Texts  this.document.server.elements.udom.value
   =this.document.client.elements.udom.value;
     my %lt=&Apache::lonlocal::texthash(  
           'un'       => 'Username',  uextkey=this.document.client.elements.uextkey.value;
           'pw'       => 'Password',  lextkey=this.document.client.elements.lextkey.value;
           'dom'      => 'Domain',  initkeys();
           'perc'     => 'percent',  
           'load'     => 'Server Load',  if(this.document.server.action.substr(0,5) === 'http:'){
           'userload' => 'User Load',      this.document.server.elements.upass0.value
           'catalog'  => 'Course/Community Catalog',          =getCrypted(this.document.client.elements.upass$now.value);
           'log'      => 'Log in',  } else {
           'help'     => 'Log-in Help',      this.document.server.elements.upass0.value
           'serv'     => 'Server',          =this.document.client.elements.upass$now.value;
           'servadm'  => 'Server Administration',  }
           'helpdesk' => 'Contact Helpdesk',  
           'forgotpw' => 'Forgot password?',  this.document.client.elements.uname.value='';
           'newuser'  => 'New User?',  this.document.client.elements.upass$now.value='';
        );  
 # -------------------------------------------------- Change password field name  this.document.server.submit();
   return false;
     my $forgotpw = &forgotpwdisplay(%lt);  }
     $forgotpw .= '<br />' if $forgotpw;  
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);  function enableInput() {
     if ($loginhelp) {      this.document.client.elements.upass$now.removeAttribute("readOnly");
         $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';      this.document.client.elements.uname.removeAttribute("readOnly");
     }      this.document.client.elements.udom.removeAttribute("readOnly");
       return;
 # ---------------------------------------------------- Serve out DES JavaScript  }
     {  
     my $jsh=Apache::File->new($include."/londes.js");  // ]]>
     $r->print(<$jsh>);  </script>
     }  
 # ---------------------------------------------------------- Serve rest of page  ENDSCRIPT
   
     $r->print(  # --------------------------------------------------- Print login screen header
     '<div class="LC_Box"'  
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'      my %add_entries = (
 );         bgcolor      => "$mainbg",
          text         => "$font",
     $r->print(<<ENDSERVERFORM);         link         => "$link",
 <form name="server" action="/adm/authenticate" method="post" target="_top">         vlink        => "$vlink",
    <input type="hidden" name="logtoken" value="$logtoken" />         alink        => "$alink",
    <input type="hidden" name="serverid" value="$lonhost" />                 onload       => 'javascript:enableInput();',);
    <input type="hidden" name="uname" value="" />  
    <input type="hidden" name="upass0" value="" />      my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
    <input type="hidden" name="upass1" value="" />      @hosts = &Apache::lonnet::current_machine_ids();
    <input type="hidden" name="upass2" value="" />      $lonhost_in_use = $lonhost;
    <input type="hidden" name="udom" value="" />      if (@hosts > 1) {
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />          foreach my $hostid (@hosts) {
    <input type="hidden" name="localres" value="$env{'form.localres'}" />              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
   </form>                  $lonhost_in_use = $hostid;
 ENDSERVERFORM                  last;
     my $coursecatalog;              }
     if (($showcoursecat eq '') || ($showcoursecat)) {          }
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';      }
     }      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
     my $newuserlink;      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
     if ($shownewuserlink) {      $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';      if ($headextra) {
     }          my $omitextra;
     my $logintitle =          if ($headextra_exempt ne '') {
         '<h2 class="LC_hcell"'              my @exempt = split(',',$headextra_exempt);
        .' style="background:'.$loginbox_header_bgcol.';'              my $ip = $ENV{'REMOTE_ADDR'};
        .' color:'.$loginbox_header_textcol.'">'              if (grep(/^\Q$ip\E$/,@exempt)) {
        .$lt{'log'}                  $omitextra = 1;
        .'</h2>';              }
           }
     my $noscript_warning='<noscript><span class="LC_warning"><b>'          unless ($omitextra) {
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')              my $confname = $defdom.'-domainconfig';
                         .'</b></span></noscript>';              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
     my $helpdeskscript;                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,                  unless ($extra eq '-1') {
                                        $authdomain,\$helpdeskscript,                      $js .= "\n".$extra."\n";
                                        $showhelpdesk,\@possdoms);                  }
               }
     my $loginform=(<<LFORM);          }
 <form name="client" action="" onsubmit="return(send())">      }
   <input type="hidden" name="lextkey" value="$lextkey" />  
   <input type="hidden" name="uextkey" value="$uextkey" />      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
   <b><label for="uname">$lt{'un'}</label>:</b><br />         { 'redirect'       => [$expire,'/adm/roles'],
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" /><br />   'add_entries' => \%add_entries,
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />   'only_body'   => 1,}));
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />  
   <b><label for="udom">$lt{'dom'}</label>:</b><br />  # ----------------------------------------------------------------------- Texts
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" /><br />  
   <input type="submit" value="$lt{'log'}" />      my %lt=&Apache::lonlocal::texthash(
 </form>            'un'       => 'Username',
 LFORM            'pw'       => 'Password',
             'dom'      => 'Domain',
     if ($showbanner) {            'perc'     => 'percent',
         $r->print(<<HEADER);            'load'     => 'Server Load',
 <!-- The LON-CAPA Header -->            'userload' => 'User Load',
 <div style="background:$pgbg;margin:0;width:100%;">            'catalog'  => 'Course/Community Catalog',
   <img src="$img" border="0" alt="The Learning Online Network with CAPA" />            'log'      => 'Log in',
 </div>            'help'     => 'Log-in Help',
 HEADER            'serv'     => 'Server',
     }            'servadm'  => 'Server Administration',
     $r->print(<<ENDTOP);            'helpdesk' => 'Contact Helpdesk',
 <div style="float:left;margin-top:0;">            'forgotpw' => 'Forgot password?',
 <div class="LC_Box" style="background:$loginbox_bg;">            'newuser'  => 'New User?',
   $logintitle         );
   $loginform  # -------------------------------------------------- Change password field name
   $noscript_warning  
 </div>      my $forgotpw = &forgotpwdisplay(%lt);
         $forgotpw .= '<br />' if $forgotpw;
 <div class="LC_Box" style="padding-top: 10px;">      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
   $loginhelp      if ($loginhelp) {
   $forgotpw          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
   $contactblock      }
   $newuserlink  
   $coursecatalog  # ---------------------------------------------------- Serve out DES JavaScript
 </div>      {
 </div>      my $jsh=Apache::File->new($include."/londes.js");
       $r->print(<$jsh>);
 <div>      }
 ENDTOP  # ---------------------------------------------------------- Serve rest of page
     if ($showmainlogo) {  
         $r->print(' <img src="'.$logo.'" alt="" />'."\n");      $r->print(
     }      '<div class="LC_Box"'
 $r->print(<<ENDTOP);     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
 $announcements  );
 </div>  
 <hr style="clear:both;" />      $r->print(<<ENDSERVERFORM);
 ENDTOP  <form name="server" action="/adm/authenticate" method="post" target="_top">
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);     <input type="hidden" name="logtoken" value="$logtoken" />
     $domainrow = <<"END";     <input type="hidden" name="serverid" value="$lonhost" />
       <tr>     <input type="hidden" name="uname" value="" />
        <td  align="left" valign="top">     <input type="hidden" name="upass0" value="" />
         <small><b>$lt{'dom'}:&nbsp;</b></small>     <input type="hidden" name="udom" value="" />
        </td>     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
        <td  align="left" valign="top">     <input type="hidden" name="localres" value="$env{'form.localres'}" />
         <small><tt>&nbsp;$domain</tt></small>    </form>
        </td>  ENDSERVERFORM
       </tr>      my $coursecatalog;
 END      if (($showcoursecat eq '') || ($showcoursecat)) {
     $serverrow = <<"END";          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
       <tr>      }
        <td  align="left" valign="top">      my $newuserlink;
         <small><b>$lt{'serv'}:&nbsp;</b></small>      if ($shownewuserlink) {
        </td>          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
        <td align="left" valign="top">      }
         <small><tt>&nbsp;$lonhost ($role)</tt></small>      my $logintitle =
        </td>          '<h2 class="LC_hcell"'
       </tr>         .' style="background:'.$loginbox_header_bgcol.';'
 END         .' color:'.$loginbox_header_textcol.'">'
     if ($loadlim) {         .$lt{'log'}
         $loadrow = <<"END";         .'</h2>';
       <tr>  
        <td align="left" valign="top">      my $noscript_warning='<noscript><span class="LC_warning"><b>'
         <small><b>$lt{'load'}:&nbsp;</b></small>                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
        </td>                          .'</b></span></noscript>';
        <td align="left" valign="top">      my $helpdeskscript;
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
        </td>                                         $authdomain,\$helpdeskscript,
       </tr>                                         $showhelpdesk,\@possdoms);
 END  
     }      my $mobileargs;
     if ($uloadlim) {      if ($clientmobile) {
         $userloadrow = <<"END";          $mobileargs = 'autocapitalize="off" autocorrect="off"';
       <tr>      }
        <td align="left" valign="top">      my $loginform=(<<LFORM);
         <small><b>$lt{'userload'}:&nbsp;</b></small>  <form name="client" action="" onsubmit="return(send())">
        </td>    <input type="hidden" name="lextkey" value="$lextkey" />
        <td align="left" valign="top">    <input type="hidden" name="uextkey" value="$uextkey" />
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>    <b><label for="uname">$lt{'un'}</label>:</b><br />
        </td>    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
       </tr>    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
 END    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
     }    <b><label for="udom">$lt{'dom'}</label>:</b><br />
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
         $versionrow = <<"END";    <input type="submit" value="$lt{'log'}" />
       <tr>  </form>
        <td colspan="2" align="left">  LFORM
         <small>$version</small>  
        </td>      if ($showbanner) {
       </tr>          $r->print(<<HEADER);
 END  <!-- The LON-CAPA Header -->
     }  <div style="background:$pgbg;margin:0;width:100%;">
     <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
     $r->print(<<ENDDOCUMENT);  </div>
     <div style="float: left;">  HEADER
      <table border="0" cellspacing="0" cellpadding="0">      }
 $domainrow      $r->print(<<ENDTOP);
 $serverrow  <div style="float:left;margin-top:0;">
 $loadrow      <div class="LC_Box" style="background:$loginbox_bg;">
 $userloadrow    $logintitle
 $versionrow    $loginform
      </table>    $noscript_warning
     </div>  </div>
     <div style="float: right;">   
     $domainlogo  <div class="LC_Box" style="padding-top: 10px;">
     </div>    $loginhelp
     <br style="clear:both;" />    $forgotpw
  </div>    $contactblock
     $newuserlink
 <script type="text/javascript">    $coursecatalog
 // <![CDATA[  </div>
 // the if prevents the script error if the browser can not handle this  </div>
 if ( document.client.uname ) { document.client.uname.focus(); }  
 // ]]>  <div>
 </script>  ENDTOP
 $helpdeskscript      if ($showmainlogo) {
           $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
 ENDDOCUMENT      }
     my %endargs = ( 'noredirectlink' => 1, );  $r->print(<<ENDTOP);
     $r->print(&Apache::loncommon::end_page(\%endargs));  $announcements
     return OK;  </div>
 }  <hr style="clear:both;" />
   ENDTOP
 sub check_loginvia {      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
     my ($domain,$lonhost) = @_;      $domainrow = <<"END";
     if ($domain eq '' || $lonhost eq '') {        <tr>
         return;         <td  align="left" valign="top">
     }          <small><b>$lt{'dom'}:&nbsp;</b></small>
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);         </td>
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};         <td  align="left" valign="top">
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};          <small><tt>&nbsp;$domain</tt></small>
     my $output;         </td>
     if ($loginvia ne '') {        </tr>
         my $noredirect;  END
         my $ip = $ENV{'REMOTE_ADDR'};      $serverrow = <<"END";
         if ($ip eq '127.0.0.1') {        <tr>
             $noredirect = 1;         <td  align="left" valign="top">
         } else {          <small><b>$lt{'serv'}:&nbsp;</b></small>
             if ($loginvia_exempt ne '') {         </td>
                 my @exempt = split(',',$loginvia_exempt);         <td align="left" valign="top">
                 if (grep(/^\Q$ip\E$/,@exempt)) {          <small><tt>&nbsp;$lonhost ($role)</tt></small>
                     $noredirect = 1;         </td>
                 }        </tr>
             }  END
         }      if ($loadlim) {
         unless ($noredirect) {          $loadrow = <<"END";
             my ($newhost,$path);        <tr>
             if ($loginvia =~ /:/) {         <td align="left" valign="top">
                 ($newhost,$path) = split(':',$loginvia);          <small><b>$lt{'load'}:&nbsp;</b></small>
             } else {         </td>
                 $newhost = $loginvia;         <td align="left" valign="top">
             }          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
             if ($newhost ne $lonhost) {         </td>
                 if (&Apache::lonnet::hostname($newhost) ne '') {        </tr>
                     $output = &redirect_page($newhost,$path);  END
                 }      }
             }      if ($uloadlim) {
         }          $userloadrow = <<"END";
     }        <tr>
     return $output;         <td align="left" valign="top">
 }          <small><b>$lt{'userload'}:&nbsp;</b></small>
          </td>
 sub redirect_page {         <td align="left" valign="top">
     my ($desthost,$path) = @_;          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
     my $protocol = $Apache::lonnet::protocol{$desthost};         </td>
     $protocol = 'http' if ($protocol ne 'https');        </tr>
     unless ($path =~ m{^/}) {  END
         $path = '/'.$path;      }
     }      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;          $versionrow = <<"END";
     if ($env{'form.firsturl'} ne '') {        <tr>
         $url .='?firsturl='.$env{'form.firsturl'};         <td colspan="2" align="left">
     }          <small>$version</small>
     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,         </td>
                                                     {'redirect' => [0,$url],});        </tr>
     my $end_page   = &Apache::loncommon::end_page();  END
     return $start_page.$end_page;      }
 }  
       $r->print(<<ENDDOCUMENT);
 sub contactdisplay {      <div style="float: left;">
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,       <table border="0" cellspacing="0" cellpadding="0">
         $possdoms) = @_;  $domainrow
     my $contactblock;  $serverrow
     my $origmail;  $loadrow    
     if (ref($possdoms) eq 'ARRAY') {  $userloadrow
         if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {   $versionrow
             $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};       </table>
         }      </div>
     }      <div style="float: right;">
     my $requestmail =       $domainlogo
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',      </div>
                                                  $authdomain,$origmail);      <br style="clear:both;" />
     unless ($showhelpdesk eq '0') {   </div>
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {  
             $showhelpdesk = 1;  <script type="text/javascript">
         } else {  // <![CDATA[
             $showhelpdesk = 0;  // the if prevents the script error if the browser can not handle this
         }  if ( document.client.uname ) { document.client.uname.focus(); }
     }  // ]]>
     if ($servadm && $showadminmail) {  </script>
         $contactblock .= $$lt{'servadm'}.':<br />'.  $helpdeskscript
                          '<tt>'.$servadm.'</tt><br />';  
     }  ENDDOCUMENT
     if ($showhelpdesk) {      my %endargs = ( 'noredirectlink' => 1, );
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';      $r->print(&Apache::loncommon::end_page(\%endargs));
         my $thisurl = &escape('/adm/login');      return OK;
         $$helpdeskscript = <<"ENDSCRIPT";  }
 <script type="text/javascript">  
 // <![CDATA[  sub check_loginvia {
 function helpdesk() {      my ($domain,$lonhost) = @_;
     var possdom = document.client.udom.value;      if ($domain eq '' || $lonhost eq '') {
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');          return;
     if (codedom == '') {      }
         codedom = "$authdomain";      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
     }      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
     var querystr = "origurl=$thisurl&codedom="+codedom;      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
     document.location.href = "/adm/helpdesk?"+querystr;      my $output;
     return;      if ($loginvia ne '') {
 }          my $noredirect;
 // ]]>          my $ip = $ENV{'REMOTE_ADDR'};
 </script>          if ($ip eq '127.0.0.1') {
 ENDSCRIPT              $noredirect = 1;
     }          } else {
     return $contactblock;              if ($loginvia_exempt ne '') {
 }                  my @exempt = split(',',$loginvia_exempt);
                   if (grep(/^\Q$ip\E$/,@exempt)) {
 sub forgotpwdisplay {                      $noredirect = 1;
     my (%lt) = @_;                  }
     my $prompt_for_resetpw = 1;               }
     if ($prompt_for_resetpw) {          }
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';          unless ($noredirect) {
     }              my ($newhost,$path);
     return;              if ($loginvia =~ /:/) {
 }                  ($newhost,$path) = split(':',$loginvia);
               } else {
 sub coursecatalog_link {                  $newhost = $loginvia;
     my ($linkname) = @_;              }
     return <<"END";              if ($newhost ne $lonhost) {
       <a href="/adm/coursecatalog">$linkname</a>                  if (&Apache::lonnet::hostname($newhost) ne '') {
 END                      $output = &redirect_page($newhost,$path);
 }                  }
               }
 sub newuser_link {          }
     my ($linkname) = @_;      }
     return '<a href="/adm/createaccount">'.$linkname.'</a>';      return $output;
 }  }
   
 1;  sub redirect_page {
 __END__      my ($desthost,$path) = @_;
       my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
       unless ($path =~ m{^/}) {
           $path = '/'.$path;
       }
       my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
       if ($env{'form.firsturl'} ne '') {
           $url .='?firsturl='.$env{'form.firsturl'};
       }
       my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                                       {'redirect' => [0,$url],});
       my $end_page   = &Apache::loncommon::end_page();
       return $start_page.$end_page;
   }
   
   sub contactdisplay {
       my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
           $possdoms) = @_;
       my $contactblock;
       my $origmail;
       if (ref($possdoms) eq 'ARRAY') {
           if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
               $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
           }
       }
       my $requestmail =
           &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                    $authdomain,$origmail);
       unless ($showhelpdesk eq '0') {
           if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
               $showhelpdesk = 1;
           } else {
               $showhelpdesk = 0;
           }
       }
       if ($servadm && $showadminmail) {
           $contactblock .= $$lt{'servadm'}.':<br />'.
                            '<tt>'.$servadm.'</tt><br />';
       }
       if ($showhelpdesk) {
           $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
           my $thisurl = &escape('/adm/login');
           $$helpdeskscript = <<"ENDSCRIPT";
   <script type="text/javascript">
   // <![CDATA[
   function helpdesk() {
       var possdom = document.client.udom.value;
       var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
       if (codedom == '') {
           codedom = "$authdomain";
       }
       var querystr = "origurl=$thisurl&codedom="+codedom;
       document.location.href = "/adm/helpdesk?"+querystr;
       return;
   }
   // ]]>
   </script>
   ENDSCRIPT
       }
       return $contactblock;
   }
   
   sub forgotpwdisplay {
       my (%lt) = @_;
       my $prompt_for_resetpw = 1;
       if ($prompt_for_resetpw) {
           return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
       }
       return;
   }
   
   sub coursecatalog_link {
       my ($linkname) = @_;
       return <<"END";
         <a href="/adm/coursecatalog">$linkname</a>
   END
   }
   
   sub newuser_link {
       my ($linkname) = @_;
       return '<a href="/adm/createaccount">'.$linkname.'</a>';
   }
   
   1;
   __END__

Removed from v.1.155  
changed lines
  Added in v.1.170


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