Handle hostnames with upper-case letters
[webmin.git] / pptp-server / edit_options.cgi
1 #!/usr/local/bin/perl
2 # edit_options.cgi
3 # XXX +chap options?
4
5 require './pptp-server-lib.pl';
6 $access{'options'} || &error($text{'options_ecannot'});
7 $out = `pppd --help 2>&1`;
8 if ($out =~ /version\s+(\S+)/i) {
9         $vers = $1;
10         }
11 &ui_print_header(undef, $text{'options_title'}, "", "options", 0, 0, 0, undef, undef, undef,
12         &text('options_version', $vers));
13
14 $conf = &get_config();
15 $option = &find_conf("option", $conf);
16 $option ||= $config{'ppp_options'};
17 @opts = &parse_ppp_options($option);
18
19 if ($option eq $config{'ppp_options'}) {
20         print &text('options_desc0', "<tt>$option</tt>"),"\n";
21         }
22 else {
23         print &text('options_desc1', "<tt>$option</tt>"),"\n";
24         }
25 print "$text{'options_desc2'}<p>\n";
26
27 print "<form action=save_options.cgi>\n";
28 print "<table border width=100%>\n";
29 print "<tr $tb> <td><b>$text{'options_header'}</b></td> </tr>\n";
30 print "<tr $cb> <td><table width=100%>\n";
31
32 $lock = &find("lock", \@opts);
33 print "<tr> <td><b>$text{'options_lock'}</b></td>\n";
34 printf "<td><input type=radio name=lock value=1 %s> %s\n",
35         $lock ? "checked" : "", $text{'yes'};
36 printf "<input type=radio name=lock value=0 %s> %s</td>\n",
37         $lock ? "" : "checked", $text{'no'};
38
39 $proxy = &find("proxyarp", \@opts);
40 print "<td><b>$text{'options_proxyarp'}</b></td>\n";
41 printf "<td><input type=radio name=proxyarp value=1 %s> %s\n",
42         $proxy ? "checked" : "", $text{'yes'};
43 printf "<input type=radio name=proxyarp value=0 %s> %s</td> </tr>\n",
44         $proxy ? "" : "checked", $text{'no'};
45
46 $mtu = &find("mtu", \@opts);
47 printf "<tr> <td><b>$text{'options_mtu'}</b></td> <td>\n";
48 printf "<input type=radio name=mtu_def value=1 %s> %s\n",
49         $mtu ? "" : "checked", $text{'default'};
50 printf "<input type=radio name=mtu_def value=0 %s>\n",
51         $mtu ? "checked" : "";
52 print "<input name=mtu size=6 value='$mtu->{'value'}'> bytes</td>\n";
53
54 $mru = &find("mru", \@opts);
55 printf "<td><b>$text{'options_mru'}</b></td> <td>\n";
56 printf "<input type=radio name=mru_def value=1 %s> %s\n",
57         $mru ? "" : "checked", $text{'default'};
58 printf "<input type=radio name=mru_def value=0 %s>\n",
59         $mru ? "checked" : "";
60 print "<input name=mru size=6 value='$mru->{'value'}'> bytes</td> </tr>\n";
61
62 print "<tr> <td colspan=4><hr></td> </tr>\n";
63
64 $auth = &find("auth", \@opts);
65 $noauth = &find("noauth", \@opts);
66 print "<tr> <td><b>$text{'options_auth'}</b></td>\n";
67 printf "<td colspan=3><input type=radio name=auth value=0 %s> %s\n",
68         $noauth || $auth ? "" : "checked", $text{'options_auth0'};
69 printf "<input type=radio name=auth value=1 %s> %s\n",
70         $noauth ? "checked" : "", $text{'options_auth1'};
71 printf "<input type=radio name=auth value=2 %s> %s</td> </tr>\n",
72         $auth ? "checked" : "", $text{'options_auth2'};
73
74 &auth_input("pap");
75 &auth_input("chap");
76
77 $login = &find("login", \@opts);
78 print "<tr> <td><b>$text{'options_login'}</b></td>\n";
79 printf "<td><input type=radio name=login value=1 %s> %s\n",
80         $login ? "checked" : "", $text{'yes'};
81 printf "<input type=radio name=login value=0 %s> %s</td>\n",
82         $login ? "" : "checked", $text{'no'};
83
84 $name = &find("name", \@opts);
85 printf "<tr> <td><b>$text{'options_name'}</b></td> <td colspan=3>\n";
86 printf "<input type=radio name=name_def value=1 %s> %s (%s)\n",
87         $name ? "" : "checked", $text{'options_hn'}, &get_system_hostname();
88 printf "<input type=radio name=name_def value=0 %s>\n",
89         $name ? "checked" : "";
90 print "<input name=name size=30 value='$name->{'value'}'></td> </tr>\n";
91
92 print "<tr> <td colspan=4><hr></td> </tr>\n";
93
94 print "<tr> <td colspan=4 align=center>$text{'options_msdesc'}</td> </tr>\n";
95
96 &foreign_require("pptp-client", "pptp-client-lib.pl");
97 if (&pptp_client::mppe_support() == 1) {
98         # Show new-style MS-CHAP options
99         &auth_input("mschap");
100         &auth_input("mschap-v2");
101         }
102 else {
103         # Show old-style MS-CHAP option
104         &auth_input("chapms");
105         &auth_input("chapms-v2");
106         }
107
108 # Show general MPPE options
109 &pptp_client::mppe_options_form(\@opts);
110
111 print "</table></td></tr></table>\n";
112 print "<input type=submit value='$text{'save'}'></form>\n";
113
114 &ui_print_footer("", $text{'index_return'});
115
116 # auth_input(name)
117 sub auth_input
118 {
119 local $a = $_[0];
120 local $req = &find("require-$a", \@opts);
121 local $ref = &find("refuse-$a", \@opts);
122 print "<tr> <td><b>",$text{'options_'.$a},"</b></td> <td colspan=3>\n";
123 printf "<input type=radio name=$a value=2 %s> %s\n",
124         $req ? "checked" : "", $text{"options_req"};
125 printf "<input type=radio name=$a value=1 %s> %s\n",
126         $req || $ref ? "" : "checked", $text{"options_all"};
127 printf "<input type=radio name=$a value=0 %s> %s</td> </tr>\n",
128         $ref ? "checked" : "", $text{"options_ref"};
129 }
130