3 # Display the login form used in session login mode
6 #$ENV{'MINISERV_INTERNAL'} || die "Can only be called by miniserv.pl";
7 require './web-lib.pl';
11 if ($gconfig{'loginbanner'} && $ENV{'HTTP_COOKIE'} !~ /banner=1/ &&
12 !$in{'logout'} && !$in{'failed'} && !$in{'timed_out'}) {
13 # Show pre-login HTML page
14 print "Set-Cookie: banner=1; path=/\r\n";
17 open(BANNER, $gconfig{'loginbanner'});
25 $sec = uc($ENV{'HTTPS'}) eq 'ON' ? "; secure" : "";
26 &get_miniserv_config(\%miniserv);
27 $sidname = $miniserv{'sidname'} || "sid";
28 print "Set-Cookie: banner=0; path=/$sec\r\n" if ($gconfig{'loginbanner'});
29 print "Set-Cookie: $sidname=x; path=/$sec\r\n" if ($in{'logout'});
30 print "Set-Cookie: testing=1; path=/$sec\r\n";
31 &ui_print_unbuffered_header(undef, undef, undef, undef, undef, 1, 1, undef, undef,
32 "onLoad='document.forms[0].pass.value = \"\"; document.forms[0].user.focus()'");
34 if ($tconfig{'inframe'}) {
35 # Framed themes lose original page
40 if (defined($in{'failed'})) {
41 print "<h3>$text{'session_failed'}</h3><p>\n";
43 elsif ($in{'logout'}) {
44 print "<h3>$text{'session_logout'}</h3><p>\n";
46 elsif ($in{'timed_out'}) {
47 print "<h3>",&text('session_timed_out', int($in{'timed_out'}/60)),"</h3><p>\n";
49 print "$text{'session_prefix'}\n";
50 print "<form action=$gconfig{'webprefix'}/session_login.cgi method=post>\n";
51 print "<input type=hidden name=page value='".&html_escape($in{'page'})."'>\n";
52 print "<table border width=40%>\n";
53 print "<tr $tb> <td><b>$text{'session_header'}</b></td> </tr>\n";
54 print "<tr $cb> <td align=center><table cellpadding=3>\n";
55 if ($gconfig{'realname'}) {
56 $host = &get_display_hostname();
59 $host = $ENV{'HTTP_HOST'};
61 $host = &html_escape($host);
63 print "<tr> <td colspan=2 align=center>",
64 &text($gconfig{'nohostname'} ? 'session_mesg2' : 'session_mesg',
65 "<tt>$host</tt>"),"</td> </tr>\n";
66 print "<tr> <td><b>$text{'session_user'}</b></td>\n";
67 print "<td><input name=user size=20 value='".&html_escape($in{'failed'})."'></td> </tr>\n";
68 print "<tr> <td><b>$text{'session_pass'}</b></td>\n";
69 print "<td><input name=pass size=20 type=password></td> </tr>\n";
70 print "<tr> <td colspan=2 align=center><input type=submit value='$text{'session_login'}'>\n";
71 print "<input type=reset value='$text{'session_clear'}'><br>\n";
72 if (!$gconfig{'noremember'}) {
73 print "<input type=checkbox name=save value=1> $text{'session_save'}\n";
75 print "</td> </tr>\n";
76 print "</table></td></tr></table><p>\n";
77 print "</form></center>\n";
78 print "$text{'session_postfix'}\n";
80 # Output frame-detection Javascript, if theme uses frames
81 if ($tconfig{'inframe'}) {
84 if (window != window.top) {
85 window.top.location = window.location;