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