Hinzugefuegt:
[ipfire-2.x.git] / html / cgi-bin / pppsetup.cgi
1 #!/usr/bin/perl
2 #
3 # SmoothWall CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The SmoothWall Team
8 #
9
10 use strict;
11
12 # enable only the following on debugging purpose
13 #use warnings;
14 #use CGI::Carp 'fatalsToBrowser';
15
16 require '/var/ipfire/general-functions.pl';
17 require "${General::swroot}/lang.pl";
18 require "${General::swroot}/header.pl";
19
20 our %pppsettings=();
21 my %temppppsettings=();
22 our %modemsettings=();
23 our %isdnsettings=();
24 our %netsettings=();
25 my %selected=();
26 my %checked=();
27 my @profilenames=();
28 my $errormessage = '';
29 my $maxprofiles = 5;
30 my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
31
32 &Header::showhttpheaders();
33
34 $pppsettings{'ACTION'} = '';
35 &initprofile();
36 &Header::getcgihash(\%pppsettings);
37
38 if ($pppsettings{'ACTION'} ne '' &&
39 (-e '/var/run/ppp-ipcop.pid' || -e "${General::swroot}/red/active"))
40 {
41 $errormessage = $Lang::tr{'unable to alter profiles while red is active'};
42 # read in the current vars
43 %pppsettings = ();
44 $pppsettings{'VALID'} = '';
45 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
46 }
47 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'})
48 {
49 unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) {
50 $errormessage = $Lang::tr{'invalid input'};
51 goto ERROR; }
52 my $type = $pppsettings{'TYPE'};
53 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
54 $pppsettings{'TYPE'} = $type;
55 }
56 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'})
57 {
58 if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|usb\/ttyACM0|usb\/ttyACM1|usb\/ttyACM2|usb\/ttyACM3|isdn1|isdn2)$/) {
59 $errormessage = $Lang::tr{'invalid input'};
60 goto ERROR; }
61 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800)$/) {
62 $errormessage = $Lang::tr{'invalid input'};
63 goto ERROR; }
64 if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) {
65 $errormessage = $Lang::tr{'invalid input'};
66 goto ERROR; }
67 if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) {
68 $errormessage = $Lang::tr{'invalid input'};
69 goto ERROR;
70 }
71
72 if ($pppsettings{'PROFILENAME'} eq '') {
73 $errormessage = $Lang::tr{'profile name not given'};
74 $pppsettings{'PROFILENAME'} = '';
75 goto ERROR; }
76 if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) {
77 if ($pppsettings{'TELEPHONE'} eq '') {
78 $errormessage = $Lang::tr{'telephone not set'};
79 goto ERROR; }
80 if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) {
81 $errormessage = $Lang::tr{'bad characters in the telephone number field'};
82 goto ERROR; }
83 }
84 unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) {
85 if ($pppsettings{'USERNAME'} eq '') {
86 $errormessage = $Lang::tr{'username not set'};
87 goto ERROR; }
88 if ($pppsettings{'PASSWORD'} eq '') {
89 $errormessage = $Lang::tr{'password not set'};
90 goto ERROR; }
91 }
92
93 if ($pppsettings{'TIMEOUT'} eq '') {
94 $errormessage = $Lang::tr{'idle timeout not set'};
95 goto ERROR; }
96 if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) {
97 $errormessage = $Lang::tr{'only digits allowed in the idle timeout'};
98 goto ERROR; }
99
100 if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) {
101 $errormessage = $Lang::tr{'bad characters in script field'};
102 goto ERROR; }
103
104 if ($pppsettings{'DNS1'})
105 {
106 if (!(&General::validip($pppsettings{'DNS1'}))) {
107 $errormessage = $Lang::tr{'invalid primary dns'};
108 goto ERROR; }
109 }
110 if ($pppsettings{'DNS2'})
111 {
112 if (!(&General::validip($pppsettings{'DNS2'}))) {
113 $errormessage = $Lang::tr{'invalid secondary dns'};
114 goto ERROR; }
115 }
116
117 if ($pppsettings{'MAXRETRIES'} eq '') {
118 $errormessage = $Lang::tr{'max retries not set'};
119 goto ERROR; }
120 if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) {
121 $errormessage = $Lang::tr{'only digits allowed in max retries field'};
122 goto ERROR; }
123
124 if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) {
125 $errormessage = $Lang::tr{'only digits allowed in holdoff field'};
126 goto ERROR; }
127
128 my $drivererror = 0;
129 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) {
130 my $modem = '';
131 my $speedtouch = &Header::speedtouchversion;
132 if ($speedtouch >=0 && $speedtouch <=4) {
133 if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; }
134 $pppsettings{'MODEM'} = $modem;
135 } else {
136 $modem='v0123';
137 $errormessage ="$Lang::tr{'unknown'} Rev $speedtouch";
138 goto ERROR;
139 }
140 if (! -e "${General::swroot}/alcatelusb/firmware.$modem.bin") {
141 $errormessage = $Lang::tr{'no alcatelusb firmware'};
142 $drivererror = 1;
143 goto ERROR;
144 }
145 }
146
147 if($pppsettings{'TYPE'} eq 'eciadsl' && (!(-e "${General::swroot}/eciadsl/synch.bin"))) {
148 $errormessage = $Lang::tr{'no eciadsl synch.bin file'};
149 $drivererror = 1;
150 goto ERROR; }
151
152 if($pppsettings{'TYPE'} eq 'fritzdsl' && (!(-e "/lib/modules/$kernel/misc/fcdslusb.o.gz"))) {
153 $errormessage = $Lang::tr{'no fritzdsl driver'};
154 $drivererror = 1;
155 goto ERROR; }
156
157 if( $pppsettings{'USEIBOD'} eq 'on' && $pppsettings{'COMPORT'} eq 'isdn1') {
158 $errormessage = $Lang::tr{'ibod for dual isdn only'};
159 goto ERROR; }
160
161 if ($pppsettings{'TYPE'} eq 'pptp') {
162 $errormessage = '';
163 if ($pppsettings{'METHOD'} eq 'STATIC') {
164 if (! &General::validip($pppsettings{'ROUTERIP'})) {
165 $errormessage = $Lang::tr{'router ip'}.' '.$Lang::tr{'invalid ip'};
166 }
167 } else {
168 if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) ) {
169 $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.' '.$Lang::tr{'invalid hostname'};
170 }
171 }
172 if ($errormessage ne '') {goto ERROR; }
173 }
174
175 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) {
176 if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) {
177 $errormessage = $Lang::tr{'invalid vpi vpci'};
178 goto ERROR; }
179 if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) {
180 $errormessage = $Lang::tr{'invalid vpi vpci'};
181 goto ERROR; }
182 if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) {
183 $errormessage = $Lang::tr{'invalid vpi vpci'};
184 goto ERROR; }
185 if ( $pppsettings{'PROTOCOL'} eq '' ) {
186 $errormessage = $Lang::tr{'invalid input'};
187 goto ERROR; }
188 }
189
190 if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \
191 ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) {
192 $errormessage = $Lang::tr{'invalid input'};
193 goto ERROR; }
194
195 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) {
196 if ($pppsettings{'DHCP_HOSTNAME'} ne '') {
197 if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) {
198 $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; }
199 }
200 }
201
202 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) {
203 $errormessage = '';
204 if (! &General::validip($pppsettings{'IP'})) {
205 $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; }
206 if (! &General::validip($pppsettings{'GATEWAY'})) {
207 $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; }
208 if (! &General::validmask($pppsettings{'NETMASK'})) {
209 $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; }
210 if ($pppsettings{'BROADCAST'} ne '') {
211 if (! &General::validip($pppsettings{'BROADCAST'})) {
212 $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; }
213 }
214 if( $pppsettings{'DNS'} eq 'Automatic') {
215 $errormessage = $Lang::tr{'invalid input'}; }
216 if ($errormessage ne '') {goto ERROR; }
217 }
218
219 if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \
220 $pppsettings{'RECONNECTION'} eq 'dialondemand' ) {
221 $errormessage = $Lang::tr{'invalid input'};
222 goto ERROR; }
223
224 if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) {
225 $errormessage = $Lang::tr{'dod not compatible with ddns'};
226 goto ERROR; }
227
228 if ( ($pppsettings{'TYPE'} =~ /^(bewanadsl)$/) && $pppsettings{'MODEM'} eq '') {
229 $errormessage = $Lang::tr{'no modem selected'};
230 goto ERROR; }
231
232 if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
233 $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; }
234 if( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
235 $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; }
236 delete $pppsettings{'ENCAP_RFC1483'};
237 delete $pppsettings{'ENCAP_RFC2364'};
238
239 ERROR:
240 if ($errormessage) {
241 $pppsettings{'VALID'} = 'no'; }
242 else {
243 $pppsettings{'VALID'} = 'yes'; }
244
245 # write cgi vars to the file.
246 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
247 \%pppsettings);
248
249 # make link and write secret file.
250 &updatesettings();
251 &writesecrets();
252
253 &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}");
254 if ($drivererror) {
255 my $refresh = "<META HTTP-EQUIV='refresh' CONTENT='1; URL=/cgi-bin/upload.cgi'>";
256 my $title = $Lang::tr{'upload'};
257 &Header::openpage($title, 0, $refresh);
258 }
259 }
260 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'select'})
261 {
262 my $profile = $pppsettings{'PROFILE'};
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 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
276 \%pppsettings);
277
278 &writesecrets();
279
280 &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}");
281 }
282 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'})
283 {
284 &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}");
285
286 my $profile = $pppsettings{'PROFILE'};
287 truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0);
288
289 %temppppsettings = ();
290 $temppppsettings{'PROFILE'} = '';
291 &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
292 \%temppppsettings);
293
294 # make link.
295 &updatesettings();
296
297 # read in the new params "early" so we can write secrets.
298 %pppsettings = ();
299 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
300 $pppsettings{'PROFILE'} = $profile;
301 &initprofile;
302 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
303 \%pppsettings);
304 }
305 else
306 {
307 # read in the current vars
308 %pppsettings = ();
309 $pppsettings{'VALID'} = '';
310 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
311 }
312
313 # read in the profile names into @profilenames.
314 my $c=0;
315 for ($c = 1; $c <= $maxprofiles; $c++)
316 {
317 %temppppsettings = ();
318 $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty profile'};
319 &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings);
320 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
321 }
322
323 if ($pppsettings{'VALID'} eq '')
324 {
325 if ($pppsettings{'PROFILE'} eq '') {
326 $pppsettings{'PROFILE'} = '1';
327 &initprofile();
328 }
329 }
330 for ($c = 1; $c <= $maxprofiles; $c++) {
331 $selected{'PROFILE'}{$c} = ''; }
332 $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
333 for ($c = 1; $c <= $maxprofiles; $c++) {
334 $selected{'BACKUPPROFILE'}{$c} = ''; }
335 $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'";
336
337 $selected{'TYPE'}{'modem'} = '';
338 $selected{'TYPE'}{'serial'} = '';
339 $selected{'TYPE'}{'isdn'} = '';
340 $selected{'TYPE'}{'pppoe'} = '';
341 $selected{'TYPE'}{'pptp'} = '';
342 $selected{'TYPE'}{'alcatelusb'} = '';
343 $selected{'TYPE'}{'alcatelusbk'} = '';
344 $selected{'TYPE'}{'pulsardsl'} = '';
345 $selected{'TYPE'}{'eciadsl'} = '';
346 $selected{'TYPE'}{'fritzdsl'} = '';
347 $selected{'TYPE'}{'bewanadsl'} = '';
348 $selected{'TYPE'}{'eagleusbadsl'} = '';
349 $selected{'TYPE'}{'conexantusbadsl'} = '';
350 $selected{'TYPE'}{'conexantpciadsl'} = '';
351 $selected{'TYPE'}{'amedynusbadsl'} = '';
352 $selected{'TYPE'}{'3cp4218usbadsl'} = '';
353 $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'";
354
355 $checked{'DEBUG'}{'off'} = '';
356 $checked{'DEBUG'}{'on'} = '';
357 $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'";
358
359 $selected{'COMPORT'}{'ttyS0'} = '';
360 $selected{'COMPORT'}{'ttyS1'} = '';
361 $selected{'COMPORT'}{'ttyS2'} = '';
362 $selected{'COMPORT'}{'ttyS3'} = '';
363 $selected{'COMPORT'}{'ttyS4'} = '';
364 $selected{'COMPORT'}{'usb/ttyACM0'} = '';
365 $selected{'COMPORT'}{'usb/ttyACM1'} = '';
366 $selected{'COMPORT'}{'usb/ttyACM2'} = '';
367 $selected{'COMPORT'}{'usb/ttyACM3'} = '';
368 $selected{'COMPORT'}{'isdn1'} = '';
369 $selected{'COMPORT'}{'isdn2'} = '';
370 $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'";
371
372 $selected{'DTERATE'}{'9600'} = '';
373 $selected{'DTERATE'}{'19200'} = '';
374 $selected{'DTERATE'}{'38400'} = '';
375 $selected{'DTERATE'}{'57600'} = '';
376 $selected{'DTERATE'}{'115200'} = '';
377 $selected{'DTERATE'}{'230400'} = '';
378 $selected{'DTERATE'}{'460800'} = '';
379 $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'";
380
381 $checked{'SPEAKER'}{'off'} = '';
382 $checked{'SPEAKER'}{'on'} = '';
383 $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'";
384
385 $selected{'DIALMODE'}{'T'} = '';
386 $selected{'DIALMODE'}{'P'} = '';
387 $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'";
388
389 $checked{'RECONNECTION'}{'manual'} = '';
390 $checked{'RECONNECTION'}{'persistent'} = '';
391 $checked{'RECONNECTION'}{'dialondemand'} = '';
392 $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'";
393
394 $checked{'DIALONDEMANDDNS'}{'off'} = '';
395 $checked{'DIALONDEMANDDNS'}{'on'} = '';
396 $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'";
397
398 $checked{'AUTOCONNECT'}{'off'} = '';
399 $checked{'AUTOCONNECT'}{'on'} = '';
400 $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'";
401
402 $checked{'SENDCR'}{'off'} = '';
403 $checked{'SENDCR'}{'on'} = '';
404 $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'";
405 $checked{'USEDOV'}{'off'} = '';
406 $checked{'USEDOV'}{'on'} = '';
407 $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'";
408 $checked{'USEIBOD'}{'off'} = '';
409 $checked{'USEIBOD'}{'on'} = '';
410 $checked{'USEIBOD'}{$pppsettings{'USEIBOD'}} = "checked='checked'";
411
412 $checked{'MODEM'}{'PCIST'} = '';
413 $checked{'MODEM'}{'USB'} = '';
414 $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'";
415
416 $selected{'LINE'}{'WO'} = '';
417 $selected{'LINE'}{'ES'} = '';
418 $selected{'LINE'}{'ES03'} = '';
419 $selected{'LINE'}{'FR'} = '';
420 $selected{'LINE'}{'FR04'} = '';
421 $selected{'LINE'}{'FR10'} = '';
422 $selected{'LINE'}{'IT'} = '';
423 $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'";
424
425 $checked{'MODULATION'}{'GDMT'} = '';
426 $checked{'MODULATION'}{'ANSI'} = '';
427 $checked{'MODULATION'}{'GLITE'} = '';
428 $checked{'MODULATION'}{'AUTO'} = '';
429 $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'";
430
431 $checked{'PROTOCOL'}{'RFC1483'} = '';
432 $checked{'PROTOCOL'}{'RFC2364'} = '';
433 $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'";
434
435 $selected{'ENCAP'}{'0'} = '';
436 $selected{'ENCAP'}{'1'} = '';
437 $selected{'ENCAP'}{'2'} = '';
438 $selected{'ENCAP'}{'3'} = '';
439 $selected{'ENCAP'}{'4'} = '';
440 $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'";
441 $checked{'METHOD'}{'STATIC'} = '';
442 $checked{'METHOD'}{'PPPOE'} = '';
443 $checked{'METHOD'}{'PPPOE_PLUGIN'} = '';
444 $checked{'METHOD'}{'DHCP'} = '';
445 $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'";
446
447 $selected{'AUTH'}{'pap-or-chap'} = '';
448 $selected{'AUTH'}{'pap'} = '';
449 $selected{'AUTH'}{'chap'} = '';
450 $selected{'AUTH'}{'standard-login-script'} = '';
451 $selected{'AUTH'}{'demon-login-script'} = '';
452 $selected{'AUTH'}{'other-login-script'} = '';
453 $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'";
454
455 $checked{'DNS'}{'Automatic'} = '';
456 $checked{'DNS'}{'Manual'} = '';
457 $checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'";
458
459 &Header::openpage($Lang::tr{'ppp setup'}, 1, '');
460
461 &Header::openbigbox('100%', 'left', '', $errormessage);
462
463 if ($errormessage) {
464 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
465 print "<CLASS name='base'>$errormessage\n";
466 print "&nbsp;</CLASS>\n";
467 &Header::closebox();
468 }
469
470
471 ###
472 ### Box for selecting profile
473 ###
474 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
475 &Header::openbox('100%', 'left', $Lang::tr{'profiles'});
476 print <<END
477 <table width='100%'>
478 <tr>
479 <td align='right'>$Lang::tr{'profile'}:</td>
480 <td>
481 <select name='PROFILE'>
482 END
483 ;
484 for ($c = 1; $c <= $maxprofiles; $c++)
485 {
486 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
487 }
488 print <<END
489 </select></td>
490 <td><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td>
491 <td><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td>
492 <td width='30%'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td>
493 </tr>
494 </table>
495 END
496 ;
497 &Header::closebox();
498 &Header::openbox('100%', 'left', $Lang::tr{'connection'}.':');
499 print <<END
500 <table width='100%'>
501 <tr>
502 <td align='right'>$Lang::tr{'interface'}:</td>
503 <td>
504 <select name='TYPE'>
505 <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option>
506 <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option>
507 END
508 ;
509 if ($isdnsettings{'ENABLED'} eq 'on') {
510 print "\t<option value='isdn' $selected{'TYPE'}{'isdn'}>$Lang::tr{'isdn'}</option>\n";
511 }
512 if ($netsettings{'RED_TYPE'} eq 'PPPOE') {
513 print "\t<option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>\n";
514 }
515 if ($netsettings{'RED_TYPE'} eq 'PPTP') {
516 print "\t<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>\n";
517 }
518 if (-f "/proc/bus/usb/devices") {
519 print <<END
520 <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option>
521 <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option>
522 <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option>
523 <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option>
524 <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option>
525 <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option>
526 <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option>
527 END
528 ;
529 }
530 print <<END
531 <option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>
532 <option value='pulsardsl' $selected{'TYPE'}{'pulsardsl'}>Pulsar ADSL</option>
533 <option value='bewanadsl' $selected{'TYPE'}{'bewanadsl'}>Bewan ADSL PCI st/USB st</option>
534 <option value='conexantpciadsl' $selected{'TYPE'}{'conexantpciadsl'}>Conexant PCI ADSL</option>
535 </select></td>
536 <td width='50%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td>
537 </tr>
538 <tr>
539 <td align='right'>USB:</td>
540 END
541 ;
542 if (-f "/proc/bus/usb/devices") {
543 my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`;
544 if ($usb eq '') {
545 print "\t<td>$Lang::tr{'not running'}</td></tr>\n";
546 } else {
547 print "\t<td>$usb</td></tr>\n";
548 }
549 }
550
551 if ($pppsettings{'TYPE'}) {
552 print "</table><table width='100%'>";
553 if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/) {
554 print <<END
555 <tr>
556 <td align='right'>$Lang::tr{'interface'}:</td>
557 <td><select name='COMPORT'>
558 END
559 ;
560 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
561 print <<END
562 <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>$Lang::tr{'modem on com1'}</option>
563 <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>$Lang::tr{'modem on com2'}</option>
564 <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>$Lang::tr{'modem on com3'}</option>
565 <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>$Lang::tr{'modem on com4'}</option>
566 <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>$Lang::tr{'modem on com5'}</option>
567 <option value='usb/ttyACM0' $selected{'COMPORT'}{'usb/ttyACM0'}>$Lang::tr{'usb modem on acm0'}</option>
568 <option value='usb/ttyACM1' $selected{'COMPORT'}{'usb/ttyACM1'}>$Lang::tr{'usb modem on acm1'}</option>
569 <option value='usb/ttyACM2' $selected{'COMPORT'}{'usb/ttyACM2'}>$Lang::tr{'usb modem on acm2'}</option>
570 <option value='usb/ttyACM3' $selected{'COMPORT'}{'usb/ttyACM3'}>$Lang::tr{'usb modem on acm3'}</option>
571 </select></td>
572 END
573 ;
574 } elsif ($pppsettings{'TYPE'} eq 'isdn') {
575 print <<END
576 <option value='isdn1' $selected{'COMPORT'}{'isdn1'}>$Lang::tr{'isdn1'}</option>
577 <option value='isdn2' $selected{'COMPORT'}{'isdn2'}>$Lang::tr{'isdn2'}</option>
578 </select></td>
579 END
580 ;
581 }
582 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
583 print <<END
584 <td align='right'>$Lang::tr{'computer to modem rate'}</td>
585 <td><select name='DTERATE'>
586 <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option>
587 <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option>
588 <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option>
589 <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option>
590 <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option>
591 <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option>
592 <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option>
593 </select></td>
594 </tr>
595 END
596 ;
597 } else {
598 print "<td colspan='2'>&nbsp;</td></tr>\n";
599 }
600 if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/ ) {
601 print "<tr><td align='right'>$Lang::tr{'number'}</td>\n";
602 print "<td><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}' /></td>\n";
603 if ($pppsettings{'TYPE'} eq 'modem' ) {
604 print "<td align='right'>$Lang::tr{'modem speaker on'}</td>\n";
605 print "<td><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n";
606 } else {
607 print "<td colspan='2'>&nbsp;</td></tr>\n";
608 }
609 }
610 }
611 if ($pppsettings{'TYPE'} eq 'modem') {
612 print <<END
613 <tr>
614 <td align='right'>$Lang::tr{'dialing mode'}</td>
615 <td><select name='DIALMODE'>
616 <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option>
617 <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option>
618 </select></td>
619 <td align='right'>$Lang::tr{'send cr'}</td>
620 <td><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td>
621 </tr>
622 END
623 ;
624 }
625
626 print <<END
627 <tr>
628 <td align='right'>$Lang::tr{'idle timeout'}</td>
629 <td><input type='text' size='5' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td>
630 <td colspan='2'>&nbsp;</td>
631 </tr>
632 END
633 ;
634 if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && ( $netsettings{'RED_TYPE'} eq "DHCP" || $netsettings{'RED_TYPE'} eq "STATIC") ) {
635 $pppsettings{'AUTOCONNECT'} = 'on';
636 print "<tr><td align='right'>$Lang::tr{'connect on ipfire restart'}</td>\n";
637 print "<td><input type='checkbox' disabled='disabled' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'} /></td>\n";
638 } else {
639 print "<tr><td align='right'>$Lang::tr{'connect on ipfire restart'}</td>\n";
640 print "<td><input type='checkbox' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'} /></td>\n";
641 }
642 print <<END
643 <td align='right'>$Lang::tr{'connection debugging'}:</td>
644 <td><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td>
645 </tr>
646 <tr>
647 <td colspan='5'><br /><hr /><b>$Lang::tr{'reconnection'}:</b></td>
648 </tr>
649 <tr>
650 <td colspan='4'>
651 <input type='radio' name='RECONNECTION' value='manual' $checked{'RECONNECTION'}{'manual'} />$Lang::tr{'manual'}</td>
652 </tr>
653 END
654 ;
655 if ($pppsettings{'TYPE'} ne 'isdn') {
656 print <<END
657 <tr>
658 <td>
659 <input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'} />$Lang::tr{'persistent'}</td>
660 <td colspan='2' align='right'>$Lang::tr{'backupprofile'}:</td>
661 <td>
662 <select name='BACKUPPROFILE'>
663 END
664 ;
665 for ($c = 1; $c <= $maxprofiles; $c++) {
666 print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
667 }
668 print <<END
669 </select></td>
670 </tr>
671 END
672 ;
673 }
674 print <<END
675 <tr>
676 <td>
677 <input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'} />$Lang::tr{'dod'}</td>
678 <td colspan='2' align='right'>$Lang::tr{'dod for dns'}</td>
679 <td><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td>
680
681 </tr>
682 <tr>
683 <td align='right'>$Lang::tr{'holdoff'}:</td>
684 <td><input type='text' size='5' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td>
685 <td align='right'>$Lang::tr{'maximum retries'}</td>
686 <td><input type='text' size='5' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td>
687 </tr>
688 END
689 ;
690
691 if ($pppsettings{'TYPE'} eq 'isdn') {
692 print <<END
693 </table>
694 <table width='100%'>
695 <tr>
696 <td colspan='5'><br /><hr /><b>$Lang::tr{'isdn settings'}</b></td>
697 </tr>
698 <tr>
699 <td align='right'>$Lang::tr{'use ibod'}</td>
700 <td><input type='checkbox' name='USEIBOD' $checked{'USEIBOD'}{'on'} /></td>
701 <td align='right'>$Lang::tr{'use dov'}</td>
702 <td><input type='checkbox' name='USEDOV' $checked{'USEDOV'}{'on'} /></td>
703 </tr>
704 END
705 ;
706 }
707
708 if ($pppsettings{'TYPE'} eq 'pptp')
709 {
710 print <<END
711 </table>
712
713 <table width='100%'>
714 <tr>
715 <td colspan='5'><br /><hr /><b>$Lang::tr{'pptp settings'}</b></td>
716 </tr>
717 <tr>
718 <td colspan='2' align='right'>$Lang::tr{'phonebook entry'}</td>
719 <td><input type='text' name='PHONEBOOK' value='$pppsettings{'PHONEBOOK'}' /></td>
720 </tr>
721 <tr>
722 <td><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td>
723 <td align='right'>$Lang::tr{'router ip'}</td>
724 <td><input type='text' name='ROUTERIP' value='$pppsettings{'ROUTERIP'}' /></td>
725 </tr>
726 <tr>
727 <td>&nbsp;</td>
728 <td colspan='3'><hr /></td>
729 </tr>
730 <tr>
731 <td><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td>
732 <td align='right'>$Lang::tr{'hostname'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
733 <td><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td>
734 </tr>
735 END
736 ;
737 }
738 if ($pppsettings{'TYPE'} eq 'pppoe')
739 {
740 print <<END
741 </table>
742 <table width='100%'>
743 <tr>
744 <td colspan='5'><br /><hr /><b>$Lang::tr{'pppoe settings'}</b></td>
745 </tr>
746 END
747 ;
748 }
749 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/)
750 {
751
752 print <<END
753 </table>
754 <table width='100%'>
755 <tr>
756 <td colspan='5'><br /><hr /><b>$Lang::tr{'adsl settings'}:</b></td>
757 </tr>
758 <tr>
759 <td nowrap='nowrap' align='right'>$Lang::tr{'vpi number'}</td>
760 <td><input type='text' size='5' name='VPI' value='$pppsettings{'VPI'}' /></td>
761 <td align='right'>$Lang::tr{'vci number'}</td>
762 <td colspan='2'><input type='text' size='5' name='VCI' value='$pppsettings{'VCI'}' /></td>
763 </tr>
764 <tr>
765 <td>&nbsp;</td>
766 <td colspan='4'><hr /></td>
767 </tr>
768 END
769 ;
770 }
771 if ($pppsettings{'TYPE'} eq 'bewanadsl')
772 {
773 print <<END
774 <tr>
775 <td align='right'>$Lang::tr{'modem'}:</td>
776 <td colspan='2' nowrap='nowrap'>
777 <input type='radio' name='MODEM' value='PCIST' $checked{'MODEM'}{'PCIST'} />Bewan ADSL PCI st</td>
778 <td colspan='2'><input type='radio' name='MODEM' value='USB' $checked{'MODEM'}{'USB'} />Bewan ADSL USB st</td>
779 </tr>
780 <tr>
781 <td>&nbsp;</td>
782 <td colspan='4'><hr /></td>
783 </tr>
784 END
785 ;
786 }
787 if ($pppsettings{'TYPE'} =~ /^(3cp4218usbadsl|bewanadsl)$/)
788 {
789 print <<END
790 <tr>
791 <td align='right'>$Lang::tr{'modulation'}:</td>
792 <td><input type='radio' name='MODULATION' value='AUTO' $checked{'MODULATION'}{'AUTO'} />$Lang::tr{'automatic'}</td>
793 <td><input type='radio' name='MODULATION' value='ANSI' $checked{'MODULATION'}{'ANSI'} />ANSI T1.483</td>
794 <td><input type='radio' name='MODULATION' value='GDMT' $checked{'MODULATION'}{'GDMT'} />G.DMT</td>
795 <td><input type='radio' name='MODULATION' value='GLITE' $checked{'MODULATION'}{'GLITE'} />G.Lite</td>
796 </tr>
797 <tr>
798 <td>&nbsp;</td>
799 <td colspan='4'><hr /></td>
800 </tr>
801 END
802 ;
803 }
804
805 if ($pppsettings{'TYPE'} eq 'eagleusbadsl')
806 {
807 print <<END
808 <tr>
809 <td align='right'>$Lang::tr{'country'}:</td>
810 <td>
811 <select name='LINE'>
812 <option value='WO' $selected{'LINE'}{'WO'}>$Lang::tr{'other countries'}</option>
813 <option value='ES' $selected{'LINE'}{'ES'}>ESPANA</option>
814 <option value='ES03' $selected{'LINE'}{'ES03'}>ESPANA03</option>
815 <option value='FR' $selected{'LINE'}{'FR'}>FRANCE</option>
816 <option value='FR04' $selected{'LINE'}{'FR04'}>FRANCE04</option>
817 <option value='FR10' $selected{'LINE'}{'FR04'}>FRANCE10</option>
818 <option value='IT' $selected{'LINE'}{'IT'}>ITALIA</option>
819 </select></td>
820 </tr>
821 <tr>
822 <td>&nbsp;</td>
823 <td colspan='4'><hr /></td>
824 </tr>
825 END
826 ;
827 }
828 if ($pppsettings{'TYPE'} eq 'eciadsl')
829 {
830 print <<END
831 <tr>
832 <td align='right'>$Lang::tr{'modem'}:</td>
833 <td colspan='5'>
834 <select name='MODEM'>
835 END
836 ;
837 open (MODEMS, "/etc/eciadsl/modems.db") or die 'Unable to open modems database.';
838 while (my $line = <MODEMS>) {
839 $line =~ /^([\S\ ]+).*$/;
840 my $modem = $1;
841 $modem =~ s/^\s*(.*?)\s*$/$1/;
842 print "<option value='$modem'";
843 if ($pppsettings{'MODEM'} =~ /$modem/) { print " selected";}
844 print ">$modem</option>\n";
845 }
846 close (MODEMS);
847
848 print <<END
849 </select>
850 </td>
851 </tr>
852 <tr>
853 <td>&nbsp;</td>
854 <td colspan='4'><hr /></td>
855 </tr>
856 END
857 ;
858 }
859 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/)
860 {
861 print <<END
862 <tr>
863 <td valign='top' align='right'>$Lang::tr{'protocol'}:</td>
864 <td nowrap='nowrap'>
865 <input type='radio' name='PROTOCOL' value='RFC2364' $checked{'PROTOCOL'}{'RFC2364'} />RFC2364 PPPoA</td>
866 END
867 ;
868 }
869 if ($pppsettings{'TYPE'} eq 'alcatelusb')
870 {
871 print "<td colspan=3>&nbsp;</td></tr>";
872 }
873
874 if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/)
875 {
876 print <<END
877 <td align='right'>$Lang::tr{'encapsulation'}:</td>
878 <td colspan='2' width='30%'>
879 <select name='ENCAP_RFC2364'>
880 <option value='0' $selected{'ENCAP'}{'0'}>VCmux</option>
881 <option value='1' $selected{'ENCAP'}{'1'}>LLC</option>
882 </select>
883 </td>
884 </tr>
885 END
886 ;
887 }
888 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/)
889 {
890 print <<END
891 <tr>
892 <td>&nbsp;</td>
893 <td colspan='4'><hr /></td>
894 </tr>
895 <tr>
896 <td>&nbsp;</td>
897 <td valign='top'>
898 <input type='radio' name='PROTOCOL' value='RFC1483' $checked{'PROTOCOL'}{'RFC1483'} />RFC 1483 / 2684</td>
899 END
900 ;
901 }
902 if ($pppsettings{'TYPE'} eq 'alcatelusb')
903 {
904 print "<td colspan='3'>&nbsp;</td></tr>";
905 }
906
907 if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/)
908 {
909 if ($pppsettings{'TYPE'} ne 'fritzdsl')
910 {
911 print <<END
912 <td align='right'>$Lang::tr{'encapsulation'}:</td>
913 <td colspan='2'>
914 <select name='ENCAP_RFC1483'>
915 <option value='0' $selected{'ENCAP'}{'0'}>BRIDGED_ETH_LLC</option>
916 <option value='1' $selected{'ENCAP'}{'1'}>BRIDGED_ETH_VC</option>
917 <option value='2' $selected{'ENCAP'}{'2'}>ROUTED_IP_LLC</option>
918 <option value='3' $selected{'ENCAP'}{'3'}>ROUTED_IP_VC</option>
919 </select>
920 </td>
921 </tr>
922 <tr>
923 <td colspan='2'>&nbsp;</td>
924 <td colspan='3'><hr /></td>
925 </tr>
926 END
927 ;
928 } else {
929 print <<END
930 <td colspan='4'>PPPoE</td>
931 </tr>
932 END
933 ;
934 }
935 }
936 if ($pppsettings{'TYPE'} =~ /^(pppoe|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/)
937 {
938 print <<END
939 <tr>
940 <td>&nbsp;</td>
941 <td>&nbsp;</td>
942 <td><input type='radio' name='METHOD' value='PPPOE_PLUGIN' $checked{'METHOD'}{'PPPOE_PLUGIN'} />PPPoE plugin</td>
943 <td align='right'>$Lang::tr{'service name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
944 <td><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td>
945 </tr>
946 <tr>
947 <td>&nbsp;</td>
948 <td>&nbsp;</td>
949 <td><input type='radio' name='METHOD' value='PPPOE' $checked{'METHOD'}{'PPPOE'} />$Lang::tr{'pppoe'}</td>
950 <td align='right'>$Lang::tr{'concentrator name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
951 <td><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td>
952 </tr>
953
954 END
955 ;
956 }
957 if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/)
958 {
959 print <<END
960 <tr>
961 <td colspan='2'>&nbsp;</td>
962 <td colspan='3'><hr /></td>
963 </tr>
964 <tr>
965 <td>&nbsp;</td>
966 <td>&nbsp;</td>
967 <td rowspan='4'><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td>
968 <td align='right'>$Lang::tr{'static ip'}:</td>
969 <td><input type='text' size='16' name='IP' value='$pppsettings{'IP'}' /></td>
970 </tr>
971 <tr>
972 <td>&nbsp;</td>
973 <td>&nbsp;</td>
974 <td align='right'>$Lang::tr{'gateway ip'}:</td>
975 <td><input type='text' size='16' name='GATEWAY' value='$pppsettings{'GATEWAY'}' /></td>
976 </tr>
977 <tr>
978 <td>&nbsp;</td>
979 <td>&nbsp;</td>
980 <td align='right'>$Lang::tr{'netmask'}:</td>
981 <td><input type='text' size='16' name='NETMASK' value='$pppsettings{'NETMASK'}' /></td>
982 </tr>
983 <tr>
984 <td>&nbsp;</td>
985 <td>&nbsp;</td>
986 <td align='right' nowrap='nowrap'>$Lang::tr{'broadcast'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
987 <td><input type='text' size='16' name='BROADCAST' value='$pppsettings{'BROADCAST'}' /></td>
988 </tr>
989 END
990 ;
991 if ($pppsettings{'TYPE'} =~ /^(eciadsl|eagleusbadsl)$/)
992 {
993 print <<END
994 <tr>
995 <td colspan='2'>&nbsp;</td>
996 <td colspan='3'><hr /></td>
997 </tr>
998 <tr>
999 <td>&nbsp;</td>
1000 <td>&nbsp;</td>
1001 <td><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td>
1002 <td align='right'>$Lang::tr{'hostname'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1003 <td><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td>
1004 </tr>
1005 END
1006 ;
1007 }
1008 }
1009 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|eciadsl|fritzdsl)$/) {
1010 print "<tr><td>&nbsp;</td><td colspan='4'><hr /></td></tr>";
1011 }
1012 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) {
1013 my $speedtouch = &Header::speedtouchversion;
1014 if (($speedtouch >= 0) && ($speedtouch <=4)) {
1015 my $modem;
1016 if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; }
1017 print "<tr><td align='right'>$Lang::tr{'firmware'}:</td>";
1018 if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") {
1019 print "<td>$Lang::tr{'present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1020 } else {
1021 print "<td>$Lang::tr{'not present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1022 }
1023 } else {
1024 print "<tr><td colspan='5'>$Lang::tr{'unknown'} Rev $speedtouch</td></tr>";
1025 }
1026 } elsif ($pppsettings{'TYPE'} eq 'eciadsl') {
1027 print "<tr><td align='right'>$Lang::tr{'driver'}:</td>";
1028 if (-e "${General::swroot}/eciadsl/synch.bin") {
1029 print "<td>$Lang::tr{'present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1030 } else {
1031 print "<td>$Lang::tr{'not present'}</td><td colspan='3'>&nbsp;</td></tr>\n"; }
1032 } elsif ($pppsettings{'TYPE'} eq 'fritzdsl') {
1033 print "<tr><td align='right'>$Lang::tr{'driver'}:</td>";
1034 if (-e "/lib/modules/$kernel/misc/fcdslusb.o.gz") {
1035 print "<td>$Lang::tr{'present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1036 } else {
1037 print "<td>$Lang::tr{'not present'}</td><td colspan='3'>&nbsp;</td></tr>\n"; }
1038 }
1039 print <<END
1040 </table>
1041 <table width='100%'>
1042 <tr>
1043 <td colspan='5'><br /><hr /><b>$Lang::tr{'authentication'}</b></td>
1044 </tr>
1045 <tr>
1046 <td align='right'>$Lang::tr{'username'}</td>
1047 <td><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td>
1048 <td align='right'>$Lang::tr{'password'}</td>
1049 <td><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td>
1050 </tr>
1051 <tr>
1052 <td align='right'>$Lang::tr{'method'}</td>
1053 <td><select name='AUTH'>
1054 <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option>
1055 <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option>
1056 <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option>
1057 END
1058 ;
1059 if ($pppsettings{'TYPE'} eq 'modem') {
1060 print <<END
1061 <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option>
1062 <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'demon login script'}</option>
1063 <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option>
1064 END
1065 ;
1066 }
1067 print <<END
1068 </select></td>
1069 <td align='right'>$Lang::tr{'script name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1070 <td nowrap='nowrap'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td>
1071 </tr>
1072 </table>
1073 <table width='100%'>
1074 <tr>
1075 <td colspan='5'><br /><hr /><b>DNS:</b></td>
1076 </tr>
1077 <tr>
1078 <td colspan='5'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td>
1079 </tr>
1080 <tr>
1081 <td><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td>
1082 <td align='right'>$Lang::tr{'primary dns'}</td>
1083 <td><input type='text' size='16' name='DNS1' value='$pppsettings{'DNS1'}' /></td>
1084 <td align='right'>$Lang::tr{'secondary dns'}</td>
1085 <td><input type='text' size='16' name='DNS2' value='$pppsettings{'DNS2'}' /></td>
1086 </tr>
1087 <tr>
1088 <td colspan='5'><br /><hr /></td>
1089 </tr>
1090 <tr>
1091 <td>&nbsp;</td>
1092 <td align='right'>$Lang::tr{'profile name'}</td>
1093 <td><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}' /></td>
1094 <td><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
1095 </tr>
1096 <tr>
1097 <td colspan='5'><br /><hr /></td>
1098 </tr>
1099 <tr>
1100 <td align='right'>$Lang::tr{'legend'}:</td>
1101 <td><img src='/blob.gif' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
1102 </tr>
1103 </table>
1104 END
1105 ;
1106 &Header::closebox();
1107 }
1108
1109 print "</form>\n";
1110
1111 &Header::closebigbox();
1112
1113 &Header::closepage();
1114
1115 sub updatesettings
1116 {
1117 # make a link from the selected profile to the "default" one.
1118 unlink("${General::swroot}/ppp/settings");
1119 link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
1120 "${General::swroot}/ppp/settings");
1121 system ("/bin/touch", "${General::swroot}/ppp/updatesettings");
1122 if ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
1123 # eagle-usb.conf is in backup but link DSPcode.bin can't, so the link is created in rc.eagleusbadsl
1124 open(FILE, ">/${General::swroot}/eagle-usb/eagle-usb.conf") or die "Unable to write eagle-usb.conf file";
1125 flock(FILE, 2);
1126 # decimal to hexa
1127 $modemsettings{'VPI'} = uc(sprintf('%X', $pppsettings{'VPI'}));
1128 $modemsettings{'VCI'} = uc(sprintf('%X', $pppsettings{'VCI'}));
1129 if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
1130 $modemsettings{'Encapsulation'} =1+$pppsettings{'ENCAP'}
1131 } elsif ( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
1132 $modemsettings{'Encapsulation'} =6-$pppsettings{'ENCAP'}
1133 }
1134 print FILE "<eaglectrl>\n";
1135 print FILE "VPI=$modemsettings{'VPI'}\n";
1136 print FILE "VCI=$modemsettings{'VCI'}\n";
1137 print FILE "Encapsulation=$modemsettings{'Encapsulation'}\n";
1138 print FILE "Linetype=0A\n";
1139 print FILE "RatePollFreq=00000009\n";
1140 print FILE "</eaglectrl>\n";
1141 close FILE;
1142 }
1143 }
1144
1145 sub writesecrets
1146 {
1147 # write secrets file.
1148 open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
1149 flock(FILE, 2);
1150 my $username = $pppsettings{'USERNAME'};
1151 my $password = $pppsettings{'PASSWORD'};
1152 print FILE "'$username' * '$password'\n";
1153 chmod 0600, "${General::swroot}/ppp/secrets";
1154 close FILE;
1155 }
1156
1157 sub initprofile
1158 {
1159 $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'};
1160 $pppsettings{'COMPORT'} = 'ttyS0';
1161 $pppsettings{'DTERATE'} = 115200;
1162 $pppsettings{'SPEAKER'} = 'off';
1163 $pppsettings{'RECONNECTION'} = 'manual';
1164 $pppsettings{'DIALONDEMANDDNS'} = 'off';
1165 $pppsettings{'AUTOCONNECT'} = 'off';
1166 $pppsettings{'SENDCR'} = 'off';
1167 $pppsettings{'USEIBOD'} = 'off';
1168 $pppsettings{'USEDOV'} = 'off';
1169 $pppsettings{'MODEM'} = 'PCIST';
1170 $pppsettings{'LINE'} = 'WO';
1171 $pppsettings{'ENCAP'} = '0';
1172 $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1';
1173 $pppsettings{'PROTOCOL'} = 'RFC2364';
1174 $pppsettings{'METHOD'} = 'PPPOE_PLUGIN';
1175 $pppsettings{'DIALMODE'} = 'T';
1176 $pppsettings{'MAXRETRIES'} = 5;
1177 $pppsettings{'HOLDOFF'} = 30;
1178 $pppsettings{'TIMEOUT'} = 15;
1179 $pppsettings{'MODULATION'} = 'AUTO';
1180 $pppsettings{'AUTH'} = 'pap-or-chap';
1181 $pppsettings{'DNS'} = 'Automatic';
1182 $pppsettings{'DEBUG'} = 'off';
1183 $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'};
1184
1185 # Get ISDN settings so we can see if ISDN is enabled or not.
1186 $isdnsettings{'ENABLED'} = 'off';
1187 &General::readhash("${General::swroot}/isdn/settings", \%isdnsettings);
1188
1189 # Get PPPoE settings so we can see if PPPoE is enabled or not.
1190 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
1191
1192 # empty profile partial pre-initialization
1193 if ($netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/) {
1194 $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'});
1195 } elsif ($isdnsettings{'ENABLED'} eq 'on') {
1196 $pppsettings{'TYPE'}='isdn';
1197 } else {
1198 $pppsettings{'TYPE'}='modem';
1199 }
1200 }
1201