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