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

version 1.159, 2014/10/04 02:59:32 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);
     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,      my $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost};
        { 'redirect'       => [$expire,'/adm/roles'],       my $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost};
  'add_entries' => \%add_entries,      if ($headextra) {
  'only_body'   => 1,}));          my $omitextra;
           if ($headextra_exempt ne '') {
 # ----------------------------------------------------------------------- Texts              my @exempt = split(',',$headextra_exempt);
               my $ip = $ENV{'REMOTE_ADDR'};
     my %lt=&Apache::lonlocal::texthash(              if (grep(/^\Q$ip\E$/,@exempt)) {
           'un'       => 'Username',                  $omitextra = 1;
           'pw'       => 'Password',              }
           'dom'      => 'Domain',          }
           'perc'     => 'percent',          unless ($omitextra) {
           'load'     => 'Server Load',              my $confname = $defdom.'-domainconfig';
           'userload' => 'User Load',              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost/\E}) {
           'catalog'  => 'Course/Community Catalog',                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
           'log'      => 'Log in',                  unless ($extra eq '-1') {
           'help'     => 'Log-in Help',                      $js .= "\n".$extra."\n";
           'serv'     => 'Server',                  }
           'servadm'  => 'Server Administration',              }
           'helpdesk' => 'Contact Helpdesk',          }
           'forgotpw' => 'Forgot password?',      }
           'newuser'  => 'New User?',  
        );      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
 # -------------------------------------------------- Change password field name         { 'redirect'       => [$expire,'/adm/roles'],
    'add_entries' => \%add_entries,
     my $forgotpw = &forgotpwdisplay(%lt);   'only_body'   => 1,}));
     $forgotpw .= '<br />' if $forgotpw;  
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);  # ----------------------------------------------------------------------- Texts
     if ($loginhelp) {  
         $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';      my %lt=&Apache::lonlocal::texthash(
     }            'un'       => 'Username',
             'pw'       => 'Password',
 # ---------------------------------------------------- Serve out DES JavaScript            'dom'      => 'Domain',
     {            'perc'     => 'percent',
     my $jsh=Apache::File->new($include."/londes.js");            'load'     => 'Server Load',
     $r->print(<$jsh>);            'userload' => 'User Load',
     }            'catalog'  => 'Course/Community Catalog',
 # ---------------------------------------------------------- Serve rest of page            'log'      => 'Log in',
             'help'     => 'Log-in Help',
     $r->print(            'serv'     => 'Server',
     '<div class="LC_Box"'            'servadm'  => 'Server Administration',
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'            'helpdesk' => 'Contact Helpdesk',
 );            'forgotpw' => 'Forgot password?',
             'newuser'  => 'New User?',
     $r->print(<<ENDSERVERFORM);         );
 <form name="server" action="/adm/authenticate" method="post" target="_top">  # -------------------------------------------------- Change password field name
    <input type="hidden" name="logtoken" value="$logtoken" />  
    <input type="hidden" name="serverid" value="$lonhost" />      my $forgotpw = &forgotpwdisplay(%lt);
    <input type="hidden" name="uname" value="" />      $forgotpw .= '<br />' if $forgotpw;
    <input type="hidden" name="upass0" value="" />      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
    <input type="hidden" name="upass1" value="" />      if ($loginhelp) {
    <input type="hidden" name="upass2" value="" />          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
    <input type="hidden" name="udom" value="" />      }
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />  
    <input type="hidden" name="localres" value="$env{'form.localres'}" />  # ---------------------------------------------------- Serve out DES JavaScript
   </form>      {
 ENDSERVERFORM      my $jsh=Apache::File->new($include."/londes.js");
     my $coursecatalog;      $r->print(<$jsh>);
     if (($showcoursecat eq '') || ($showcoursecat)) {      }
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';  # ---------------------------------------------------------- Serve rest of page
     }  
     my $newuserlink;      $r->print(
     if ($shownewuserlink) {      '<div class="LC_Box"'
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
     }  );
     my $logintitle =  
         '<h2 class="LC_hcell"'      $r->print(<<ENDSERVERFORM);
        .' style="background:'.$loginbox_header_bgcol.';'  <form name="server" action="/adm/authenticate" method="post" target="_top">
        .' color:'.$loginbox_header_textcol.'">'     <input type="hidden" name="logtoken" value="$logtoken" />
        .$lt{'log'}     <input type="hidden" name="serverid" value="$lonhost" />
        .'</h2>';     <input type="hidden" name="uname" value="" />
      <input type="hidden" name="upass0" value="" />
     my $noscript_warning='<noscript><span class="LC_warning"><b>'     <input type="hidden" name="upass1" value="" />
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')     <input type="hidden" name="upass2" value="" />
                         .'</b></span></noscript>';     <input type="hidden" name="udom" value="" />
     my $helpdeskscript;     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,     <input type="hidden" name="localres" value="$env{'form.localres'}" />
                                        $authdomain,\$helpdeskscript,    </form>
                                        $showhelpdesk,\@possdoms);  ENDSERVERFORM
       my $coursecatalog;
     my $mobileargs;      if (($showcoursecat eq '') || ($showcoursecat)) {
     if ($clientmobile) {          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
         $mobileargs = 'autocapitalize="off" autocorrect="off"';       }
     }      my $newuserlink;
     my $loginform=(<<LFORM);      if ($shownewuserlink) {
 <form name="client" action="" onsubmit="return(send())">          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
   <input type="hidden" name="lextkey" value="$lextkey" />      }
   <input type="hidden" name="uextkey" value="$uextkey" />      my $logintitle =
   <b><label for="uname">$lt{'un'}</label>:</b><br />          '<h2 class="LC_hcell"'
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />         .' style="background:'.$loginbox_header_bgcol.';'
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />         .' color:'.$loginbox_header_textcol.'">'
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />         .$lt{'log'}
   <b><label for="udom">$lt{'dom'}</label>:</b><br />         .'</h2>';
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />  
   <input type="submit" value="$lt{'log'}" />      my $noscript_warning='<noscript><span class="LC_warning"><b>'
 </form>                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
 LFORM                          .'</b></span></noscript>';
       my $helpdeskscript;
     if ($showbanner) {      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
         $r->print(<<HEADER);                                         $authdomain,\$helpdeskscript,
 <!-- The LON-CAPA Header -->                                         $showhelpdesk,\@possdoms);
 <div style="background:$pgbg;margin:0;width:100%;">  
   <img src="$img" border="0" alt="The Learning Online Network with CAPA" />      my $mobileargs;
 </div>      if ($clientmobile) {
 HEADER          $mobileargs = 'autocapitalize="off" autocorrect="off"';
     }      }
     $r->print(<<ENDTOP);      my $loginform=(<<LFORM);
 <div style="float:left;margin-top:0;">  <form name="client" action="" onsubmit="return(send())">
 <div class="LC_Box" style="background:$loginbox_bg;">    <input type="hidden" name="lextkey" value="$lextkey" />
   $logintitle    <input type="hidden" name="uextkey" value="$uextkey" />
   $loginform    <b><label for="uname">$lt{'un'}</label>:</b><br />
   $noscript_warning    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
 </div>    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
       <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
 <div class="LC_Box" style="padding-top: 10px;">    <b><label for="udom">$lt{'dom'}</label>:</b><br />
   $loginhelp    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
   $forgotpw    <input type="submit" value="$lt{'log'}" />
   $contactblock  </form>
   $newuserlink  LFORM
   $coursecatalog  
 </div>      if ($showbanner) {
 </div>          $r->print(<<HEADER);
   <!-- The LON-CAPA Header -->
 <div>  <div style="background:$pgbg;margin:0;width:100%;">
 ENDTOP    <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
     if ($showmainlogo) {  </div>
         $r->print(' <img src="'.$logo.'" alt="" />'."\n");  HEADER
     }      }
 $r->print(<<ENDTOP);      $r->print(<<ENDTOP);
 $announcements  <div style="float:left;margin-top:0;">
 </div>  <div class="LC_Box" style="background:$loginbox_bg;">
 <hr style="clear:both;" />    $logintitle
 ENDTOP    $loginform
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);    $noscript_warning
     $domainrow = <<"END";  </div>
       <tr>   
        <td  align="left" valign="top">  <div class="LC_Box" style="padding-top: 10px;">
         <small><b>$lt{'dom'}:&nbsp;</b></small>    $loginhelp
        </td>    $forgotpw
        <td  align="left" valign="top">    $contactblock
         <small><tt>&nbsp;$domain</tt></small>    $newuserlink
        </td>    $coursecatalog
       </tr>  </div>
 END  </div>
     $serverrow = <<"END";  
       <tr>  <div>
        <td  align="left" valign="top">  ENDTOP
         <small><b>$lt{'serv'}:&nbsp;</b></small>      if ($showmainlogo) {
        </td>          $r->print(' <img src="'.$logo.'" alt="" />'."\n");
        <td align="left" valign="top">      }
         <small><tt>&nbsp;$lonhost ($role)</tt></small>  $r->print(<<ENDTOP);
        </td>  $announcements
       </tr>  </div>
 END  <hr style="clear:both;" />
     if ($loadlim) {  ENDTOP
         $loadrow = <<"END";      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
       <tr>      $domainrow = <<"END";
        <td align="left" valign="top">        <tr>
         <small><b>$lt{'load'}:&nbsp;</b></small>         <td  align="left" valign="top">
        </td>          <small><b>$lt{'dom'}:&nbsp;</b></small>
        <td align="left" valign="top">         </td>
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>         <td  align="left" valign="top">
        </td>          <small><tt>&nbsp;$domain</tt></small>
       </tr>         </td>
 END        </tr>
     }  END
     if ($uloadlim) {      $serverrow = <<"END";
         $userloadrow = <<"END";        <tr>
       <tr>         <td  align="left" valign="top">
        <td align="left" valign="top">          <small><b>$lt{'serv'}:&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;$lonhost ($role)</tt></small>
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>         </td>
        </td>        </tr>
       </tr>  END
 END      if ($loadlim) {
     }          $loadrow = <<"END";
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {        <tr>
         $versionrow = <<"END";         <td align="left" valign="top">
       <tr>          <small><b>$lt{'load'}:&nbsp;</b></small>
        <td colspan="2" align="left">         </td>
         <small>$version</small>         <td align="left" valign="top">
        </td>          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
       </tr>         </td>
 END        </tr>
     }  END
       }
     $r->print(<<ENDDOCUMENT);      if ($uloadlim) {
     <div style="float: left;">          $userloadrow = <<"END";
      <table border="0" cellspacing="0" cellpadding="0">        <tr>
 $domainrow         <td align="left" valign="top">
 $serverrow          <small><b>$lt{'userload'}:&nbsp;</b></small>
 $loadrow             </td>
 $userloadrow         <td align="left" valign="top">
 $versionrow          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
      </table>         </td>
     </div>        </tr>
     <div style="float: right;">  END
     $domainlogo      }
     </div>      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
     <br style="clear:both;" />          $versionrow = <<"END";
  </div>        <tr>
          <td colspan="2" align="left">
 <script type="text/javascript">          <small>$version</small>
 // <![CDATA[         </td>
 // the if prevents the script error if the browser can not handle this        </tr>
 if ( document.client.uname ) { document.client.uname.focus(); }  END
 // ]]>      }
 </script>  
 $helpdeskscript      $r->print(<<ENDDOCUMENT);
       <div style="float: left;">
 ENDDOCUMENT       <table border="0" cellspacing="0" cellpadding="0">
     my %endargs = ( 'noredirectlink' => 1, );  $domainrow
     $r->print(&Apache::loncommon::end_page(\%endargs));  $serverrow
     return OK;  $loadrow    
 }  $userloadrow
   $versionrow
 sub check_loginvia {       </table>
     my ($domain,$lonhost) = @_;      </div>
     if ($domain eq '' || $lonhost eq '') {      <div style="float: right;">
         return;      $domainlogo
     }      </div>
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);      <br style="clear:both;" />
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};   </div>
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};  
     my $output;  <script type="text/javascript">
     if ($loginvia ne '') {  // <![CDATA[
         my $noredirect;  // the if prevents the script error if the browser can not handle this
         my $ip = $ENV{'REMOTE_ADDR'};  if ( document.client.uname ) { document.client.uname.focus(); }
         if ($ip eq '127.0.0.1') {  // ]]>
             $noredirect = 1;  </script>
         } else {  $helpdeskscript
             if ($loginvia_exempt ne '') {  
                 my @exempt = split(',',$loginvia_exempt);  ENDDOCUMENT
                 if (grep(/^\Q$ip\E$/,@exempt)) {      my %endargs = ( 'noredirectlink' => 1, );
                     $noredirect = 1;      $r->print(&Apache::loncommon::end_page(\%endargs));
                 }      return OK;
             }  }
         }  
         unless ($noredirect) {  sub check_loginvia {
             my ($newhost,$path);      my ($domain,$lonhost) = @_;
             if ($loginvia =~ /:/) {      if ($domain eq '' || $lonhost eq '') {
                 ($newhost,$path) = split(':',$loginvia);          return;
             } else {      }
                 $newhost = $loginvia;      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
             }      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
             if ($newhost ne $lonhost) {      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
                 if (&Apache::lonnet::hostname($newhost) ne '') {      my $output;
                     $output = &redirect_page($newhost,$path);      if ($loginvia ne '') {
                 }          my $noredirect;
             }          my $ip = $ENV{'REMOTE_ADDR'};
         }          if ($ip eq '127.0.0.1') {
     }              $noredirect = 1;
     return $output;          } else {
 }              if ($loginvia_exempt ne '') {
                   my @exempt = split(',',$loginvia_exempt);
 sub redirect_page {                  if (grep(/^\Q$ip\E$/,@exempt)) {
     my ($desthost,$path) = @_;                      $noredirect = 1;
     my $protocol = $Apache::lonnet::protocol{$desthost};                  }
     $protocol = 'http' if ($protocol ne 'https');              }
     unless ($path =~ m{^/}) {          }
         $path = '/'.$path;          unless ($noredirect) {
     }              my ($newhost,$path);
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;              if ($loginvia =~ /:/) {
     if ($env{'form.firsturl'} ne '') {                  ($newhost,$path) = split(':',$loginvia);
         $url .='?firsturl='.$env{'form.firsturl'};              } else {
     }                  $newhost = $loginvia;
     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,              }
                                                     {'redirect' => [0,$url],});              if ($newhost ne $lonhost) {
     my $end_page   = &Apache::loncommon::end_page();                  if (&Apache::lonnet::hostname($newhost) ne '') {
     return $start_page.$end_page;                      $output = &redirect_page($newhost,$path);
 }                  }
               }
 sub contactdisplay {          }
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,      }
         $possdoms) = @_;      return $output;
     my $contactblock;  }
     my $origmail;  
     if (ref($possdoms) eq 'ARRAY') {  sub redirect_page {
         if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {       my ($desthost,$path) = @_;
             $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      my $protocol = $Apache::lonnet::protocol{$desthost};
         }      $protocol = 'http' if ($protocol ne 'https');
     }      unless ($path =~ m{^/}) {
     my $requestmail =           $path = '/'.$path;
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',      }
                                                  $authdomain,$origmail);      my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
     unless ($showhelpdesk eq '0') {      if ($env{'form.firsturl'} ne '') {
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {          $url .='?firsturl='.$env{'form.firsturl'};
             $showhelpdesk = 1;      }
         } else {      my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
             $showhelpdesk = 0;                                                      {'redirect' => [0,$url],});
         }      my $end_page   = &Apache::loncommon::end_page();
     }      return $start_page.$end_page;
     if ($servadm && $showadminmail) {  }
         $contactblock .= $$lt{'servadm'}.':<br />'.  
                          '<tt>'.$servadm.'</tt><br />';  sub contactdisplay {
     }      my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
     if ($showhelpdesk) {          $possdoms) = @_;
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';      my $contactblock;
         my $thisurl = &escape('/adm/login');      my $origmail;
         $$helpdeskscript = <<"ENDSCRIPT";      if (ref($possdoms) eq 'ARRAY') {
 <script type="text/javascript">          if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
 // <![CDATA[              $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
 function helpdesk() {          }
     var possdom = document.client.udom.value;      }
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');      my $requestmail =
     if (codedom == '') {          &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
         codedom = "$authdomain";                                                   $authdomain,$origmail);
     }      unless ($showhelpdesk eq '0') {
     var querystr = "origurl=$thisurl&codedom="+codedom;          if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
     document.location.href = "/adm/helpdesk?"+querystr;              $showhelpdesk = 1;
     return;          } else {
 }              $showhelpdesk = 0;
 // ]]>          }
 </script>      }
 ENDSCRIPT      if ($servadm && $showadminmail) {
     }          $contactblock .= $$lt{'servadm'}.':<br />'.
     return $contactblock;                           '<tt>'.$servadm.'</tt><br />';
 }      }
       if ($showhelpdesk) {
 sub forgotpwdisplay {          $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
     my (%lt) = @_;          my $thisurl = &escape('/adm/login');
     my $prompt_for_resetpw = 1;           $$helpdeskscript = <<"ENDSCRIPT";
     if ($prompt_for_resetpw) {  <script type="text/javascript">
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';  // <![CDATA[
     }  function helpdesk() {
     return;      var possdom = document.client.udom.value;
 }      var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
       if (codedom == '') {
 sub coursecatalog_link {          codedom = "$authdomain";
     my ($linkname) = @_;      }
     return <<"END";      var querystr = "origurl=$thisurl&codedom="+codedom;
       <a href="/adm/coursecatalog">$linkname</a>      document.location.href = "/adm/helpdesk?"+querystr;
 END      return;
 }  }
   // ]]>
 sub newuser_link {  </script>
     my ($linkname) = @_;  ENDSCRIPT
     return '<a href="/adm/createaccount">'.$linkname.'</a>';      }
 }      return $contactblock;
   }
 1;  
 __END__  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.159  
changed lines
  Added in v.1.161


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