Commit 797df667 authored by Franco Fichtner's avatar Franco Fichtner

vpn: going down in style

parent e17d4515
This diff is collapsed.
......@@ -37,35 +37,37 @@ if (!is_array($config['ipsec'])) {
}
if (!is_array($config['ipsec']['mobilekey'])) {
$config['ipsec']['mobilekey'] = array();
$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);;
}
if (!empty($user['ipsecpsk'])) {
$userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);
;
}
}
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');
$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 ($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;
}
}
$pgtitle = gettext("VPN: IPsec: Keys");
......@@ -84,16 +86,19 @@ include("head.inc");
<?php
if ($savemsg)
print_info_box($savemsg);
if (is_subsystem_dirty('ipsec'))
print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));
if ($savemsg) {
print_info_box($savemsg);
}
if (is_subsystem_dirty('ipsec')) {
print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));
}
?>
?>
<section class="col-xs-12">
<? $active_tab = "/vpn_ipsec_settings.php"; include('vpn_ipsec_tabs.inc'); ?>
<? $active_tab = "/vpn_ipsec_settings.php";
include('vpn_ipsec_tabs.inc'); ?>
<div class="tab-content content-box col-xs-12">
......@@ -115,15 +120,17 @@ include("head.inc");
</table>
</td>
</tr>
<?php $i = 0; foreach ($userkeys as $secretent): ?>
<?php $i = 0; foreach ($userkeys as $secretent) :
?>
<tr>
<td class="listlr gray">
<?php
if ($secretent['ident'] == 'allusers')
echo gettext("ANY USER");
else
echo htmlspecialchars($secretent['ident']);
?>
if ($secretent['ident'] == 'allusers') {
echo gettext("ANY USER");
} else {
echo htmlspecialchars($secretent['ident']);
}
?>
</td>
<td class="listr gray">
<?=htmlspecialchars($secretent['pre-shared-key']);?>
......@@ -138,9 +145,12 @@ include("head.inc");
</form>
&nbsp;</td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
<?php $i = 0; foreach ($a_secret as $secretent): ?>
<?php $i = 0; foreach ($a_secret as $secretent) :
?>
<tr>
<td class="listlr">
<?=htmlspecialchars($secretent['ident']);?>
......@@ -148,10 +158,17 @@ include("head.inc");
<td class="listr">
<?=htmlspecialchars($secretent['pre-shared-key']);?>
</td>
<td class="list nowrap"><a href="vpn_ipsec_keys_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit key"); ?>" width="17" height="17" border="0" alt="edit" /></a>
&nbsp;<a href="vpn_ipsec_keys.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Pre-Shared Key?"); ?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete key"); ?>" width="17" height="17" border="0" alt="delete" /></a></td>
<td class="list nowrap"><a href="vpn_ipsec_keys_edit.php?id=<?=$i;
?>"><img src="./themes/<?= $g['theme'];
?>/images/icons/icon_e.gif" title="<?=gettext("edit key"); ?>" width="17" height="17" border="0" alt="edit" /></a>
&nbsp;<a href="vpn_ipsec_keys.php?act=del&amp;id=<?=$i;
?>" onclick="return confirm('<?=gettext("Do you really want to delete this Pre-Shared Key?");
?>')"><img src="./themes/<?= $g['theme'];
?>/images/icons/icon_x.gif" title="<?=gettext("delete key"); ?>" width="17" height="17" border="0" alt="delete" /></a></td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
<tr>
<td class="list" colspan="2"></td>
<td class="list">
......@@ -183,4 +200,4 @@ include("head.inc");
</div>
</section>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
......@@ -36,76 +36,80 @@ if (!is_array($config['ipsec'])) {
}
if (!is_array($config['ipsec']['mobilekey'])) {
$config['ipsec']['mobilekey'] = array();
$config['ipsec']['mobilekey'] = array();
}
ipsec_mobilekey_sort();
$a_secret = &$config['ipsec']['mobilekey'];
if (is_numericint($_GET['id']))
$id = $_GET['id'];
if (isset($_POST['id']) && is_numericint($_POST['id']))
$id = $_POST['id'];
if (is_numericint($_GET['id'])) {
$id = $_GET['id'];
}
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
}
if (isset($id) && $a_secret[$id]) {
$pconfig['ident'] = $a_secret[$id]['ident'];
$pconfig['psk'] = $a_secret[$id]['pre-shared-key'];
$pconfig['ident'] = $a_secret[$id]['ident'];
$pconfig['psk'] = $a_secret[$id]['pre-shared-key'];
}
if ($_POST) {
$userids = array();
foreach ($config['system']['user'] as $uid => $user) {
$userids[$user['name']] = $uid;
}
unset($input_errors);
$pconfig = $_POST;
/* input validation */
$reqdfields = explode(" ", "ident psk");
$reqdfieldsn = array(gettext("Identifier"),gettext("Pre-Shared Key"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (preg_match("/[^a-zA-Z0-9@\.\-]/", $_POST['ident']))
$input_errors[] = gettext("The identifier contains invalid characters.");
if (array_key_exists($_POST['ident'], $userids))
$input_errors[] = gettext("A user with this name already exists. Add the key to the user instead.");
unset($userids);
if (!$input_errors && !(isset($id) && $a_secret[$id])) {
/* make sure there are no dupes */
foreach ($a_secret as $secretent) {
if ($secretent['ident'] == $_POST['ident']) {
$input_errors[] = gettext("Another entry with the same identifier already exists.");
break;
}
}
}
if (!$input_errors) {
if (isset($id) && $a_secret[$id])
$secretent = $a_secret[$id];
$secretent['ident'] = $_POST['ident'];
$secretent['pre-shared-key'] = $_POST['psk'];
$text = "";
if (isset($id) && $a_secret[$id]) {
$a_secret[$id] = $secretent;
$text = gettext("Edited");
} else {
$a_secret[] = $secretent;
$text = gettext("Added");
}
write_config("{$text} IPsec Pre-Shared Keys");
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec_keys.php");
exit;
}
$userids = array();
foreach ($config['system']['user'] as $uid => $user) {
$userids[$user['name']] = $uid;
}
unset($input_errors);
$pconfig = $_POST;
/* input validation */
$reqdfields = explode(" ", "ident psk");
$reqdfieldsn = array(gettext("Identifier"),gettext("Pre-Shared Key"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (preg_match("/[^a-zA-Z0-9@\.\-]/", $_POST['ident'])) {
$input_errors[] = gettext("The identifier contains invalid characters.");
}
if (array_key_exists($_POST['ident'], $userids)) {
$input_errors[] = gettext("A user with this name already exists. Add the key to the user instead.");
}
unset($userids);
if (!$input_errors && !(isset($id) && $a_secret[$id])) {
/* make sure there are no dupes */
foreach ($a_secret as $secretent) {
if ($secretent['ident'] == $_POST['ident']) {
$input_errors[] = gettext("Another entry with the same identifier already exists.");
break;
}
}
}
if (!$input_errors) {
if (isset($id) && $a_secret[$id]) {
$secretent = $a_secret[$id];
}
$secretent['ident'] = $_POST['ident'];
$secretent['pre-shared-key'] = $_POST['psk'];
$text = "";
if (isset($id) && $a_secret[$id]) {
$a_secret[$id] = $secretent;
$text = gettext("Edited");
} else {
$a_secret[] = $secretent;
$text = gettext("Added");
}
write_config("{$text} IPsec Pre-Shared Keys");
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec_keys.php");
exit;
}
}
$pgtitle = gettext("VPN: IPsec: Edit Pre-Shared Key");
......@@ -123,7 +127,9 @@ include("head.inc");
<div class="container-fluid">
<div class="row">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($input_errors) {
print_input_errors($input_errors);
} ?>
<section class="col-xs-12">
......@@ -136,7 +142,8 @@ include("head.inc");
<tr>
<td valign="top" class="vncellreq"><?=gettext("Identifier"); ?></td>
<td class="vtable">
<?=$mandfldhtml;?><input name="ident" type="text" class="formfld unknown" id="ident" size="30" value="<?=htmlspecialchars($pconfig['ident']);?>" />
<?=$mandfldhtml;
?><input name="ident" type="text" class="formfld unknown" id="ident" size="30" value="<?=htmlspecialchars($pconfig['ident']);?>" />
<br />
<?=gettext("This can be either an IP address, fully qualified domain name or an e-mail address"); ?>.
</td>
......@@ -144,16 +151,19 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
<td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="psk" type="text" class="formfld unknown" id="psk" size="40" value="<?=htmlspecialchars($pconfig['psk']);?>" />
<?=$mandfldhtml;
?><input name="psk" type="text" class="formfld unknown" id="psk" size="40" value="<?=htmlspecialchars($pconfig['psk']);?>" />
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<?php if (isset($id) && $a_secret[$id]): ?>
<?php if (isset($id) && $a_secret[$id]) :
?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
</table>
......@@ -174,4 +184,4 @@ include("head.inc");
</div>
</section>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
$tab_array = array();
$tab_array[0] = array(gettext("Tunnels"), $_SERVER['PHP_SELF'] == "/vpn_ipsec.php", "vpn_ipsec.php");
$tab_array[1] = array(gettext("Mobile clients"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_mobile.php", "vpn_ipsec_mobile.php");
$tab_array[2] = array(gettext("Pre-Shared Keys"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_keys.php", "vpn_ipsec_keys.php");
$tab_array[3] = array(gettext("Advanced Settings"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_settings.php", "vpn_ipsec_settings.php");
display_top_tabs($tab_array);
?>
$tab_array = array();
$tab_array[0] = array(gettext("Tunnels"), $_SERVER['PHP_SELF'] == "/vpn_ipsec.php", "vpn_ipsec.php");
$tab_array[1] = array(gettext("Mobile clients"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_mobile.php", "vpn_ipsec_mobile.php");
$tab_array[2] = array(gettext("Pre-Shared Keys"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_keys.php", "vpn_ipsec_keys.php");
$tab_array[3] = array(gettext("Advanced Settings"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_settings.php", "vpn_ipsec_settings.php");
display_top_tabs($tab_array);
This diff is collapsed.
......@@ -33,42 +33,42 @@ require_once("guiconfig.inc");
require_once("vpn.inc");
if (!is_array($config['l2tp']['user'])) {
$config['l2tp']['user'] = array();
$config['l2tp']['user'] = array();
}
$a_secret = &$config['l2tp']['user'];
if ($_POST) {
$pconfig = $_POST;
if ($_POST['apply']) {
$retval = 0;
if (!is_subsystem_dirty('rebootreq')) {
$retval = vpn_l2tp_configure();
}
$savemsg = get_std_save_message($retval);
if ($retval == 0) {
if (is_subsystem_dirty('l2tpusers'))
clear_subsystem_dirty('l2tpusers');
}
}
$pconfig = $_POST;
if ($_POST['apply']) {
$retval = 0;
if (!is_subsystem_dirty('rebootreq')) {
$retval = vpn_l2tp_configure();
}
$savemsg = get_std_save_message($retval);
if ($retval == 0) {
if (is_subsystem_dirty('l2tpusers')) {
clear_subsystem_dirty('l2tpusers');
}
}
}
}
if ($_GET['act'] == "del") {
if ($a_secret[$_GET['id']]) {
unset($a_secret[$_GET['id']]);
write_config();
mark_subsystem_dirty('l2tpusers');
redirectHeader("vpn_l2tp_users.php");
exit;
}
if ($a_secret[$_GET['id']]) {
unset($a_secret[$_GET['id']]);
write_config();
mark_subsystem_dirty('l2tpusers');
redirectHeader("vpn_l2tp_users.php");
exit;
}
}
include("head.inc");
$main_buttons = array(
array('label'=>gettext("add user"), 'href'=>'vpn_l2tp_users_edit.php'),
array('label'=>gettext("add user"), 'href'=>'vpn_l2tp_users_edit.php'),
);
?>
......@@ -80,12 +80,17 @@ $main_buttons = array(
<div class="container-fluid">
<div class="row">
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (isset($config['l2tp']['radius']['enable']))
print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used.")); ?>
<?php if (is_subsystem_dirty('l2tpusers')): ?><br/>
<?php if ($savemsg) {
print_info_box($savemsg);
} ?>
<?php if (isset($config['l2tp']['radius']['enable'])) {
print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used."));
} ?>
<?php if (is_subsystem_dirty('l2tpusers')) :
?><br/>
<?php print_info_box_np(gettext("The l2tp user list has been modified") . ".<br />" . gettext("You must apply the changes in order for them to take effect") . ".<br /><b>" . gettext("Warning: this will terminate all current l2tp sessions!") . "</b>");?>
<?php endif; ?>
<?php
endif; ?>
<div id="inputerrors"></div>
......@@ -93,11 +98,11 @@ $main_buttons = array(
<section class="col-xs-12">
<?php
$tab_array = array();
$tab_array[0] = array(gettext("Configuration"), false, "vpn_l2tp.php");
$tab_array[1] = array(gettext("Users"), true, "vpn_l2tp_users.php");
display_top_tabs($tab_array);
?>
$tab_array = array();
$tab_array[0] = array(gettext("Configuration"), false, "vpn_l2tp.php");
$tab_array[1] = array(gettext("Users"), true, "vpn_l2tp_users.php");
display_top_tabs($tab_array);
?>
<div class="tab-content content-box col-xs-12">
......@@ -110,23 +115,30 @@ $main_buttons = array(
<td class="listhdr"><?=gettext("IP address");?></td>
<td class="list"></td>
</tr>
<?php $i = 0; foreach ($a_secret as $secretent): ?>
<?php $i = 0; foreach ($a_secret as $secretent) :
?>
<tr>
<td class="listlr">
<?=htmlspecialchars($secretent['name']);?>
</td>
<td class="listr">
<?php if($secretent['ip'] == "") $secretent['ip'] = "Dynamic"; ?>
<?php if ($secretent['ip'] == "") {
$secretent['ip'] = "Dynamic";
} ?>
<?=htmlspecialchars($secretent['ip']);?>&nbsp;
</td>
<td class="list nowrap" width="150">
<a href="vpn_l2tp_users_edit.php?id=<?=$i;?>" class="btn btn-default"><span class="glyphicon glyphicon-edit"></span></a>
<a href="vpn_l2tp_users.php?act=del&amp;id=<?=$i;?>" class="btn btn-default" onclick="return confirm('<?=gettext("Do you really want to delete this user?");?>')"title="<?=gettext("delete user"); ?>"><span class="glyphicon glyphicon-remove"></span></a>
<a href="vpn_l2tp_users.php?act=del&amp;id=<?=$i;
?>" class="btn btn-default" onclick="return confirm('<?=gettext("Do you really want to delete this user?");
?>')"title="<?=gettext("delete user"); ?>"><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
</table>
</div>
......@@ -138,4 +150,4 @@ $main_buttons = array(
</div>
</section>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment