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

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

Removed from v.1.158.2.2  
changed lines
  Added in v.1.161


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