From 761882a1be689d2b70803a5612cd5db537e8644e Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Thu, 4 Sep 2014 09:09:09 -0300 Subject: More improvements on IPsec GUI (Ticket #3328): * Allow to reorder P2 entries * Allow to remove multiple P2 entries * Add an icon to quickly toggle enable/disable status of p1 items --- usr/local/www/vpn_ipsec.php | 202 +++++++++++++++++++++++++++++++++----------- 1 file changed, 153 insertions(+), 49 deletions(-) diff --git a/usr/local/www/vpn_ipsec.php b/usr/local/www/vpn_ipsec.php index 6b348c6..a1af171 100644 --- a/usr/local/www/vpn_ipsec.php +++ b/usr/local/www/vpn_ipsec.php @@ -84,6 +84,17 @@ if ($_POST) { header("Location: vpn_ipsec.php"); exit; } + } else if (isset($_POST['delp2_x'])) { + /* delete selected p2 entries */ + if (is_array($_POST['p2entry']) && count($_POST['p2entry'])) { + foreach ($_POST['p2entry'] as $p2entrydel) { + unset($a_phase2[$p2entrydel]); + } + if (write_config()) + mark_subsystem_dirty('ipsec'); + header("Location: vpn_ipsec.php"); + exit; + } } else { /* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */ unset($movebtn); @@ -128,6 +139,49 @@ if ($_POST) { header("Location: vpn_ipsec.php"); exit; } + + unset($movebtn); + foreach ($_POST as $pn => $pd) { + if (preg_match("/movep2_(\d+)_x/", $pn, $matches)) { + $movebtn = $matches[1]; + break; + } + } + /* move selected p2 entries before this */ + if (isset($movebtn) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) { + $a_phase2_new = array(); + + /* copy all p2 entries < $movebtn and not selected */ + for ($i = 0; $i < $movebtn; $i++) { + if (!in_array($i, $_POST['p2entry'])) + $a_phase2_new[] = $a_phase2[$i]; + } + + /* copy all selected p2 entries */ + for ($i = 0; $i < count($a_phase2); $i++) { + if ($i == $movebtn) + continue; + if (in_array($i, $_POST['p2entry'])) + $a_phase2_new[] = $a_phase2[$i]; + } + + /* copy $movebtn p2 entry */ + if ($movebtn < count($a_phase2)) + $a_phase2_new[] = $a_phase2[$movebtn]; + + /* copy all p2 entries > $movebtn and not selected */ + for ($i = $movebtn+1; $i < count($a_phase2); $i++) { + if (!in_array($i, $_POST['p2entry'])) + $a_phase2_new[] = $a_phase2[$i]; + } + if (count($a_phase2_new) > 0) + $a_phase2 = $a_phase2_new; + + if (write_config()) + mark_subsystem_dirty('ipsec'); + header("Location: vpn_ipsec.php"); + exit; + } } } @@ -165,6 +219,19 @@ if (isset($_GET['p1index']) && is_numericint($_GET['p1index']) && isset($a_phase header("Location: vpn_ipsec.php"); exit; +} else if (isset($_GET['p2index']) && is_numericint($_GET['p2index']) && isset($a_phase2[$_GET['p2index']])) { + if ($_GET['act'] == "togglep2") { + if (isset($a_phase2[$_GET['p2index']]['disabled'])) + unset($a_phase2[$_GET['p2index']]['disabled']); + else + $a_phase2[$_GET['p2index']]['disabled'] = true; + + write_config(); + mark_subsystem_dirty('ipsec'); + } + + header("Location: vpn_ipsec.php"); + exit; } $pgtitle = array(gettext("VPN"),gettext("IPsec")); @@ -366,81 +433,83 @@ include("head.inc");
-
@@ -493,23 +597,23 @@ include("head.inc"); $i++; endforeach; // $a_phase1 as $ph1ent ?> - +
- +?> " border="0" alt="move" /> - - " /> - + " /> + +?> @@ -519,17 +623,17 @@ include("head.inc");
- +?> " border="0" alt="delete" /> - +?> " onclick="return confirm('')" /> - +?>
-- cgit v1.1