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