Annotation of loncom/auth/lonlogin.pm, revision 1.158
1.1 albertel 1: # The LearningOnline Network
2: # Login Screen
1.11 www 3: #
1.158 ! raeburn 4: # $Id: lonlogin.pm,v 1.157 2013/09/29 00:49:24 raeburn Exp $
1.11 www 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: #
1.14 albertel 28:
1.1 albertel 29: package Apache::lonlogin;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::File ();
1.63 albertel 34: use Apache::lonnet;
1.12 albertel 35: use Apache::loncommon();
1.49 www 36: use Apache::lonauth();
1.50 www 37: use Apache::lonlocal;
1.71 albertel 38: use Apache::migrateuser();
1.75 www 39: use lib '/home/httpd/lib/perl/';
40: use LONCAPA;
41:
1.1 albertel 42: sub handler {
43: my $r = shift;
1.71 albertel 44:
45: &Apache::loncommon::get_unprocessed_cgi
1.79 albertel 46: (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
47: $ENV{'REDIRECT_QUERY_STRING'}),
1.71 albertel 48: ['interface','username','domain','firsturl','localpath','localres',
1.157 raeburn 49: 'token','role','symb','iptoken']);
1.102 raeburn 50: if (!defined($env{'form.firsturl'})) {
51: &Apache::lonacc::get_posted_cgi($r,['firsturl']);
52: }
1.71 albertel 53:
54: # -- check if they are a migrating user
55: if (defined($env{'form.token'})) {
56: return &Apache::migrateuser::handler($r);
57: }
58:
1.53 www 59: &Apache::loncommon::no_cache($r);
60: &Apache::lonlocal::get_language_handle($r);
1.54 www 61: &Apache::loncommon::content_type($r,'text/html');
1.1 albertel 62: $r->send_http_header;
63: return OK if $r->header_only;
64:
1.49 www 65:
66: # Are we re-routing?
1.149 raeburn 67: my $londocroot = $r->dir_config('lonDocRoot');
68: if (-e "$londocroot/lon-status/reroute.txt") {
1.49 www 69: &Apache::lonauth::reroute($r);
70: return OK;
71: }
1.55 www 72:
1.143 raeburn 73: $env{'form.firsturl'} =~ s/(`)/'/g;
1.71 albertel 74:
1.55 www 75: # -------------------------------- Prevent users from attempting to login twice
1.95 albertel 76: my $handle = &Apache::lonnet::check_for_valid_session($r);
1.135 raeburn 77: if ($handle ne '') {
78: my $lonidsdir=$r->dir_config('lonIDsDir');
79: if ($handle=~/^publicuser\_/) {
1.70 www 80: # For "public user" - remove it, we apparently really want to login
1.135 raeburn 81: unlink($r->dir_config('lonIDsDir')."/$handle.id");
82: } else {
1.55 www 83: # Indeed, a valid token is found
1.135 raeburn 84: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
85: my $start_page =
86: &Apache::loncommon::start_page('Already logged in');
87: my $end_page =
88: &Apache::loncommon::end_page();
89: my $dest = '/adm/roles';
90: if ($env{'form.firsturl'} ne '') {
91: $dest = $env{'form.firsturl'};
92: }
93: $r->print(
1.100 bisitz 94: $start_page
1.150 golterma 95: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
1.117 hauer 96: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
1.125 raeburn 97: '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
1.135 raeburn 98: .$end_page
1.100 bisitz 99: );
1.135 raeburn 100: return OK;
101: }
1.55 www 102: }
103:
104: # ---------------------------------------------------- No valid token, continue
1.16 www 105:
1.157 raeburn 106: # ---------------------------- Not possible to really login to domain "public"
1.70 www 107: if ($env{'form.domain'} eq 'public') {
108: $env{'form.domain'}='';
109: $env{'form.username'}='';
110: }
1.157 raeburn 111:
112: # ------ Is this page requested because /adm/migrateuser detected an IP change?
113: my %sessiondata;
114: if ($env{'form.iptoken'}) {
115: %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
116: my $delete = &Apache::lonnet::tmpdel($env{'form.token'});
117: }
1.32 www 118: # ----------------------------------------------------------- Process Interface
1.63 albertel 119: $env{'form.interface'}=~s/\W//g;
1.16 www 120:
1.156 raeburn 121: (undef,undef,undef,undef,undef,undef,my $clientmobile) =
122: &Apache::loncommon::decode_user_agent();
1.94 albertel 123:
124: my $iconpath=
125: &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
126:
1.126 raeburn 127: my $lonhost = $r->dir_config('lonHostID');
1.87 raeburn 128: my $domain = &Apache::lonnet::default_login_domain();
1.126 raeburn 129: if ($lonhost ne '') {
1.157 raeburn 130: unless ($sessiondata{'sessionserver'}) {
131: my $redirect = &check_loginvia($domain,$lonhost);
132: if ($redirect) {
133: $r->print($redirect);
134: return OK;
135: }
136: }
1.126 raeburn 137: }
138:
1.157 raeburn 139: if (($sessiondata{'domain'}) &&
140: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
141: $domain=$sessiondata{'domain'};
142: } elsif (($env{'form.domain'}) &&
1.89 albertel 143: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
1.63 albertel 144: $domain=$env{'form.domain'};
1.46 www 145: }
1.157 raeburn 146:
1.1 albertel 147: my $role = $r->dir_config('lonRole');
148: my $loadlim = $r->dir_config('lonLoadLim');
1.145 www 149: my $uloadlim= $r->dir_config('lonUserLoadLim');
1.90 raeburn 150: my $servadm = $r->dir_config('lonAdmEMail');
1.1 albertel 151: my $tabdir = $r->dir_config('lonTabDir');
1.6 www 152: my $include = $r->dir_config('lonIncludes');
1.37 www 153: my $expire = $r->dir_config('lonExpire');
1.44 www 154: my $version = $r->dir_config('lonVersion');
1.88 albertel 155: my $host_name = &Apache::lonnet::hostname($lonhost);
1.1 albertel 156:
1.30 www 157: # --------------------------------------------- Default values for login fields
1.157 raeburn 158:
159: my ($authusername,$authdomain);
160: if ($sessiondata{'username'}) {
161: $authusername=$sessiondata{'username'};
162: } else {
1.158 ! raeburn 163: $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
1.157 raeburn 164: $authusername=($env{'form.username'}?$env{'form.username'}:'');
165: }
166: if ($sessiondata{'domain'}) {
167: $authdomain=$sessiondata{'domain'};
1.158 ! raeburn 168: } else {
! 169: $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
1.157 raeburn 170: $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
171: }
1.30 www 172:
173: # ---------------------------------------------------------- Determine own load
1.1 albertel 174: my $loadavg;
1.41 albertel 175: {
176: my $loadfile=Apache::File->new('/proc/loadavg');
177: $loadavg=<$loadfile>;
178: }
1.1 albertel 179: $loadavg =~ s/\s.*//g;
1.147 raeburn 180:
181: my ($loadpercent,$userloadpercent);
182: if ($loadlim) {
183: $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
184: }
185: if ($uloadlim) {
186: $userloadpercent=&Apache::lonnet::userload();
187: }
1.1 albertel 188:
1.31 www 189: my $firsturl=
1.63 albertel 190: ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
1.141 raeburn 191:
1.45 www 192: # ----------------------------------------------------------- Get announcements
193: my $announcements=&Apache::lonnet::getannounce();
1.6 www 194: # -------------------------------------------------------- Set login parameters
195:
196: my @hexstr=('0','1','2','3','4','5','6','7',
197: '8','9','a','b','c','d','e','f');
198: my $lkey='';
199: for (0..7) {
200: $lkey.=$hexstr[rand(15)];
201: }
202:
203: my $ukey='';
204: for (0..7) {
205: $ukey.=$hexstr[rand(15)];
206: }
207:
208: my $lextkey=hex($lkey);
1.15 www 209: if ($lextkey>2147483647) { $lextkey-=4294967296; }
210:
1.6 www 211: my $uextkey=hex($ukey);
1.15 www 212: if ($uextkey>2147483647) { $uextkey-=4294967296; }
213:
1.31 www 214: # -------------------------------------------------------- Store away log token
1.123 raeburn 215: my $tokenextras;
216: if ($env{'form.role'}) {
217: $tokenextras = '&role='.&escape($env{'form.role'});
218: }
219: if ($env{'form.symb'}) {
1.124 raeburn 220: if (!$tokenextras) {
221: $tokenextras = '&';
222: }
1.123 raeburn 223: $tokenextras .= '&symb='.&escape($env{'form.symb'});
224: }
1.6 www 225: my $logtoken=Apache::lonnet::reply(
1.123 raeburn 226: 'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
1.6 www 227: $lonhost);
1.31 www 228:
1.148 raeburn 229: # -- If we cannot talk to ourselves, or hostID does not map to a hostname
230: # we are in serious trouble
1.31 www 231:
1.148 raeburn 232: if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
233: if ($logtoken eq 'no_such_host') {
234: &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
235: }
1.31 www 236: my $spares='';
1.64 albertel 237: my $last;
238: foreach my $hostid (sort
239: {
1.88 albertel 240: &Apache::lonnet::hostname($a) cmp
241: &Apache::lonnet::hostname($b);
1.64 albertel 242: }
243: keys(%Apache::lonnet::spareid)) {
1.58 matthew 244: next if ($hostid eq $lonhost);
1.88 albertel 245: my $hostname = &Apache::lonnet::hostname($hostid);
1.148 raeburn 246: next if (($last eq $hostname) || ($hostname eq ''));
1.58 matthew 247: $spares.='<br /><font size="+1"><a href="http://'.
1.88 albertel 248: $hostname.
1.58 matthew 249: '/adm/login?domain='.$authdomain.'">'.
1.88 albertel 250: $hostname.'</a>'.
1.106 bisitz 251: ' '.&mt('(preferred)').'</font>'.$/;
1.88 albertel 252: $last=$hostname;
1.58 matthew 253: }
1.148 raeburn 254: if ($spares) {
255: $spares.= '<br />';
256: }
1.151 raeburn 257: my %all_hostnames = &Apache::lonnet::all_hostnames();
258: foreach my $hostid (sort
1.107 tempelho 259: {
260: &Apache::lonnet::hostname($a) cmp
261: &Apache::lonnet::hostname($b);
262: }
263: keys(%all_hostnames)) {
1.151 raeburn 264: next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
265: my $hostname = &Apache::lonnet::hostname($hostid);
266: next if (($last eq $hostname) || ($hostname eq ''));
267: $spares.='<br /><a href="http://'.
268: $hostname.
269: '/adm/login?domain='.$authdomain.'">'.
270: $hostname.'</a>';
271: $last=$hostname;
272: }
273: $r->print(
1.107 tempelho 274: '<html>'
275: .'<head><title>'
276: .&mt('The LearningOnline Network with CAPA')
277: .'</title></head>'
278: .'<body bgcolor="#FFFFFF">'
279: .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
280: .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
1.148 raeburn 281: .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
1.151 raeburn 282: if ($spares) {
283: $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
284: .'</p>'
285: .$spares);
286: }
287: $r->print('</body>'
288: .'</html>'
289: );
290: return OK;
291: }
1.31 www 292:
293: # ----------------------------------------------- Apparently we are in business
1.151 raeburn 294: $servadm=~s/\,/\<br \/\>/g;
1.38 www 295:
1.21 www 296: # ----------------------------------------------------------- Front page design
1.151 raeburn 297: my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
298: my $font=&Apache::loncommon::designparm('login.font',$domain);
299: my $link=&Apache::loncommon::designparm('login.link',$domain);
300: my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
301: my $alink=&Apache::loncommon::designparm('login.alink',$domain);
302: my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
303: my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
304: my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
305: my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
306: my $logo=&Apache::loncommon::designparm('login.logo',$domain);
307: my $img=&Apache::loncommon::designparm('login.img',$domain);
308: my $domainlogo=&Apache::loncommon::domainlogo($domain);
309: my $showbanner = 1;
310: my $showmainlogo = 1;
311: if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
312: $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
313: }
314: if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
315: $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
316: }
1.153 raeburn 317: my $showadminmail;
318: my @possdoms = &Apache::lonnet::current_machine_domains();
319: if (grep(/^\Q$domain\E$/,@possdoms)) {
320: $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
321: }
1.151 raeburn 322: my $showcoursecat =
323: &Apache::loncommon::designparm('login.coursecatalog',$domain);
324: my $shownewuserlink =
325: &Apache::loncommon::designparm('login.newuser',$domain);
1.153 raeburn 326: my $showhelpdesk =
327: &Apache::loncommon::designparm('login.helpdesk',$domain);
1.151 raeburn 328: my $now=time;
329: my $js = (<<ENDSCRIPT);
1.107 tempelho 330:
1.116 bisitz 331: <script type="text/javascript" language="JavaScript">
1.122 bisitz 332: // <![CDATA[
1.107 tempelho 333: function send()
334: {
335: this.document.server.elements.uname.value
336: =this.document.client.elements.uname.value;
337:
338: this.document.server.elements.udom.value
339: =this.document.client.elements.udom.value;
340:
341: uextkey=this.document.client.elements.uextkey.value;
342: lextkey=this.document.client.elements.lextkey.value;
343: initkeys();
344:
345: this.document.server.elements.upass0.value
346: =crypted(this.document.client.elements.upass$now.value.substr(0,15));
347: this.document.server.elements.upass1.value
348: =crypted(this.document.client.elements.upass$now.value.substr(15,15));
349: this.document.server.elements.upass2.value
350: =crypted(this.document.client.elements.upass$now.value.substr(30,15));
1.6 www 351:
1.107 tempelho 352: this.document.client.elements.uname.value='';
353: this.document.client.elements.upass$now.value='';
1.6 www 354:
1.107 tempelho 355: this.document.server.submit();
356: return false;
357: }
1.139 raeburn 358:
359: function enableInput() {
1.144 bisitz 360: this.document.client.elements.upass$now.removeAttribute("readOnly");
361: this.document.client.elements.uname.removeAttribute("readOnly");
362: this.document.client.elements.udom.removeAttribute("readOnly");
1.139 raeburn 363: return;
364: }
365:
1.122 bisitz 366: // ]]>
1.107 tempelho 367: </script>
1.98 raeburn 368:
1.16 www 369: ENDSCRIPT
1.6 www 370:
1.98 raeburn 371: # --------------------------------------------------- Print login screen header
372:
1.151 raeburn 373: my %add_entries = (
1.108 tempelho 374: bgcolor => "$mainbg",
1.107 tempelho 375: text => "$font",
376: link => "$link",
377: vlink => "$vlink",
1.139 raeburn 378: alink => "$alink",
379: onload => 'javascript:enableInput();',);
1.107 tempelho 380:
1.151 raeburn 381: $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
1.107 tempelho 382: { 'redirect' => [$expire,'/adm/roles'],
383: 'add_entries' => \%add_entries,
384: 'only_body' => 1,}));
1.98 raeburn 385:
386: # ----------------------------------------------------------------------- Texts
387:
1.151 raeburn 388: my %lt=&Apache::lonlocal::texthash(
1.129 bisitz 389: 'un' => 'Username',
390: 'pw' => 'Password',
391: 'dom' => 'Domain',
392: 'perc' => 'percent',
393: 'load' => 'Server Load',
394: 'userload' => 'User Load',
395: 'catalog' => 'Course/Community Catalog',
396: 'log' => 'Log in',
397: 'help' => 'Log-in Help',
398: 'serv' => 'Server',
399: 'servadm' => 'Server Administration',
400: 'helpdesk' => 'Contact Helpdesk',
401: 'forgotpw' => 'Forgot password?',
402: 'newuser' => 'New User?',
403: );
1.98 raeburn 404: # -------------------------------------------------- Change password field name
1.131 jms 405:
1.151 raeburn 406: my $forgotpw = &forgotpwdisplay(%lt);
407: $forgotpw .= '<br />' if $forgotpw;
1.152 raeburn 408: my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
409: if ($loginhelp) {
410: $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
411: }
1.98 raeburn 412:
413: # ---------------------------------------------------- Serve out DES JavaScript
1.151 raeburn 414: {
415: my $jsh=Apache::File->new($include."/londes.js");
416: $r->print(<$jsh>);
417: }
1.98 raeburn 418: # ---------------------------------------------------------- Serve rest of page
419:
1.151 raeburn 420: $r->print(
1.137 bisitz 421: '<div class="LC_Box"'
422: .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
423: );
1.6 www 424:
1.151 raeburn 425: $r->print(<<ENDSERVERFORM);
1.140 raeburn 426: <form name="server" action="/adm/authenticate" method="post" target="_top">
1.33 www 427: <input type="hidden" name="logtoken" value="$logtoken" />
428: <input type="hidden" name="serverid" value="$lonhost" />
429: <input type="hidden" name="uname" value="" />
1.65 www 430: <input type="hidden" name="upass0" value="" />
431: <input type="hidden" name="upass1" value="" />
432: <input type="hidden" name="upass2" value="" />
1.33 www 433: <input type="hidden" name="udom" value="" />
1.63 albertel 434: <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
435: <input type="hidden" name="localres" value="$env{'form.localres'}" />
1.14 albertel 436: </form>
1.16 www 437: ENDSERVERFORM
1.151 raeburn 438: my $coursecatalog;
439: if (($showcoursecat eq '') || ($showcoursecat)) {
440: $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
441: }
442: my $newuserlink;
443: if ($shownewuserlink) {
444: $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
445: }
446: my $logintitle =
447: '<h2 class="LC_hcell"'
448: .' style="background:'.$loginbox_header_bgcol.';'
449: .' color:'.$loginbox_header_textcol.'">'
450: .$lt{'log'}
451: .'</h2>';
452:
453: my $noscript_warning='<noscript><span class="LC_warning"><b>'
454: .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
455: .'</b></span></noscript>';
456: my $helpdeskscript;
457: my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
1.153 raeburn 458: $authdomain,\$helpdeskscript,
459: $showhelpdesk,\@possdoms);
1.107 tempelho 460:
1.156 raeburn 461: my $mobileargs;
462: if ($clientmobile) {
463: $mobileargs = 'autocapitalize="off" autocorrect="off"';
464: }
1.151 raeburn 465: my $loginform=(<<LFORM);
1.122 bisitz 466: <form name="client" action="" onsubmit="return(send())">
1.115 bisitz 467: <input type="hidden" name="lextkey" value="$lextkey" />
468: <input type="hidden" name="uextkey" value="$uextkey" />
1.108 tempelho 469: <b><label for="uname">$lt{'un'}</label>:</b><br />
1.156 raeburn 470: <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
1.108 tempelho 471: <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
1.139 raeburn 472: <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
1.108 tempelho 473: <b><label for="udom">$lt{'dom'}</label>:</b><br />
1.156 raeburn 474: <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
1.108 tempelho 475: <input type="submit" value="$lt{'log'}" />
476: </form>
477: LFORM
478:
1.109 raeburn 479: if ($showbanner) {
480: $r->print(<<HEADER);
481: <!-- The LON-CAPA Header -->
1.132 bisitz 482: <div style="background:$pgbg;margin:0;width:100%;">
483: <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
484: </div>
1.109 raeburn 485: HEADER
486: }
487: $r->print(<<ENDTOP);
1.146 bisitz 488: <div style="float:left;margin-top:0;">
1.137 bisitz 489: <div class="LC_Box" style="background:$loginbox_bg;">
1.112 muellerd 490: $logintitle
1.137 bisitz 491: $loginform
492: $noscript_warning
1.108 tempelho 493: </div>
1.107 tempelho 494:
1.137 bisitz 495: <div class="LC_Box" style="padding-top: 10px;">
1.132 bisitz 496: $loginhelp
497: $forgotpw
498: $contactblock
499: $newuserlink
1.130 bisitz 500: $coursecatalog
1.107 tempelho 501: </div>
1.118 tempelho 502: </div>
1.137 bisitz 503:
504: <div>
1.118 tempelho 505: ENDTOP
506: if ($showmainlogo) {
507: $r->print(' <img src="'.$logo.'" alt="" />'."\n");
508: }
509: $r->print(<<ENDTOP);
510: $announcements
1.137 bisitz 511: </div>
512: <hr style="clear:both;" />
1.108 tempelho 513: ENDTOP
1.147 raeburn 514: my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
515: $domainrow = <<"END";
1.14 albertel 516: <tr>
1.110 muellerd 517: <td align="left" valign="top">
1.132 bisitz 518: <small><b>$lt{'dom'}: </b></small>
1.14 albertel 519: </td>
1.110 muellerd 520: <td align="left" valign="top">
1.14 albertel 521: <small><tt> $domain</tt></small>
522: </td>
523: </tr>
1.147 raeburn 524: END
525: $serverrow = <<"END";
1.14 albertel 526: <tr>
1.110 muellerd 527: <td align="left" valign="top">
1.132 bisitz 528: <small><b>$lt{'serv'}: </b></small>
1.14 albertel 529: </td>
1.110 muellerd 530: <td align="left" valign="top">
1.14 albertel 531: <small><tt> $lonhost ($role)</tt></small>
532: </td>
533: </tr>
1.147 raeburn 534: END
535: if ($loadlim) {
536: $loadrow = <<"END";
1.14 albertel 537: <tr>
1.110 muellerd 538: <td align="left" valign="top">
1.132 bisitz 539: <small><b>$lt{'load'}: </b></small>
1.14 albertel 540: </td>
1.110 muellerd 541: <td align="left" valign="top">
1.51 www 542: <small><tt> $loadpercent $lt{'perc'}</tt></small>
1.42 albertel 543: </td>
544: </tr>
1.147 raeburn 545: END
546: }
547: if ($uloadlim) {
548: $userloadrow = <<"END";
1.42 albertel 549: <tr>
1.110 muellerd 550: <td align="left" valign="top">
1.132 bisitz 551: <small><b>$lt{'userload'}: </b></small>
1.42 albertel 552: </td>
1.110 muellerd 553: <td align="left" valign="top">
1.51 www 554: <small><tt> $userloadpercent $lt{'perc'}</tt></small>
1.14 albertel 555: </td>
556: </tr>
1.147 raeburn 557: END
558: }
559: if (($version ne '') && ($version ne '<!-- VERSION -->')) {
560: $versionrow = <<"END";
1.132 bisitz 561: <tr>
562: <td colspan="2" align="left">
563: <small>$version</small>
564: </td>
565: </tr>
1.147 raeburn 566: END
567: }
568:
1.151 raeburn 569: $r->print(<<ENDDOCUMENT);
1.147 raeburn 570: <div style="float: left;">
571: <table border="0" cellspacing="0" cellpadding="0">
572: $domainrow
573: $serverrow
574: $loadrow
575: $userloadrow
576: $versionrow
1.14 albertel 577: </table>
1.141 raeburn 578: </div>
579: <div style="float: right;">
580: $domainlogo
581: </div>
582: <br style="clear:both;" />
1.107 tempelho 583: </div>
1.25 bowersj2 584:
1.59 albertel 585: <script type="text/javascript">
1.122 bisitz 586: // <![CDATA[
1.59 albertel 587: // the if prevents the script error if the browser can not handle this
1.25 bowersj2 588: if ( document.client.uname ) { document.client.uname.focus(); }
1.122 bisitz 589: // ]]>
1.25 bowersj2 590: </script>
1.62 raeburn 591: $helpdeskscript
1.14 albertel 592:
1.1 albertel 593: ENDDOCUMENT
1.98 raeburn 594: my %endargs = ( 'noredirectlink' => 1, );
595: $r->print(&Apache::loncommon::end_page(\%endargs));
1.1 albertel 596: return OK;
1.60 raeburn 597: }
598:
1.133 raeburn 599: sub check_loginvia {
600: my ($domain,$lonhost) = @_;
601: if ($domain eq '' || $lonhost eq '') {
602: return;
603: }
604: my %domconfhash = &Apache::loncommon::get_domainconf($domain);
605: my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
606: my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
607: my $output;
608: if ($loginvia ne '') {
609: my $noredirect;
610: my $ip = $ENV{'REMOTE_ADDR'};
611: if ($ip eq '127.0.0.1') {
612: $noredirect = 1;
613: } else {
614: if ($loginvia_exempt ne '') {
615: my @exempt = split(',',$loginvia_exempt);
616: if (grep(/^\Q$ip\E$/,@exempt)) {
617: $noredirect = 1;
618: }
619: }
620: }
621: unless ($noredirect) {
622: my ($newhost,$path);
623: if ($loginvia =~ /:/) {
624: ($newhost,$path) = split(':',$loginvia);
625: } else {
626: $newhost = $loginvia;
627: }
628: if ($newhost ne $lonhost) {
629: if (&Apache::lonnet::hostname($newhost) ne '') {
630: $output = &redirect_page($newhost,$path);
631: }
632: }
633: }
634: }
635: return $output;
636: }
637:
1.126 raeburn 638: sub redirect_page {
1.133 raeburn 639: my ($desthost,$path) = @_;
1.126 raeburn 640: my $protocol = $Apache::lonnet::protocol{$desthost};
641: $protocol = 'http' if ($protocol ne 'https');
1.133 raeburn 642: unless ($path =~ m{^/}) {
643: $path = '/'.$path;
644: }
645: my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
1.126 raeburn 646: if ($env{'form.firsturl'} ne '') {
647: $url .='?firsturl='.$env{'form.firsturl'};
648: }
1.136 raeburn 649: my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
1.126 raeburn 650: {'redirect' => [0,$url],});
651: my $end_page = &Apache::loncommon::end_page();
652: return $start_page.$end_page;
653: }
654:
1.60 raeburn 655: sub contactdisplay {
1.153 raeburn 656: my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
657: $possdoms) = @_;
1.60 raeburn 658: my $contactblock;
1.153 raeburn 659: my $origmail;
660: if (ref($possdoms) eq 'ARRAY') {
661: if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
662: $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
663: }
664: }
665: my $requestmail =
666: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
667: $authdomain,$origmail);
1.154 raeburn 668: unless ($showhelpdesk eq '0') {
669: if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
670: $showhelpdesk = 1;
671: } else {
1.153 raeburn 672: $showhelpdesk = 0;
673: }
1.62 raeburn 674: }
1.90 raeburn 675: if ($servadm && $showadminmail) {
1.130 bisitz 676: $contactblock .= $$lt{'servadm'}.':<br />'.
677: '<tt>'.$servadm.'</tt><br />';
1.90 raeburn 678: }
1.60 raeburn 679: if ($showhelpdesk) {
1.114 tempelho 680: $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
1.75 www 681: my $thisurl = &escape('/adm/login');
1.62 raeburn 682: $$helpdeskscript = <<"ENDSCRIPT";
683: <script type="text/javascript">
1.122 bisitz 684: // <![CDATA[
1.62 raeburn 685: function helpdesk() {
1.155 raeburn 686: var possdom = document.client.udom.value;
687: var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
1.62 raeburn 688: if (codedom == '') {
689: codedom = "$authdomain";
690: }
691: var querystr = "origurl=$thisurl&codedom="+codedom;
692: document.location.href = "/adm/helpdesk?"+querystr;
693: return;
694: }
1.122 bisitz 695: // ]]>
1.62 raeburn 696: </script>
697: ENDSCRIPT
1.60 raeburn 698: }
699: return $contactblock;
700: }
1.83 raeburn 701:
702: sub forgotpwdisplay {
1.84 raeburn 703: my (%lt) = @_;
1.83 raeburn 704: my $prompt_for_resetpw = 1;
705: if ($prompt_for_resetpw) {
1.107 tempelho 706: return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
1.84 raeburn 707: }
708: return;
709: }
710:
1.90 raeburn 711: sub coursecatalog_link {
712: my ($linkname) = @_;
713: return <<"END";
1.137 bisitz 714: <a href="/adm/coursecatalog">$linkname</a>
1.90 raeburn 715: END
716: }
717:
1.101 raeburn 718: sub newuser_link {
719: my ($linkname) = @_;
1.130 bisitz 720: return '<a href="/adm/createaccount">'.$linkname.'</a>';
1.101 raeburn 721: }
722:
1.1 albertel 723: 1;
724: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>