Diff for /loncom/auth/lonlogin.pm between versions 1.153 and 1.166

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

Removed from v.1.153  
changed lines
  Added in v.1.166


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