From f4bd25a7c6c8e35509e50521d97e7ddb8c6915d0 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 22 Sep 2015 07:17:56 +0545 Subject: Redmine #4568 Preserve MLPPP settings when saving interface settings RELENG_2_2 Vagain with errors fixed. Supersedes https://github.com/pfsense/pfsense/pull/1781 --- usr/local/www/interfaces.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'usr') diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index d1b1726..7184dee 100644 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -176,7 +176,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']); @@ -544,20 +544,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_remote0"); $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); @@ -716,11 +716,11 @@ if ($_POST['apply']) { $input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59)."); 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'])) $input_errors[] = gettext("The idle timeout value must be an integer."); @@ -894,6 +894,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']; @@ -1109,9 +1115,13 @@ if ($_POST['apply']) { $a_ppps[$pppid]['ports'] = $wancfg['if']; $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']; @@ -2878,9 +2888,9 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), - + / - 0; $i--): ?> @@ -2891,7 +2901,7 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), - + @@ -2912,6 +2922,9 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), + +
+ -- cgit v1.1