Diff for /loncom/auth/lonlogin.pm between versions 1.157 and 1.161

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


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