Project

General

Profile

Download (5.76 KB) Statistics
| Branch: | Tag: | Revision:
1 958420c5 jim-p
<?php
2
/*
3
	vpn_ipsec_keys.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5
	
6
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
7
	All rights reserved.
8
	
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
	
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
	
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
	
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
##|+PRIV
32
##|*IDENT=page-vpn-ipsec-listkeys
33
##|*NAME=VPN: IPsec: Pre-Shared Keys List
34
##|*DESCR=Allow access to the 'VPN: IPsec: Pre-Shared Keys List' page.
35
##|*MATCH=vpn_ipsec_keys.php*
36
##|-PRIV
37
38
require("functions.inc");
39
require("guiconfig.inc");
40
require_once("ipsec.inc");
41
require_once("vpn.inc");
42
43
if (!is_array($config['ipsec']['mobilekey'])) {
44
	$config['ipsec']['mobilekey'] = array();
45
}
46
ipsec_mobilekey_sort();
47
$a_secret = &$config['ipsec']['mobilekey'];
48
49 66a72c9f jim-p
$userkeys = array();
50
foreach ($config['system']['user'] as $id => $user) {
51
	if (isset($user['ipsecpsk'])) {
52
		$k = array();
53
		$k["ident"] = $user['name'];
54
		$k["pre-shared-key"] = $user['ipsecpsk'];
55
		$k["id"] = $id;
56
		$userkeys[] = $k;
57
	}
58
}
59
60
61 958420c5 jim-p
if ($_GET['act'] == "del") {
62
	if ($a_secret[$_GET['id']]) {
63
		unset($a_secret[$_GET['id']]);
64 171b0468 Rafael Lucas
		write_config(gettext("Deleted IPsec Pre-Shared Key"));
65 958420c5 jim-p
		mark_subsystem_dirty('ipsec');
66
		header("Location: vpn_ipsec_keys.php");
67
		exit;
68
	}
69
}
70
71 76b89c84 Carlos Eduardo Ramos
$pgtitle = gettext("VPN: IPsec: Keys");
72 6deedfde jim-p
$statusurl = "diag_ipsec.php";
73
$logurl = "diag_logs_ipsec.php";
74
75 958420c5 jim-p
include("head.inc");
76
77
?>
78
79
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
80
<?php include("fbegin.inc"); ?>
81
<form action="vpn_ipsec.php" method="post">
82
<?php 
83
if ($savemsg)
84
	print_info_box($savemsg);
85
if (is_subsystem_dirty('ipsec'))
86 76b89c84 Carlos Eduardo Ramos
	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."));
87 958420c5 jim-p
88
?>
89
<table width="100%" border="0" cellpadding="0" cellspacing="0">
90
  <tr><td class="tabnavtbl">
91
<?php
92
	$tab_array = array();
93 76b89c84 Carlos Eduardo Ramos
	$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
94
	$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
95
	$tab_array[2] = array(gettext("Pre-shared keys"), true, "vpn_ipsec_keys.php");
96 958420c5 jim-p
	display_top_tabs($tab_array);
97
?>
98
  </td></tr>
99
  <tr> 
100
    <td>
101
	<div id="mainarea">
102
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
103
                <tr> 
104 76b89c84 Carlos Eduardo Ramos
                  <td class="listhdrr"><?=gettext("Identifier"); ?></td>
105
                  <td class="listhdr"><?=gettext("Pre-shared key"); ?></td>
106 958420c5 jim-p
                  <td class="list">
107
			<table border="0" cellspacing="0" cellpadding="1">
108
			    <tr>
109
			        <td width="20" heigth="17"></td>
110 76b89c84 Carlos Eduardo Ramos
				<td><a href="vpn_ipsec_keys_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add key"); ?>" width="17" height="17" border="0"></a></td>
111 958420c5 jim-p
			    </tr>
112
			</table>
113
		  </td>
114
		</tr>
115 66a72c9f jim-p
			  <?php $i = 0; foreach ($userkeys as $secretent): ?>
116
		<tr>
117
		<td class="listlr gray">
118
			<?=htmlspecialchars($secretent['ident']);?>
119
		</td>
120
		<td class="listr gray">
121
			<?=htmlspecialchars($secretent['pre-shared-key']);?>
122
		</td>
123 76b89c84 Carlos Eduardo Ramos
		<td class="list" nowrap><a href="system_usermanager.php?act=edit&id=<?=$secretent['id'];?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit key"); ?>" width="17" height="17" border="0"></a>
124 66a72c9f jim-p
		&nbsp;</td>
125
				</tr>
126
			  <?php $i++; endforeach; ?>
127
128 958420c5 jim-p
			  <?php $i = 0; foreach ($a_secret as $secretent): ?>
129
                <tr> 
130
                  <td class="listlr">
131
                    <?=htmlspecialchars($secretent['ident']);?>
132
                  </td>
133
                  <td class="listr">
134
                    <?=htmlspecialchars($secretent['pre-shared-key']);?>
135
                  </td>
136 76b89c84 Carlos Eduardo Ramos
                  <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"></a>
137
                     &nbsp;<a href="vpn_ipsec_keys.php?act=del&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"></a></td>
138 958420c5 jim-p
				</tr>
139
			  <?php $i++; endforeach; ?>
140
                <tr> 
141
                  <td class="list" colspan="2"></td>
142
                  <td class="list">
143
			<table border="0" cellspacing="0" cellpadding="1">
144
			    <tr>
145
			        <td width="20" heigth="17"></td>
146 76b89c84 Carlos Eduardo Ramos
				<td><a href="vpn_ipsec_keys_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add key"); ?>" width="17" height="17" border="0"></a></td>
147 958420c5 jim-p
			    </tr>
148
			</table>
149
		  </td>
150
		</tr>
151
              </table>
152
	</div>
153
      </td>
154
    </tr>
155
</table>
156
</form>
157
<?php include("fend.inc"); ?>
158
</body>
159
</html>