]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/pppsetup.cgi
d7e5799ec067af7372e94d496dc70eb1df13f4d2
[ipfire-2.x.git] / html / cgi-bin / pppsetup.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
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 ###############################################################################
21
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31
32 our %pppsettings=();
33 my %temppppsettings=();
34 our %modemsettings=();
35 our %netsettings=();
36 my %selected=();
37 my %checked=();
38 my @profilenames=();
39 my $errormessage = '';
40 my $maxprofiles = 5;
41
42 # This call is safe, because no user input will be processed.
43 my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
44
45 my %color = ();
46 my %mainsettings = ();
47 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
48 &General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
49
50 &Header::showhttpheaders();
51
52 $pppsettings{'ACTION'} = '';
53 &initprofile();
54 &Header::getcgihash(\%pppsettings);
55
56 if ($pppsettings{'ACTION'} ne '' &&
57 ( -e "${General::swroot}/red/active")){
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);}
63 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'})
64 {
65 unless ($pppsettings{'TYPE'} =~ /^(modem|serial|pppoe|pptp|vdsl|pppoeatm|pptpatm)$/) {
66 $errormessage = $Lang::tr{'invalid input'};
67 goto ERROR; }
68 my $type = $pppsettings{'TYPE'};
69 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
70 $pppsettings{'TYPE'} = $type;
71 }
72 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'})
73 {
74 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|ttyACM[0-9]|ttyUSB[0-9]|rfcomm0|rfcomm1)$/) {
75 $errormessage = $Lang::tr{'invalid input'};
76 goto ERROR; }
77 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'MONPORT'} !~ /^(|ttyACM[0-9]|ttyUSB[0-9]|rfcomm0|rfcomm1)$/) {
78 $errormessage = $Lang::tr{'invalid input'};
79 goto ERROR; }
80 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800|921600)$/) {
81 $errormessage = $Lang::tr{'invalid input'};
82 goto ERROR; }
83 if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) {
84 $errormessage = $Lang::tr{'invalid input'};
85 goto ERROR; }
86 if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) {
87 $errormessage = $Lang::tr{'invalid input'};
88 goto ERROR;
89 }
90
91 if ($pppsettings{'PROFILENAME'} eq '') {
92 $errormessage = $Lang::tr{'profile name not given'};
93 $pppsettings{'PROFILENAME'} = '';
94 goto ERROR; }
95 if ($pppsettings{'TYPE'} =~ /^(modem)$/) {
96 if ($pppsettings{'TELEPHONE'} eq '') {
97 $errormessage = $Lang::tr{'telephone not set'};
98 goto ERROR; }
99 if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) {
100 $errormessage = $Lang::tr{'bad characters in the telephone number field'};
101 goto ERROR; }
102 }
103 unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) {
104 if ($pppsettings{'USERNAME'} eq '') {
105 $errormessage = $Lang::tr{'username not set'};
106 goto ERROR; }
107 }
108
109 if ($pppsettings{'TIMEOUT'} eq '') {
110 $errormessage = $Lang::tr{'idle timeout not set'};
111 goto ERROR; }
112 if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) {
113 $errormessage = $Lang::tr{'only digits allowed in the idle timeout'};
114 goto ERROR; }
115
116 if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) {
117 $errormessage = $Lang::tr{'bad characters in script field'};
118 goto ERROR; }
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 if ($pppsettings{'TYPE'} =~ /^(pppoeatm|pptpatm)$/) {
132 if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) {
133 $errormessage = $Lang::tr{'invalid vpi vpci'};
134 goto ERROR; }
135 if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) {
136 $errormessage = $Lang::tr{'invalid vpi vpci'};
137 goto ERROR; }
138 if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) {
139 $errormessage = $Lang::tr{'invalid vpi vpci'};
140 goto ERROR; }
141 if ($pppsettings{'ATM_DEV'} eq '') {
142 $errormessage = $Lang::tr{'invalid input'};
143 goto ERROR; }
144 if ( $pppsettings{'PROTOCOL'} eq '' ) {
145 $errormessage = $Lang::tr{'invalid input'};
146 goto ERROR; }
147 }
148
149 if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \
150 ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) {
151 $errormessage = $Lang::tr{'invalid input'};
152 goto ERROR; }
153
154 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) {
155 if ($pppsettings{'DHCP_HOSTNAME'} ne '') {
156 if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) {
157 $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; }
158 }
159 }
160
161 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) {
162 $errormessage = '';
163 if (! &General::validip($pppsettings{'IP'})) {
164 $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; }
165 if (! &General::validip($pppsettings{'GATEWAY'})) {
166 $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; }
167 if (! &General::validmask($pppsettings{'NETMASK'})) {
168 $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; }
169 if ($pppsettings{'BROADCAST'} ne '') {
170 if (! &General::validip($pppsettings{'BROADCAST'})) {
171 $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; }
172 }
173 if ($errormessage ne '') {goto ERROR; }
174 }
175
176 if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \
177 $pppsettings{'RECONNECTION'} eq 'dialondemand' ) {
178 $errormessage = $Lang::tr{'invalid input'};
179 goto ERROR; }
180
181 # Read-in ddns config file, to check if at least one provider is enabled.
182 open(FILE, "${General::swroot}/ddns/config");
183 my @ddns_config = <FILE>;
184 close(FILE);
185
186 if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && grep(/on/, @ddns_config) ) {
187 $errormessage = $Lang::tr{'dod not compatible with ddns'};
188 goto ERROR; }
189
190 # if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
191 # $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; }
192 # if( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
193 # $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; }
194 delete $pppsettings{'ENCAP_RFC1483'};
195 delete $pppsettings{'ENCAP_RFC2364'};
196
197 if ((!($pppsettings{'INET_VLAN'} =~ /^\d+$/)) ||
198 ($pppsettings{'INET_VLAN'} eq '') ||
199 ($pppsettings{'INET_VLAN'} > 4095) ) {
200 $errormessage = 'INET_VLAN - '.$Lang::tr{'invalid input'}; }
201
202 if ((!($pppsettings{'IPTV_VLAN'} =~ /^\d+$/)) ||
203 ($pppsettings{'IPTV_VLAN'} eq '') ||
204 ($pppsettings{'IPTV_VLAN'} > 4095) ) {
205 $errormessage = 'IPTV_VLAN - '.$Lang::tr{'invalid input'}; }
206
207 ERROR:
208 if ($errormessage) {
209 $pppsettings{'VALID'} = 'no'; }
210 else {
211 $pppsettings{'VALID'} = 'yes'; }
212
213 # write cgi vars to the file.
214 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
215 \%pppsettings);
216
217 # make link and write secret file.
218 &updatesettings();
219 &writesecrets();
220
221 &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}");
222 }
223 if ($pppsettings{'ACTION'} eq $Lang::tr{'select'})
224 {
225 my $profile = $pppsettings{'PROFILE'};
226 %temppppsettings = ();
227 $temppppsettings{'PROFILE'} = '';
228 &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
229 \%temppppsettings);
230
231 # make link.
232 &updatesettings();
233
234 # read in the new params "early" so we can write secrets.
235 %pppsettings = ();
236 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
237 $pppsettings{'PROFILE'} = $profile;
238 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
239 \%pppsettings);
240
241 &writesecrets();
242
243 &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}");
244 }
245 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'})
246 {
247 &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}");
248
249 my $profile = $pppsettings{'PROFILE'};
250 truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0);
251
252 %temppppsettings = ();
253 $temppppsettings{'PROFILE'} = '';
254 &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
255 \%temppppsettings);
256
257 # make link.
258 &updatesettings();
259
260 # read in the new params "early" so we can write secrets.
261 %pppsettings = ();
262 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
263 $pppsettings{'PROFILE'} = $profile;
264 &initprofile;
265 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
266 \%pppsettings);
267 }
268 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'})
269 {
270 }
271 else
272 {
273 # read in the current vars
274 %pppsettings = ();
275 $pppsettings{'VALID'} = '';
276 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
277 }
278
279 # read in the profile names into @profilenames.
280 my $c=0;
281 for ($c = 1; $c <= $maxprofiles; $c++)
282 {
283 %temppppsettings = ();
284 $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty profile'};
285 &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings);
286 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
287 }
288
289 if ($pppsettings{'VALID'} eq '')
290 {
291 if ($pppsettings{'PROFILE'} eq '') {
292 $pppsettings{'PROFILE'} = '1';
293 &initprofile();
294 }
295 }
296 for ($c = 1; $c <= $maxprofiles; $c++) {
297 $selected{'PROFILE'}{$c} = ''; }
298 $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
299 for ($c = 1; $c <= $maxprofiles; $c++) {
300 $selected{'BACKUPPROFILE'}{$c} = ''; }
301 $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'";
302
303 $selected{'TYPE'}{'modem'} = '';
304 $selected{'TYPE'}{'serial'} = '';
305 $selected{'TYPE'}{'pppoe'} = '';
306 $selected{'TYPE'}{'pptp'} = '';
307 $selected{'TYPE'}{'vdsl'} = '';
308 $selected{'TYPE'}{'pppoeatm'} = '';
309 $selected{'TYPE'}{'pptpatm'} = '';
310 $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'";
311 $checked{'DEBUG'}{'off'} = '';
312 $checked{'DEBUG'}{'on'} = '';
313 $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'";
314
315 $selected{'COMPORT'}{'ttyS0'} = '';
316 $selected{'COMPORT'}{'ttyS1'} = '';
317 $selected{'COMPORT'}{'ttyS2'} = '';
318 $selected{'COMPORT'}{'ttyS3'} = '';
319 $selected{'COMPORT'}{'ttyS4'} = '';
320 $selected{'COMPORT'}{'ttyACM0'} = '';
321 $selected{'COMPORT'}{'ttyACM1'} = '';
322 $selected{'COMPORT'}{'ttyACM2'} = '';
323 $selected{'COMPORT'}{'ttyACM3'} = '';
324 $selected{'COMPORT'}{'ttyACM4'} = '';
325 $selected{'COMPORT'}{'ttyACM5'} = '';
326 $selected{'COMPORT'}{'ttyACM6'} = '';
327 $selected{'COMPORT'}{'ttyACM7'} = '';
328 $selected{'COMPORT'}{'ttyACM8'} = '';
329 $selected{'COMPORT'}{'ttyACM9'} = '';
330 $selected{'COMPORT'}{'ttyUSB0'} = '';
331 $selected{'COMPORT'}{'ttyUSB1'} = '';
332 $selected{'COMPORT'}{'ttyUSB2'} = '';
333 $selected{'COMPORT'}{'ttyUSB3'} = '';
334 $selected{'COMPORT'}{'ttyUSB4'} = '';
335 $selected{'COMPORT'}{'ttyUSB5'} = '';
336 $selected{'COMPORT'}{'ttyUSB6'} = '';
337 $selected{'COMPORT'}{'ttyUSB7'} = '';
338 $selected{'COMPORT'}{'ttyUSB8'} = '';
339 $selected{'COMPORT'}{'ttyUSB9'} = '';
340 $selected{'COMPORT'}{'rfcomm0'} = '';
341 $selected{'COMPORT'}{'rfcomm1'} = '';
342 $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'";
343
344 $selected{'MONPORT'}{''} = '';
345 $selected{'MONPORT'}{'ttyACM0'} = '';
346 $selected{'MONPORT'}{'ttyACM1'} = '';
347 $selected{'MONPORT'}{'ttyACM2'} = '';
348 $selected{'MONPORT'}{'ttyACM3'} = '';
349 $selected{'MONPORT'}{'ttyACM4'} = '';
350 $selected{'MONPORT'}{'ttyACM5'} = '';
351 $selected{'MONPORT'}{'ttyACM6'} = '';
352 $selected{'MONPORT'}{'ttyACM7'} = '';
353 $selected{'MONPORT'}{'ttyACM8'} = '';
354 $selected{'MONPORT'}{'ttyACM9'} = '';
355 $selected{'MONPORT'}{'ttyUSB0'} = '';
356 $selected{'MONPORT'}{'ttyUSB1'} = '';
357 $selected{'MONPORT'}{'ttyUSB2'} = '';
358 $selected{'MONPORT'}{'ttyUSB3'} = '';
359 $selected{'MONPORT'}{'ttyUSB4'} = '';
360 $selected{'MONPORT'}{'ttyUSB5'} = '';
361 $selected{'MONPORT'}{'ttyUSB6'} = '';
362 $selected{'MONPORT'}{'ttyUSB7'} = '';
363 $selected{'MONPORT'}{'ttyUSB8'} = '';
364 $selected{'MONPORT'}{'ttyUSB9'} = '';
365 $selected{'MONPORT'}{'rfcomm0'} = '';
366 $selected{'MONPORT'}{'rfcomm1'} = '';
367 $selected{'MONPORT'}{$pppsettings{'MONPORT'}} = "selected='selected'";
368
369 $selected{'DTERATE'}{'9600'} = '';
370 $selected{'DTERATE'}{'19200'} = '';
371 $selected{'DTERATE'}{'38400'} = '';
372 $selected{'DTERATE'}{'57600'} = '';
373 $selected{'DTERATE'}{'115200'} = '';
374 $selected{'DTERATE'}{'230400'} = '';
375 $selected{'DTERATE'}{'460800'} = '';
376 $selected{'DTERATE'}{'921600'} = '';
377 $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'";
378
379 $checked{'SPEAKER'}{'off'} = '';
380 $checked{'SPEAKER'}{'on'} = '';
381 $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'";
382
383 $selected{'DIALMODE'}{'T'} = '';
384 $selected{'DIALMODE'}{'P'} = '';
385 $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'";
386
387 $checked{'RECONNECTION'}{'persistent'} = '';
388 $checked{'RECONNECTION'}{'dialondemand'} = '';
389 $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'";
390
391 $checked{'DIALONDEMANDDNS'}{'off'} = '';
392 $checked{'DIALONDEMANDDNS'}{'on'} = '';
393 $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'";
394
395 $checked{'AUTOCONNECT'}{'off'} = '';
396 $checked{'AUTOCONNECT'}{'on'} = '';
397 $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'";
398
399 $checked{'SENDCR'}{'off'} = '';
400 $checked{'SENDCR'}{'on'} = '';
401 $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'";
402 $checked{'USEDOV'}{'off'} = '';
403 $checked{'USEDOV'}{'on'} = '';
404 $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'";
405
406 $checked{'MODEM'}{'PCIST'} = '';
407 $checked{'MODEM'}{'USB'} = '';
408 $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'";
409
410 $selected{'LINE'}{'WO'} = '';
411 $selected{'LINE'}{'ES'} = '';
412 $selected{'LINE'}{'ES03'} = '';
413 $selected{'LINE'}{'FR'} = '';
414 $selected{'LINE'}{'FR04'} = '';
415 $selected{'LINE'}{'FR10'} = '';
416 $selected{'LINE'}{'IT'} = '';
417 $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'";
418
419 $checked{'MODULATION'}{'GDMT'} = '';
420 $checked{'MODULATION'}{'ANSI'} = '';
421 $checked{'MODULATION'}{'GLITE'} = '';
422 $checked{'MODULATION'}{'AUTO'} = '';
423 $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'";
424
425 $checked{'PROTOCOL'}{'RFC1483'} = '';
426 $checked{'PROTOCOL'}{'RFC2364'} = '';
427 $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'";
428
429 $selected{'ENCAP'}{'0'} = '';
430 $selected{'ENCAP'}{'1'} = '';
431 #$selected{'ENCAP'}{'2'} = '';
432 #$selected{'ENCAP'}{'3'} = '';
433 #$selected{'ENCAP'}{'4'} = '';
434 $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'";
435
436 $checked{'METHOD'}{'STATIC'} = '';
437 $checked{'METHOD'}{'PPPOE'} = '';
438 $checked{'METHOD'}{'DHCP'} = '';
439 $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'";
440
441 $selected{'AUTH'}{'pap-or-chap'} = '';
442 $selected{'AUTH'}{'pap'} = '';
443 $selected{'AUTH'}{'chap'} = '';
444 $selected{'AUTH'}{'standard-login-script'} = '';
445 $selected{'AUTH'}{'demon-login-script'} = '';
446 $selected{'AUTH'}{'other-login-script'} = '';
447 $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'";
448
449 $checked{'IPTV'}{'enable'} = '';
450 $checked{'IPTV'}{'disable'} = '';
451 $checked{'IPTV'}{$pppsettings{'IPTV'}} = "checked='checked'";
452
453 if ($pppsettings{'INET_VLAN'} eq '') { $pppsettings{'INET_VLAN'}='7'; }
454 if ($pppsettings{'IPTV_VLAN'} eq '') { $pppsettings{'IPTV_VLAN'}='8'; }
455
456 &Header::openpage($Lang::tr{'ppp setup'}, 1, '');
457 &Header::openbigbox('100%', 'left', '', $errormessage);
458
459 if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
460 $errormessage = $Lang::tr{'dialup red not ppp'};
461 &Header::openbox('100%', 'center', $Lang::tr{'error messages'});
462 print "<class name='base'>$errormessage\n";
463 print "&nbsp;</class>\n";
464 &Header::closebox();
465 &Header::closebigbox();
466
467 &Header::closepage();
468 exit(1);
469 }
470
471 if ($errormessage) {
472 &Header::openbox('100%', 'center', $Lang::tr{'error messages'});
473 print "<class name='base'>$errormessage\n";
474 print "&nbsp;</class>\n";
475 &Header::closebox();
476 }
477
478
479 ###
480 ### Box for selecting profile
481 ###
482 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
483 &Header::openbox('100%', 'center', $Lang::tr{'profile'});
484 print <<END
485 <table width='95%' cellspacing='0'>
486 <tr>
487 <td align='left'>$Lang::tr{'profile'}</td>
488 <td align='left'>
489 <select name='PROFILE' style="width: 165px">
490 END
491 ;
492 for ($c = 1; $c <= $maxprofiles; $c++)
493 {
494 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
495 }
496 print <<END
497 </select></td>
498 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td>
499 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td>
500 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td>
501 </tr>
502 </table>
503 <br></br>
504 <hr></hr>
505 END
506 ;
507
508 &Header::closebox();
509 &Header::openbox('100%', 'center', $Lang::tr{'connection'});
510
511 print <<END
512 <table width='95%' cellspacing='0'>
513 <tr>
514 <td width='25%'>$Lang::tr{'interface'}:</td>
515 <td width='25%'>
516 <select name='TYPE' style="width: 165px">
517 END
518 ;
519 if ($netsettings{'RED_TYPE'} eq 'PPPOE' ) {
520 print <<END
521 <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option>
522 <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option>
523 <option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>
524 <option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>
525 <option value='vdsl' $selected{'TYPE'}{'vdsl'}>VDSL</option>
526 END
527 ;
528
529 # Read-in atm devices from proc.
530 open(PROC, "/proc/net/atm/devices");
531 my @atm_devices = <PROC>;
532 close(PROC);
533
534 my $atmdev = grep(/0/, @atm_devices);
535 chomp ($atmdev);
536 if ($atmdev ne '') {
537 print <<END
538 <option value='pppoeatm' $selected{'TYPE'}{'pppoeatm'}>PPPoE over ATM-BRIDGE</option>
539 <option value='pptpatm' $selected{'TYPE'}{'pptpatm'}>PPTP over ATM-BRIDGE</option>
540 END
541 ;
542 }
543 }
544 #if (0) {
545 # print <<END
546 # <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option>
547 # <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option>
548 # <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option>
549 # <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option>
550 # <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option>
551 # <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option>
552 # <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option>
553 #END
554 #;
555 #}
556 # print "<option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>";
557
558 print <<END
559 </select></td>
560 <td colspan='1' width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}'></td>
561 END
562 ;
563 if ($pppsettings{'TYPE'} =~ /^(modem)$/) {
564 print <<END
565 <td colspan='1' width='25%'><a href='modem.cgi'>$Lang::tr{'modem configuration'}</a></td>
566 END
567 ;
568 }
569
570 print "</tr>";
571
572 #if (-f "/proc/bus/usb/devices") {
573 # <td colspan='2' width='50%'>USB:</td>
574 # my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`;
575 # if ($usb eq '') {
576 # print "\t<td colspan='2' width='50%'>$Lang::tr{'not running'}</td></tr>\n";
577 # } else {
578 # print "\t<td colspan='2' width='50%'>$usb</td></tr>\n";
579 # }
580 #}
581
582 if ($pppsettings{'TYPE'}) {
583 print "<tr><td colspan='4' width='100%'><br></br></td></tr>";
584
585 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/) {
586 print <<END
587
588 <tr>
589 <td colspan='3' width='75%'>$Lang::tr{'interface'}:</td>
590 <td width='25%'><select name='COMPORT' style="width: 165px">
591 END
592 ;
593 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
594 print <<END
595 <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>COM1</option>
596 <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>COM2</option>
597 <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>COM3</option>
598 <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>COM4</option>
599 <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>COM5</option>
600 <option value='ttyUSB0' $selected{'COMPORT'}{'ttyUSB0'}>ttyUSB0</option>
601 <option value='ttyUSB1' $selected{'COMPORT'}{'ttyUSB1'}>ttyUSB1</option>
602 <option value='ttyUSB2' $selected{'COMPORT'}{'ttyUSB2'}>ttyUSB2</option>
603 <option value='ttyUSB3' $selected{'COMPORT'}{'ttyUSB3'}>ttyUSB3</option>
604 <option value='ttyUSB4' $selected{'COMPORT'}{'ttyUSB4'}>ttyUSB4</option>
605 <option value='ttyUSB5' $selected{'COMPORT'}{'ttyUSB5'}>ttyUSB5</option>
606 <option value='ttyUSB6' $selected{'COMPORT'}{'ttyUSB6'}>ttyUSB6</option>
607 <option value='ttyUSB7' $selected{'COMPORT'}{'ttyUSB7'}>ttyUSB7</option>
608 <option value='ttyUSB8' $selected{'COMPORT'}{'ttyUSB8'}>ttyUSB8</option>
609 <option value='ttyUSB9' $selected{'COMPORT'}{'ttyUSB9'}>ttyUSB9</option>
610 <option value='rfcomm0' $selected{'COMPORT'}{'rfcomm0'}>rfcomm0 (bluetooth)</option>
611 <option value='rfcomm1' $selected{'COMPORT'}{'rfcomm1'}>rfcomm1 (bluetooth)</option>
612 END
613 ;
614 if ($pppsettings{'TYPE'} ne 'serial' ) {
615 print <<END
616 <option value='ttyACM0' $selected{'COMPORT'}{'ttyACM0'}>ttyACM0</option>
617 <option value='ttyACM1' $selected{'COMPORT'}{'ttyACM1'}>ttyACM1</option>
618 <option value='ttyACM2' $selected{'COMPORT'}{'ttyACM2'}>ttyACM2</option>
619 <option value='ttyACM3' $selected{'COMPORT'}{'ttyACM3'}>ttyACM3</option>
620 <option value='ttyACM4' $selected{'COMPORT'}{'ttyACM4'}>ttyACM4</option>
621 <option value='ttyACM5' $selected{'COMPORT'}{'ttyACM5'}>ttyACM5</option>
622 <option value='ttyACM6' $selected{'COMPORT'}{'ttyACM6'}>ttyACM6</option>
623 <option value='ttyACM7' $selected{'COMPORT'}{'ttyACM7'}>ttyACM7</option>
624 <option value='ttyACM8' $selected{'COMPORT'}{'ttyACM8'}>ttyACM8</option>
625 <option value='ttyACM9' $selected{'COMPORT'}{'ttyACM9'}>ttyACM9</option>
626 END
627 ;
628 }
629 print "</select></td> "}
630
631 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/) {
632 print <<END;
633 <tr>
634 <td colspan='3' width='75%'>$Lang::tr{'monitor interface'}:</td>
635 <td width='25%'>
636 <select name="MONPORT" style="width: 165px;">
637 <option value="" $selected{'MONPORT'}{''}>---</option>
638 <option value="ttyUSB0" $selected{'MONPORT'}{'ttyUSB0'}>ttyUSB0</option>
639 <option value="ttyUSB1" $selected{'MONPORT'}{'ttyUSB1'}>ttyUSB1</option>
640 <option value="ttyUSB2" $selected{'MONPORT'}{'ttyUSB2'}>ttyUSB2</option>
641 <option value="ttyUSB3" $selected{'MONPORT'}{'ttyUSB3'}>ttyUSB3</option>
642 <option value="ttyUSB4" $selected{'MONPORT'}{'ttyUSB4'}>ttyUSB4</option>
643 <option value="ttyUSB5" $selected{'MONPORT'}{'ttyUSB5'}>ttyUSB5</option>
644 <option value="ttyUSB6" $selected{'MONPORT'}{'ttyUSB6'}>ttyUSB6</option>
645 <option value="ttyUSB7" $selected{'MONPORT'}{'ttyUSB7'}>ttyUSB7</option>
646 <option value="ttyUSB8" $selected{'MONPORT'}{'ttyUSB8'}>ttyUSB8</option>
647 <option value="ttyUSB9" $selected{'MONPORT'}{'ttyUSB9'}>ttyUSB9</option>
648 <option value="rfcomm0" $selected{'COMPORT'}{'rfcomm0'}>rfcomm0 (bluetooth)</option>
649 <option value="rfcomm1" $selected{'COMPORT'}{'rfcomm1'}>rfcomm1 (bluetooth)</option>
650 <option value="ttyACM0" $selected{'COMPORT'}{'ttyACM0'}>ttyACM0</option>
651 <option value="ttyACM1" $selected{'COMPORT'}{'ttyACM1'}>ttyACM1</option>
652 <option value="ttyACM2" $selected{'COMPORT'}{'ttyACM2'}>ttyACM2</option>
653 <option value="ttyACM3" $selected{'COMPORT'}{'ttyACM3'}>ttyACM3</option>
654 <option value="ttyACM4" $selected{'COMPORT'}{'ttyACM4'}>ttyACM4</option>
655 <option value="ttyACM5" $selected{'COMPORT'}{'ttyACM5'}>ttyACM5</option>
656 <option value="ttyACM6" $selected{'COMPORT'}{'ttyACM6'}>ttyACM6</option>
657 <option value="ttyACM7" $selected{'COMPORT'}{'ttyACM7'}>ttyACM7</option>
658 <option value="ttyACM8" $selected{'COMPORT'}{'ttyACM8'}>ttyACM8</option>
659 <option value="ttyACM9" $selected{'COMPORT'}{'ttyACM9'}>ttyACM9</option>
660 </select>
661 </td>
662 </tr>
663 END
664 }
665
666 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
667 print <<END
668 <tr>
669 <td colspan='3' width='75%'>$Lang::tr{'computer to modem rate'}</td>
670 <td width='25%'><select name='DTERATE' style="width: 165px">
671 <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option>
672 <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option>
673 <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option>
674 <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option>
675 <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option>
676 <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option>
677 <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option>
678 <option value='921600' $selected{'DTERATE'}{'921600'}>921600</option>
679 </select></td>
680 </tr>
681 END
682 ;
683 }
684 if ($pppsettings{'TYPE'} =~ /^(modem)$/ ) {
685 print "<tr><td colspan='3' width='75%'>$Lang::tr{'number'}&nbsp;<img src='/blob.gif' alt='*' /></td>\n";
686 print "<td width='25%'><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}'></td><tr>\n";
687 if ($pppsettings{'TYPE'} eq 'modem' ) {
688 print "<tr><td colspan='3' width='75%'>$Lang::tr{'modem speaker on'}</td>\n";
689 print "<td width='25%'><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n";
690 }
691 }
692 }
693 if ($pppsettings{'TYPE'} eq 'modem') {
694 print <<END
695 <tr>
696 <td colspan='3' width='75%'>$Lang::tr{'dialing mode'}</td>
697 <td width='25%'><select name='DIALMODE' style="width: 165px">
698 <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option>
699 <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option>
700 </select></td>
701 </tr>
702 <tr>
703 <td colspan='3' width='75%'>$Lang::tr{'optional at cmd'}&nbsp;1</td>
704 <td width='25%'><input type='text' name='ADD_AT1' value='$pppsettings{'ADD_AT1'}'></td>
705 </tr>
706 <tr>
707 <td colspan='3' width='75%'>$Lang::tr{'optional at cmd'}&nbsp;2</td>
708 <td width='25%'><input type='text' name='ADD_AT2' value='$pppsettings{'ADD_AT2'}'></td>
709 </tr>
710 <tr>
711 <td colspan='3' width='75%'>$Lang::tr{'optional at cmd'}&nbsp;3</td>
712 <td width='25%'><input type='text' name='ADD_AT3' value='$pppsettings{'ADD_AT3'}'></td>
713 </tr>
714 <tr>
715 <td colspan='3' width='75%'>$Lang::tr{'send cr'}</td>
716 <td width='50%'><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td>
717 </tr>
718 END
719 ;
720 }
721
722 print <<END
723 <tr>
724 <td colspan='3' width='75%'>$Lang::tr{'idle timeout'}&nbsp;<img src='/blob.gif' alt='*' /></td>
725 <td width='25%'><input type='text' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td>
726 </tr>
727 <tr>
728 <td colspan='3' width='75%'>$Lang::tr{'connection debugging'}:</td>
729 <td width='25%'><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td>
730 </tr>
731 <tr>
732 <td colspan='4' width='100%'><br></br></td></tr>
733 <tr>
734 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'reconnection'}:</b></td>
735 </tr>
736 <tr>
737 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'}>$Lang::tr{'dod'}</td>
738 </tr>
739 END
740 ;
741 print <<END
742 <tr>
743 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'}>$Lang::tr{'persistent'}</td>
744 </tr>
745 <tr>
746 <td colspan='3' width='75%'>$Lang::tr{'backupprofile'}:</td>
747 <td width='25%'><select name='BACKUPPROFILE' style="width: 165px">
748 END
749 ;
750 for ($c = 1; $c <= $maxprofiles; $c++) {
751 print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
752 }
753 print <<END
754 </select></td>
755 </tr>
756 <tr>
757 <td colspan='3' width='75%'>$Lang::tr{'dod for dns'}</td>
758 <td width='25%'><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td>
759 </tr>
760 <tr>
761 <td colspan='3' width='75%'>$Lang::tr{'holdoff'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
762 <td width='25%'><input type='text' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td>
763 </tr>
764 <tr>
765 <td colspan='3' width='75%'>$Lang::tr{'maximum retries'}&nbsp;<img src='/blob.gif' alt='*' /></td>
766 <td width='25%'><input type='text' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td>
767 </tr>
768 END
769 ;
770
771 if ($pppsettings{'TYPE'} eq 'pptp')
772 {
773
774 print <<END
775 <tr><td colspan='4' width='100%'><br></br></td></tr>
776 <tr>
777 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pptp settings'}</b></td>
778 </tr>
779 <tr>
780 <td width='25%'>$Lang::tr{'pptp peer'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
781 <td colspan='3'><input size=50 type='text' name='PPTP_PEER' value='$pppsettings{'PPTP_PEER'}' /></td>
782 </tr>
783 <tr>
784 <td width='25%'>$Lang::tr{'pptp netconfig'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
785 <td colspan='3'><input size=50 type='text' name='PPTP_NICCFG' value='$pppsettings{'PPTP_NICCFG'}' /></td>
786 </tr>
787 <tr>
788 <td width='25%'>$Lang::tr{'pptp route'}:</td>
789 <td colspan='3'><input size=50 type='text' name='PPTP_ROUTE' value='$pppsettings{'PPTP_ROUTE'}' /></td>
790 </tr>
791
792 END
793 ;
794 }
795
796 if ($pppsettings{'TYPE'} =~ /^(pppoeatm|pptpatm)$/)
797 {
798
799 print <<END
800 <tr>
801 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'atm settings'}:</b></td>
802 <tr>
803 <td nowrap='nowrap'>$Lang::tr{'atm device'}</td>
804 <td><input type='text' size='5' name='ATM_DEV' value='$pppsettings{'ATM_DEV'}' /></td>
805 <td> $Lang::tr{'encapsulation'}:</td>
806 <td>
807 <select name='ENCAP'>
808 <option value='0' $selected{'ENCAP'}{'0'}>LLC</option>
809 <option value='1' $selected{'ENCAP'}{'1'}>VCmux</option>
810 </select>
811 </td>
812 </tr>
813 <tr>
814 <td nowrap='nowrap'>$Lang::tr{'vpi number'}</td>
815 <td><input type='text' size='5' name='VPI' value='$pppsettings{'VPI'}' /></td>
816 <td> $Lang::tr{'vci number'}</td>
817 <td><input type='text' size='5' name='VCI' value='$pppsettings{'VCI'}' /></td>
818 </tr>
819 END
820 ;
821 }
822
823 if ($pppsettings{'TYPE'} =~ /^(pppoe|vdsl|pppoeatm)$/) {
824 print <<END
825 <tr>
826 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>IPTV/VLAN:</b></td>
827 </tr>
828 END
829 ;
830 if ( -e '/opt/pakfire/db/installed/meta-igmpproxy'){
831 print <<END
832 <tr>
833 <td colspan='3' width='100%'><input type='radio' name='IPTV' value='enable' $checked{'IPTV'}{'enable'}>$Lang::tr{'on'}</td>
834 <td colspan='1' rowspan='2' width='100%'><textarea name='IPTVSERVERS' cols='16' wrap='off'>
835 END
836 ;
837 print $pppsettings{'IPTVSERVERS'};
838 print <<END
839 </textarea></td>
840 </tr>
841 <tr>
842 <td colspan='3' width='100%'><input type='radio' name='IPTV' value='disable' $checked{'IPTV'}{'disable'}>$Lang::tr{'off'}</td>
843 </tr>
844 <tr>
845 <td>INET_VLAN</td>
846 <td><input size=5 type='number' name='INET_VLAN' value='$pppsettings{'INET_VLAN'}' /></td>
847 <td>IPTV_VLAN</td>
848 <td><input size=5 type='number' name='IPTV_VLAN' value='$pppsettings{'IPTV_VLAN'}' /></td>
849 </tr>
850
851 END
852 ;
853 }
854 else {
855 print "<tr><td colspan='4' width='100%'>No IPTV possible install addon igmpproxy</td></tr>";
856 if ($pppsettings{'TYPE'} eq 'vdsl') {
857 print <<END
858 <tr>
859 <td>INET_VLAN</td>
860 <td><input size=5 type='number' name='INET_VLAN' value='$pppsettings{'INET_VLAN'}' /></td>
861 </tr>
862 END
863 ;
864 }
865 }
866 }
867
868 if ($pppsettings{'TYPE'} eq 'pppoe' || $pppsettings{'TYPE'} eq 'pppoeatm' || $pppsettings{'TYPE'} eq 'vdsl')
869 {
870 print <<END
871 <tr><td colspan='4' width='100%'><br></br></td></tr>
872 <tr>
873 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pppoe settings'}</b></td>
874 </tr>
875 <tr>
876 <td width='25%'>$Lang::tr{'service name'}</td>
877 <td colspan='2' width='50%'></td>
878 <td width='25%'><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td>
879 </tr>
880 <tr>
881 <td width='25%'>$Lang::tr{'concentrator name'}</td>
882 <td colspan='2' width='50%'></td>
883 <td width='25%'><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td>
884 </tr>
885 END
886 ;
887 }
888
889 print <<END
890 <tr><td colspan='4' width='100%'><br></br></td></tr>
891 <tr>
892 <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>MTU/MRU</b></td>
893 </tr>
894 <tr>
895 <tr>
896 <td width='25%'>MTU:</td>
897 <td width='25%'><input type='text' name='MTU' value='$pppsettings{'MTU'}' /></td>
898 </tr>
899 <tr>
900 <td width='25%'>MRU:</td>
901 <td width='25%'><input type='text' name='MRU' value='$pppsettings{'MRU'}' /></td>
902 </tr>
903 END
904 ;
905
906 print <<END
907 <tr><td colspan='4' width='100%'><br></br></td></tr>
908 <tr>
909 <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>$Lang::tr{'authentication'}</b></td>
910 </tr>
911 <tr>
912 <td width='25%'>$Lang::tr{'username'}&nbsp;<img src='/blob.gif' alt='*' /></td>
913 <td width='25%'><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td>
914 <td width='25%'>$Lang::tr{'password'}&nbsp;</td>
915 <td width='25%'><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td>
916 </tr>
917 <tr>
918 <td width='25%'>$Lang::tr{'method'}</td>
919 <td width='25%'><select name='AUTH' style="width: 165px">
920 <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option>
921 <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option>
922 <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option>
923 END
924 ;
925 if ($pppsettings{'TYPE'} eq 'modem') {
926 print <<END
927 <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option>
928 <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'daemon login script'}</option>
929 <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option>
930 END
931 ;
932 }
933 print <<END
934 </select></td>
935 <td width='25%'>$Lang::tr{'script name'}</td>
936 <td width='25%'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td>
937 </tr>
938 <tr><td colspan='4' width='100%'><br></br><hr></hr><br></br></td></tr>
939 <tr>
940 <td width='25%'>$Lang::tr{'profile name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
941 <td width='25%'><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}'>
942 <td colspan='2' width='50%'></td>
943 </tr>
944 <tr>
945 <td align='center' colspan='4' width='100%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td>
946 </tr>
947 <tr>
948 <td colspan='2' width='50%'>$Lang::tr{'legend'}:</td>
949 <td colspan='2' width='50%'><img src='/blob.gif' alt='*' />&nbsp;$Lang::tr{'required field'}</td>
950 </tr>
951 END
952 ;
953 }
954
955 print "</table>";
956
957 &Header::closebox();
958
959 print "</form>\n";
960
961 &Header::closebigbox();
962
963 &Header::closepage();
964
965 sub updatesettings
966 {
967 # make a link from the selected profile to the "default" one.
968 unlink("${General::swroot}/ppp/settings");
969 link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
970 "${General::swroot}/ppp/settings");
971
972 # Write updatesettings file.
973 open(FILE, ">/${General::swroot}/ppp/updatesettings");
974 close(FILE);
975 }
976
977 sub writesecrets
978 {
979 # write secrets file.
980 open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
981 flock(FILE, 2);
982 my $username = $pppsettings{'USERNAME'};
983 my $password = $pppsettings{'PASSWORD'};
984 print FILE "'$username' * '$password'\n";
985 chmod 0600, "${General::swroot}/ppp/secrets";
986 close FILE;
987 }
988
989 sub initprofile
990 {
991 $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'};
992 $pppsettings{'COMPORT'} = 'ttyS0';
993 $pppsettings{'MONPORT'} = '';
994 $pppsettings{'DTERATE'} = 115200;
995 $pppsettings{'SPEAKER'} = 'off';
996 $pppsettings{'RECONNECTION'} = 'persistent';
997 $pppsettings{'DIALONDEMANDDNS'} = 'off';
998 $pppsettings{'AUTOCONNECT'} = 'on';
999 $pppsettings{'SENDCR'} = 'off';
1000 $pppsettings{'USEIBOD'} = 'off';
1001 $pppsettings{'USEDOV'} = 'off';
1002 $pppsettings{'MODEM'} = 'PCIST';
1003 $pppsettings{'LINE'} = 'WO';
1004 $pppsettings{'ENCAP'} = '0';
1005 $pppsettings{'VPI'} = '1';
1006 $pppsettings{'VCI'} = '32';
1007 $pppsettings{'ATM_DEV'} = '0';
1008 $pppsettings{'PPTP_PEER'} = '10.0.0.138';
1009 $pppsettings{'PPTP_NICCFG'} = '10.0.0.140/24 broadcast 10.0.0.255';
1010 $pppsettings{'PPTP_ROUTE'} = '';
1011 $pppsettings{'PROTOCOL'} = 'RFC2364';
1012 $pppsettings{'MTU'} = '';
1013 $pppsettings{'MRU'} = '';
1014 $pppsettings{'DIALMODE'} = 'T';
1015 $pppsettings{'MAXRETRIES'} = 5;
1016 $pppsettings{'HOLDOFF'} = 30;
1017 $pppsettings{'TIMEOUT'} = 15;
1018 $pppsettings{'MODULATION'} = 'AUTO';
1019 $pppsettings{'AUTH'} = 'pap-or-chap';
1020 $pppsettings{'DEBUG'} = 'off';
1021 $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'};
1022 $pppsettings{'IPTVSERVERS'} = '192.168.2.51/32';
1023 $pppsettings{'IPTV'} = 'disable';
1024 $pppsettings{'INET_VLAN'} = '7';
1025 $pppsettings{'IPTV_VLAN'} = '8';
1026
1027 if ( -e '/usr/local/bin/igmpproxy'){
1028 $pppsettings{'IPTV'} = 'enable';
1029 }
1030
1031 # Get PPPoE settings so we can see if PPPoE is enabled or not.
1032 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
1033
1034 # empty profile partial pre-initialization
1035 if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/) {
1036 $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'});
1037 } else {
1038 $pppsettings{'TYPE'}='modem';
1039 }
1040 }
1041