$ph2found = true; break; } } } if ($ph2found === true) { $pconfig['ikeid'] = $ph2['ikeid']; $pconfig['disabled'] = isset($ph2['disabled']); $pconfig['mode'] = $ph2['mode']; $pconfig['descr'] = $ph2['descr']; $pconfig['uniqid'] = $ph2['uniqid']; if (!empty($ph2['natlocalid'])) { idinfo_to_pconfig("natlocal", $ph2['natlocalid'], $pconfig); } idinfo_to_pconfig("local", $ph2['localid'], $pconfig); idinfo_to_pconfig("remote", $ph2['remoteid'], $pconfig); $pconfig['proto'] = $ph2['protocol']; ealgos_to_pconfig($ph2['encryption-algorithm-option'], $pconfig); $pconfig['halgos'] = $ph2['hash-algorithm-option']; $pconfig['pfsgroup'] = $ph2['pfsgroup']; $pconfig['lifetime'] = $ph2['lifetime']; $pconfig['pinghost'] = $ph2['pinghost']; $pconfig['reqid'] = $ph2['reqid']; if (isset($ph2['mobile'])) { $pconfig['mobile'] = true; } } else { $pconfig['ikeid'] = $_GET['ikeid']; /* defaults */ $pconfig['localid_type'] = "lan"; $pconfig['remoteid_type'] = "network";
foreach (explode(",", $phase2_fields) as $fieldname) { $fieldname = trim($fieldname); if (isset($config['ipsec']['phase2'][$p2index][$fieldname])) { $pconfig[$fieldname] = $config['ipsec']['phase2'][$p2index][$fieldname]; } elseif (!isset($pconfig[$fieldname])) { // initialize element $pconfig[$fieldname] = null; } } // fields with some kind of logic $pconfig['disabled'] = isset($config['ipsec']['phase2'][$p2index]['disabled']); if (!empty($config['ipsec']['phase2'][$p2index]['natlocalid'])) { idinfo_to_pconfig("natlocal", $config['ipsec']['phase2'][$p2index]['natlocalid'], $pconfig); } idinfo_to_pconfig("local", $config['ipsec']['phase2'][$p2index]['localid'], $pconfig); idinfo_to_pconfig("remote", $config['ipsec']['phase2'][$p2index]['remoteid'], $pconfig); ealgos_to_pconfig($config['ipsec']['phase2'][$p2index]['encryption-algorithm-option'], $pconfig); if (isset($config['ipsec']['phase2'][$p2index]['mobile'])) { $pconfig['mobile'] = true; } if (!empty($_GET['dup'])) { $pconfig['uniqid'] = uniqid(); } } else { if (isset($_GET['ikeid'])) { $pconfig['ikeid'] = $_GET['ikeid']; } /* defaults */ $pconfig['localid_type'] = "lan"; $pconfig['remoteid_type'] = "network"; $pconfig['protocol'] = "esp";
$a_phase2 =& $config['ipsec']['phase2']; $p2index = $_GET['p2index']; if (isset($_POST['p2index'])) { $p2index = $_POST['p2index']; } if (isset($_GET['dup'])) { $p2index = $_GET['dup']; } if (isset($p2index) && $a_phase2[$p2index]) { $pconfig['ikeid'] = $a_phase2[$p2index]['ikeid']; $pconfig['disabled'] = isset($a_phase2[$p2index]['disabled']); $pconfig['mode'] = $a_phase2[$p2index]['mode']; $pconfig['descr'] = $a_phase2[$p2index]['descr']; $old_ph2ent = $a_phase2[$p2index]; idinfo_to_pconfig("local", $a_phase2[$p2index]['localid'], $pconfig); idinfo_to_pconfig("remote", $a_phase2[$p2index]['remoteid'], $pconfig); $pconfig['proto'] = $a_phase2[$p2index]['protocol']; ealgos_to_pconfig($a_phase2[$p2index]['encryption-algorithm-option'], $pconfig); $pconfig['halgos'] = $a_phase2[$p2index]['hash-algorithm-option']; $pconfig['pfsgroup'] = $a_phase2[$p2index]['pfsgroup']; $pconfig['lifetime'] = $a_phase2[$p2index]['lifetime']; $pconfig['pinghost'] = $a_phase2[$p2index]['pinghost']; if (isset($a_phase2[$p2index]['mobile'])) { $pconfig['mobile'] = true; } } else { $pconfig['ikeid'] = $_GET['ikeid']; /* defaults */ $pconfig['localid_type'] = "lan"; $pconfig['remoteid_type'] = "network"; $pconfig['proto'] = "esp";