Diff for /loncom/auth/lonlogin.pm between versions 1.52 and 1.137

version 1.52, 2003/09/17 13:47:55 version 1.137, 2010/05/06 16:15:59
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,  
 # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9,  
 # 1/17/01 Gerd Kortemeyer  
 #  
 # 2/7/02,2/8,2/12,2/14,2/15,2/19 Josh Brunskole  
 #   
 # 7/10/02 Jeremy Bowers  
   
 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 lib '/home/httpd/lib/perl/';
   use LONCAPA;
    
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     $r->content_type('text/html');  
       &Apache::loncommon::get_unprocessed_cgi
    (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
         $ENV{'REDIRECT_QUERY_STRING'}),
    ['interface','username','domain','firsturl','localpath','localres',
     'token','role','symb']);
       if (!defined($env{'form.firsturl'})) {
           &Apache::lonacc::get_posted_cgi($r,['firsturl']);
       }
   
   # -- check if they are a migrating user
       if (defined($env{'form.token'})) {
    return &Apache::migrateuser::handler($r);
       }
   
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
       &Apache::lonlocal::get_language_handle($r);
       &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;
   
Line 57  sub handler { Line 69  sub handler {
  return OK;   return OK;
     }      }
   
     &Apache::loncommon::get_unprocessed_cgi  
      ($ENV{'QUERY_STRING'}.'&'.$ENV{'request.querystring'},  
       ['interface','username','domain','firsturl','localpath','localres']);  
    
 # -------------------------------------------------------------------- Language  
   
     &Apache::lonlocal::get_language_handle();  # -------------------------------- Prevent users from attempting to login twice
       my $handle = &Apache::lonnet::check_for_valid_session($r);
       if ($handle ne '') {
           my $lonidsdir=$r->dir_config('lonIDsDir');
           if ($handle=~/^publicuser\_/) {
   # For "public user" - remove it, we apparently really want to login
       unlink($r->dir_config('lonIDsDir')."/$handle.id");
           } else {
   # Indeed, a valid token is found
               &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
       my $start_page = 
           &Apache::loncommon::start_page('Already logged in');
       my $end_page = 
           &Apache::loncommon::end_page();
               my $dest = '/adm/roles';
               if ($env{'form.firsturl'} ne '') {
                   $dest = $env{'form.firsturl'}; 
               }
       $r->print(
                     $start_page
                    .'<h1>'.&mt('You are already logged in!').'</h1>'
                    .'<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>'
                    .$end_page
                    );
               return OK;
           }
       }
   
   # ---------------------------------------------------- No valid token, continue
   
    # ---------------------------- Not possible to really login to domain "public"
       if ($env{'form.domain'} eq 'public') {
    $env{'form.domain'}='';
    $env{'form.username'}='';
       }
 # ----------------------------------------------------------- Process Interface  # ----------------------------------------------------------- Process Interface
     $ENV{'form.interface'}=~s/\W//g;      $env{'form.interface'}=~s/\W//g;
   
     my $textbrowsers=$r->dir_config('lonTextBrowsers');  
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};      my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
       
     foreach (split(/\:/,$textbrowsers)) {      my $iconpath= 
  if ($httpbrowser=~/$_/i) {   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
     $ENV{'form.interface'}='textual';  
         }      my $lonhost = $r->dir_config('lonHostID');
       my $domain = &Apache::lonnet::default_login_domain();
       if ($lonhost ne '') {
           my $redirect = &check_loginvia($domain,$lonhost);
           if ($redirect) {
               $r->print($redirect);
               return OK;
           } 
     }      }
   
     my $fullgraph=($ENV{'form.interface'} ne 'textual');      if (($env{'form.domain'}) && 
     my $port_to_use=$r->dir_config('lonhttpdPort');   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
     if (!defined($port_to_use)) {   $domain=$env{'form.domain'};
  $port_to_use='8080';  
     }  
     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.  
                   $r->dir_config('lonIconsURL');  
     my $domain  = $r->dir_config('lonDefDomain');  
     if (($ENV{'form.domain'}) &&   
  ($Apache::lonnet::domaindescription{$ENV{'form.domain'}})) {  
  $domain=$ENV{'form.domain'};  
     }      }
     my $role    = $r->dir_config('lonRole');      my $role    = $r->dir_config('lonRole');
     my $loadlim = $r->dir_config('lonLoadLim');      my $loadlim = $r->dir_config('lonLoadLim');
     my $servadm = $r->dir_config('lonAdmEMail');      my $servadm = $r->dir_config('lonAdmEMail');
     my $sysadm  = $r->dir_config('lonSysEMail');  
     my $lonhost = $r->dir_config('lonHostID');  
     my $tabdir  = $r->dir_config('lonTabDir');      my $tabdir  = $r->dir_config('lonTabDir');
     my $include = $r->dir_config('lonIncludes');      my $include = $r->dir_config('lonIncludes');
     my $expire  = $r->dir_config('lonExpire');      my $expire  = $r->dir_config('lonExpire');
     my $version = $r->dir_config('lonVersion');      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=($ENV{'form.username'}?$ENV{'form.username'}:'');      my $authusername=($env{'form.username'}?$env{'form.username'}:'');
     my $authdomain=($ENV{'form.domain'}?$ENV{'form.domain'}:$domain);      my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
   
 # ---------------------------------------------------------- Determine own load  # ---------------------------------------------------------- Determine own load
     my $loadavg;      my $loadavg;
Line 111  sub handler { Line 149  sub handler {
  $loadavg=<$loadfile>;   $loadavg=<$loadfile>;
     }      }
     $loadavg =~ s/\s.*//g;      $loadavg =~ s/\s.*//g;
     my $loadpercent=100*$loadavg/$loadlim;      my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
     my $userloadpercent=&Apache::lonnet::userload();      my $userloadpercent=&Apache::lonnet::userload();
   
 # ------------------------------------------------------- Do the load balancing  # ------------------------------------------------------- Do the load balancing
     my $otherserver='http://'.$ENV{'SERVER_NAME'};      my $otherserver= &Apache::lonnet::absolute_url($host_name);
     my $firsturl=      my $firsturl=
     ($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'});      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
 # ---------------------------------------- Are we access server and overloaded?  # ---------------------------------------------------------- Are we overloaded?
     if (($role eq 'access') &&      if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
  (($userloadpercent>100.0)||($loadpercent>100.0))) {  
         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);          my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
  if ($unloaded) { $otherserver=$unloaded; }   if ($unloaded) { $otherserver=$unloaded; }
     }      }
Line 148  sub handler { Line 185  sub handler {
     if ($uextkey>2147483647) { $uextkey-=4294967296; }      if ($uextkey>2147483647) { $uextkey-=4294967296; }
   
 # -------------------------------------------------------- Store away log token  # -------------------------------------------------------- Store away log token
       my $tokenextras;
       if ($env{'form.role'}) {
           $tokenextras = '&role='.&escape($env{'form.role'});
       }
       if ($env{'form.symb'}) {
           if (!$tokenextras) {
               $tokenextras = '&';
           }
           $tokenextras .= '&symb='.&escape($env{'form.symb'});
       }
     my $logtoken=Apache::lonnet::reply(      my $logtoken=Apache::lonnet::reply(
        'tmpput:'.$ukey.$lkey.'&'.$firsturl,         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
        $lonhost);         $lonhost);
   
 # ------------------- If we cannot talk to ourselves, we are in serious trouble  # ------------------- If we cannot talk to ourselves, we are in serious trouble
   
     if ($logtoken eq 'con_lost') {      if ($logtoken eq 'con_lost') {
         my $spares='';          my $spares='';
         foreach (keys %Apache::lonnet::hostname) {   my $last;
             if ($_ ne $lonhost) {          foreach my $hostid (sort
                $spares.='<br /><a href="http://'.$Apache::lonnet::hostname{$_}.      {
  '/adm/login?domain='.$authdomain.'">'.   &Apache::lonnet::hostname($a) cmp
                  $Apache::lonnet::hostname{$_}.'</a>';      &Apache::lonnet::hostname($b);
                if ($Apache::lonnet::spareid{$_}) {      }
    $spares.=' (preferred)';      keys(%Apache::lonnet::spareid)) {
                }              next if ($hostid eq $lonhost);
    }      my $hostname = &Apache::lonnet::hostname($hostid);
       next if ($last eq $hostname);
               $spares.='<br /><font size="+1"><a href="http://'.
                   $hostname.
                   '/adm/login?domain='.$authdomain.'">'.
                   $hostname.'</a>'.
                   ' '.&mt('(preferred)').'</font>'.$/;
       $last=$hostname;
         }          }
  $r->print(<<ENDTROUBLE);  $spares.= '<br />';
 <html>  my %all_hostnames = &Apache::lonnet::all_hostnames();
 <head><title>The LearningOnline Network with CAPA</title></head>  foreach my $hostid (sort
 <body bgcolor="#FFFFFF">      {
 <img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />   &Apache::lonnet::hostname($a) cmp
 <h3>This LON-CAPA server is temporarily not available for login</h3>      &Apache::lonnet::hostname($b);
 <p>Please attempt to login to one of the following servers:</p>$spares      }
 <p>If the problem persists, please contact <tt>$servadm</tt>.</p>      keys(%all_hostnames)) {
 </body>      next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
 </html>      my $hostname = &Apache::lonnet::hostname($hostid);
 ENDTROUBLE      next if ($last eq $hostname);
         return OK;      $spares.='<br /><a href="http://'.
     }   $hostname.
    '/adm/login?domain='.$authdomain.'">'.
    $hostname.'</a>';
       $last=$hostname;
   }
   $r->print(
      '<html>'
     .'<head><title>'
     .&mt('The LearningOnline Network with CAPA')
     .'</title></head>'
     .'<body bgcolor="#FFFFFF">'
     .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
     .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
     .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>'
     .'<p>'.&mt('Please attempt to login to one of the following servers:').'</p>'
     .$spares
     .'</body>'
     .'</html>'
   );
   return OK;
   }
   
 # ----------------------------------------------- Apparently we are in business  # ----------------------------------------------- Apparently we are in business
   $servadm=~s/\,/\<br \/\>/g;
     my $domainlogo=&Apache::loncommon::domainlogo($domain);  
     $servadm=~s/\,/\<br \/\>/g;  
     $sysadm=~s/\,/\<br \/\>/g;  
   
 # --------------------------------------------------- Print login screen header  
     $r->print(<<ENDHEADER);  
 <html>  
 <head>  
 <meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" />  
 <title>The LearningOnline Network with CAPA Login</title>  
 </head>  
 ENDHEADER  
 # ---------------------------------------------------- Serve out DES JavaScript  
     {  
  my $jsh=Apache::File->new($include."/londes.js");  
         $r->print(<$jsh>);  
     }  
   
 # ----------------------------------------------------------- Front page design  # ----------------------------------------------------------- Front page design
     my $pgbg=  my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
       ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF');  my $font=&Apache::loncommon::designparm('login.font',$domain);
     my $font=  my $link=&Apache::loncommon::designparm('login.link',$domain);
       ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000');  my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
     my $link=  my $alink=&Apache::loncommon::designparm('login.alink',$domain);
       ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF');  my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
     my $vlink=  my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
       ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF');  my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
     my $alink=&Apache::loncommon::designparm('login.alink',$domain);  my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
     my $mainbg=  my $logo=&Apache::loncommon::designparm('login.logo',$domain);
       ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF');  my $img=&Apache::loncommon::designparm('login.img',$domain);
     my $sidebg=  my $domainlogo='<div>'.&Apache::loncommon::domainlogo($domain).'</div>';
       ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF');  my $login=&Apache::loncommon::designparm('login.login',$domain);
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);  if ($login eq '') {
     my $img=&Apache::loncommon::designparm('login.img',$domain);  $login = $iconpath.'/'.&mt('userauthentication.gif');
   }
 # ----------------------------------------------------------------------- Texts  my $showbanner = 1;
   my $showmainlogo = 1;
 my %lt=&Apache::lonlocal::texthash(  if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
   'un'  => 'Username',      $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
   'pw'  => 'Password',  }
   'dom' => 'Domain',  if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
   'perc' => 'percent',      $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
   'load' => 'Load',  }
                   'userload' => 'User Load',  my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
                   'about'  => 'aboutlon.gif',  my $showcoursecat =
                   'access' => 'accessbutton.gif',  &Apache::loncommon::designparm('login.coursecatalog',$domain);
   'auth' => 'userauthentication.gif',  my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);
   'log' => 'Log in',  my $shownewuserlink = 
   'help' => 'Help',  &Apache::loncommon::designparm('login.newuser',$domain);
   'serv' => 'Server',  my $now=time;
                   'servadm' => 'Server Administration',  my $js = (<<ENDSCRIPT);
                   'sysadm' => 'System Administration');  
   <script type="text/javascript" language="JavaScript">
   // <![CDATA[
 # ---------------------------------------------------------- Serve rest of page  function send()
     $r->print(<<ENDSCRIPT);  {
   this.document.server.elements.uname.value
 <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"  =this.document.client.elements.uname.value;
   topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>  
   this.document.server.elements.udom.value
  <script language="JavaScript">  =this.document.client.elements.udom.value;
     function send()  
     {  uextkey=this.document.client.elements.uextkey.value;
  this.document.server.elements.uname.value  lextkey=this.document.client.elements.lextkey.value;
        =this.document.client.elements.uname.value;  initkeys();
   
         this.document.server.elements.udom.value  this.document.server.elements.upass0.value
        =this.document.client.elements.udom.value;      =crypted(this.document.client.elements.upass$now.value.substr(0,15));
   this.document.server.elements.upass1.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.server.elements.imagesuppress.value  this.document.client.elements.uname.value='';
        =this.document.client.elements.imagesuppress.checked;  this.document.client.elements.upass$now.value='';
   
         this.document.server.elements.embedsuppress.value  this.document.server.submit();
        =this.document.client.elements.embedsuppress.checked;  return false;
   }
   // ]]>
   </script>
   
         this.document.server.elements.appletsuppress.value  ENDSCRIPT
        =this.document.client.elements.appletsuppress.checked;  
   
         this.document.server.elements.fontenhance.value  # --------------------------------------------------- Print login screen header
        =this.document.client.elements.fontenhance.checked;  
   
         this.document.server.elements.blackwhite.value  my %add_entries = (
        =this.document.client.elements.blackwhite.checked;         bgcolor      => "$mainbg",
          text         => "$font",
          link         => "$link",
          vlink        => "$vlink",
          alink        => "$alink",);
   
   $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
          { 'redirect'       => [$expire,'/adm/roles'], 
    'add_entries' => \%add_entries,
    'only_body'   => 1,}));
   
         this.document.server.elements.remember.value  # ----------------------------------------------------------------------- Texts
        =this.document.client.elements.remember.checked;  
   
         uextkey=this.document.client.elements.uextkey.value;  my %lt=&Apache::lonlocal::texthash(
         lextkey=this.document.client.elements.lextkey.value;            'un'       => 'Username',
         initkeys();            'pw'       => 'Password',
             'dom'      => 'Domain',
             'perc'     => 'percent',
             'load'     => 'Server Load',
             'userload' => 'User Load',
             'catalog'  => 'Course/Community Catalog',
             'log'      => 'Log in',
             'help'     => 'Log-in Help',
             'serv'     => 'Server',
             'servadm'  => 'Server Administration',
             'helpdesk' => 'Contact Helpdesk',
             'forgotpw' => 'Forgot password?',
             'newuser'  => 'New User?',
          );
   # -------------------------------------------------- Change password field name
   
   my $forgotpw = &forgotpwdisplay(%lt);
   $forgotpw .= '<br />' if $forgotpw;
   my $loginhelp = &loginhelpdisplay($authdomain,%lt);
   $loginhelp .= '<br />' if $loginhelp;
   
         this.document.server.elements.upass.value  # ---------------------------------------------------- Serve out DES JavaScript
     =crypted(this.document.client.elements.upass.value);  {
   my $jsh=Apache::File->new($include."/londes.js");
   $r->print(<$jsh>);
   }
   # ---------------------------------------------------------- Serve rest of page
   
         this.document.server.submit();  $r->print(
  return false;      '<div class="LC_Box"'
     }     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
  </script>  );
 ENDSCRIPT  
   
     if ($fullgraph) {  #
  $r->print(  #  If the loadbalancing yielded just http:// because perhaps there's no loadbalancing?
   '<table width="100%" cellpadding=0 cellspacing=0 border=0>');  #  then just us a relative link to authenticate:
     }  #
   
     $r->print(<<ENDSERVERFORM);  $r->print(<<ENDSERVERFORM);
   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">  <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
    <input type="hidden" name="logtoken" value="$logtoken" />     <input type="hidden" name="logtoken" value="$logtoken" />
    <input type="hidden" name="serverid" value="$lonhost" />     <input type="hidden" name="serverid" value="$lonhost" />
    <input type="hidden" name="interface" value="$ENV{'form.interface'}" />  
    <input type="hidden" name="uname" value="" />     <input type="hidden" name="uname" value="" />
    <input type="hidden" name="upass" value="" />     <input type="hidden" name="upass0" value="" />
      <input type="hidden" name="upass1" value="" />
      <input type="hidden" name="upass2" value="" />
    <input type="hidden" name="udom" value="" />     <input type="hidden" name="udom" value="" />
    <input type="hidden" name="imagesuppress"  value="" />     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
    <input type="hidden" name="appletsuppress"  value="" />     <input type="hidden" name="localres" value="$env{'form.localres'}" />
    <input type="hidden" name="embedsuppress"  value="" />  
    <input type="hidden" name="fontenhance"  value="" />  
    <input type="hidden" name="blackwhite"  value="" />  
    <input type="hidden" name="remember"  value="" />  
    <input type="hidden" name="localpath" value="$ENV{'form.localpath'}" />  
    <input type="hidden" name="localres" value="$ENV{'form.localres'}" />  
   </form>    </form>
 ENDSERVERFORM  ENDSERVERFORM
     if ($fullgraph) { $r->print(<<ENDTOP);  my $coursecatalog;
   <!-- The LON-CAPA Header -->  if (($showcoursecat eq '') || ($showcoursecat)) {
   <tr>      $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
   }
    <!-- Row 1 Columns 2-4 -->  my $newuserlink;
    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>  if ($shownewuserlink) {
   </tr>      $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
   
   <!-- The gray bar that starts the two table frames -->  
   <tr>  
   
    <!-- Row 2 Column 1 -->  
    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>  
   
    <!-- Row 2 Column 2 -->  
    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>  
   
    <!-- Row 2 Column 3 -->  
    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>  
   
    <!-- Row 2 Column 4 -->  
    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>  
   </tr>  
   <tr>  
      
    <!-- A cell that will hold the 'access' and 'about' buttons -->  
    <!-- Row 3 Column 1 -->  
    <td valign="top" height=60 align="center" bgcolor="$sidebg">  
     <a href="/adm/login?interface=textual"><img src="$iconpath/$lt{'access'}" border=0 alt="Accessibility Options" /></a>  
     <br />  
     <a href="/adm/about.html"><img src="$iconpath/$lt{'about'}" border=0 alt="About LON-CAPA" /></a>  
    </td>  
   
    <!-- The shaded space between the two main columns -->  
    <!-- Row 3 Column 2 -->  
    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>  
   
    <!-- The right main column holding the large LON-CAPA logo-->  
    <!-- Rows 3-4 Column 3 -->  
    <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">  
     <center>  
      <img src="$logo" alt="" />  
     </center>  
    </td>  
   
    <!-- Row 3 Column 4 -->  
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>  
   </tr>  
   <tr>  
   
    <!-- The entry form -->  
    <!-- Row 4 Column 1 -->  
    <td align="center" valign="middle" bgcolor="$sidebg">  
 ENDTOP  
 } else {  
     $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>'.$announcements);  
 }  }
     $r->print('<form name="client" onsubmit="return(send())">');  my $logintitle =
     unless ($fullgraph) {      '<h2 class="LC_hcell"'
         $r->print(<<ENDACCESSOPTIONS);     .' style="background:'.$loginbox_header_bgcol.';'
 <h3>Select Accessibility Options</h3>     .' color:'.$loginbox_header_textcol.'">';
 <input type="checkbox" name="imagesuppress" /> Suppress rendering of images<br />  if ($loginheader eq 'text') {
 <input type="checkbox" name="appletsuppress" /> Suppress Java applets<br />      $logintitle .= $lt{'log'};
 <input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia<br />  
 <input type="checkbox" name="fontenhance" /> Increase font size<br />  
 <input type="checkbox" name="blackwhite" /> Switch to black and white mode<br />  
 <p>If you have accessibility needs that are not addressed by this interface,   
 please  
 contact the system administrator at <tt>$sysadm</tt>.</p><br />  
 <input type="checkbox" name="remember" /> Remember these settings for next login<hr />  
 ENDACCESSOPTIONS  
 } else {  } else {
     $r->print(<<ENDNOOPT);      $logintitle .= '<img src="'.$login.'"'.
 <input type="hidden" name="imagesuppress"  value="" />                     ' alt="'.&mt('User Authentication').'" />';
 <input type="hidden" name="embedsuppress"  value="" />  }
 <input type="hidden" name="appletsuppress"  value="" />  $logintitle .= '</h2>';
 <input type="hidden" name="fontenhance"  value="" />  
 <input type="hidden" name="blackwhite"  value="" />  my $noscript_warning='<noscript><span class="LC_warning"><b>'
 <input type="hidden" name="remember"  value="" />                       .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
 ENDNOOPT                      .'</b></span></noscript>';
 }  my $helpdeskscript;
     $r->print(<<ENDLOGIN);  my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
      <input type="hidden" name="lextkey" value="$lextkey">                                     $authdomain,\$helpdeskscript);
      <input type="hidden" name="uextkey" value="$uextkey">  
   my $loginform=(<<LFORM);
      <!-- Start the sub-table for text and input alignment -->  <form name="client" action="" onsubmit="return(send())">
      <table border=0 cellspacing=0 cellpadding=0>    <input type="hidden" name="lextkey" value="$lextkey" />
       <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr>    <input type="hidden" name="uextkey" value="$uextkey" />
       <tr>    <b><label for="uname">$lt{'un'}</label>:</b><br />
        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'un'}:</b></font></td>    <input type="text" name="uname" id="uname" size="15" value="$authusername" /><br />
        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
       </tr>    <input type="password" name="upass$now" id="upass$now" size="15" /><br />
       <tr>    <b><label for="udom">$lt{'dom'}</label>:</b><br />
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'pw'}:</b></font></td>    <input type="text" name="udom" id="udom" size="15" value="$authdomain" /><br />
        <td bgcolor="$mainbg"><input type="password" name="upass" size="10" /></td>    <input type="submit" value="$lt{'log'}" />
       </tr>  </form>
       <tr>  LFORM
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:</b></font></td>  
        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>      if ($showbanner) {
       </tr>          $r->print(<<HEADER);
       <tr>  <!-- The LON-CAPA Header -->
        <td bgcolor="$mainbg">&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">$lt{'help'}</a></td>  <div style="background:$pgbg;margin:0;width:100%;">
        <td bgcolor="$mainbg" valign="bottom" align="center">    <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
         <br />  </div>
         <input type="submit" value="$lt{'log'}" />  HEADER
        </td>      }
       </tr>      $r->print(<<ENDTOP);
      </table>  <div style="float:left;">
      <!-- End sub-table -->  <div class="LC_Box" style="background:$loginbox_bg;">
     </form>    $logintitle
 ENDLOGIN    $loginform
     if ($fullgraph) {    $noscript_warning
  $r->print(<<ENDDOCUMENT);  </div>
    </td>    
   <div class="LC_Box" style="padding-top: 10px;">
    <!-- Row 4 Column 2 -->    $loginhelp
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>    $forgotpw
     $contactblock
    <!-- Row 4 Column 3 -->    $newuserlink
 <td bgcolor="$mainbg">$announcements</td>    $coursecatalog
   </div>
    <!-- Row 4 Column 4 -->  </div>
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>  
   </tr>  <div>
   <tr>  ENDTOP
       if ($showmainlogo) {
    <!-- Row 5 Column 1 -->          $r->print(' <img src="'.$logo.'" alt="" />'."\n");
    <td bgcolor="$sidebg" valign="middle" align="left">      }
      <br />  $r->print(<<ENDTOP);
      <table border=0 cellspacing=0 cellpadding=0>  $announcements
   $domainlogo
   </div>
   <hr style="clear:both;" />
   ENDTOP
   
   $r->print(<<ENDDOCUMENT);
        <table border="0" cellspacing="0" cellpadding="0">
       <tr>        <tr>
        <td bgcolor="$sidebg" align="left" valign="top">         <td  align="left" valign="top">
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>          <small><b>$lt{'dom'}:&nbsp;</b></small>
        </td>         </td>
        <td bgcolor="$sidebg" align="left" valign="top">         <td  align="left" valign="top">
         <small><tt>&nbsp;$domain</tt></small>          <small><tt>&nbsp;$domain</tt></small>
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
        <td bgcolor="$sidebg" align="left" valign="top">         <td  align="left" valign="top">
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>          <small><b>$lt{'serv'}:&nbsp;</b></small>
        </td>         </td>
        <td bgcolor="$sidebg" align="left" valign="top">         <td align="left" valign="top">
         <small><tt>&nbsp;$lonhost ($role)</tt></small>          <small><tt>&nbsp;$lonhost ($role)</tt></small>
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
        <td bgcolor="$sidebg" align="left" valign="top">         <td align="left" valign="top">
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small>          <small><b>$lt{'load'}:&nbsp;</b></small>
        </td>         </td>
        <td bgcolor="$sidebg" align="left" valign="top">         <td align="left" valign="top">
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
        <td bgcolor="$sidebg" align="left" valign="top">         <td align="left" valign="top">
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small>          <small><b>$lt{'userload'}:&nbsp;</b></small>
        </td>         </td>
        <td bgcolor="$sidebg" align="left" valign="top">         <td align="left" valign="top">
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
        </td>         </td>
       </tr>        </tr>
         <tr>
          <td colspan="2" align="left">
           <small>$version</small>
          </td>
         </tr>
      </table>       </table>
      <br />   </div>
     <small>  
      <b>&nbsp;&nbsp;&nbsp;$lt{'sysadm'}:</b><br />  
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sysadm</tt><br />  
      <b>&nbsp;&nbsp;&nbsp;$lt{'servadm'}:</b><br />  
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$servadm</tt><br />&nbsp;<br />  
      &nbsp;&nbsp;&nbsp;$version  
     </small>  
    </td>  
   
    <!-- Row 5 Column 2 -->  <script type="text/javascript">
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>  // <![CDATA[
   // the if prevents the script error if the browser can not handle this
   if ( document.client.uname ) { document.client.uname.focus(); }
   // ]]>
   </script>
   $helpdeskscript
   
    <!-- Row 5 Column 3 -->  ENDDOCUMENT
    <td width="100%" valign="bottom" bgcolor="$mainbg">      my %endargs = ( 'noredirectlink' => 1, );
 $domainlogo      $r->print(&Apache::loncommon::end_page(\%endargs));
 </td>      return OK;
   }
   
    <!-- Row 5 Column 4 -->  sub check_loginvia {
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>      my ($domain,$lonhost) = @_;
   </tr>      if ($domain eq '' || $lonhost eq '') {
   <tr>          return;
       }
       my %domconfhash = &Apache::loncommon::get_domainconf($domain);
       my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
       my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
       my $output;
       if ($loginvia ne '') {
           my $noredirect;
           my $ip = $ENV{'REMOTE_ADDR'};
           if ($ip eq '127.0.0.1') {
               $noredirect = 1;
           } else {
               if ($loginvia_exempt ne '') {
                   my @exempt = split(',',$loginvia_exempt);
                   if (grep(/^\Q$ip\E$/,@exempt)) {
                       $noredirect = 1;
                   }
               }
           }
           unless ($noredirect) {
               my ($newhost,$path);
               if ($loginvia =~ /:/) {
                   ($newhost,$path) = split(':',$loginvia);
               } else {
                   $newhost = $loginvia;
               }
               if ($newhost ne $lonhost) {
                   if (&Apache::lonnet::hostname($newhost) ne '') {
                       $output = &redirect_page($newhost,$path);
                   }
               }
           }
       }
       return $output;
   }
   
    <!-- Row 6 Column 1 -->  sub redirect_page {
    <td bgcolor="$sidebg">&nbsp;</td>      my ($desthost,$path) = @_;
       my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
       unless ($path =~ m{^/}) {
           $path = '/'.$path;
       }
       my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
       if ($env{'form.firsturl'} ne '') {
           $url .='?firsturl='.$env{'form.firsturl'};
       }
       my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                                       {'redirect' => [0,$url],});
       my $end_page   = &Apache::loncommon::end_page();
       return $start_page.$end_page;
   }
   
    <!-- Row 6 Column 2 -->  sub contactdisplay {
    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>      my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript) = @_;
       my $contactblock;
       my $showhelpdesk = 0;
       my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
       if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
           $showhelpdesk = 1;
       }
       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 codedom = document.client.udom.value;
       if (codedom == '') {
           codedom = "$authdomain";
       }
       var querystr = "origurl=$thisurl&codedom="+codedom;
       document.location.href = "/adm/helpdesk?"+querystr;
       return;
   }
   // ]]>
   </script>
   ENDSCRIPT
       }
       return $contactblock;
   }
   
    <!-- Row 6 Column 3 -->  sub forgotpwdisplay {
    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>      my (%lt) = @_;
       my $prompt_for_resetpw = 1; 
       if ($prompt_for_resetpw) {
           return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
       }
       return;
   }
   
    <!-- Row 6 Column 4 -->  sub loginhelpdisplay {
    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>      my ($authdomain,%lt) = @_;
   </tr>      my $login_help = 1;
  </table>      if ($login_help) {
           my $dom = $authdomain;
           if ($dom eq '') {
               $dom = &Apache::lonnet::default_login_domain();
           }
           my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
           my $loginhelp_url = $helpconfig{'helpsettings'}{'loginhelpurl'};
           if ($loginhelp_url ne '') {
               return '<a href="'.$loginhelp_url.'">'.$lt{'help'}.'</a>';
           } else {
               return '<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a>';
           }
       }
       return;
   }
   
 <script>  sub coursecatalog_link {
 // the if prevents the script error if the browser can't handle this      my ($linkname) = @_;
 if ( document.client.uname ) { document.client.uname.focus(); }      return <<"END";
 </script>        <a href="/adm/coursecatalog">$linkname</a>
   END
   }
   
 ENDDOCUMENT  sub newuser_link {
       my ($linkname) = @_;
       return '<a href="/adm/createaccount">'.$linkname.'</a>';
 }  }
     $r->print('</body></html>');  
     return OK;  
 }   
   
 1;  1;
 __END__  __END__

Removed from v.1.52  
changed lines
  Added in v.1.137


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