Project

General

Profile

Download (7.17 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec_keys.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5
	part of pfSense
6
	
7
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	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
require_once("filter.inc");
45

    
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
$userkeys = array();
53
foreach ($config['system']['user'] as $id => $user) {
54
	if (!empty($user['ipsecpsk'])) {
55
		$userkeys[] = array('ident' => $user['name'], 'type' => 'PSK', 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);;
56
	}
57
}
58

    
59
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
}
67

    
68
if ($_GET['act'] == "del") {
69
	if ($a_secret[$_GET['id']]) {
70
		unset($a_secret[$_GET['id']]);
71
		write_config(gettext("Deleted IPsec Pre-Shared Key"));
72
		mark_subsystem_dirty('ipsec');
73
		header("Location: vpn_ipsec_keys.php");
74
		exit;
75
	}
76
}
77

    
78
$pgtitle = gettext("VPN: IPsec: Keys");
79
$shortcut_section = "ipsec";
80

    
81
include("head.inc");
82

    
83
?>
84

    
85
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
86
<?php include("fbegin.inc"); ?>
87
<form action="vpn_ipsec_keys.php" method="post">
88
<?php 
89
if ($savemsg)
90
	print_info_box($savemsg);
91
if (is_subsystem_dirty('ipsec'))
92
	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

    
94
?>
95
</form>
96
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec keys">
97
  <tr><td class="tabnavtbl">
98
<?php
99
	$tab_array = array();
100
	$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
101
	$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
102
	$tab_array[2] = array(gettext("Pre-Shared Keys"), true, "vpn_ipsec_keys.php");
103
	$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
104
	display_top_tabs($tab_array);
105
?>
106
  </td></tr>
107
  <tr> 
108
    <td>
109
	<div id="mainarea">
110
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
111
                <tr> 
112
                  <td class="listhdrr"><?=gettext("Identifier"); ?></td>
113
                  <td class="listhdrr"><?=gettext("Type"); ?></td>
114
                  <td class="listhdr"><?=gettext("Pre-Shared Key"); ?></td>
115
                  <td class="list">
116
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
117
			    <tr>
118
			        <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
			    </tr>
121
			</table>
122
		  </td>
123
		</tr>
124
			  <?php $i = 0; foreach ($userkeys as $secretent): ?>
125
		<tr>
126
		<td class="listlr gray">
127
			<?php
128
				if ($secretent['ident'] == 'allusers')
129
					echo gettext("ANY USER");
130
				else
131
					echo htmlspecialchars($secretent['ident']);
132
			?>
133
		</td>
134
		<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
		<td class="listr gray">
143
			<?=htmlspecialchars($secretent['pre-shared-key']);?>
144
		</td>
145
		<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
		&nbsp;</td>
154
				</tr>
155
			  <?php $i++; endforeach; ?>
156

    
157
			  <?php $i = 0; foreach ($a_secret as $secretent): ?>
158
                <tr> 
159
                  <td class="listlr">
160
                    <?=htmlspecialchars($secretent['ident']);?>
161
                  </td>
162
		<td class="listlr">
163
			<?php
164
				if (empty($secretent['type']))
165
					echo 'PSK';
166
				else
167
					echo htmlspecialchars($secretent['type']);
168
			?>
169
		</td>
170
                  <td class="listr">
171
                    <?=htmlspecialchars($secretent['pre-shared-key']);?>
172
                  </td>
173
                  <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
				</tr>
176
			  <?php $i++; endforeach; ?>
177
                <tr> 
178
                  <td class="list" colspan="3"></td>
179
                  <td class="list">
180
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
181
			    <tr>
182
			        <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
			    </tr>
185
			</table>
186
		  </td>
187
		</tr>
188
              </table>
189
	</div>
190
      </td>
191
    </tr>
192
	<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
</table>
205
<?php include("fend.inc"); ?>
206
</body>
207
</html>
(238-238/256)