diff options
author | Phil Davis <phil.davis@inf.org> | 2015-09-18 12:47:49 +0545 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-09-21 17:35:10 -0300 |
commit | 66fd7b47679187ddcfaf5852a55b2af15394f341 (patch) | |
tree | 4a55bc345cafcc7ddc3efa366fb7384dcf98f04e /src/usr/local | |
parent | bf213d1d10dc7452cc1587ec727fede2c58d82f3 (diff) | |
download | pfsense-66fd7b47679187ddcfaf5852a55b2af15394f341.zip pfsense-66fd7b47679187ddcfaf5852a55b2af15394f341.tar.gz |
Redmine #4568 Preserve MLPPP settings when saving interface settings
This is a resubmit of https://github.com/pfsense/pfsense/pull/1900 after integrating to the current master.
Diffstat (limited to 'src/usr/local')
-rw-r--r-- | src/usr/local/www/interfaces.php | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index ad0c8d5..c3714ab 100644 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -210,7 +210,7 @@ if ($wancfg['if'] == $a_ppps[$pppid]['if']) { } else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp") { $pconfig['pptp_username'] = $a_ppps[$pppid]['username']; $pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']); - $pconfig['pptp_local'] = explode(",", $a_ppps[$pppid]['localip']); + $pconfig['pptp_localip'] = explode(",", $a_ppps[$pppid]['localip']); $pconfig['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']); $pconfig['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']); $pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); @@ -605,20 +605,20 @@ if ($_POST['apply']) { break; case "pptp": if ($_POST['pptp_dialondemand']) { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout"); + $reqdfields = explode(" ", "pptp_username pptp_password pptp_local0 pptp_subnet0 pptp_remote0 pptp_dialondemand pptp_idletimeout"); $reqdfieldsn = array(gettext("PPTP username"), gettext("PPTP password"), gettext("PPTP local IP address"), gettext("PPTP subnet"), gettext("PPTP remote IP address"), gettext("Dial on demand"), gettext("Idle timeout value")); } else { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote"); + $reqdfields = explode(" ", "pptp_username pptp_password pptp_local0 pptp_subnet0 pptp_remote"); $reqdfieldsn = array(gettext("PPTP username"), gettext("PPTP password"), gettext("PPTP local IP address"), gettext("PPTP subnet"), gettext("PPTP remote IP address")); } do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); break; case "l2tp": if ($_POST['pptp_dialondemand']) { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout"); + $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote0 pptp_dialondemand pptp_idletimeout"); $reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"), gettext("Dial on demand"), gettext("Idle timeout value")); } else { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote"); + $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote0"); $reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address")); } do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); @@ -809,13 +809,13 @@ if ($_POST['apply']) { if ($_POST['pppoe_resetdate'] != "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) { $input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy)."); } - if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local']))) { + if (($_POST['pptp_local0'] && !is_ipaddrv4($_POST['pptp_local0']))) { $input_errors[] = gettext("A valid PPTP local IP address must be specified."); } - if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) { + if (($_POST['pptp_subnet0'] && !is_numeric($_POST['pptp_subnet0']))) { $input_errors[] = gettext("A valid PPTP subnet bit count must be specified."); } - if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface]))) { + if (($_POST['pptp_remote0'] && !is_ipaddrv4($_POST['pptp_remote0']) && !is_hostname($_POST['gateway'][$iface]))) { $input_errors[] = gettext("A valid PPTP remote IP address must be specified."); } if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) { @@ -1015,6 +1015,12 @@ if ($_POST['apply']) { } } if (!$input_errors) { + // These 3 fields can be a list of multiple data items when used for MLPPP. + // The UI in this code only processes the first of the list, so save the data here then we can preserve any other entries. + $poriginal['pptp_localip'] = explode(",", $a_ppps[$pppid]['localip']); + $poriginal['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']); + $poriginal['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']); + if ($wancfg['ipaddr'] != $_POST['type']) { if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) { $wancfg['if'] = $a_ppps[$pppid]['ports']; @@ -1240,9 +1246,13 @@ if ($_POST['apply']) { } $a_ppps[$pppid]['username'] = $_POST['pptp_username']; $a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']); - $a_ppps[$pppid]['localip'] = $_POST['pptp_local']; - $a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet']; - $a_ppps[$pppid]['gateway'] = $_POST['pptp_remote']; + // Replace the first (0) entry with the posted data. Preserve any other entries that might be there. + $poriginal['pptp_localip'][0] = $_POST['pptp_local0']; + $a_ppps[$pppid]['localip'] = implode(',', $poriginal['pptp_localip']); + $poriginal['pptp_subnet'][0] = $_POST['pptp_subnet0']; + $a_ppps[$pppid]['subnet'] = implode(',', $poriginal['pptp_subnet']); + $poriginal['pptp_remote'][0] = $_POST['pptp_remote0']; + $a_ppps[$pppid]['gateway'] = implode(',', $poriginal['pptp_remote']); $a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false; if (!empty($_POST['pptp_idletimeout'])) { $a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout']; @@ -2776,13 +2786,13 @@ $section->addInput(new Form_Input( )); $section->addInput(new Form_IpAddress( - 'pptp_local', + 'pptp_local0', 'Local IP address', - $pconfig['pptp_local'][0] -))->addMask('pptp_subnet', $pconfig['pptp_subnet'][0]); + $pconfig['pptp_localip'][0] +))->addMask('pptp_subnet0', $pconfig['pptp_subnet'][0]); $section->addInput(new Form_IpAddress( - 'pptp_remote', + 'pptp_remote0', 'Remote IP address', $pconfig['pptp_remote'][0] )); @@ -2806,9 +2816,15 @@ $section->addInput(new Form_Input( 'An idle timeout of zero disables this feature.'); if (isset($pconfig['pppid'])) { + if (isset($pconfig['pptp_localip'][1]) || isset($pconfig['pptp_subnet'][1]) || isset($pconfig['pptp_remote'][1])) { + $mlppp_text = gettext("There are additional Local and Remote IP addresses defined for MLPPP.") . "<br />"; + } else { + $mlppp_text = ""; + } + $section->addInput(new Form_StaticText( 'Advanced and MLPPP', - '<a href="/interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) . '" class="navlnk">Click here for additional PPTP and L2TP configuration options. Save first if you made changes.</a>' + $mlppp_text . '<a href="/interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) . '" class="navlnk">Click here for additional PPTP and L2TP configuration options. Save first if you made changes.</a>' )); } else { $section->addInput(new Form_StaticText( |