]>
Commit | Line | Data |
---|---|---|
ac1cfefa | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
ac1cfefa MT |
21 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
25 | #use warnings; | |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
27 | ||
986e08d9 | 28 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
29 | require "${General::swroot}/lang.pl"; |
30 | require "${General::swroot}/header.pl"; | |
31 | ||
32 | our %pppsettings=(); | |
33 | my %temppppsettings=(); | |
34 | our %modemsettings=(); | |
35 | our %isdnsettings=(); | |
36 | our %netsettings=(); | |
37 | my %selected=(); | |
38 | my %checked=(); | |
39 | my @profilenames=(); | |
40 | my $errormessage = ''; | |
41 | my $maxprofiles = 5; | |
42 | my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`; | |
43 | ||
f2fdd0c1 CS |
44 | my %color = (); |
45 | my %mainsettings = (); | |
46 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
47 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
48 | ||
ac1cfefa MT |
49 | &Header::showhttpheaders(); |
50 | ||
51 | $pppsettings{'ACTION'} = ''; | |
52 | &initprofile(); | |
53 | &Header::getcgihash(\%pppsettings); | |
54 | ||
55 | if ($pppsettings{'ACTION'} ne '' && | |
197f8d43 | 56 | (-e '/var/run/ppp-ipcop.pid' || -e "${General::swroot}/red/active")) |
ac1cfefa | 57 | { |
197f8d43 MT |
58 | $errormessage = $Lang::tr{'unable to alter profiles while red is active'}; |
59 | # read in the current vars | |
60 | %pppsettings = (); | |
61 | $pppsettings{'VALID'} = ''; | |
62 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
ac1cfefa MT |
63 | } |
64 | elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'}) | |
65 | { | |
197f8d43 MT |
66 | unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp|pppoeatm)$/) { |
67 | $errormessage = $Lang::tr{'invalid input'}; | |
68 | goto ERROR; } | |
69 | my $type = $pppsettings{'TYPE'}; | |
70 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
71 | $pppsettings{'TYPE'} = $type; | |
ac1cfefa MT |
72 | } |
73 | elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'}) | |
74 | { | |
ac6dd0a7 | 75 | if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|ttyACM0|ttyACM1|ttyACM2|ttyACM3|ttyUSB0|ttyUSB1|ttyUSB2|ttyUSB3|isdn1|isdn2)$/) { |
197f8d43 MT |
76 | $errormessage = $Lang::tr{'invalid input'}; |
77 | goto ERROR; } | |
78 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800|921600)$/) { | |
79 | $errormessage = $Lang::tr{'invalid input'}; | |
80 | goto ERROR; } | |
81 | if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) { | |
82 | $errormessage = $Lang::tr{'invalid input'}; | |
83 | goto ERROR; } | |
84 | if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) { | |
85 | $errormessage = $Lang::tr{'invalid input'}; | |
86 | goto ERROR; | |
87 | } | |
88 | ||
89 | if ($pppsettings{'PROFILENAME'} eq '') { | |
90 | $errormessage = $Lang::tr{'profile name not given'}; | |
91 | $pppsettings{'PROFILENAME'} = ''; | |
92 | goto ERROR; } | |
93 | if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) { | |
94 | if ($pppsettings{'TELEPHONE'} eq '') { | |
95 | $errormessage = $Lang::tr{'telephone not set'}; | |
96 | goto ERROR; } | |
97 | if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) { | |
98 | $errormessage = $Lang::tr{'bad characters in the telephone number field'}; | |
99 | goto ERROR; } | |
100 | } | |
101 | unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) { | |
102 | if ($pppsettings{'USERNAME'} eq '') { | |
103 | $errormessage = $Lang::tr{'username not set'}; | |
104 | goto ERROR; } | |
105 | if ($pppsettings{'PASSWORD'} eq '') { | |
106 | $errormessage = $Lang::tr{'password not set'}; | |
107 | goto ERROR; } | |
108 | } | |
109 | ||
110 | if ($pppsettings{'TIMEOUT'} eq '') { | |
111 | $errormessage = $Lang::tr{'idle timeout not set'}; | |
112 | goto ERROR; } | |
113 | if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) { | |
114 | $errormessage = $Lang::tr{'only digits allowed in the idle timeout'}; | |
115 | goto ERROR; } | |
116 | ||
117 | if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) { | |
118 | $errormessage = $Lang::tr{'bad characters in script field'}; | |
119 | goto ERROR; } | |
120 | ||
121 | if ($pppsettings{'DNS1'}) | |
122 | { | |
123 | if (!(&General::validip($pppsettings{'DNS1'}))) { | |
124 | $errormessage = $Lang::tr{'invalid primary dns'}; | |
125 | goto ERROR; } | |
126 | } | |
127 | if ($pppsettings{'DNS2'}) | |
128 | { | |
129 | if (!(&General::validip($pppsettings{'DNS2'}))) { | |
130 | $errormessage = $Lang::tr{'invalid secondary dns'}; | |
131 | goto ERROR; } | |
132 | } | |
133 | ||
134 | if ($pppsettings{'MAXRETRIES'} eq '') { | |
135 | $errormessage = $Lang::tr{'max retries not set'}; | |
136 | goto ERROR; } | |
137 | if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) { | |
138 | $errormessage = $Lang::tr{'only digits allowed in max retries field'}; | |
139 | goto ERROR; } | |
140 | ||
141 | if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) { | |
142 | $errormessage = $Lang::tr{'only digits allowed in holdoff field'}; | |
143 | goto ERROR; } | |
144 | ||
145 | if ($pppsettings{'TYPE'} eq 'pptp') { | |
146 | $errormessage = ''; | |
147 | if ($pppsettings{'METHOD'} eq 'STATIC') { | |
148 | if (! &General::validip($pppsettings{'ROUTERIP'})) { | |
149 | $errormessage = $Lang::tr{'router ip'}.' '.$Lang::tr{'invalid ip'}; | |
150 | } | |
151 | } else { | |
152 | if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) ) { | |
153 | $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.' '.$Lang::tr{'invalid hostname'}; | |
154 | } | |
155 | } | |
156 | if ($errormessage ne '') {goto ERROR; } | |
157 | } | |
158 | if ($pppsettings{'TYPE'} =~ /^(pppoeatm)$/) { | |
159 | if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) { | |
160 | $errormessage = $Lang::tr{'invalid vpi vpci'}; | |
161 | goto ERROR; } | |
162 | if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) { | |
163 | $errormessage = $Lang::tr{'invalid vpi vpci'}; | |
164 | goto ERROR; } | |
165 | if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) { | |
166 | $errormessage = $Lang::tr{'invalid vpi vpci'}; | |
167 | goto ERROR; } | |
168 | if ( $pppsettings{'PROTOCOL'} eq '' ) { | |
169 | $errormessage = $Lang::tr{'invalid input'}; | |
170 | goto ERROR; } | |
171 | } | |
172 | ||
173 | if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \ | |
174 | ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) { | |
175 | $errormessage = $Lang::tr{'invalid input'}; | |
176 | goto ERROR; } | |
177 | ||
178 | if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) { | |
179 | if ($pppsettings{'DHCP_HOSTNAME'} ne '') { | |
180 | if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) { | |
181 | $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; } | |
182 | } | |
183 | } | |
184 | ||
185 | if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) { | |
186 | $errormessage = ''; | |
187 | if (! &General::validip($pppsettings{'IP'})) { | |
188 | $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; } | |
189 | if (! &General::validip($pppsettings{'GATEWAY'})) { | |
190 | $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; } | |
191 | if (! &General::validmask($pppsettings{'NETMASK'})) { | |
192 | $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; } | |
193 | if ($pppsettings{'BROADCAST'} ne '') { | |
194 | if (! &General::validip($pppsettings{'BROADCAST'})) { | |
195 | $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; } | |
196 | } | |
197 | if( $pppsettings{'DNS'} eq 'Automatic') { | |
198 | $errormessage = $Lang::tr{'invalid input'}; } | |
199 | if ($errormessage ne '') {goto ERROR; } | |
200 | } | |
201 | ||
202 | if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \ | |
203 | $pppsettings{'RECONNECTION'} eq 'dialondemand' ) { | |
204 | $errormessage = $Lang::tr{'invalid input'}; | |
205 | goto ERROR; } | |
206 | ||
207 | if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) { | |
208 | $errormessage = $Lang::tr{'dod not compatible with ddns'}; | |
209 | goto ERROR; } | |
210 | ||
211 | # if( $pppsettings{'PROTOCOL'} eq 'RFC1483') { | |
212 | # $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; } | |
213 | # if( $pppsettings{'PROTOCOL'} eq 'RFC2364') { | |
214 | # $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; } | |
215 | delete $pppsettings{'ENCAP_RFC1483'}; | |
216 | delete $pppsettings{'ENCAP_RFC2364'}; | |
ac1cfefa MT |
217 | |
218 | ERROR: | |
197f8d43 MT |
219 | if ($errormessage) { |
220 | $pppsettings{'VALID'} = 'no'; } | |
221 | else { | |
222 | $pppsettings{'VALID'} = 'yes'; } | |
ac1cfefa | 223 | |
197f8d43 MT |
224 | # write cgi vars to the file. |
225 | &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
226 | \%pppsettings); | |
ac1cfefa | 227 | |
197f8d43 MT |
228 | # make link and write secret file. |
229 | &updatesettings(); | |
230 | &writesecrets(); | |
ac1cfefa | 231 | |
197f8d43 | 232 | &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}"); |
ac1cfefa | 233 | } |
cb5e9c6c | 234 | if ($pppsettings{'ACTION'} eq $Lang::tr{'select'}) |
ac1cfefa | 235 | { |
197f8d43 MT |
236 | my $profile = $pppsettings{'PROFILE'}; |
237 | %temppppsettings = (); | |
238 | $temppppsettings{'PROFILE'} = ''; | |
239 | &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
240 | \%temppppsettings); | |
ac1cfefa | 241 | |
197f8d43 MT |
242 | # make link. |
243 | &updatesettings(); | |
ac1cfefa | 244 | |
197f8d43 MT |
245 | # read in the new params "early" so we can write secrets. |
246 | %pppsettings = (); | |
247 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
248 | $pppsettings{'PROFILE'} = $profile; | |
249 | &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
250 | \%pppsettings); | |
ac1cfefa | 251 | |
197f8d43 | 252 | &writesecrets(); |
ac1cfefa | 253 | |
197f8d43 | 254 | &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}"); |
ac1cfefa MT |
255 | } |
256 | elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'}) | |
257 | { | |
197f8d43 MT |
258 | &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}"); |
259 | ||
260 | my $profile = $pppsettings{'PROFILE'}; | |
261 | truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0); | |
262 | ||
263 | %temppppsettings = (); | |
264 | $temppppsettings{'PROFILE'} = ''; | |
265 | &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
266 | \%temppppsettings); | |
267 | ||
268 | # make link. | |
269 | &updatesettings(); | |
270 | ||
271 | # read in the new params "early" so we can write secrets. | |
272 | %pppsettings = (); | |
273 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
274 | $pppsettings{'PROFILE'} = $profile; | |
275 | &initprofile; | |
276 | &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
277 | \%pppsettings); | |
ac1cfefa | 278 | } |
d15b4ff7 CS |
279 | elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'}) |
280 | { | |
281 | } | |
ac1cfefa MT |
282 | else |
283 | { | |
197f8d43 MT |
284 | # read in the current vars |
285 | %pppsettings = (); | |
286 | $pppsettings{'VALID'} = ''; | |
287 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
ac1cfefa MT |
288 | } |
289 | ||
290 | # read in the profile names into @profilenames. | |
291 | my $c=0; | |
292 | for ($c = 1; $c <= $maxprofiles; $c++) | |
293 | { | |
197f8d43 MT |
294 | %temppppsettings = (); |
295 | $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty profile'}; | |
296 | &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); | |
297 | $profilenames[$c] = $temppppsettings{'PROFILENAME'}; | |
ac1cfefa MT |
298 | } |
299 | ||
300 | if ($pppsettings{'VALID'} eq '') | |
301 | { | |
197f8d43 MT |
302 | if ($pppsettings{'PROFILE'} eq '') { |
303 | $pppsettings{'PROFILE'} = '1'; | |
304 | &initprofile(); | |
305 | } | |
ac1cfefa MT |
306 | } |
307 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
197f8d43 | 308 | $selected{'PROFILE'}{$c} = ''; } |
ac1cfefa MT |
309 | $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; |
310 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
197f8d43 | 311 | $selected{'BACKUPPROFILE'}{$c} = ''; } |
ac1cfefa MT |
312 | $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'"; |
313 | ||
314 | $selected{'TYPE'}{'modem'} = ''; | |
315 | $selected{'TYPE'}{'serial'} = ''; | |
ac1cfefa MT |
316 | $selected{'TYPE'}{'pppoe'} = ''; |
317 | $selected{'TYPE'}{'pptp'} = ''; | |
ac1cfefa | 318 | $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'"; |
ac1cfefa MT |
319 | $checked{'DEBUG'}{'off'} = ''; |
320 | $checked{'DEBUG'}{'on'} = ''; | |
321 | $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'"; | |
322 | ||
323 | $selected{'COMPORT'}{'ttyS0'} = ''; | |
324 | $selected{'COMPORT'}{'ttyS1'} = ''; | |
325 | $selected{'COMPORT'}{'ttyS2'} = ''; | |
326 | $selected{'COMPORT'}{'ttyS3'} = ''; | |
327 | $selected{'COMPORT'}{'ttyS4'} = ''; | |
3e615c37 MT |
328 | $selected{'COMPORT'}{'ttyACM0'} = ''; |
329 | $selected{'COMPORT'}{'ttyACM1'} = ''; | |
330 | $selected{'COMPORT'}{'ttyACM2'} = ''; | |
ac6dd0a7 AF |
331 | $selected{'COMPORT'}{'ttyACM3'} = ''; |
332 | $selected{'COMPORT'}{'ttyUSB0'} = ''; | |
333 | $selected{'COMPORT'}{'ttyUSB1'} = ''; | |
334 | $selected{'COMPORT'}{'ttyUSB2'} = ''; | |
335 | $selected{'COMPORT'}{'ttyUSB3'} = ''; | |
ac1cfefa MT |
336 | $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'"; |
337 | ||
338 | $selected{'DTERATE'}{'9600'} = ''; | |
339 | $selected{'DTERATE'}{'19200'} = ''; | |
340 | $selected{'DTERATE'}{'38400'} = ''; | |
341 | $selected{'DTERATE'}{'57600'} = ''; | |
342 | $selected{'DTERATE'}{'115200'} = ''; | |
343 | $selected{'DTERATE'}{'230400'} = ''; | |
6c666a3b | 344 | $selected{'DTERATE'}{'460800'} = ''; |
a89770fa | 345 | $selected{'DTERATE'}{'921600'} = ''; |
ac1cfefa MT |
346 | $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'"; |
347 | ||
348 | $checked{'SPEAKER'}{'off'} = ''; | |
349 | $checked{'SPEAKER'}{'on'} = ''; | |
350 | $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'"; | |
351 | ||
352 | $selected{'DIALMODE'}{'T'} = ''; | |
353 | $selected{'DIALMODE'}{'P'} = ''; | |
354 | $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'"; | |
355 | ||
ac1cfefa MT |
356 | $checked{'RECONNECTION'}{'persistent'} = ''; |
357 | $checked{'RECONNECTION'}{'dialondemand'} = ''; | |
358 | $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'"; | |
359 | ||
360 | $checked{'DIALONDEMANDDNS'}{'off'} = ''; | |
361 | $checked{'DIALONDEMANDDNS'}{'on'} = ''; | |
362 | $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'"; | |
363 | ||
364 | $checked{'AUTOCONNECT'}{'off'} = ''; | |
365 | $checked{'AUTOCONNECT'}{'on'} = ''; | |
366 | $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'"; | |
367 | ||
368 | $checked{'SENDCR'}{'off'} = ''; | |
369 | $checked{'SENDCR'}{'on'} = ''; | |
370 | $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'"; | |
371 | $checked{'USEDOV'}{'off'} = ''; | |
372 | $checked{'USEDOV'}{'on'} = ''; | |
373 | $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'"; | |
ac1cfefa MT |
374 | |
375 | $checked{'MODEM'}{'PCIST'} = ''; | |
376 | $checked{'MODEM'}{'USB'} = ''; | |
377 | $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'"; | |
378 | ||
379 | $selected{'LINE'}{'WO'} = ''; | |
380 | $selected{'LINE'}{'ES'} = ''; | |
381 | $selected{'LINE'}{'ES03'} = ''; | |
382 | $selected{'LINE'}{'FR'} = ''; | |
383 | $selected{'LINE'}{'FR04'} = ''; | |
384 | $selected{'LINE'}{'FR10'} = ''; | |
385 | $selected{'LINE'}{'IT'} = ''; | |
386 | $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'"; | |
387 | ||
388 | $checked{'MODULATION'}{'GDMT'} = ''; | |
389 | $checked{'MODULATION'}{'ANSI'} = ''; | |
390 | $checked{'MODULATION'}{'GLITE'} = ''; | |
391 | $checked{'MODULATION'}{'AUTO'} = ''; | |
392 | $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'"; | |
393 | ||
394 | $checked{'PROTOCOL'}{'RFC1483'} = ''; | |
395 | $checked{'PROTOCOL'}{'RFC2364'} = ''; | |
396 | $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'"; | |
397 | ||
398 | $selected{'ENCAP'}{'0'} = ''; | |
399 | $selected{'ENCAP'}{'1'} = ''; | |
a89770fa MT |
400 | #$selected{'ENCAP'}{'2'} = ''; |
401 | #$selected{'ENCAP'}{'3'} = ''; | |
402 | #$selected{'ENCAP'}{'4'} = ''; | |
ac1cfefa | 403 | $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'"; |
a89770fa | 404 | |
ac1cfefa MT |
405 | $checked{'METHOD'}{'STATIC'} = ''; |
406 | $checked{'METHOD'}{'PPPOE'} = ''; | |
407 | $checked{'METHOD'}{'PPPOE_PLUGIN'} = ''; | |
408 | $checked{'METHOD'}{'DHCP'} = ''; | |
409 | $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'"; | |
410 | ||
411 | $selected{'AUTH'}{'pap-or-chap'} = ''; | |
412 | $selected{'AUTH'}{'pap'} = ''; | |
413 | $selected{'AUTH'}{'chap'} = ''; | |
414 | $selected{'AUTH'}{'standard-login-script'} = ''; | |
415 | $selected{'AUTH'}{'demon-login-script'} = ''; | |
416 | $selected{'AUTH'}{'other-login-script'} = ''; | |
417 | $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'"; | |
418 | ||
419 | $checked{'DNS'}{'Automatic'} = ''; | |
420 | $checked{'DNS'}{'Manual'} = ''; | |
421 | $checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'"; | |
422 | ||
423 | &Header::openpage($Lang::tr{'ppp setup'}, 1, ''); | |
ac1cfefa MT |
424 | &Header::openbigbox('100%', 'left', '', $errormessage); |
425 | ||
197f8d43 | 426 | if ($netsettings{'RED_TYPE'} ne 'PPPOE') { |
323c9327 | 427 | $errormessage = $Lang::tr{'dialup red not ppp'}; |
330345c2 | 428 | &Header::openbox('100%', 'center', $Lang::tr{'error messages'}); |
323c9327 | 429 | print "<CLASS name='base'>$errormessage\n"; |
197f8d43 MT |
430 | print " </CLASS>\n"; |
431 | &Header::closebox(); | |
432 | &Header::closebigbox(); | |
433 | ||
434 | &Header::closepage(); | |
435 | exit(1); | |
436 | } | |
437 | ||
438 | if ($errormessage) { | |
439 | &Header::openbox('100%', 'center', $Lang::tr{'error messages'}); | |
440 | print "<CLASS name='base'>$errormessage\n"; | |
441 | print " </CLASS>\n"; | |
442 | &Header::closebox(); | |
ac1cfefa MT |
443 | } |
444 | ||
445 | ||
446 | ### | |
447 | ### Box for selecting profile | |
448 | ### | |
449 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
330345c2 | 450 | &Header::openbox('100%', 'center', $Lang::tr{'profile'}); |
ac1cfefa | 451 | print <<END |
330345c2 | 452 | <table width='95%' cellspacing='0'> |
ac1cfefa | 453 | <tr> |
197f8d43 MT |
454 | <td align='left'>$Lang::tr{'profile'}</td> |
455 | <td align='left'> | |
456 | <select name='PROFILE' style="width: 165px"> | |
ac1cfefa MT |
457 | END |
458 | ; | |
459 | for ($c = 1; $c <= $maxprofiles; $c++) | |
460 | { | |
197f8d43 | 461 | print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; |
ac1cfefa MT |
462 | } |
463 | print <<END | |
197f8d43 MT |
464 | </select></td> |
465 | <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td> | |
466 | <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td> | |
467 | <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td> | |
ac1cfefa MT |
468 | </tr> |
469 | </table> | |
330345c2 MT |
470 | <br></br> |
471 | <hr></hr> | |
ac1cfefa MT |
472 | END |
473 | ; | |
330345c2 | 474 | |
ac1cfefa | 475 | &Header::closebox(); |
330345c2 MT |
476 | &Header::openbox('100%', 'center', $Lang::tr{'connection'}); |
477 | ||
ac1cfefa | 478 | print <<END |
330345c2 | 479 | <table width='95%' cellspacing='0'> |
ac1cfefa | 480 | <tr> |
197f8d43 MT |
481 | <td width='25%'>$Lang::tr{'interface'}:</td> |
482 | <td width='25%'> | |
483 | <select name='TYPE' style="width: 165px"> | |
ac1cfefa MT |
484 | END |
485 | ; | |
ac1cfefa | 486 | if ($netsettings{'RED_TYPE'} eq 'PPPOE') { |
197f8d43 MT |
487 | print <<END |
488 | <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option> | |
489 | <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option> | |
490 | <option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option> | |
491 | END | |
492 | ; | |
493 | ||
a89770fa MT |
494 | my $atmdev=`cat /proc/net/atm/devices | grep 0`; |
495 | chomp ($atmdev); | |
496 | if ($atmdev ne '') { | |
197f8d43 MT |
497 | print <<END |
498 | <option value='pppoeatm' $selected{'TYPE'}{'pppoeatm'}>PPPoE over ATM-BRIDGE</option> | |
ac1cfefa MT |
499 | END |
500 | ; | |
501 | } | |
197f8d43 MT |
502 | } |
503 | #if ($netsettings{'RED_TYPE'} eq 'PPTP') {# | |
504 | # print "\t<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>\n"; | |
505 | #} | |
506 | # | |
a89770fa | 507 | #if (0) { |
197f8d43 MT |
508 | # print <<END |
509 | # <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option> | |
510 | # <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option> | |
511 | # <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option> | |
512 | # <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option> | |
513 | # <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option> | |
514 | # <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option> | |
515 | # <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option> | |
a89770fa MT |
516 | #END |
517 | #; | |
518 | #} | |
197f8d43 | 519 | # print "<option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>"; |
a89770fa | 520 | |
197f8d43 | 521 | print <<END |
a89770fa | 522 | </select></td> |
197f8d43 | 523 | <td colspan='1' width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}'></td> |
a89770fa MT |
524 | END |
525 | ; | |
197f8d43 MT |
526 | if ($pppsettings{'TYPE'} =~ /^(modem)$/) { |
527 | print <<END | |
528 | <td colspan='1' width='25%'><A HREF=modem.cgi>$Lang::tr{'modem configuration'}</A></td> | |
ac1cfefa MT |
529 | END |
530 | ; | |
ac1cfefa MT |
531 | } |
532 | ||
197f8d43 | 533 | print "</tr>"; |
a89770fa MT |
534 | |
535 | #if (-f "/proc/bus/usb/devices") { | |
197f8d43 MT |
536 | # <td colspan='2' width='50%'>USB:</td> |
537 | # my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`; | |
538 | # if ($usb eq '') { | |
539 | # print "\t<td colspan='2' width='50%'>$Lang::tr{'not running'}</td></tr>\n"; | |
540 | # } else { | |
541 | # print "\t<td colspan='2' width='50%'>$usb</td></tr>\n"; | |
542 | # } | |
a89770fa MT |
543 | #} |
544 | ||
ac1cfefa | 545 | if ($pppsettings{'TYPE'}) { |
197f8d43 | 546 | print "<tr><td colspan='4' width='100%'><br></br></td></tr>"; |
a89770fa | 547 | |
197f8d43 MT |
548 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/) { |
549 | print <<END | |
a89770fa | 550 | |
ac1cfefa | 551 | <tr> |
197f8d43 MT |
552 | <td colspan='3' width='75%'>$Lang::tr{'interface'}:</td> |
553 | <td width='25%'><select name='COMPORT' style="width: 165px"> | |
ac1cfefa MT |
554 | END |
555 | ; | |
197f8d43 MT |
556 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) { |
557 | print <<END | |
558 | <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>COM1</option> | |
559 | <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>COM2</option> | |
560 | <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>COM3</option> | |
561 | <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>COM4</option> | |
562 | <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>COM5</option> | |
ac6dd0a7 AF |
563 | <option value='ttyUSB0' $selected{'COMPORT'}{'ttyUSB0'}>ttyUSB0</option> |
564 | <option value='ttyUSB1' $selected{'COMPORT'}{'ttyUSB1'}>ttyUSB1</option> | |
565 | <option value='ttyUSB2' $selected{'COMPORT'}{'ttyUSB2'}>ttyUSB2</option> | |
566 | <option value='ttyUSB3' $selected{'COMPORT'}{'ttyUSB3'}>ttyUSB3</option> | |
d15b4ff7 CS |
567 | END |
568 | ; | |
197f8d43 MT |
569 | if ($pppsettings{'TYPE'} ne 'serial' ) { |
570 | print <<END | |
571 | <option value='ttyACM0' $selected{'COMPORT'}{'ttyACM0'}>$Lang::tr{'usb modem on acm0'}</option> | |
572 | <option value='ttyACM1' $selected{'COMPORT'}{'ttyACM1'}>$Lang::tr{'usb modem on acm1'}</option> | |
573 | <option value='ttyACM2' $selected{'COMPORT'}{'ttyACM2'}>$Lang::tr{'usb modem on acm2'}</option> | |
574 | <option value='ttyACM3' $selected{'COMPORT'}{'ttyACM3'}>$Lang::tr{'usb modem on acm3'}</option> | |
ac1cfefa | 575 | END |
ac1cfefa | 576 | ; |
197f8d43 MT |
577 | } |
578 | print "</select></td> "} | |
579 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) { | |
580 | print <<END | |
330345c2 MT |
581 | <tr> |
582 | <td colspan='3' width='75%'>$Lang::tr{'computer to modem rate'}</td> | |
197f8d43 MT |
583 | <td width='25%'><select name='DTERATE' style="width: 165px"> |
584 | <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option> | |
585 | <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option> | |
586 | <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option> | |
587 | <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option> | |
588 | <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option> | |
589 | <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option> | |
590 | <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option> | |
591 | <option value='921600' $selected{'DTERATE'}{'921600'}>921600</option> | |
592 | </select></td> | |
ac1cfefa MT |
593 | </tr> |
594 | END | |
595 | ; | |
197f8d43 MT |
596 | } |
597 | if ($pppsettings{'TYPE'} =~ /^(modem)$/ ) { | |
598 | print "<tr><td colspan='3' width='75%'>$Lang::tr{'number'}</td>\n"; | |
599 | print "<td width='25%'><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}'></td><tr>\n"; | |
600 | if ($pppsettings{'TYPE'} eq 'modem' ) { | |
601 | print "<tr><td colspan='3' width='75%'>$Lang::tr{'modem speaker on'}</td>\n"; | |
602 | print "<td width='25%'><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n"; | |
603 | } | |
604 | } | |
605 | } | |
606 | if ($pppsettings{'TYPE'} eq 'modem') { | |
607 | print <<END | |
ac1cfefa | 608 | <tr> |
197f8d43 MT |
609 | <td colspan='3' width='75%'>$Lang::tr{'dialing mode'}</td> |
610 | <td width='25%'><select name='DIALMODE' style="width: 165px"> | |
611 | <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option> | |
612 | <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option> | |
613 | </select></td> | |
330345c2 MT |
614 | </tr> |
615 | <tr> | |
616 | <td colspan='3' width='75%'>$Lang::tr{'send cr'}</td> | |
197f8d43 | 617 | <td width='50%'><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td> |
ac1cfefa MT |
618 | </tr> |
619 | END | |
620 | ; | |
621 | } | |
622 | ||
623 | print <<END | |
624 | <tr> | |
197f8d43 MT |
625 | <td colspan='3' width='75%'>$Lang::tr{'idle timeout'}</td> |
626 | <td width='25%'><input type='text' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td> | |
ac1cfefa | 627 | </tr> |
330345c2 MT |
628 | <tr> |
629 | <td colspan='3' width='75%'>$Lang::tr{'connection debugging'}:</td> | |
197f8d43 | 630 | <td width='25%'><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td> |
330345c2 MT |
631 | </tr> |
632 | <tr> | |
633 | <td colspan='4' width='100%'><br></br></td></tr> | |
ac1cfefa | 634 | <tr> |
197f8d43 | 635 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'reconnection'}:</b></td> |
ac1cfefa | 636 | </tr> |
330345c2 | 637 | <tr> |
197f8d43 | 638 | <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'}>$Lang::tr{'dod'}</td> |
330345c2 | 639 | </tr> |
ac1cfefa MT |
640 | END |
641 | ; | |
642 | if ($pppsettings{'TYPE'} ne 'isdn') { | |
643 | print <<END | |
330345c2 | 644 | <tr> |
197f8d43 | 645 | <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'}>$Lang::tr{'persistent'}</td> |
330345c2 MT |
646 | </tr> |
647 | <tr> | |
648 | <td colspan='3' width='75%'>$Lang::tr{'backupprofile'}:</td> | |
197f8d43 | 649 | <td width='25%'><select name='BACKUPPROFILE' style="width: 165px"> |
ac1cfefa MT |
650 | END |
651 | ; | |
197f8d43 MT |
652 | for ($c = 1; $c <= $maxprofiles; $c++) { |
653 | print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; | |
654 | } | |
655 | print <<END | |
656 | </select></td> | |
ac1cfefa MT |
657 | </tr> |
658 | END | |
659 | ; | |
660 | } | |
661 | print <<END | |
330345c2 | 662 | <tr> |
197f8d43 | 663 | <td colspan='3' width='75%'>$Lang::tr{'dod for dns'}</td> |
330345c2 MT |
664 | <td width='25%'><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td> |
665 | </tr> | |
ac1cfefa | 666 | <tr> |
197f8d43 MT |
667 | <td colspan='3' width='75%'>$Lang::tr{'holdoff'}:</td> |
668 | <td width='25%'><input type='text' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td> | |
ac1cfefa MT |
669 | </tr> |
670 | <tr> | |
197f8d43 MT |
671 | <td colspan='3' width='75%'>$Lang::tr{'maximum retries'}</td> |
672 | <td width='25%'><input type='text' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td> | |
ac1cfefa MT |
673 | </tr> |
674 | END | |
675 | ; | |
676 | ||
ac1cfefa MT |
677 | if ($pppsettings{'TYPE'} eq 'pptp') |
678 | { | |
679 | print <<END | |
330345c2 | 680 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 681 | <tr> |
197f8d43 | 682 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pptp settings'}</b></td> |
ac1cfefa MT |
683 | </tr> |
684 | <tr> | |
197f8d43 MT |
685 | <td width='25%'>$Lang::tr{'phonebook entry'}</td> |
686 | <td colspan='2' width='50%'></td> | |
687 | <td width='25%'><input type='text' name='PHONEBOOK' value='$pppsettings{'PHONEBOOK'}' /></td> | |
ac1cfefa MT |
688 | </tr> |
689 | <tr> | |
197f8d43 MT |
690 | <td width='25%'><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td> |
691 | <td colspan='2' width='50%'>$Lang::tr{'router ip'}</td> | |
692 | <td width='25%'><input type='text' name='ROUTERIP' value='$pppsettings{'ROUTERIP'}' /></td> | |
ac1cfefa MT |
693 | </tr> |
694 | <tr> | |
197f8d43 MT |
695 | <td width='25%'><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td> |
696 | <td colspan='2' width='50%'>$Lang::tr{'hostname'}: <img src='/blob.gif' alt='*' /></td> | |
697 | <td width='25%'><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td> | |
ac1cfefa MT |
698 | </tr> |
699 | END | |
700 | ; | |
701 | } | |
a89770fa MT |
702 | if ($pppsettings{'TYPE'} =~ /^(pppoeatm)$/) |
703 | { | |
704 | ||
705 | print <<END | |
a89770fa | 706 | <tr> |
197f8d43 | 707 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'adsl settings'}:</b></td> |
a89770fa MT |
708 | <tr> |
709 | ||
197f8d43 MT |
710 | <td> $Lang::tr{'encapsulation'}:</td> |
711 | <td colspan='2' width='30%'> | |
712 | <select name='ENCAP'> | |
713 | <option value='0' $selected{'ENCAP'}{'0'}>LLC</option> | |
714 | <option value='1' $selected{'ENCAP'}{'1'}>VCmux</option> | |
715 | </select> | |
716 | </td> | |
a89770fa MT |
717 | </tr> |
718 | <tr> | |
719 | ||
197f8d43 MT |
720 | <td nowrap='nowrap'>$Lang::tr{'vpi number'}</td> |
721 | <td><input type='text' size='5' name='VPI' value='$pppsettings{'VPI'}' /></td> | |
722 | <td align='right'>$Lang::tr{'vci number'}</td> | |
723 | <td colspan='2'><input type='text' size='5' name='VCI' value='$pppsettings{'VCI'}' /></td> | |
a89770fa MT |
724 | </tr> |
725 | END | |
726 | ; | |
727 | } | |
728 | ||
729 | ||
730 | if ($pppsettings{'TYPE'} eq 'pppoe' || $pppsettings{'TYPE'} eq 'pppoeatm') | |
ac1cfefa MT |
731 | { |
732 | print <<END | |
330345c2 | 733 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 734 | <tr> |
197f8d43 | 735 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pppoe settings'}</b></td> |
ac1cfefa MT |
736 | </tr> |
737 | <tr> | |
197f8d43 MT |
738 | <td width='25%'><input type='radio' name='METHOD' value='PPPOE_PLUGIN' $checked{'METHOD'}{'PPPOE_PLUGIN'} />PPPoE plugin</td> |
739 | <td colspan='2' width='50%'>$Lang::tr{'service name'} <img src='/blob.gif' alt='*' /></td> | |
740 | <td width='25%'><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td> | |
ac1cfefa MT |
741 | </tr> |
742 | <tr> | |
197f8d43 MT |
743 | <td width='25%'><input type='radio' name='METHOD' value='PPPOE' $checked{'METHOD'}{'PPPOE'} />$Lang::tr{'pppoe'}</td> |
744 | <td colspan='2' width='50%'>$Lang::tr{'concentrator name'} <img src='/blob.gif' alt='*' /></td> | |
745 | <td width='25%'><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td> | |
ac1cfefa | 746 | </tr> |
2ed35f39 | 747 | <tr> |
197f8d43 MT |
748 | <td width='25%'>MTU</td> |
749 | <td colspan='2' width='50%'></td> | |
750 | <td width='25%'><input type='text' name='MTU' value='$pppsettings{'MTU'}' /></td> | |
2ed35f39 | 751 | </tr> |
ac1cfefa MT |
752 | END |
753 | ; | |
754 | } | |
755 | ||
ac1cfefa | 756 | print <<END |
330345c2 | 757 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 758 | <tr> |
197f8d43 | 759 | <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>$Lang::tr{'authentication'}</b></td> |
ac1cfefa MT |
760 | </tr> |
761 | <tr> | |
197f8d43 MT |
762 | <td width='25%'>$Lang::tr{'username'}</td> |
763 | <td width='25%'><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td> | |
764 | <td width='25%'>$Lang::tr{'password'}</td> | |
765 | <td width='25%'><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td> | |
ac1cfefa MT |
766 | </tr> |
767 | <tr> | |
197f8d43 MT |
768 | <td width='25%'>$Lang::tr{'method'}</td> |
769 | <td width='25%'><select name='AUTH' style="width: 165px"> | |
770 | <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option> | |
771 | <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option> | |
772 | <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option> | |
ac1cfefa MT |
773 | END |
774 | ; | |
775 | if ($pppsettings{'TYPE'} eq 'modem') { | |
776 | print <<END | |
197f8d43 MT |
777 | <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option> |
778 | <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'demon login script'}</option> | |
779 | <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option> | |
ac1cfefa MT |
780 | END |
781 | ; | |
782 | } | |
783 | print <<END | |
197f8d43 MT |
784 | </select></td> |
785 | <td width='25%'>$Lang::tr{'script name'} <img src='/blob.gif' alt='*' /></td> | |
786 | <td width='25%'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td> | |
ac1cfefa | 787 | </tr> |
330345c2 | 788 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 789 | <tr> |
197f8d43 | 790 | <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>DNS:</b></td> |
ac1cfefa MT |
791 | </tr> |
792 | <tr> | |
197f8d43 | 793 | <td colspan='4' width='100%'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td> |
ac1cfefa MT |
794 | </tr> |
795 | <tr> | |
197f8d43 | 796 | <td colspan='4' width='100%'><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td> |
ac1cfefa MT |
797 | </tr> |
798 | <tr> | |
197f8d43 MT |
799 | <td width='25%'>$Lang::tr{'primary dns'}</td> |
800 | <td width='25%'><input type='text' name='DNS1' value='$pppsettings{'DNS1'}'></td> | |
801 | <td width='25%'>$Lang::tr{'secondary dns'}</td> | |
802 | <td width='25%'><input type='text' name='DNS2' value='$pppsettings{'DNS2'}'></td> | |
ac1cfefa | 803 | </tr> |
330345c2 | 804 | <tr><td colspan='4' width='100%'><br></br><hr></hr><br></br></td></tr> |
ac1cfefa | 805 | <tr> |
197f8d43 MT |
806 | <td width='25%'>$Lang::tr{'profile name'}</td> |
807 | <td width='25%'><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}'> | |
808 | <td colspan='2' width='50%'></td> | |
ac1cfefa MT |
809 | </tr> |
810 | <tr> | |
330345c2 | 811 | <td align='center' colspan='4' width='100%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td> |
ac1cfefa MT |
812 | </tr> |
813 | <tr> | |
197f8d43 MT |
814 | <td colspan='2' width='50%'>$Lang::tr{'legend'}:</td> |
815 | <td colspan='2' width='50%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td> | |
ac1cfefa MT |
816 | </tr> |
817 | </table> | |
818 | END | |
819 | ; | |
820 | &Header::closebox(); | |
821 | } | |
822 | ||
823 | print "</form>\n"; | |
824 | ||
825 | &Header::closebigbox(); | |
826 | ||
827 | &Header::closepage(); | |
828 | ||
829 | sub updatesettings | |
830 | { | |
197f8d43 MT |
831 | # make a link from the selected profile to the "default" one. |
832 | unlink("${General::swroot}/ppp/settings"); | |
833 | link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
834 | "${General::swroot}/ppp/settings"); | |
835 | system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings"); | |
ac1cfefa MT |
836 | } |
837 | ||
838 | sub writesecrets | |
839 | { | |
197f8d43 MT |
840 | # write secrets file. |
841 | open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; | |
842 | flock(FILE, 2); | |
843 | my $username = $pppsettings{'USERNAME'}; | |
844 | my $password = $pppsettings{'PASSWORD'}; | |
845 | print FILE "'$username' * '$password'\n"; | |
846 | chmod 0600, "${General::swroot}/ppp/secrets"; | |
847 | close FILE; | |
ac1cfefa MT |
848 | } |
849 | ||
850 | sub initprofile | |
851 | { | |
197f8d43 MT |
852 | $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'}; |
853 | $pppsettings{'COMPORT'} = 'ttyS0'; | |
854 | $pppsettings{'DTERATE'} = 115200; | |
855 | $pppsettings{'SPEAKER'} = 'off'; | |
856 | $pppsettings{'RECONNECTION'} = 'persistent'; | |
857 | $pppsettings{'DIALONDEMANDDNS'} = 'off'; | |
858 | $pppsettings{'AUTOCONNECT'} = 'on'; | |
859 | $pppsettings{'SENDCR'} = 'off'; | |
860 | $pppsettings{'USEIBOD'} = 'off'; | |
861 | $pppsettings{'USEDOV'} = 'off'; | |
862 | $pppsettings{'MODEM'} = 'PCIST'; | |
863 | $pppsettings{'LINE'} = 'WO'; | |
864 | $pppsettings{'ENCAP'} = '0'; | |
865 | $pppsettings{'VPI'} = '1'; | |
866 | $pppsettings{'VCI'} = '32'; | |
867 | $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1'; | |
868 | $pppsettings{'PROTOCOL'} = 'RFC2364'; | |
869 | $pppsettings{'METHOD'} = 'PPPOE_PLUGIN'; | |
870 | if ( $pppsettings{'METHOD'} eq 'PPPOE_PLUGIN' ) { | |
871 | $pppsettings{'MTU'} = '1492'; | |
872 | $pppsettings{'MRU'} = '1492'; | |
285c5bbd | 873 | } else { |
197f8d43 MT |
874 | $pppsettings{'MTU'} = '1452'; |
875 | $pppsettings{'MRU'} = '1452'; | |
f515baeb | 876 | } |
197f8d43 MT |
877 | $pppsettings{'DIALMODE'} = 'T'; |
878 | $pppsettings{'MAXRETRIES'} = 5; | |
879 | $pppsettings{'HOLDOFF'} = 30; | |
880 | $pppsettings{'TIMEOUT'} = 15; | |
881 | $pppsettings{'MODULATION'} = 'AUTO'; | |
882 | $pppsettings{'AUTH'} = 'pap-or-chap'; | |
883 | $pppsettings{'DNS'} = 'Automatic'; | |
884 | $pppsettings{'DEBUG'} = 'off'; | |
885 | $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'}; | |
886 | ||
887 | # Get PPPoE settings so we can see if PPPoE is enabled or not. | |
888 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
889 | ||
890 | # empty profile partial pre-initialization | |
891 | if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/) { | |
892 | $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'}); | |
893 | } else { | |
894 | $pppsettings{'TYPE'}='modem'; | |
895 | } | |
ac1cfefa MT |
896 | } |
897 |