]>
git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - html/cgi-bin/pppsetup.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
12 # enable only the following on debugging purpose
14 #use CGI::Carp 'fatalsToBrowser';
16 require '/var/ipfire/general-functions.pl';
17 require "${General::swroot}/lang.pl";
18 require "${General::swroot}/header.pl";
21 my %temppppsettings=();
22 our %modemsettings=();
28 my $errormessage = '';
30 my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
33 my %mainsettings = ();
34 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
35 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
37 &Header
::showhttpheaders
();
39 $pppsettings{'ACTION'} = '';
41 &Header
::getcgihash
(\
%pppsettings);
43 if ($pppsettings{'ACTION'} ne '' &&
44 (-e
'/var/run/ppp-ipcop.pid' || -e
"${General::swroot}/red/active"))
46 $errormessage = $Lang::tr
{'unable to alter profiles while red is active'};
47 # read in the current vars
49 $pppsettings{'VALID'} = '';
50 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
52 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'refresh'})
54 unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp)$/) {
55 $errormessage = $Lang::tr
{'invalid input'};
57 my $type = $pppsettings{'TYPE'};
58 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
59 $pppsettings{'TYPE'} = $type;
61 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'save'})
63 if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|ttyACM0|ttyACM1|ttyACM2|ttyACM3|isdn1|isdn2)$/) {
64 $errormessage = $Lang::tr
{'invalid input'};
66 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800)$/) {
67 $errormessage = $Lang::tr
{'invalid input'};
69 if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) {
70 $errormessage = $Lang::tr
{'invalid input'};
72 if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) {
73 $errormessage = $Lang::tr
{'invalid input'};
77 if ($pppsettings{'PROFILENAME'} eq '') {
78 $errormessage = $Lang::tr
{'profile name not given'};
79 $pppsettings{'PROFILENAME'} = '';
81 if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) {
82 if ($pppsettings{'TELEPHONE'} eq '') {
83 $errormessage = $Lang::tr
{'telephone not set'};
85 if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) {
86 $errormessage = $Lang::tr
{'bad characters in the telephone number field'};
89 unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) {
90 if ($pppsettings{'USERNAME'} eq '') {
91 $errormessage = $Lang::tr
{'username not set'};
93 if ($pppsettings{'PASSWORD'} eq '') {
94 $errormessage = $Lang::tr
{'password not set'};
98 if ($pppsettings{'TIMEOUT'} eq '') {
99 $errormessage = $Lang::tr
{'idle timeout not set'};
101 if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) {
102 $errormessage = $Lang::tr
{'only digits allowed in the idle timeout'};
105 if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) {
106 $errormessage = $Lang::tr
{'bad characters in script field'};
109 if ($pppsettings{'DNS1'})
111 if (!(&General
::validip
($pppsettings{'DNS1'}))) {
112 $errormessage = $Lang::tr
{'invalid primary dns'};
115 if ($pppsettings{'DNS2'})
117 if (!(&General
::validip
($pppsettings{'DNS2'}))) {
118 $errormessage = $Lang::tr
{'invalid secondary dns'};
122 if ($pppsettings{'MAXRETRIES'} eq '') {
123 $errormessage = $Lang::tr
{'max retries not set'};
125 if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) {
126 $errormessage = $Lang::tr
{'only digits allowed in max retries field'};
129 if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) {
130 $errormessage = $Lang::tr
{'only digits allowed in holdoff field'};
133 if ($pppsettings{'TYPE'} eq 'pptp') {
135 if ($pppsettings{'METHOD'} eq 'STATIC') {
136 if (! &General
::validip
($pppsettings{'ROUTERIP'})) {
137 $errormessage = $Lang::tr
{'router ip'}.' '.$Lang::tr
{'invalid ip'};
140 if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General
::validfqdn
($pppsettings{'DHCP_HOSTNAME'})) ) {
141 $errormessage = $errormessage.' '.$Lang::tr
{'hostname'}.' '.$Lang::tr
{'invalid hostname'};
144 if ($errormessage ne '') {goto ERROR
; }
147 if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \
148 ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) {
149 $errormessage = $Lang::tr
{'invalid input'};
152 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) {
153 if ($pppsettings{'DHCP_HOSTNAME'} ne '') {
154 if (! &General
::validfqdn
($pppsettings{'DHCP_HOSTNAME'})) {
155 $errormessage = $errormessage.' '.$Lang::tr
{'hostname'}.': '.$Lang::tr
{'invalid hostname'}; }
159 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) {
161 if (! &General
::validip
($pppsettings{'IP'})) {
162 $errormessage = $Lang::tr
{'static ip'}.' '.$Lang::tr
{'invalid ip'}; }
163 if (! &General
::validip
($pppsettings{'GATEWAY'})) {
164 $errormessage = $errormessage.' '.$Lang::tr
{'gateway ip'}.' '.$Lang::tr
{'invalid ip'}; }
165 if (! &General
::validmask
($pppsettings{'NETMASK'})) {
166 $errormessage = $errormessage.' '.$Lang::tr
{'netmask'}.' '.$Lang::tr
{'invalid netmask'}; }
167 if ($pppsettings{'BROADCAST'} ne '') {
168 if (! &General
::validip
($pppsettings{'BROADCAST'})) {
169 $errormessage = $errormessage.' '.$Lang::tr
{'broadcast'}.' '.$Lang::tr
{'invalid broadcast ip'}; }
171 if( $pppsettings{'DNS'} eq 'Automatic') {
172 $errormessage = $Lang::tr
{'invalid input'}; }
173 if ($errormessage ne '') {goto ERROR
; }
176 if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \
177 $pppsettings{'RECONNECTION'} eq 'dialondemand' ) {
178 $errormessage = $Lang::tr
{'invalid input'};
181 if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) {
182 $errormessage = $Lang::tr
{'dod not compatible with ddns'};
185 if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
186 $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; }
187 if( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
188 $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; }
189 delete $pppsettings{'ENCAP_RFC1483'};
190 delete $pppsettings{'ENCAP_RFC2364'};
194 $pppsettings{'VALID'} = 'no'; }
196 $pppsettings{'VALID'} = 'yes'; }
198 # write cgi vars to the file.
199 &General
::writehash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
202 # make link and write secret file.
206 &General
::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}");
208 if ($pppsettings{'ACTION'} eq $Lang::tr
{'select'})
210 my $profile = $pppsettings{'PROFILE'};
211 %temppppsettings = ();
212 $temppppsettings{'PROFILE'} = '';
213 &General
::readhash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
219 # read in the new params "early" so we can write secrets.
221 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
222 $pppsettings{'PROFILE'} = $profile;
223 &General
::writehash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
228 &General
::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}");
230 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'delete'})
232 &General
::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}");
234 my $profile = $pppsettings{'PROFILE'};
235 truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0);
237 %temppppsettings = ();
238 $temppppsettings{'PROFILE'} = '';
239 &General
::readhash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
245 # read in the new params "early" so we can write secrets.
247 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
248 $pppsettings{'PROFILE'} = $profile;
250 &General
::writehash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
255 # read in the current vars
257 $pppsettings{'VALID'} = '';
258 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
261 # read in the profile names into @profilenames.
263 for ($c = 1; $c <= $maxprofiles; $c++)
265 %temppppsettings = ();
266 $temppppsettings{'PROFILENAME'} = $Lang::tr
{'empty profile'};
267 &General
::readhash
("${General::swroot}/ppp/settings-$c", \
%temppppsettings);
268 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
271 if ($pppsettings{'VALID'} eq '')
273 if ($pppsettings{'PROFILE'} eq '') {
274 $pppsettings{'PROFILE'} = '1';
278 for ($c = 1; $c <= $maxprofiles; $c++) {
279 $selected{'PROFILE'}{$c} = ''; }
280 $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
281 for ($c = 1; $c <= $maxprofiles; $c++) {
282 $selected{'BACKUPPROFILE'}{$c} = ''; }
283 $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'";
285 $selected{'TYPE'}{'modem'} = '';
286 $selected{'TYPE'}{'serial'} = '';
287 $selected{'TYPE'}{'pppoe'} = '';
288 $selected{'TYPE'}{'pptp'} = '';
289 $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'";
291 $checked{'DEBUG'}{'off'} = '';
292 $checked{'DEBUG'}{'on'} = '';
293 $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'";
295 $selected{'COMPORT'}{'ttyS0'} = '';
296 $selected{'COMPORT'}{'ttyS1'} = '';
297 $selected{'COMPORT'}{'ttyS2'} = '';
298 $selected{'COMPORT'}{'ttyS3'} = '';
299 $selected{'COMPORT'}{'ttyS4'} = '';
300 $selected{'COMPORT'}{'ttyACM0'} = '';
301 $selected{'COMPORT'}{'ttyACM1'} = '';
302 $selected{'COMPORT'}{'ttyACM2'} = '';
303 $selected{'COMPORT'}{'ttyACM3'} = '';
304 $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'";
306 $selected{'DTERATE'}{'9600'} = '';
307 $selected{'DTERATE'}{'19200'} = '';
308 $selected{'DTERATE'}{'38400'} = '';
309 $selected{'DTERATE'}{'57600'} = '';
310 $selected{'DTERATE'}{'115200'} = '';
311 $selected{'DTERATE'}{'230400'} = '';
312 $selected{'DTERATE'}{'460800'} = '';
313 $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'";
315 $checked{'SPEAKER'}{'off'} = '';
316 $checked{'SPEAKER'}{'on'} = '';
317 $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'";
319 $selected{'DIALMODE'}{'T'} = '';
320 $selected{'DIALMODE'}{'P'} = '';
321 $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'";
323 $checked{'RECONNECTION'}{'manual'} = '';
324 $checked{'RECONNECTION'}{'persistent'} = '';
325 $checked{'RECONNECTION'}{'dialondemand'} = '';
326 $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'";
328 $checked{'DIALONDEMANDDNS'}{'off'} = '';
329 $checked{'DIALONDEMANDDNS'}{'on'} = '';
330 $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'";
332 $checked{'AUTOCONNECT'}{'off'} = '';
333 $checked{'AUTOCONNECT'}{'on'} = '';
334 $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'";
336 $checked{'SENDCR'}{'off'} = '';
337 $checked{'SENDCR'}{'on'} = '';
338 $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'";
339 $checked{'USEDOV'}{'off'} = '';
340 $checked{'USEDOV'}{'on'} = '';
341 $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'";
343 $checked{'MODEM'}{'PCIST'} = '';
344 $checked{'MODEM'}{'USB'} = '';
345 $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'";
347 $selected{'LINE'}{'WO'} = '';
348 $selected{'LINE'}{'ES'} = '';
349 $selected{'LINE'}{'ES03'} = '';
350 $selected{'LINE'}{'FR'} = '';
351 $selected{'LINE'}{'FR04'} = '';
352 $selected{'LINE'}{'FR10'} = '';
353 $selected{'LINE'}{'IT'} = '';
354 $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'";
356 $checked{'MODULATION'}{'GDMT'} = '';
357 $checked{'MODULATION'}{'ANSI'} = '';
358 $checked{'MODULATION'}{'GLITE'} = '';
359 $checked{'MODULATION'}{'AUTO'} = '';
360 $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'";
362 $checked{'PROTOCOL'}{'RFC1483'} = '';
363 $checked{'PROTOCOL'}{'RFC2364'} = '';
364 $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'";
366 $selected{'ENCAP'}{'0'} = '';
367 $selected{'ENCAP'}{'1'} = '';
368 $selected{'ENCAP'}{'2'} = '';
369 $selected{'ENCAP'}{'3'} = '';
370 $selected{'ENCAP'}{'4'} = '';
371 $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'";
372 $checked{'METHOD'}{'STATIC'} = '';
373 $checked{'METHOD'}{'PPPOE'} = '';
374 $checked{'METHOD'}{'PPPOE_PLUGIN'} = '';
375 $checked{'METHOD'}{'DHCP'} = '';
376 $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'";
378 $selected{'AUTH'}{'pap-or-chap'} = '';
379 $selected{'AUTH'}{'pap'} = '';
380 $selected{'AUTH'}{'chap'} = '';
381 $selected{'AUTH'}{'standard-login-script'} = '';
382 $selected{'AUTH'}{'demon-login-script'} = '';
383 $selected{'AUTH'}{'other-login-script'} = '';
384 $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'";
386 $checked{'DNS'}{'Automatic'} = '';
387 $checked{'DNS'}{'Manual'} = '';
388 $checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'";
390 &Header
::openpage
($Lang::tr
{'ppp setup'}, 1, '');
391 &Header
::openbigbox
('100%', 'left', '', $errormessage);
394 &Header
::openbox
('100%', 'center', $Lang::tr
{'error messages'});
395 print "<CLASS name='base'>$errormessage\n";
396 print " </CLASS>\n";
402 ### Box for selecting profile
404 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
405 &Header
::openbox
('100%', 'center', $Lang::tr
{'profile'});
407 <table width='95%' cellspacing='0'>
409 <td align='left'>$Lang::tr{'profile'}</td>
411 <select name='PROFILE' style="width: 165px">
414 for ($c = 1; $c <= $maxprofiles; $c++)
416 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
420 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td>
421 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td>
422 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td>
431 &Header
::openbox
('100%', 'center', $Lang::tr
{'connection'});
434 <table width='95%' cellspacing='0'>
436 <td width='25%'>$Lang::tr{'interface'}:</td>
438 <select name='TYPE' style="width: 165px">
439 <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option>
440 <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option>
443 if ($netsettings{'RED_TYPE'} eq 'PPPOE') {
444 print "\t<option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>\n";
446 if ($netsettings{'RED_TYPE'} eq 'PPTP') {
447 print "\t<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>\n";
449 if (-f
"/proc/bus/usb/devices") {
451 <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option>
452 <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option>
453 <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option>
454 <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option>
455 <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option>
456 <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option>
457 <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option>
462 # print "<option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>";
465 <td colspan='2' width='50%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}'></td>
468 <td colspan='2' width='50%'>USB:</td>
471 if (-f
"/proc/bus/usb/devices") {
472 my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`;
474 print "\t<td colspan='2' width='50%'>$Lang::tr{'not running'}</td></tr>\n";
476 print "\t<td colspan='2' width='50%'>$usb</td></tr>\n";
480 if ($pppsettings{'TYPE'}) {
481 print "<tr><td colspan='4' width='100%'><br></br></td></tr>";
482 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/) {
485 <td colspan='3' width='75%'>$Lang::tr{'interface'}:</td>
486 <td width='25%'><select name='COMPORT' style="width: 165px">
489 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
491 <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>$Lang::tr{'modem on com1'}</option>
492 <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>$Lang::tr{'modem on com2'}</option>
493 <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>$Lang::tr{'modem on com3'}</option>
494 <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>$Lang::tr{'modem on com4'}</option>
495 <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>$Lang::tr{'modem on com5'}</option>
496 <option value='ttyACM0' $selected{'COMPORT'}{'ttyACM0'}>$Lang::tr{'usb modem on acm0'}</option>
497 <option value='ttyACM1' $selected{'COMPORT'}{'ttyACM1'}>$Lang::tr{'usb modem on acm1'}</option>
498 <option value='ttyACM2' $selected{'COMPORT'}{'ttyACM2'}>$Lang::tr{'usb modem on acm2'}</option>
499 <option value='ttyACM3' $selected{'COMPORT'}{'ttyACM3'}>$Lang::tr{'usb modem on acm3'}</option>
504 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
507 <td colspan='3' width='75%'>$Lang::tr{'computer to modem rate'}</td>
508 <td width='25%'><select name='DTERATE' style="width: 165px">
509 <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option>
510 <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option>
511 <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option>
512 <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option>
513 <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option>
514 <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option>
515 <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option>
521 if ($pppsettings{'TYPE'} =~ /^(modem)$/ ) {
522 print "<tr><td colspan='3' width='75%'>$Lang::tr{'number'}</td>\n";
523 print "<td width='25%'><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}'></td><tr>\n";
524 if ($pppsettings{'TYPE'} eq 'modem' ) {
525 print "<tr><td colspan='3' width='75%'>$Lang::tr{'modem speaker on'}</td>\n";
526 print "<td width='25%'><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n";
530 if ($pppsettings{'TYPE'} eq 'modem') {
533 <td colspan='3' width='75%'>$Lang::tr{'dialing mode'}</td>
534 <td width='25%'><select name='DIALMODE' style="width: 165px">
535 <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option>
536 <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option>
540 <td colspan='3' width='75%'>$Lang::tr{'send cr'}</td>
541 <td width='50%'><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td>
549 <td colspan='3' width='75%'>$Lang::tr{'idle timeout'}</td>
550 <td width='25%'><input type='text' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td>
554 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && ( $netsettings{'RED_TYPE'} eq "DHCP" || $netsettings{'RED_TYPE'} eq "STATIC") ) {
555 $pppsettings{'AUTOCONNECT'} = 'on';
556 print "<tr><td colspan='3' width='75%'>$Lang::tr{'connect on ipfire restart'}</td>\n";
557 print "<td width='25%'><input type='checkbox' disabled='disabled' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'}></td>\n";
559 print "<tr><td colspan='3' width='75%'>$Lang::tr{'connect on ipfire restart'}</td>\n";
560 print "<td width='25%'><input type='checkbox' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'}></td>\n";
565 <td colspan='3' width='75%'>$Lang::tr{'connection debugging'}:</td>
566 <td width='25%'><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td>
569 <td colspan='4' width='100%'><br></br></td></tr>
571 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'reconnection'}:</b></td>
574 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='manual' $checked{'RECONNECTION'}{'manual'}>$Lang::tr{'manual'}</td>
577 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'}>$Lang::tr{'dod'}</td>
581 if ($pppsettings{'TYPE'} ne 'isdn') {
584 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'}>$Lang::tr{'persistent'}</td>
587 <td colspan='3' width='75%'>$Lang::tr{'backupprofile'}:</td>
588 <td width='25%'><select name='BACKUPPROFILE' style="width: 165px">
591 for ($c = 1; $c <= $maxprofiles; $c++) {
592 print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
602 <td colspan='3' width='75%'>$Lang::tr{'dod for dns'}</td>
603 <td width='25%'><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td>
606 <td colspan='3' width='75%'>$Lang::tr{'holdoff'}:</td>
607 <td width='25%'><input type='text' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td>
610 <td colspan='3' width='75%'>$Lang::tr{'maximum retries'}</td>
611 <td width='25%'><input type='text' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td>
616 if ($pppsettings{'TYPE'} eq 'pptp')
619 <tr><td colspan='4' width='100%'><br></br></td></tr>
621 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pptp settings'}</b></td>
624 <td width='25%'>$Lang::tr{'phonebook entry'}</td>
625 <td colspan='2' width='50%'></td>
626 <td width='25%'><input type='text' name='PHONEBOOK' value='$pppsettings{'PHONEBOOK'}' /></td>
629 <td width='25%'><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td>
630 <td colspan='2' width='50%'>$Lang::tr{'router ip'}</td>
631 <td width='25%'><input type='text' name='ROUTERIP' value='$pppsettings{'ROUTERIP'}' /></td>
634 <td width='25%'><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td>
635 <td colspan='2' width='50%'>$Lang::tr{'hostname'}: <img src='/blob.gif' alt='*' /></td>
636 <td width='25%'><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td>
641 if ($pppsettings{'TYPE'} eq 'pppoe')
644 <tr><td colspan='4' width='100%'><br></br></td></tr>
646 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pppoe settings'}</b></td>
649 <td width='25%'><input type='radio' name='METHOD' value='PPPOE_PLUGIN' $checked{'METHOD'}{'PPPOE_PLUGIN'} />PPPoE plugin</td>
650 <td colspan='2' width='50%'>$Lang::tr{'service name'} <img src='/blob.gif' alt='*' /></td>
651 <td width='25%'><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td>
654 <td width='25%'><input type='radio' name='METHOD' value='PPPOE' $checked{'METHOD'}{'PPPOE'} />$Lang::tr{'pppoe'}</td>
655 <td colspan='2' width='50%'>$Lang::tr{'concentrator name'} <img src='/blob.gif' alt='*' /></td>
656 <td width='25%'><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td>
659 <td width='25%'>MTU</td>
660 <td colspan='2' width='50%'></td>
661 <td width='25%'><input type='text' name='MTU' value='$pppsettings{'MTU'}' /></td>
668 <tr><td colspan='4' width='100%'><br></br></td></tr>
670 <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>$Lang::tr{'authentication'}</b></td>
673 <td width='25%'>$Lang::tr{'username'}</td>
674 <td width='25%'><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td>
675 <td width='25%'>$Lang::tr{'password'}</td>
676 <td width='25%'><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td>
679 <td width='25%'>$Lang::tr{'method'}</td>
680 <td width='25%'><select name='AUTH' style="width: 165px">
681 <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option>
682 <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option>
683 <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option>
686 if ($pppsettings{'TYPE'} eq 'modem') {
688 <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option>
689 <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'demon login script'}</option>
690 <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option>
696 <td width='25%'>$Lang::tr{'script name'} <img src='/blob.gif' alt='*' /></td>
697 <td width='25%'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td>
699 <tr><td colspan='4' width='100%'><br></br></td></tr>
701 <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>DNS:</b></td>
704 <td colspan='4' width='100%'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td>
707 <td colspan='4' width='100%'><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td>
710 <td width='25%'>$Lang::tr{'primary dns'}</td>
711 <td width='25%'><input type='text' name='DNS1' value='$pppsettings{'DNS1'}'></td>
712 <td width='25%'>$Lang::tr{'secondary dns'}</td>
713 <td width='25%'><input type='text' name='DNS2' value='$pppsettings{'DNS2'}'></td>
715 <tr><td colspan='4' width='100%'><br></br><hr></hr><br></br></td></tr>
717 <td width='25%'>$Lang::tr{'profile name'}</td>
718 <td width='25%'><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}'>
719 <td colspan='2' width='50%'></td>
722 <td align='center' colspan='4' width='100%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td>
725 <td colspan='2' width='50%'>$Lang::tr{'legend'}:</td>
726 <td colspan='2' width='50%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td>
736 &Header
::closebigbox
();
738 &Header
::closepage
();
742 # make a link from the selected profile to the "default" one.
743 unlink("${General::swroot}/ppp/settings");
744 link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
745 "${General::swroot}/ppp/settings");
746 system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings");
751 # write secrets file.
752 open(FILE
, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
754 my $username = $pppsettings{'USERNAME'};
755 my $password = $pppsettings{'PASSWORD'};
756 print FILE
"'$username' * '$password'\n";
757 chmod 0600, "${General::swroot}/ppp/secrets";
763 $pppsettings{'PROFILENAME'} = $Lang::tr
{'unnamed'};
764 $pppsettings{'COMPORT'} = 'ttyS0';
765 $pppsettings{'DTERATE'} = 115200;
766 $pppsettings{'SPEAKER'} = 'off';
767 $pppsettings{'RECONNECTION'} = 'manual';
768 $pppsettings{'DIALONDEMANDDNS'} = 'off';
769 $pppsettings{'AUTOCONNECT'} = 'off';
770 $pppsettings{'SENDCR'} = 'off';
771 $pppsettings{'USEIBOD'} = 'off';
772 $pppsettings{'USEDOV'} = 'off';
773 $pppsettings{'MODEM'} = 'PCIST';
774 $pppsettings{'LINE'} = 'WO';
775 $pppsettings{'ENCAP'} = '0';
776 $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1';
777 $pppsettings{'PROTOCOL'} = 'RFC2364';
778 $pppsettings{'METHOD'} = 'PPPOE_PLUGIN';
779 if ( $pppsettings{'METHOD'} eq 'PPPOE_PLUGIN' ) {
780 $pppsettings{'MTU'} = '1492';
781 $pppsettings{'MRU'} = '1492';
783 $pppsettings{'MTU'} = '1452';
784 $pppsettings{'MRU'} = '1452';
786 $pppsettings{'DIALMODE'} = 'T';
787 $pppsettings{'MAXRETRIES'} = 5;
788 $pppsettings{'HOLDOFF'} = 30;
789 $pppsettings{'TIMEOUT'} = 15;
790 $pppsettings{'MODULATION'} = 'AUTO';
791 $pppsettings{'AUTH'} = 'pap-or-chap';
792 $pppsettings{'DNS'} = 'Automatic';
793 $pppsettings{'DEBUG'} = 'off';
794 $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'};
796 # Get PPPoE settings so we can see if PPPoE is enabled or not.
797 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
799 # empty profile partial pre-initialization
800 if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/) {
801 $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'});
803 $pppsettings{'TYPE'}='modem';