diff --git a/src/www/vpn_ipsec_keys.php b/src/www/vpn_ipsec_keys.php index b90698585..58cfcb293 100644 --- a/src/www/vpn_ipsec_keys.php +++ b/src/www/vpn_ipsec_keys.php @@ -39,35 +39,33 @@ if (!is_array($config['ipsec'])) { if (!is_array($config['ipsec']['mobilekey'])) { $config['ipsec']['mobilekey'] = array(); -} -ipsec_mobilekey_sort(); -$a_secret = &$config['ipsec']['mobilekey']; - -$userkeys = array(); -foreach ($config['system']['user'] as $id => $user) { - if (!empty($user['ipsecpsk'])) { - $userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id); - ; - } +} else { + ipsec_mobilekey_sort(); } -if (isset($_POST['apply'])) { - $retval = vpn_ipsec_configure(); - /* reload the filter in the background */ - filter_configure(); - $savemsg = get_std_save_message($retval); - if (is_subsystem_dirty('ipsec')) { - clear_subsystem_dirty('ipsec'); - } -} - -if ($_GET['act'] == "del") { - if ($a_secret[$_GET['id']]) { - unset($a_secret[$_GET['id']]); - write_config(gettext("Deleted IPsec Pre-Shared Key")); - mark_subsystem_dirty('ipsec'); - header("Location: vpn_ipsec_keys.php"); - exit; +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['act']) && isset($_POST['id']) && is_numericint($_POST['id']) && $_POST['act'] == "del") { + // delete entry + if (isset($config['ipsec']['mobilekey'][$_POST['id']])) { + unset($config['ipsec']['mobilekey'][$_POST['id']]); + write_config(gettext("Deleted IPsec Pre-Shared Key")); + mark_subsystem_dirty('ipsec'); + header("Location: vpn_ipsec_keys.php"); + exit; + } + } elseif (isset($_POST['apply'])) { + // apply changes + $retval = vpn_ipsec_configure(); + /* reload the filter in the background */ + filter_configure(); + $savemsg = get_std_save_message($retval); + if (is_subsystem_dirty('ipsec')) { + clear_subsystem_dirty('ipsec'); + } + } else { + // nothing to post, redirect + header("Location: vpn_ipsec_keys.php"); + exit; } } @@ -75,130 +73,127 @@ $pgtitle = gettext("VPN: IPsec: Keys"); $shortcut_section = "ipsec"; include("head.inc"); - ?> + + +
-
-
+
+
+" . gettext("You must apply the changes in order for them to take effect.")); + } - - " . gettext("You must apply the changes in order for them to take effect.")); - } - - ?> - -
- - - -
- -
- -
- - - - - - -
- - - - - -
+?> +
+ +
+ +
+ + + + + - $user) { + if (!empty($user['ipsecpsk'])) { + $userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id); + ; + } + } + foreach ($userkeys as $secretent) : ?> - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + -
+
- - - - - - - - " /> - -  
+ + + " class="btn btn-default btn-xs"> +
- - - - " width="17" height="17" border="0" alt="edit" /> -  ')">" width="17" height="17" border="0" alt="delete" />
- - - - - -
+
+ + + + + " class="btn btn-default btn-xs"> + " class="act_delete btn btn-default btn-xs"> +
+
-
- - -
-

- - - :
-
- -
-

-
-
-
- +
+
+ +
+ + :
+
+ +
+
+
+