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