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