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'])) { ...@@ -37,35 +37,37 @@ if (!is_array($config['ipsec'])) {
} }
if (!is_array($config['ipsec']['mobilekey'])) { if (!is_array($config['ipsec']['mobilekey'])) {
$config['ipsec']['mobilekey'] = array(); $config['ipsec']['mobilekey'] = array();
} }
ipsec_mobilekey_sort(); ipsec_mobilekey_sort();
$a_secret = &$config['ipsec']['mobilekey']; $a_secret = &$config['ipsec']['mobilekey'];
$userkeys = array(); $userkeys = array();
foreach ($config['system']['user'] as $id => $user) { foreach ($config['system']['user'] as $id => $user) {
if (!empty($user['ipsecpsk'])) { if (!empty($user['ipsecpsk'])) {
$userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);; $userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);
} ;
}
} }
if (isset($_POST['apply'])) { if (isset($_POST['apply'])) {
$retval = vpn_ipsec_configure(); $retval = vpn_ipsec_configure();
/* reload the filter in the background */ /* reload the filter in the background */
filter_configure(); filter_configure();
$savemsg = get_std_save_message($retval); $savemsg = get_std_save_message($retval);
if (is_subsystem_dirty('ipsec')) if (is_subsystem_dirty('ipsec')) {
clear_subsystem_dirty('ipsec'); clear_subsystem_dirty('ipsec');
}
} }
if ($_GET['act'] == "del") { if ($_GET['act'] == "del") {
if ($a_secret[$_GET['id']]) { if ($a_secret[$_GET['id']]) {
unset($a_secret[$_GET['id']]); unset($a_secret[$_GET['id']]);
write_config(gettext("Deleted IPsec Pre-Shared Key")); write_config(gettext("Deleted IPsec Pre-Shared Key"));
mark_subsystem_dirty('ipsec'); mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec_keys.php"); header("Location: vpn_ipsec_keys.php");
exit; exit;
} }
} }
$pgtitle = gettext("VPN: IPsec: Keys"); $pgtitle = gettext("VPN: IPsec: Keys");
...@@ -84,16 +86,19 @@ include("head.inc"); ...@@ -84,16 +86,19 @@ include("head.inc");
<?php <?php
if ($savemsg) if ($savemsg) {
print_info_box($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 (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"> <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"> <div class="tab-content content-box col-xs-12">
...@@ -115,15 +120,17 @@ include("head.inc"); ...@@ -115,15 +120,17 @@ include("head.inc");
</table> </table>
</td> </td>
</tr> </tr>
<?php $i = 0; foreach ($userkeys as $secretent): ?> <?php $i = 0; foreach ($userkeys as $secretent) :
?>
<tr> <tr>
<td class="listlr gray"> <td class="listlr gray">
<?php <?php
if ($secretent['ident'] == 'allusers') if ($secretent['ident'] == 'allusers') {
echo gettext("ANY USER"); echo gettext("ANY USER");
else } else {
echo htmlspecialchars($secretent['ident']); echo htmlspecialchars($secretent['ident']);
?> }
?>
</td> </td>
<td class="listr gray"> <td class="listr gray">
<?=htmlspecialchars($secretent['pre-shared-key']);?> <?=htmlspecialchars($secretent['pre-shared-key']);?>
...@@ -138,9 +145,12 @@ include("head.inc"); ...@@ -138,9 +145,12 @@ include("head.inc");
</form> </form>
&nbsp;</td> &nbsp;</td>
</tr> </tr>
<?php $i++; endforeach; ?> <?php $i++;
endforeach; ?>
<?php $i = 0; foreach ($a_secret as $secretent): ?> <?php $i = 0; foreach ($a_secret as $secretent) :
?>
<tr> <tr>
<td class="listlr"> <td class="listlr">
<?=htmlspecialchars($secretent['ident']);?> <?=htmlspecialchars($secretent['ident']);?>
...@@ -148,10 +158,17 @@ include("head.inc"); ...@@ -148,10 +158,17 @@ include("head.inc");
<td class="listr"> <td class="listr">
<?=htmlspecialchars($secretent['pre-shared-key']);?> <?=htmlspecialchars($secretent['pre-shared-key']);?>
</td> </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> <td class="list nowrap"><a href="vpn_ipsec_keys_edit.php?id=<?=$i;
&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> ?>"><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> </tr>
<?php $i++; endforeach; ?> <?php $i++;
endforeach; ?>
<tr> <tr>
<td class="list" colspan="2"></td> <td class="list" colspan="2"></td>
<td class="list"> <td class="list">
...@@ -183,4 +200,4 @@ include("head.inc"); ...@@ -183,4 +200,4 @@ include("head.inc");
</div> </div>
</section> </section>
<?php include("foot.inc"); ?> <?php include("foot.inc");
...@@ -36,76 +36,80 @@ if (!is_array($config['ipsec'])) { ...@@ -36,76 +36,80 @@ if (!is_array($config['ipsec'])) {
} }
if (!is_array($config['ipsec']['mobilekey'])) { if (!is_array($config['ipsec']['mobilekey'])) {
$config['ipsec']['mobilekey'] = array(); $config['ipsec']['mobilekey'] = array();
} }
ipsec_mobilekey_sort(); ipsec_mobilekey_sort();
$a_secret = &$config['ipsec']['mobilekey']; $a_secret = &$config['ipsec']['mobilekey'];
if (is_numericint($_GET['id'])) if (is_numericint($_GET['id'])) {
$id = $_GET['id']; $id = $_GET['id'];
if (isset($_POST['id']) && is_numericint($_POST['id'])) }
$id = $_POST['id']; if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
}
if (isset($id) && $a_secret[$id]) { if (isset($id) && $a_secret[$id]) {
$pconfig['ident'] = $a_secret[$id]['ident']; $pconfig['ident'] = $a_secret[$id]['ident'];
$pconfig['psk'] = $a_secret[$id]['pre-shared-key']; $pconfig['psk'] = $a_secret[$id]['pre-shared-key'];
} }
if ($_POST) { if ($_POST) {
$userids = array(); $userids = array();
foreach ($config['system']['user'] as $uid => $user) { foreach ($config['system']['user'] as $uid => $user) {
$userids[$user['name']] = $uid; $userids[$user['name']] = $uid;
} }
unset($input_errors); unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
/* input validation */ /* input validation */
$reqdfields = explode(" ", "ident psk"); $reqdfields = explode(" ", "ident psk");
$reqdfieldsn = array(gettext("Identifier"),gettext("Pre-Shared Key")); $reqdfieldsn = array(gettext("Identifier"),gettext("Pre-Shared Key"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (preg_match("/[^a-zA-Z0-9@\.\-]/", $_POST['ident'])) if (preg_match("/[^a-zA-Z0-9@\.\-]/", $_POST['ident'])) {
$input_errors[] = gettext("The identifier contains invalid characters."); $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."); if (array_key_exists($_POST['ident'], $userids)) {
unset($userids); $input_errors[] = gettext("A user with this name already exists. Add the key to the user instead.");
}
if (!$input_errors && !(isset($id) && $a_secret[$id])) { unset($userids);
/* make sure there are no dupes */
foreach ($a_secret as $secretent) { if (!$input_errors && !(isset($id) && $a_secret[$id])) {
if ($secretent['ident'] == $_POST['ident']) { /* make sure there are no dupes */
$input_errors[] = gettext("Another entry with the same identifier already exists."); foreach ($a_secret as $secretent) {
break; 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]) if (!$input_errors) {
$secretent = $a_secret[$id]; if (isset($id) && $a_secret[$id]) {
$secretent = $a_secret[$id];
$secretent['ident'] = $_POST['ident']; }
$secretent['pre-shared-key'] = $_POST['psk'];
$text = ""; $secretent['ident'] = $_POST['ident'];
$secretent['pre-shared-key'] = $_POST['psk'];
if (isset($id) && $a_secret[$id]) { $text = "";
$a_secret[$id] = $secretent;
$text = gettext("Edited"); if (isset($id) && $a_secret[$id]) {
} else { $a_secret[$id] = $secretent;
$a_secret[] = $secretent; $text = gettext("Edited");
$text = gettext("Added"); } else {
} $a_secret[] = $secretent;
$text = gettext("Added");
write_config("{$text} IPsec Pre-Shared Keys"); }
mark_subsystem_dirty('ipsec');
write_config("{$text} IPsec Pre-Shared Keys");
header("Location: vpn_ipsec_keys.php"); mark_subsystem_dirty('ipsec');
exit;
} header("Location: vpn_ipsec_keys.php");
exit;
}
} }
$pgtitle = gettext("VPN: IPsec: Edit Pre-Shared Key"); $pgtitle = gettext("VPN: IPsec: Edit Pre-Shared Key");
...@@ -123,7 +127,9 @@ include("head.inc"); ...@@ -123,7 +127,9 @@ include("head.inc");
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <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"> <section class="col-xs-12">
...@@ -136,7 +142,8 @@ include("head.inc"); ...@@ -136,7 +142,8 @@ include("head.inc");
<tr> <tr>
<td valign="top" class="vncellreq"><?=gettext("Identifier"); ?></td> <td valign="top" class="vncellreq"><?=gettext("Identifier"); ?></td>
<td class="vtable"> <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 /> <br />
<?=gettext("This can be either an IP address, fully qualified domain name or an e-mail address"); ?>. <?=gettext("This can be either an IP address, fully qualified domain name or an e-mail address"); ?>.
</td> </td>
...@@ -144,16 +151,19 @@ include("head.inc"); ...@@ -144,16 +151,19 @@ include("head.inc");
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
<td width="78%" class="vtable"> <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> </td>
</tr> </tr>
<tr> <tr>
<td width="22%" valign="top">&nbsp;</td> <td width="22%" valign="top">&nbsp;</td>
<td width="78%"> <td width="78%">
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" /> <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);?>" /> <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php endif; ?> <?php
endif; ?>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -174,4 +184,4 @@ include("head.inc"); ...@@ -174,4 +184,4 @@ include("head.inc");
</div> </div>
</section> </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 <?php
$tab_array = array(); $tab_array = array();
$tab_array[0] = array(gettext("Tunnels"), $_SERVER['PHP_SELF'] == "/vpn_ipsec.php", "vpn_ipsec.php"); $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[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[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"); $tab_array[3] = array(gettext("Advanced Settings"), $_SERVER['PHP_SELF'] == "/vpn_ipsec_settings.php", "vpn_ipsec_settings.php");
display_top_tabs($tab_array); display_top_tabs($tab_array);
?>
This diff is collapsed.
...@@ -33,42 +33,42 @@ require_once("guiconfig.inc"); ...@@ -33,42 +33,42 @@ require_once("guiconfig.inc");
require_once("vpn.inc"); require_once("vpn.inc");
if (!is_array($config['l2tp']['user'])) { if (!is_array($config['l2tp']['user'])) {
$config['l2tp']['user'] = array(); $config['l2tp']['user'] = array();
} }
$a_secret = &$config['l2tp']['user']; $a_secret = &$config['l2tp']['user'];
if ($_POST) { if ($_POST) {
$pconfig = $_POST;
$pconfig = $_POST;
if ($_POST['apply']) {
if ($_POST['apply']) { $retval = 0;
$retval = 0; if (!is_subsystem_dirty('rebootreq')) {
if (!is_subsystem_dirty('rebootreq')) { $retval = vpn_l2tp_configure();
$retval = vpn_l2tp_configure(); }
} $savemsg = get_std_save_message($retval);
$savemsg = get_std_save_message($retval); if ($retval == 0) {
if ($retval == 0) { if (is_subsystem_dirty('l2tpusers')) {
if (is_subsystem_dirty('l2tpusers')) clear_subsystem_dirty('l2tpusers');
clear_subsystem_dirty('l2tpusers'); }
} }
} }
} }
if ($_GET['act'] == "del") { if ($_GET['act'] == "del") {
if ($a_secret[$_GET['id']]) { if ($a_secret[$_GET['id']]) {
unset($a_secret[$_GET['id']]); unset($a_secret[$_GET['id']]);
write_config(); write_config();
mark_subsystem_dirty('l2tpusers'); mark_subsystem_dirty('l2tpusers');
redirectHeader("vpn_l2tp_users.php"); redirectHeader("vpn_l2tp_users.php");
exit; exit;
} }
} }
include("head.inc"); include("head.inc");
$main_buttons = array( $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( ...@@ -80,12 +80,17 @@ $main_buttons = array(
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php if ($savemsg) print_info_box($savemsg); ?> <?php if ($savemsg) {
<?php if (isset($config['l2tp']['radius']['enable'])) print_info_box($savemsg);
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 (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 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> <div id="inputerrors"></div>
...@@ -93,11 +98,11 @@ $main_buttons = array( ...@@ -93,11 +98,11 @@ $main_buttons = array(
<section class="col-xs-12"> <section class="col-xs-12">
<?php <?php
$tab_array = array(); $tab_array = array();
$tab_array[0] = array(gettext("Configuration"), false, "vpn_l2tp.php"); $tab_array[0] = array(gettext("Configuration"), false, "vpn_l2tp.php");
$tab_array[1] = array(gettext("Users"), true, "vpn_l2tp_users.php"); $tab_array[1] = array(gettext("Users"), true, "vpn_l2tp_users.php");
display_top_tabs($tab_array); display_top_tabs($tab_array);
?> ?>
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
...@@ -110,23 +115,30 @@ $main_buttons = array( ...@@ -110,23 +115,30 @@ $main_buttons = array(
<td class="listhdr"><?=gettext("IP address");?></td> <td class="listhdr"><?=gettext("IP address");?></td>
<td class="list"></td> <td class="list"></td>
</tr> </tr>
<?php $i = 0; foreach ($a_secret as $secretent): ?> <?php $i = 0; foreach ($a_secret as $secretent) :
?>
<tr> <tr>
<td class="listlr"> <td class="listlr">
<?=htmlspecialchars($secretent['name']);?> <?=htmlspecialchars($secretent['name']);?>
</td> </td>
<td class="listr"> <td class="listr">
<?php if($secretent['ip'] == "") $secretent['ip'] = "Dynamic"; ?> <?php if ($secretent['ip'] == "") {
$secretent['ip'] = "Dynamic";
} ?>
<?=htmlspecialchars($secretent['ip']);?>&nbsp; <?=htmlspecialchars($secretent['ip']);?>&nbsp;
</td> </td>
<td class="list nowrap" width="150"> <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_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> </td>
</tr> </tr>
<?php $i++; endforeach; ?> <?php $i++;
endforeach; ?>
</table> </table>
</div> </div>
...@@ -138,4 +150,4 @@ $main_buttons = array( ...@@ -138,4 +150,4 @@ $main_buttons = array(
</div> </div>
</section> </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