Project

General

Profile

Download (6.79 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 29aef6c4 Jim Thompson
	Copyright (C) 2013-2014 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 f1bede03 Ermal
		$userkeys[] = array('ident' => $user['name'], '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 2a2b247b jim-p
                  <td class="listhdr"><?=gettext("Pre-Shared Key"); ?></td>
114 958420c5 jim-p
                  <td class="list">
115 4d07ca6a Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
116 958420c5 jim-p
			    <tr>
117 4d07ca6a Colin Fleming
			        <td width="20" height="17"></td>
118
				<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>
119 958420c5 jim-p
			    </tr>
120
			</table>
121
		  </td>
122
		</tr>
123 66a72c9f jim-p
			  <?php $i = 0; foreach ($userkeys as $secretent): ?>
124
		<tr>
125
		<td class="listlr gray">
126 f1bede03 Ermal
			<?php
127
				if ($secretent['ident'] == 'allusers')
128
					echo gettext("ANY USER");
129
				else
130
					echo htmlspecialchars($secretent['ident']);
131
			?>
132 66a72c9f jim-p
		</td>
133
		<td class="listr gray">
134
			<?=htmlspecialchars($secretent['pre-shared-key']);?>
135
		</td>
136 1a6769a6 Renato Botelho
		<td class="list nowrap">
137
			<form action="system_usermanager.php" method="post" name="form_edit_key">
138
				<input type="hidden" name="act" value="edit" />
139
				<input type="hidden" name="userid" value="<?=$secretent['id'];?>" />
140
				<input type="image" name="edituser[]" width="17" height="17" border="0"
141
					src="/themes/<?=$g['theme'];?>/images/icons/icon_e.gif"
142
					title="<?=gettext("edit");?>" />
143
			</form>
144 66a72c9f jim-p
		&nbsp;</td>
145
				</tr>
146
			  <?php $i++; endforeach; ?>
147
148 958420c5 jim-p
			  <?php $i = 0; foreach ($a_secret as $secretent): ?>
149
                <tr> 
150
                  <td class="listlr">
151
                    <?=htmlspecialchars($secretent['ident']);?>
152
                  </td>
153
                  <td class="listr">
154
                    <?=htmlspecialchars($secretent['pre-shared-key']);?>
155
                  </td>
156 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>
157
                     &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>
158 958420c5 jim-p
				</tr>
159
			  <?php $i++; endforeach; ?>
160
                <tr> 
161
                  <td class="list" colspan="2"></td>
162
                  <td class="list">
163 4d07ca6a Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
164 958420c5 jim-p
			    <tr>
165 4d07ca6a Colin Fleming
			        <td width="20" height="17"></td>
166
				<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>
167 958420c5 jim-p
			    </tr>
168
			</table>
169
		  </td>
170
		</tr>
171
              </table>
172
	</div>
173
      </td>
174
    </tr>
175 f1bede03 Ermal
	<tr>
176
		<td colspan="4">
177
			<p>
178
			<span class="vexpl">
179
			<span class="red">
180
				<strong><?=gettext("Note"); ?>:<br /></strong>
181
			</span>
182
			<?=gettext("PSK for any user can be set by using an identifier of any/ANY");?>
183
			</span>
184
			</p>
185
		</td>
186
	</tr>
187 958420c5 jim-p
</table>
188
<?php include("fend.inc"); ?>
189
</body>
190
</html>