3 # Display ADSL configuration options
4 # XXX new-style ADSL config in redhat 7.2 and above!
5 # XXX effects start/stop and bootup as well
7 require './adsl-client-lib.pl';
8 $vers = &get_pppoe_version(\$out);
9 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
10 &help_search_link("pppoe", "man", "doc"), undef, undef,
11 $vers ? &text('index_version', $vers) : undef);
15 print "<p>",&text('index_eadsl', "<tt>$config{'pppoe_cmd'}</tt>",
16 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
18 elsif (!($conf = &get_config())) {
20 if ($config{'conf_style'} == 0) {
23 &text('index_econfig', "<tt>$config{'pppoe_conf'}</tt>",
24 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
27 # On redhat systems, the file needs to be created by this
29 print "<p>",&text('index_esetup',
30 "<tt>$config{'pppoe_conf'}</tt>"),"<p>\n";
31 print "<center><form action=setup.cgi>\n";
32 print "<input type=submit value='$text{'index_setup'}'>\n";
33 print "</form></center>\n";
36 elsif (&find("TYPE", $conf) =~ /modem/i) {
37 # For a modem on a redhat system
38 $config{'pppoe_conf'} =~ /^(.*)\//;
39 print "<p>",&text('index_emodem', "<tt>$1</tt>",
40 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
43 # Show configuration form
44 $conf = &get_config();
45 print "$text{'index_desc'}<p>\n";
46 print "<form action=save.cgi method=post>\n";
47 print "<table border width=100%>\n";
48 print "<tr $tb> <td><b>$text{'index_header'}</b></td> </tr>\n";
49 print "<tr $cb> <td><table width=100%>\n";
51 # Show network interface field
52 &foreign_require("net", "net-lib.pl");
53 $eth = &find("ETH", $conf);
54 print "<tr> <td><b>",&hlink($text{'index_eth'}, "eth"),"</b></td>\n";
55 @ifcs = &net::active_interfaces(1);
56 print "<td><select name=eth>\n";
59 next if ($i->{'fullname'} !~ /^eth(\d+)$/);
60 printf "<option value='%s' %s>%s\n",
61 $i->{'name'}, $eth eq $i->{'name'} ? "selected" : "",
63 $found++ if ($eth eq $i->{'name'});
65 printf "<option value='' %s>%s\n",
66 $found ? "" : "selected", $text{'index_other'};
68 printf "<input name=other size=6 value='%s'></td>\n",
71 # Show on-demand field
72 $demand = &find("DEMAND", $conf);
73 print "<td><b>",&hlink($text{'index_demand'},"demand"),"</b></td>\n";
74 printf "<td nowrap><input type=radio name=demand value=yes %s> %s\n",
75 $demand !~ /^\d+$/i ? "" : "checked", $text{'index_timeout'};
76 printf "<input name=timeout value='%s' size=4>\n",
77 $demand !~ /^\d+$/i ? "" : $demand;
78 printf "<input type=radio name=demand value=no %s> %s</td> </tr>\n",
79 $demand !~ /^\d+$/i ? "checked" : "", $text{'no'};
82 $user = &find("USER", $conf);
83 print "<tr> <td><b>",&hlink($text{'index_user'},"user"),"</b></td>\n";
84 printf "<td><input name=user size=20 value='%s'></td>\n",
87 # Show password field (from pap-secrets)
88 ($sec) = grep { $_->{'client'} eq $user } &list_secrets();
89 print "<td><b>",&hlink($text{'index_sec'},"sec"),"</b></td>\n";
90 printf "<td><input type=password name=sec size=20 value='%s'></td> </tr>\n",
93 # Show DNS config buttons
94 $dns = &find("USEPEERDNS", $conf) || &find("PEERDNS", $conf);
95 print "<tr> <td><b>",&hlink($text{'index_dns'}, "dns"),"</b></td>\n";
96 printf "<td><input type=radio name=dns value=yes %s> %s\n",
97 $dns =~ /yes/i ? "checked" : "", $text{'yes'};
98 printf "<input type=radio name=dns value=no %s> %s</td>\n",
99 $dns =~ /yes/i ? "" : "checked", $text{'no'};
101 # Show connect timeout field
102 $connect = &find("CONNECT_TIMEOUT", $conf);
103 print "<td><b>",&hlink($text{'index_connect'},"connect"),"</b></td>\n";
104 printf "<td nowrap><input type=radio name=connect_def value=1 %s> %s\n",
105 $connect == 0 ? "checked" : "", $text{'index_forever'};
106 printf "<input type=radio name=connect_def value=0 %s>\n",
107 $connect == 0 ? "" : "checked";
108 printf "<input name=connect size=4 value='%s'> %s</td> </tr>\n",
109 $connect == 0 ? "" : $connect, $text{'index_secs'};
112 $mss = &find("CLAMPMSS", $conf);
113 print "<tr> <td><b>",&hlink($text{'index_mss'},"mss"),"</b></td>\n";
114 printf "<td nowrap><input type=radio name=mss value=yes %s> %s\n",
115 $mss =~ /no/i ? "" : "checked", $text{'index_psize'};
116 printf "<input name=psize value='%s' size=5> %s\n",
117 $mss =~ /no/i ? "" : $mss, $text{'index_bytes'};
118 printf "<input type=radio name=mss value=no %s> %s</td>\n",
119 $mss =~ /no/i ? "checked" : "", $text{'no'};
122 $fw = &find("FIREWALL", $conf);
125 print "<td><b>",&hlink($text{'index_fw'},"fw"),"</b></td>\n";
126 print "<td><select name=fw>\n";
127 foreach $f ('NONE', 'STANDALONE', 'MASQUERADE') {
128 printf "<option value=%s %s>%s\n",
129 $f, lc($f) eq lc($fw) ? "selected" : "",
130 $text{'index_fw_'.lc($f)};
132 print "</select></td> </tr>\n";
138 print "</table></td></tr></table>\n";
139 print "<input type=submit value='$text{'index_save'}'></form>\n";
141 # Show connected/disconnect buttons
143 print &ui_buttons_start();
144 local ($dev, $ip) = &get_adsl_ip();
147 print &ui_buttons_row("stop.cgi", $text{'index_stop'},
148 &text('index_stopdesc', "<tt>$ip</tt>",
149 "<tt>$config{'stop_cmd'}</tt>"));
151 elsif ($dev eq "demand") {
152 # Offer to cancel on-demand connection
153 print &ui_buttons_row("stop.cgi", $text{'index_cdemand'},
154 &text('index_cdemanddesc',
155 "<tt>$config{'stop_cmd'}</tt>"));
158 # Offer to cancel connect
159 print &ui_buttons_row("stop.cgi", $text{'index_cancel'},
160 &text('index_canceldesc',
161 "<tt>$config{'stop_cmd'}</tt>"));
165 print &ui_buttons_row("start.cgi", $text{'index_start'},
166 &text('index_startdesc',
167 "<tt>$config{'start_cmd'}</tt>"));
170 # Show boot-time button
171 if ($config{'conf_style'} == 1 && ($onboot = find("ONBOOT", $conf))) {
172 # Offer to turn on/off starting at boot
173 print &ui_buttons_row("rbootup.cgi", $text{'index_boot'},
174 $text{'index_bootdesc'}, undef,
175 &ui_yesno_radio("onboot",
176 $onboot =~ /yes/i ? 1 : 0));
178 elsif (&foreign_check("init")) {
179 # Offer to enable/disable init script
180 &foreign_require("init", "init-lib.pl");
181 $boot = &init::action_status("adsl");
183 print &ui_buttons_row("bootup.cgi", $text{'index_boot'},
184 $text{'index_bootdesc'}, undef,
185 &ui_yesno_radio("boot",
186 $boot == 2 ? 1 : 0));
190 print &ui_buttons_end();
193 &ui_print_footer("/", $text{'index'});