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