Catalan translation, other random fixes
[webmin.git] / session_login.cgi
1 #!/usr/local/bin/perl
2 # session_login.cgi
3 # Display the login form used in session login mode
4
5 $pragma_no_cache = 1;
6 #$ENV{'MINISERV_INTERNAL'} || die "Can only be called by miniserv.pl";
7 require './web-lib.pl';
8 require './ui-lib.pl';
9 &init_config();
10 &ReadParse();
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";
15         &PrintHeader();
16         $url = $in{'page'};
17         open(BANNER, $gconfig{'loginbanner'});
18         while(<BANNER>) {
19                 s/LOGINURL/$url/g;
20                 print;
21                 }
22         close(BANNER);
23         return;
24         }
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,
32                             undef, "onLoad='document.forms[0].pass.value = \"\"; document.forms[0].user.focus()'");
33
34 if ($tconfig{'inframe'}) {
35         # Framed themes lose original page
36         $in{'page'} = "/";
37         }
38
39 print "<center>\n";
40 if (defined($in{'failed'})) {
41         print "<h3>$text{'session_failed'}</h3><p>\n";
42         }
43 elsif ($in{'logout'}) {
44         print "<h3>$text{'session_logout'}</h3><p>\n";
45         }
46 elsif ($in{'timed_out'}) {
47         print "<h3>",&text('session_timed_out', int($in{'timed_out'}/60)),"</h3><p>\n";
48         }
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();
57         }
58 else {
59         $host = $ENV{'HTTP_HOST'};
60         $host =~ s/:\d+//g;
61         $host = &html_escape($host);
62         }
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";
74         }
75 print "</td> </tr>\n";
76 print "</table></td></tr></table><p>\n";
77 print "</form></center>\n";
78 print "$text{'session_postfix'}\n";
79
80 # Output frame-detection Javascript, if theme uses frames
81 if ($tconfig{'inframe'}) {
82         print <<EOF;
83 <script>
84 if (window != window.top) {
85         window.top.location = window.location;
86         }
87 </script>
88 EOF
89         }
90
91 &ui_print_footer();
92