Project

General

Profile

Download (6.72 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / vpn_ipsec_keys.php @ a1b66bec

1
<?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
require_once("filter.inc");
43

    
44
if (!is_array($config['ipsec']['mobilekey'])) {
45
	$config['ipsec']['mobilekey'] = array();
46
}
47
ipsec_mobilekey_sort();
48
$a_secret = &$config['ipsec']['mobilekey'];
49

    
50
$userkeys = array();
51
foreach ($config['system']['user'] as $id => $user) {
52
	if (!empty($user['ipsecpsk'])) {
53
		$userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);;
54
	}
55
}
56

    
57
if (isset($_POST['apply'])) {
58
	$retval = vpn_ipsec_configure();
59
	/* reload the filter in the background */
60
	filter_configure();
61
	$savemsg = get_std_save_message($retval);
62
	if (is_subsystem_dirty('ipsec'))
63
		clear_subsystem_dirty('ipsec');
64
}
65

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

    
76
$pgtitle = gettext("VPN: IPsec: Keys");
77
$shortcut_section = "ipsec";
78

    
79
include("head.inc");
80

    
81
?>
82

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

    
92
?>
93
</form>
94
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec keys">
95
  <tr><td class="tabnavtbl">
96
<?php
97
	$tab_array = array();
98
	$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
99
	$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
100
	$tab_array[2] = array(gettext("Pre-Shared Keys"), true, "vpn_ipsec_keys.php");
101
	$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
102
	display_top_tabs($tab_array);
103
?>
104
  </td></tr>
105
  <tr> 
106
    <td>
107
	<div id="mainarea">
108
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
109
                <tr> 
110
                  <td class="listhdrr"><?=gettext("Identifier"); ?></td>
111
                  <td class="listhdr"><?=gettext("Pre-Shared Key"); ?></td>
112
                  <td class="list">
113
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
114
			    <tr>
115
			        <td width="20" height="17"></td>
116
				<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>
117
			    </tr>
118
			</table>
119
		  </td>
120
		</tr>
121
			  <?php $i = 0; foreach ($userkeys as $secretent): ?>
122
		<tr>
123
		<td class="listlr gray">
124
			<?php
125
				if ($secretent['ident'] == 'allusers')
126
					echo gettext("ANY USER");
127
				else
128
					echo htmlspecialchars($secretent['ident']);
129
			?>
130
		</td>
131
		<td class="listr gray">
132
			<?=htmlspecialchars($secretent['pre-shared-key']);?>
133
		</td>
134
		<td class="list nowrap">
135
			<form action="system_usermanager.php" method="post" name="form_edit_key">
136
				<input type="hidden" name="act" value="edit" />
137
				<input type="hidden" name="userid" value="<?=$secretent['id'];?>" />
138
				<input type="image" name="edituser[]" width="17" height="17" border="0"
139
					src="/themes/<?=$g['theme'];?>/images/icons/icon_e.gif"
140
					title="<?=gettext("edit");?>" />
141
			</form>
142
		&nbsp;</td>
143
				</tr>
144
			  <?php $i++; endforeach; ?>
145

    
146
			  <?php $i = 0; foreach ($a_secret as $secretent): ?>
147
                <tr> 
148
                  <td class="listlr">
149
                    <?=htmlspecialchars($secretent['ident']);?>
150
                  </td>
151
                  <td class="listr">
152
                    <?=htmlspecialchars($secretent['pre-shared-key']);?>
153
                  </td>
154
                  <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>
155
                     &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>
156
				</tr>
157
			  <?php $i++; endforeach; ?>
158
                <tr> 
159
                  <td class="list" colspan="2"></td>
160
                  <td class="list">
161
			<table border="0" cellspacing="0" cellpadding="1" summary="add key">
162
			    <tr>
163
			        <td width="20" height="17"></td>
164
				<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>
165
			    </tr>
166
			</table>
167
		  </td>
168
		</tr>
169
              </table>
170
	</div>
171
      </td>
172
    </tr>
173
	<tr>
174
		<td colspan="4">
175
			<p>
176
			<span class="vexpl">
177
			<span class="red">
178
				<strong><?=gettext("Note"); ?>:<br /></strong>
179
			</span>
180
			<?=gettext("PSK for any user can be set by using an identifier of any/ANY");?>
181
			</span>
182
			</p>
183
		</td>
184
	</tr>
185
</table>
186
<?php include("fend.inc"); ?>
187
</body>
188
</html>
(238-238/256)