File:  [LON-CAPA] / loncom / auth / lonlogin.pm
Revision 1.28: download - view: text, annotated - select for diffs
Thu Jan 16 01:37:26 2003 UTC (21 years, 4 months ago) by www
Branches: MAIN
CVS tags: HEAD
Help link with common login problems on login and welcome screens.
Unfortunately, we cannot use the cool help system here, since it will
not work when pop-up ad filters are installed.

    1: # The LearningOnline Network
    2: # Login Screen
    3: #
    4: # $Id: lonlogin.pm,v 1.28 2003/01/16 01:37:26 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   29: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9,
   30: # 1/17/01 Gerd Kortemeyer
   31: #
   32: # 2/7/02,2/8,2/12,2/14,2/15,2/19 Josh Brunskole
   33: # 
   34: # 7/10/02 Jeremy Bowers
   35: 
   36: package Apache::lonlogin;
   37: 
   38: use strict;
   39: use Apache::Constants qw(:common);
   40: use Apache::File ();
   41: use Apache::lonnet();
   42: use Apache::loncommon();
   43: 
   44: sub handler {
   45:     my $r = shift;
   46:     $r->content_type('text/html');
   47:     &Apache::loncommon::no_cache($r);
   48:     $r->send_http_header;
   49:     return OK if $r->header_only;
   50: 
   51: 
   52:     &Apache::loncommon::get_unprocessed_cgi
   53:                          ($ENV{'QUERY_STRING'},['interface']);
   54: 
   55:     $ENV{'form.interface'}=~s/\W//g;
   56: 
   57:     my $fullgraph=($ENV{'form.interface'} ne 'textual');
   58: 
   59:     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':8080'.
   60:                   $r->dir_config('lonIconsURL');
   61:     my $domain  = $r->dir_config('lonDefDomain');
   62:     my $role    = $r->dir_config('lonRole');
   63:     my $loadlim = $r->dir_config('lonLoadLim');
   64:     my $servadm = $r->dir_config('lonAdmEMail');
   65:     my $sysadm  = $r->dir_config('lonSysEMail');
   66:     my $lonhost = $r->dir_config('lonHostID');
   67:     my $tabdir  = $r->dir_config('lonTabDir');
   68:     my $include = $r->dir_config('lonIncludes');
   69: 
   70:     my $loadavg;
   71:    {
   72:        my $loadfile=Apache::File->new('/proc/loadavg');
   73:        $loadavg=<$loadfile>;
   74:    }
   75:     $loadavg =~ s/\s.*//g;
   76:     my $loadpercent=100*$loadavg/$loadlim;
   77: 
   78:     my $otherserver='http://'.$ENV{'SERVER_NAME'};
   79:     my $firsturl=$ENV{'request.firsturl'};
   80: # ---------------------------------------- Are we access server and overloaded?
   81:     if (($role eq 'access') && ($loadpercent>100.0)) {
   82:         $otherserver=Apache::lonnet::spareserver($loadpercent);
   83:     }
   84: 
   85: # -------------------------------------------------------- Set login parameters
   86: 
   87:     my @hexstr=('0','1','2','3','4','5','6','7',
   88:                 '8','9','a','b','c','d','e','f');
   89:     my $lkey='';
   90:     for (0..7) {
   91:         $lkey.=$hexstr[rand(15)];
   92:     }
   93: 
   94:     my $ukey='';
   95:     for (0..7) {
   96:         $ukey.=$hexstr[rand(15)];
   97:     }
   98: 
   99:     my $lextkey=hex($lkey);
  100:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
  101: 
  102:     my $uextkey=hex($ukey);
  103:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
  104: 
  105:     my $logtoken=Apache::lonnet::reply(
  106:        'tmpput:'.$ukey.$lkey.'&'.$firsturl,
  107:        $lonhost);
  108:     my $domainlogo=&Apache::loncommon::domainlogo();
  109: # --------------------------------------------------- Print login screen header
  110:     $r->print(<<ENDHEADER);
  111: <html>
  112: <head>
  113: <title>The LearningOnline Network with CAPA Login</title>
  114: </head>
  115: ENDHEADER
  116: # ---------------------------------------------------- Serve out DES JavaScript
  117:     {
  118: 	my $jsh=Apache::File->new($include."/londes.js");
  119:         $r->print(<$jsh>);
  120:     }
  121: 
  122: # ----------------------------------------------------------- Front page design
  123:     my $pgbg=&Apache::loncommon::designparm('login.pgbg');
  124:     my $font=&Apache::loncommon::designparm('login.font');
  125:     my $link=&Apache::loncommon::designparm('login.link');
  126:     my $vlink=&Apache::loncommon::designparm('login.vlink');
  127:     my $alink=&Apache::loncommon::designparm('login.alink');
  128:     my $mainbg=&Apache::loncommon::designparm('login.mainbg');
  129:     my $sidebg=&Apache::loncommon::designparm('login.sidebg');
  130:     my $logo=&Apache::loncommon::designparm('login.logo');
  131:     my $img=&Apache::loncommon::designparm('login.img');
  132: 
  133: 
  134: # ---------------------------------------------------------- Serve rest of page
  135:     $r->print(<<ENDSCRIPT);
  136: 
  137: <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"
  138:   topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
  139: 
  140:  <script language="JavaScript">
  141:     function send()
  142:     {
  143: 	this.document.server.elements.uname.value
  144:        =this.document.client.elements.uname.value;
  145: 
  146:         this.document.server.elements.udom.value
  147:        =this.document.client.elements.udom.value;
  148: 
  149:         uextkey=this.document.client.elements.uextkey.value;
  150:         lextkey=this.document.client.elements.lextkey.value;
  151:         initkeys();
  152: 
  153:         this.document.server.elements.upass.value
  154: 	    =crypted(this.document.client.elements.upass.value);
  155: 
  156:         this.document.server.submit();
  157: 	return false;
  158:     }
  159:  </script>
  160: ENDSCRIPT
  161: 
  162:     if ($fullgraph) {
  163: 	$r->print(
  164: 		  '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
  165:     }
  166: 
  167:     $r->print(<<ENDSERVERFORM);
  168:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
  169:    <input type=hidden name=logtoken value="$logtoken">
  170:    <input type=hidden name=serverid value="$lonhost">
  171:    <input type=hidden name=interface value="$ENV{'form.interface'}">
  172:    <input type=hidden name=uname value="">
  173:    <input type=hidden name=upass value="">
  174:    <input type=hidden name=udom value="">
  175:   </form>
  176: ENDSERVERFORM
  177:     if ($fullgraph) { $r->print(<<ENDTOP);
  178:   <!-- The LON-CAPA Header -->
  179:   <tr>
  180: 
  181:    <!-- Row 1 Columns 2-4 -->
  182:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="#006600"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>
  183:   </tr>
  184: 
  185:   <!-- The gray bar that starts the two table frames -->
  186:   <tr>
  187: 
  188:    <!-- Row 2 Column 1 -->
  189:    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>
  190: 
  191:    <!-- Row 2 Column 2 -->
  192:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
  193: 
  194:    <!-- Row 2 Column 3 -->
  195:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
  196: 
  197:    <!-- Row 2 Column 4 -->
  198:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
  199:   </tr>
  200:   <tr>
  201:    
  202:    <!-- A cell that will hold the 'access' and 'about' buttons -->
  203:    <!-- Row 3 Column 1 -->
  204:    <td valign="top" height=60 align="center" bgcolor="$sidebg">
  205:     <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 alt="Accessibility Options" /></a>
  206:     <br />
  207:     <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 alt="About LON-CAPA" /></a>
  208:    </td>
  209: 
  210:    <!-- The shaded space between the two main columns -->
  211:    <!-- Row 3 Column 2 -->
  212:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
  213: 
  214:    <!-- The right main column holding the large LON-CAPA logo-->
  215:    <!-- Rows 3-4 Column 3 -->
  216:    <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="$mainbg">
  217:     <center>
  218:      <img src="$logo" alt="" />
  219:     </center>
  220:    </td>
  221: 
  222:    <!-- Row 3 Column 4 -->
  223:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
  224:   </tr>
  225:   <tr>
  226: 
  227:    <!-- The entry form -->
  228:    <!-- Row 4 Column 1 -->
  229:    <td align="center" valign="middle" bgcolor="$sidebg">
  230: ENDTOP
  231: }
  232:     $r->print(<<ENDLOGIN);
  233:     <form name="client" onsubmit="return(send())">
  234:      <input type="hidden" name="lextkey" value="$lextkey">
  235:      <input type="hidden" name="uextkey" value="$uextkey">
  236: 
  237:      <!-- Start the sub-table for text and input alignment -->
  238:      <table border=0 cellspacing=0 cellpadding=0>
  239:       <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/userauthentication.gif" alt="User Authentication" /></td></tr>
  240:       <tr>
  241:        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;User Name:</b></font></td>
  242:        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" /></td>
  243:       </tr>
  244:       <tr>
  245:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;Password:</b></font></td>
  246:        <td bgcolor="$mainbg"><input type="password" name="upass" size="10" /></td>
  247:       </tr>
  248:       <tr>
  249:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;Domain:</b></font></td>
  250:        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value=$domain /></td>
  251:       </tr>
  252:       <tr>
  253:        <td bgcolor="$mainbg">&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">Help</a></td>
  254:        <td bgcolor="$mainbg" valign="bottom" align="center">
  255:         <br />
  256:         <input type="submit" value="Log In" />
  257:        </td>
  258:       </tr>
  259:      </table>
  260:      <!-- End sub-table -->
  261:     </form>
  262: ENDLOGIN
  263:     if ($fullgraph) {
  264: 	$r->print(<<ENDDOCUMENT);
  265:    </td>
  266: 
  267:    <!-- Row 4 Column 2 -->
  268:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
  269: 
  270:    <!-- Row 4 Column 4 -->
  271:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
  272:   </tr>
  273:   <tr>
  274: 
  275:    <!-- Row 5 Column 1 -->
  276:    <td bgcolor="$sidebg" valign="middle" align="left">
  277:      <br />
  278:      <table border=0 cellspacing=0 cellpadding=0>
  279:       <tr>
  280:        <td bgcolor="$sidebg" align="left" valign="top">
  281:         <small><b>&nbsp;&nbsp;&nbsp;Domain:&nbsp;</b></small>
  282:        </td>
  283:        <td bgcolor="$sidebg" align="left" valign="top">
  284:         <small><tt>&nbsp;$domain</tt></small>
  285:        </td>
  286:       </tr>
  287:       <tr>
  288:        <td bgcolor="$sidebg" align="left" valign="top">
  289:         <small><b>&nbsp;&nbsp;&nbsp;Server:&nbsp;</b></small>
  290:        </td>
  291:        <td bgcolor="$sidebg" align="left" valign="top">
  292:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
  293:        </td>
  294:       </tr>
  295:       <tr>
  296:        <td bgcolor="$sidebg" align="left" valign="top">
  297:         <small><b>&nbsp;&nbsp;&nbsp;Load:&nbsp;</b></small>
  298:        </td>
  299:        <td bgcolor="$sidebg" align="left" valign="top">
  300:         <small><tt>&nbsp;$loadpercent percent</tt></small>
  301:        </td>
  302:       </tr>
  303:      </table>
  304:      <br />
  305:     <small>
  306:      <b>&nbsp;&nbsp;&nbsp;System Administration:</b><br />
  307:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sysadm</tt><br />
  308:      <b>&nbsp;&nbsp;&nbsp;Server Administration:</b><br />
  309:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$servadm<br />&nbsp;</tt>
  310:     </small>
  311:    </td>
  312: 
  313:    <!-- Row 5 Column 2 -->
  314:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
  315: 
  316:    <!-- Row 5 Column 3 -->
  317:    <td width="100%" valign="bottom" bgcolor="$mainbg">
  318: $domainlogo
  319: </td>
  320: 
  321:    <!-- Row 5 Column 4 -->
  322:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
  323:   </tr>
  324:   <tr>
  325: 
  326:    <!-- Row 6 Column 1 -->
  327:    <td bgcolor="$sidebg">&nbsp;</td>
  328: 
  329:    <!-- Row 6 Column 2 -->
  330:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
  331: 
  332:    <!-- Row 6 Column 3 -->
  333:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
  334: 
  335:    <!-- Row 6 Column 4 -->
  336:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
  337:   </tr>
  338:  </table>
  339: 
  340: <script>
  341: // the if prevents the script error if the browser can't handle this
  342: if ( document.client.uname ) { document.client.uname.focus(); }
  343: </script>
  344: 
  345: ENDDOCUMENT
  346: }
  347:     $r->print('</body></html>');
  348:     return OK;
  349: } 
  350: 
  351: 1;
  352: __END__

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