Project

General

Profile

Download (7.17 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 29aef6c4 Jim Thompson
	part of pfSense
6 958420c5 jim-p
	
7
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
8 ed2d1343 Renato Botelho
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 958420c5 jim-p
	All rights reserved.
10
	
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
	
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
	
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
	
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
##|+PRIV
34
##|*IDENT=page-vpn-ipsec-listkeys
35
##|*NAME=VPN: IPsec: Pre-Shared Keys List
36
##|*DESCR=Allow access to the 'VPN: IPsec: Pre-Shared Keys List' page.
37
##|*MATCH=vpn_ipsec_keys.php*
38
##|-PRIV
39
40
require("functions.inc");
41
require("guiconfig.inc");
42
require_once("ipsec.inc");
43
require_once("vpn.inc");
44 ad970c21 Renato Botelho
require_once("filter.inc");
45 958420c5 jim-p
46
if (!is_array($config['ipsec']['mobilekey'])) {
47
	$config['ipsec']['mobilekey'] = array();
48
}
49
ipsec_mobilekey_sort();
50
$a_secret = &$config['ipsec']['mobilekey'];
51
52 66a72c9f jim-p
$userkeys = array();
53
foreach ($config['system']['user'] as $id => $user) {
54 b039f099 jim-p
	if (!empty($user['ipsecpsk'])) {
55 10e2acb5 Ermal LUÇI
		$userkeys[] = array('ident' => $user['name'], 'type' => 'PSK', 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);;
56 66a72c9f jim-p
	}
57
}
58
59 b446562b Renato Botelho
if (isset($_POST['apply'])) {
60
	$retval = vpn_ipsec_configure();
61
	/* reload the filter in the background */
62
	filter_configure();
63
	$savemsg = get_std_save_message($retval);
64
	if (is_subsystem_dirty('ipsec'))
65
		clear_subsystem_dirty('ipsec');
66 130a84c5 Ermal
}
67 66a72c9f jim-p
68 958420c5 jim-p
if ($_GET['act'] == "del") {
69
	if ($a_secret[$_GET['id']]) {
70
		unset($a_secret[$_GET['id']]);
71 171b0468 Rafael Lucas
		write_config(gettext("Deleted IPsec Pre-Shared Key"));
72 958420c5 jim-p
		mark_subsystem_dirty('ipsec');
73
		header("Location: vpn_ipsec_keys.php");
74
		exit;
75
	}
76
}
77
78 76b89c84 Carlos Eduardo Ramos
$pgtitle = gettext("VPN: IPsec: Keys");
79 b32dd0a6 jim-p
$shortcut_section = "ipsec";
80 6deedfde jim-p
81 958420c5 jim-p
include("head.inc");
82
83
?>
84
85
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
86
<?php include("fbegin.inc"); ?>
87 ad970c21 Renato Botelho
<form action="vpn_ipsec_keys.php" method="post">
88 958420c5 jim-p
<?php 
89
if ($savemsg)
90
	print_info_box($savemsg);
91
if (is_subsystem_dirty('ipsec'))
92 8cd558b6 ayvis
	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."));
93 958420c5 jim-p
94
?>
95 a4c1fff2 Renato Botelho
</form>
96 4d07ca6a Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec keys">
97 958420c5 jim-p
  <tr><td class="tabnavtbl">
98
<?php
99
	$tab_array = array();
100 76b89c84 Carlos Eduardo Ramos
	$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
101
	$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
102 2a2b247b jim-p
	$tab_array[2] = array(gettext("Pre-Shared Keys"), true, "vpn_ipsec_keys.php");
103 71172088 jim-p
	$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
104 958420c5 jim-p
	display_top_tabs($tab_array);
105
?>
106
  </td></tr>
107
  <tr> 
108
    <td>
109
	<div id="mainarea">
110 4d07ca6a Colin Fleming
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
111 958420c5 jim-p
                <tr> 
112 76b89c84 Carlos Eduardo Ramos
                  <td class="listhdrr"><?=gettext("Identifier"); ?></td>
113 10e2acb5 Ermal LUÇI
                  <td class="listhdrr"><?=gettext("Type"); ?></td>
114 2a2b247b jim-p
                  <td class="listhdr"><?=gettext("Pre-Shared Key"); ?></td>
115 958420c5 jim-p
                  <td class="list">
116 4d07ca6a Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
117 958420c5 jim-p
			    <tr>
118 4d07ca6a Colin Fleming
			        <td width="20" height="17"></td>
119
				<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" alt="add" /></a></td>
120 958420c5 jim-p
			    </tr>
121
			</table>
122
		  </td>
123
		</tr>
124 66a72c9f jim-p
			  <?php $i = 0; foreach ($userkeys as $secretent): ?>
125
		<tr>
126
		<td class="listlr gray">
127 f1bede03 Ermal
			<?php
128
				if ($secretent['ident'] == 'allusers')
129
					echo gettext("ANY USER");
130
				else
131
					echo htmlspecialchars($secretent['ident']);
132
			?>
133 66a72c9f jim-p
		</td>
134 10e2acb5 Ermal LUÇI
		<td class="listlr gray">
135
			<?php
136
				if (empty($secretent['type']))
137
					echo 'PSK';
138
				else
139
					echo htmlspecialchars($secretent['type']);
140
			?>
141
		</td>
142 66a72c9f jim-p
		<td class="listr gray">
143
			<?=htmlspecialchars($secretent['pre-shared-key']);?>
144
		</td>
145 1a6769a6 Renato Botelho
		<td class="list nowrap">
146
			<form action="system_usermanager.php" method="post" name="form_edit_key">
147
				<input type="hidden" name="act" value="edit" />
148
				<input type="hidden" name="userid" value="<?=$secretent['id'];?>" />
149
				<input type="image" name="edituser[]" width="17" height="17" border="0"
150
					src="/themes/<?=$g['theme'];?>/images/icons/icon_e.gif"
151
					title="<?=gettext("edit");?>" />
152
			</form>
153 66a72c9f jim-p
		&nbsp;</td>
154
				</tr>
155
			  <?php $i++; endforeach; ?>
156
157 958420c5 jim-p
			  <?php $i = 0; foreach ($a_secret as $secretent): ?>
158
                <tr> 
159
                  <td class="listlr">
160
                    <?=htmlspecialchars($secretent['ident']);?>
161
                  </td>
162 10e2acb5 Ermal LUÇI
		<td class="listlr">
163
			<?php
164
				if (empty($secretent['type']))
165
					echo 'PSK';
166
				else
167
					echo htmlspecialchars($secretent['type']);
168
			?>
169
		</td>
170 958420c5 jim-p
                  <td class="listr">
171
                    <?=htmlspecialchars($secretent['pre-shared-key']);?>
172
                  </td>
173 4d07ca6a Colin Fleming
                  <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>
174
                     &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>
175 958420c5 jim-p
				</tr>
176
			  <?php $i++; endforeach; ?>
177
                <tr> 
178 10e2acb5 Ermal LUÇI
                  <td class="list" colspan="3"></td>
179 958420c5 jim-p
                  <td class="list">
180 4d07ca6a Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
181 958420c5 jim-p
			    <tr>
182 4d07ca6a Colin Fleming
			        <td width="20" height="17"></td>
183
				<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" alt="add" /></a></td>
184 958420c5 jim-p
			    </tr>
185
			</table>
186
		  </td>
187
		</tr>
188
              </table>
189
	</div>
190
      </td>
191
    </tr>
192 f1bede03 Ermal
	<tr>
193
		<td colspan="4">
194
			<p>
195
			<span class="vexpl">
196
			<span class="red">
197
				<strong><?=gettext("Note"); ?>:<br /></strong>
198
			</span>
199
			<?=gettext("PSK for any user can be set by using an identifier of any/ANY");?>
200
			</span>
201
			</p>
202
		</td>
203
	</tr>
204 958420c5 jim-p
</table>
205
<?php include("fend.inc"); ?>
206
</body>
207
</html>