Project

General

Profile

Download (21.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2004, 2005 Scott Ullrich
8
	Copyright (c)  2003-2005 Manuel Kasper <mk@neon1.net>
9
 *
10
 *	Redistribution and use in source and binary forms, with or without modification,
11
 *	are permitted provided that the following conditions are met:
12
 *
13
 *	1. Redistributions of source code must retain the above copyright notice,
14
 *		this list of conditions and the following disclaimer.
15
 *
16
 *	2. Redistributions in binary form must reproduce the above copyright
17
 *		notice, this list of conditions and the following disclaimer in
18
 *		the documentation and/or other materials provided with the
19
 *		distribution.
20
 *
21
 *	3. All advertising materials mentioning features or use of this software
22
 *		must display the following acknowledgment:
23
 *		"This product includes software developed by the pfSense Project
24
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
25
 *
26
 *	4. The names "pfSense" and "pfSense Project" must not be used to
27
 *		 endorse or promote products derived from this software without
28
 *		 prior written permission. For written permission, please contact
29
 *		 coreteam@pfsense.org.
30
 *
31
 *	5. Products derived from this software may not be called "pfSense"
32
 *		nor may "pfSense" appear in their names without prior written
33
 *		permission of the Electric Sheep Fencing, LLC.
34
 *
35
 *	6. Redistributions of any form whatsoever must retain the following
36
 *		acknowledgment:
37
 *
38
 *	"This product includes software developed by the pfSense Project
39
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
40
 *
41
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
42
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
45
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
53
 *
54
 *	====================================================================
55
 *
56
 */
57

    
58
##|+PRIV
59
##|*IDENT=page-vpn-ipsec
60
##|*NAME=VPN: IPsec page
61
##|*DESCR=Allow access to the 'VPN: IPsec' page.
62
##|*MATCH=vpn_ipsec.php*
63
##|-PRIV
64

    
65
require("guiconfig.inc");
66
require_once("functions.inc");
67
require_once("filter.inc");
68
require_once("shaper.inc");
69
require_once("ipsec.inc");
70
require_once("vpn.inc");
71

    
72
if (!is_array($config['ipsec']['phase1'])) {
73
	$config['ipsec']['phase1'] = array();
74
}
75

    
76
if (!is_array($config['ipsec']['phase2'])) {
77
	$config['ipsec']['phase2'] = array();
78
}
79

    
80
$a_phase1 = &$config['ipsec']['phase1'];
81
$a_phase2 = &$config['ipsec']['phase2'];
82

    
83
$pconfig['enable'] = isset($config['ipsec']['enable']);
84

    
85
if ($_POST) {
86

    
87
	if ($_POST['apply']) {
88
		$retval = 0;
89
		$retval = vpn_ipsec_configure();
90
		/* reload the filter in the background */
91
		filter_configure();
92
		$savemsg = get_std_save_message($retval);
93
		if ($retval >= 0) {
94
			if (is_subsystem_dirty('ipsec')) {
95
				clear_subsystem_dirty('ipsec');
96
			}
97
		}
98
	} else if ($_POST['submit'] == 'Save') {
99
		$pconfig = $_POST;
100

    
101
		$config['ipsec']['enable'] = $_POST['enable'] ? true : false;
102

    
103
		write_config();
104

    
105
		$retval = vpn_ipsec_configure();
106
	} else if (isset($_POST['del'])) {
107
		/* delete selected p1 entries */
108
		if (is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
109
			foreach ($_POST['p1entry'] as $p1entrydel) {
110
				unset($a_phase1[$p1entrydel]);
111
			}
112
			if (write_config()) {
113
				mark_subsystem_dirty('ipsec');
114
			}
115
		}
116
	} else if (isset($_POST['delp2'])) {
117
		/* delete selected p2 entries */
118
		if (is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
119
			foreach ($_POST['p2entry'] as $p2entrydel) {
120
				unset($a_phase2[$p2entrydel]);
121
			}
122
			if (write_config()) {
123
				mark_subsystem_dirty('ipsec');
124
			}
125
		}
126
	} else {
127
		/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
128

    
129
		// TODO: this. is. nasty.
130
		unset($delbtn, $delbtnp2, $movebtn, $movebtnp2, $togglebtn, $togglebtnp2);
131
		foreach ($_POST as $pn => $pd) {
132
			if (preg_match("/del_(\d+)/", $pn, $matches)) {
133
				$delbtn = $matches[1];
134
			} else if (preg_match("/delp2_(\d+)/", $pn, $matches)) {
135
				$delbtnp2 = $matches[1];
136
			} else if (preg_match("/move_(\d+)/", $pn, $matches)) {
137
				$movebtn = $matches[1];
138
			} else if (preg_match("/movep2_(\d+)/", $pn, $matches)) {
139
				$movebtnp2 = $matches[1];
140
			} else if (preg_match("/toggle_(\d+)/", $pn, $matches)) {
141
				$togglebtn = $matches[1];
142
			} else if (preg_match("/togglep2_(\d+)/", $pn, $matches)) {
143
				$togglebtnp2 = $matches[1];
144
			}
145
		}
146

    
147
		$save = 1;
148

    
149
		/* move selected p1 entries before this */
150
		if (isset($movebtn) && is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
151
			$a_phase1_new = array();
152

    
153
			/* copy all p1 entries < $movebtn and not selected */
154
			for ($i = 0; $i < $movebtn; $i++) {
155
				if (!in_array($i, $_POST['p1entry'])) {
156
					$a_phase1_new[] = $a_phase1[$i];
157
				}
158
			}
159

    
160
			/* copy all selected p1 entries */
161
			for ($i = 0; $i < count($a_phase1); $i++) {
162
				if ($i == $movebtn) {
163
					continue;
164
				}
165
				if (in_array($i, $_POST['p1entry'])) {
166
					$a_phase1_new[] = $a_phase1[$i];
167
				}
168
			}
169

    
170
			/* copy $movebtn p1 entry */
171
			if ($movebtn < count($a_phase1)) {
172
				$a_phase1_new[] = $a_phase1[$movebtn];
173
			}
174

    
175
			/* copy all p1 entries > $movebtn and not selected */
176
			for ($i = $movebtn+1; $i < count($a_phase1); $i++) {
177
				if (!in_array($i, $_POST['p1entry'])) {
178
					$a_phase1_new[] = $a_phase1[$i];
179
				}
180
			}
181
			if (count($a_phase1_new) > 0) {
182
				$a_phase1 = $a_phase1_new;
183
			}
184

    
185
		} else if (isset($movebtnp2) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
186
			/* move selected p2 entries before this */
187
			$a_phase2_new = array();
188

    
189
			/* copy all p2 entries < $movebtnp2 and not selected */
190
			for ($i = 0; $i < $movebtnp2; $i++) {
191
				if (!in_array($i, $_POST['p2entry'])) {
192
					$a_phase2_new[] = $a_phase2[$i];
193
				}
194
			}
195

    
196
			/* copy all selected p2 entries */
197
			for ($i = 0; $i < count($a_phase2); $i++) {
198
				if ($i == $movebtnp2) {
199
					continue;
200
				}
201
				if (in_array($i, $_POST['p2entry'])) {
202
					$a_phase2_new[] = $a_phase2[$i];
203
				}
204
			}
205

    
206
			/* copy $movebtnp2 p2 entry */
207
			if ($movebtnp2 < count($a_phase2)) {
208
				$a_phase2_new[] = $a_phase2[$movebtnp2];
209
			}
210

    
211
			/* copy all p2 entries > $movebtnp2 and not selected */
212
			for ($i = $movebtnp2+1; $i < count($a_phase2); $i++) {
213
				if (!in_array($i, $_POST['p2entry'])) {
214
					$a_phase2_new[] = $a_phase2[$i];
215
				}
216
			}
217
			if (count($a_phase2_new) > 0) {
218
				$a_phase2 = $a_phase2_new;
219
			}
220

    
221
		} else if (isset($togglebtn)) {
222
			if (isset($a_phase1[$togglebtn]['disabled'])) {
223
				unset($a_phase1[$togglebtn]['disabled']);
224
			} else {
225
				$a_phase1[$togglebtn]['disabled'] = true;
226
			}
227
		} else if (isset($togglebtnp2)) {
228
			if (isset($a_phase2[$togglebtnp2]['disabled'])) {
229
				unset($a_phase2[$togglebtnp2]['disabled']);
230
			} else {
231
				$a_phase2[$togglebtnp2]['disabled'] = true;
232
			}
233
		} else if (isset($delbtn)) {
234
			/* remove static route if interface is not WAN */
235
			if ($a_phase1[$delbtn]['interface'] <> "wan") {
236
				mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']}");
237
			}
238

    
239
			/* remove all phase2 entries that match the ikeid */
240
			$ikeid = $a_phase1[$delbtn]['ikeid'];
241
			foreach ($a_phase2 as $p2index => $ph2tmp) {
242
				if ($ph2tmp['ikeid'] == $ikeid) {
243
					unset($a_phase2[$p2index]);
244
				}
245
			}
246
			unset($a_phase1[$delbtn]);
247

    
248
		} else if (isset($delbtnp2)) {
249
			unset($a_phase2[$delbtnp2]);
250

    
251
		} else {
252
			$save = 0;
253
		}
254

    
255
		if ($save === 1) {
256
			if (write_config()) {
257
				mark_subsystem_dirty('ipsec');
258
			}
259
		}
260
	}
261
}
262

    
263
$pgtitle = array(gettext("VPN"), gettext("IPsec"));
264
$shortcut_section = "ipsec";
265

    
266
include("head.inc");
267

    
268
$tab_array = array();
269
$tab_array[] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
270
$tab_array[] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
271
$tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
272
$tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
273
display_top_tabs($tab_array);
274
?>
275

    
276
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
277

    
278
<?php
279
	if ($savemsg) {
280
		print_info_box($savemsg, 'success');
281
	}
282

    
283
	if ($pconfig['enable'] && is_subsystem_dirty('ipsec')) {
284
		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."));
285
	}
286
?>
287

    
288
<form name="mainform" method="post">
289
	<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\"";?> />&nbsp;&nbsp;<?=gettext("Enable IPsec")?><br /><br />
290
	<input name="submit" type="submit" class="btn btn-sm btn-primary" value="<?=gettext("Save"); ?>" /><br /><br />
291

    
292
	<div class="panel panel-default">
293
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IPSec tunnels')?></h2></div>
294
		<div class="panel-body table-responsive">
295
			<table class="table table-striped table-hover">
296
				<thead>
297
					<tr>
298
						<th>&nbsp;</th>
299
						<th>&nbsp;</th>
300
						<th><?=gettext("IKE")?></th>
301
						<th><?=gettext("Remote Gateway")?></th>
302
						<th><?=gettext("Mode")?></th>
303
						<th><?=gettext("P1 Protocol")?></th>
304
						<th><?=gettext("P1 Transforms")?></th>
305
						<th><?=gettext("P1 Description")?></th>
306
						<th><?=gettext("Actions")?></th>
307
					</tr>
308
				</thead>
309
				<tbody class="p1-entries">
310
<?php $i = 0; foreach ($a_phase1 as $ph1ent): ?>
311
<?php
312
	$iconfn = "pass";
313

    
314
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
315

    
316
	if ($entryStatus == 'disabled') {
317
		$iconfn .= "_d";
318
	}
319
?>
320
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
321
						<td>
322
							<input type="checkbox" id="frc<?=$i?>" name="p1entry[]" value="<?=$i?>" onclick="fr_bgcolor('<?=$i?>')" />
323
						</td>
324
						<td>
325
							<button value="toggle_<?=$i?>" name="toggle_<?=$i?>" title="<?=gettext("click to toggle enabled/disabled status")?>" class="btn btn-xs btn-default" type="submit"><?= ($entryStatus == 'disabled' ? 'enable' : 'disable') ?></button>
326
						</td>
327
						<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>">
328
<?php
329
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1")
330
				echo "V1";
331
			else
332
				echo "V2";
333
?>
334
						</td>
335
						<td>
336
<?php
337
			if ($ph1ent['interface']) {
338
				$iflabels = get_configured_interface_with_descr();
339

    
340
				$carplist = get_configured_carp_interface_list();
341
				foreach ($carplist as $cif => $carpip)
342
					$iflabels[$cif] = $carpip." (".get_vip_descr($carpip).")";
343

    
344
				$aliaslist = get_configured_ip_aliases_list();
345
				foreach ($aliaslist as $aliasip => $aliasif)
346
					$iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
347

    
348
				$grouplist = return_gateway_groups_array();
349
				foreach ($grouplist as $name => $group) {
350
					if($group[0]['vip'] != "")
351
						$vipif = $group[0]['vip'];
352
					else
353
						$vipif = $group[0]['int'];
354
					$iflabels[$name] = "GW Group {$name}";
355
				}
356
				$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
357
			}
358
			else
359
				$if = "WAN";
360

    
361
			if (!isset($ph1ent['mobile']))
362
				echo $if."<br />".$ph1ent['remote-gateway'];
363
			else
364
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
365
?>
366
				</td>
367
				<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>">
368
					<?=$spans?>
369
					<?php
370
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1")
371
						echo "{$ph1ent['mode']}";
372
					?>
373
					<?=$spane?>
374
				</td>
375
				<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>">
376
					<?=$p1_ealgos[$ph1ent['encryption-algorithm']['name']]['name']?>
377
<?php
378
			if ($ph1ent['encryption-algorithm']['keylen']) {
379
				if ($ph1ent['encryption-algorithm']['keylen']=="auto")
380
					echo " (" . gettext("auto") . ")";
381
				else
382
					echo " ({$ph1ent['encryption-algorithm']['keylen']} " . gettext("bits") . ")";
383
			}
384
?>
385
						</td>
386
						<td>
387
							<?=$p1_halgos[$ph1ent['hash-algorithm']]?>
388
						</td>
389
						<td>
390
							<?=htmlspecialchars($ph1ent['descr'])?>
391
						</td>
392
						<td style="cursor: pointer;">
393
							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
394
							<button style="display: none;" class="btn btn-default btn-xs" type="submit" id="move_<?=$i?>" name="move_<?=$i?>" value="move_<?=$i?>"><?=gettext("Move checked entries to here")?></button>
395
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?p1index=<?=$i?>" title="<?=gettext("Edit phase1 entry"); ?>"></a>
396
<?php if (!isset($ph1ent['mobile'])): ?>
397
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase1 entry"); ?>"></a>
398
<?php endif; ?>
399
							<a	class="fa fa-trash" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase1 entry'); ?>"></a>
400
							<button style="display: none;" class="btn btn-xs btn-warning" type="submit" id="del_<?=$i?>" name="del_<?=$i?>" value="del_<?=$i?>" title="<?=gettext('Delete phase1 entry'); ?>">delete</button>
401

    
402
						</td>
403
					</tr>
404
					<tr class="<?= $entryStatus ?>">
405
						<td colspan="2"></td>
406
						<td colspan="7" class="contains-table">
407
<?php
408
			if (isset($_POST["tdph2-{$i}-visible"]))
409
				$tdph2_visible = htmlspecialchars($_POST["tdph2-{$i}-visible"]);
410
			else
411
				$tdph2_visible = 0;
412
?>
413
					<input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" />
414
					<div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>>
415
<?php
416
				$phase2count=0;
417

    
418
				foreach ($a_phase2 as $ph2ent) {
419
					if ($ph2ent['ikeid'] != $ph1ent['ikeid'])
420
						continue;
421
					$phase2count++;
422
				}
423
				$fr_prefix = "frp2{$i}";
424
				$fr_header = $fr_prefix . "header";
425
?>
426
						<input type="button" onclick="show_phase2('tdph2-<?=$i?>','shph2but-<?=$i?>')" value="+" /> - <?php printf(gettext("Show %s Phase-2 entries"), $phase2count); ?>
427
					</div>
428
					<div id="tdph2-<?=$i?>" <?=($tdph2_visible != '1' ? 'style="display:none"' : '')?>>
429
						<table class="table table-striped table-hover">
430
							<thead>
431
								<tr>
432
									<th>&nbsp;</th>
433
									<th>&nbsp;</th>
434
									<th><?=gettext("Mode"); ?></th>
435
									<th><?=gettext("Local Subnet"); ?></th>
436
									<th><?=gettext("Remote Subnet"); ?></th>
437
									<th><?=gettext("P2 Protocol"); ?></th>
438
									<th><?=gettext("P2 Transforms"); ?></th>
439
									<th><?=gettext("P2 Auth Methods"); ?></th>
440
									<th><?=gettext("P2 actions")?></th>
441
								</tr>
442
							</thead>
443
							<tbody class="p2-entries">
444
<?php $j = 0; foreach ($a_phase2 as $ph2index => $ph2ent): ?>
445
<?php
446
						if ($ph2ent['ikeid'] != $ph1ent['ikeid'])
447
							continue;
448

    
449
						$fr_c = $fr_prefix . "c" . $j;
450
						$fr_d = $fr_prefix . "d" . $j;
451

    
452
						$iconfn = "pass";
453
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
454

    
455
						if ($entryStatus == 'disabled')
456
							$iconfn .= "_d";
457

    
458
?>
459
								<tr id="<?=$fr_prefix . $j?>" ondblclick="document.location='vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>'" class="<?= $entryStatus ?>">
460
									<td>
461
										<input type="checkbox" id="<?=$fr_c?>" name="p2entry[]" value="<?=$ph2index?>" onclick="fr_bgcolor('<?=$j?>', '<?=$fr_prefix?>')" />
462
									</td>
463
									<td>
464
										<button value="togglep2_<?=$ph2index?>" name="togglep2_<?=$ph2index?>" title="<?=gettext("click to toggle enabled/disabled status")?>" class="btn btn-xs btn-default" type="submit"><?= ($entryStatus == 'disabled'? 'enable' : 'disable') ?></button>
465
									</td>
466
									<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
467
										<?=$ph2ent['mode']?>
468
									</td>
469
<?php if(($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6")): ?>
470
									<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
471
										<?=ipsec_idinfo_to_text($ph2ent['localid']); ?>
472
									</td>
473
									<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
474
										<?=ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
475
									</td>
476
<?php else: ?>
477
									<td colspan="2"></td>
478
<?php endif; ?>
479
									<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
480
										<?=$p2_protos[$ph2ent['protocol']]; ?>
481
									</td>
482
									<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
483
<?php
484
								foreach ($ph2ent['encryption-algorithm-option'] as $k => $ph2ea) {
485
									if ($k)
486
										echo ", ";
487
									echo $p2_ealgos[$ph2ea['name']]['name'];
488
									if ($ph2ea['keylen']) {
489
										if ($ph2ea['keylen']=="auto")
490
											echo " (" . gettext("auto") . ")";
491
										else
492
											echo " ({$ph2ea['keylen']} " . gettext("bits") . ")";
493
									}
494
								}
495
?>
496
									</td>
497
									<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
498
<?php
499
								if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) {
500
									foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) {
501
										if ($k)
502
											echo ", ";
503
										echo $p2_halgos[$ph2ha];
504
									}
505
								}
506
?>
507
									</td>
508
									<td style="cursor: pointer;">
509
									<!--	<button class="btn btn-xs btn-default" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>"><?=gettext("Move checked P2s here")?></button> -->
510
										<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>" title="<?=gettext("Edit phase2 entry"); ?>"></a>
511
										<a class="fa fa-clone" href="vpn_ipsec_phase2.php?dup=<?=$ph2ent['uniqid']?>" title="<?=gettext("Add a new Phase 2 based on this one"); ?>"></a>
512
										<a	class="fa fa-trash" id="Xdelp2_<?=$i?>" title="<?=gettext('Delete phase2 entry'); ?>"></a>
513
										<button style="display: none;" class="btn btn-xs btn-warning" type="submit" id="delp2_<?=$ph2index?>" name="delp2_<?=$ph2index?>" value="delp2_<?=$ph2index?>" title="<?=gettext('delete phase2 entry'); ?>">delete</button>
514
									</td>
515
								</tr>
516
<?php $j++; endforeach; ?>
517
								<tr>
518
									<td colspan="8"></td>
519
									<td>
520
<?php
521
/*
522
							if ($j == 0):
523
?>
524
										<i class="icon icon-arrow-down" title="<?=gettext("move selected phase2 entries to end")?>" alt="move"></i>
525
<?php
526
							else:
527
?>
528
										<i class="icon icon-arrow-down" name="movep2_<?=$j?>" onmouseover="fr_insline(<?=$j?>, true, '<?=$fr_prefix?>')" onmouseout="fr_insline(<?=$j?>, false, '<?=$fr_prefix?>')" title="<?=gettext("move selected phase2 entries to end")?>" alt="move"></i>
529
<?php
530
							endif;
531
*/
532
?>
533
										<a class="btn btn-xs btn-success" href="vpn_ipsec_phase2.php?ikeid=<?=$ph1ent['ikeid']?><?php if (isset($ph1ent['mobile'])) echo "&amp;mobile=true"?>"><?=gettext("Add phase2 entry"); ?>
534
										</a>
535
<?php
536
/*
537
							if ($j == 0):
538
?>
539
										<i class="icon icon-remove-sign" title="<?=gettext("delete selected phase2 entries")?>" alt="delete"></i>
540
<?php
541
							else:
542
?>
543
										<i name="delp2" class="icon icon-remove-sign" title="<?=gettext("delete selected phase2 entries")?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected phase2 entries?")?>')"></i>
544
<?php
545
							endif;
546
*/
547
?>
548
											</td>
549
										</tr>
550
									</tbody>
551
								</table>
552
							</div>
553
						</td>
554
					</tr>
555
<?php
556
					$i++;
557
				endforeach;	 // $a_phase1 as $ph1ent
558
?>
559
			</tbody>
560
		</table>
561
	</div>
562
</div>
563

    
564
<nav class="action-buttons">
565
<?php
566
/*
567
	if ($i !== 0): ?>
568
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
569
<?php endif;
570
*/
571
?>
572
	<a href="vpn_ipsec_phase1.php" class="btn btn-success"><?=gettext("Add new P1")?></a>
573
<?php if ($i !== 0): ?>
574
	<input type="submit" name="del" class="btn btn-danger" value="<?=gettext("Delete selected P1s")?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected phase1 entries?")?>')" />
575
<?php endif; ?>
576
</nav>
577
</form>
578

    
579
<div class="alert alert-info">
580
	<strong><?=gettext("Note:")?></strong><br />
581
	<?=gettext("You can check your IPsec status at"); ?> <a href="diag_ipsec.php"><?=gettext("Status:IPsec"); ?></a>.<br />
582
	<?=gettext("IPsec Debug Mode can be enabled at"); ?> <a href="vpn_ipsec_settings.php"><?=gettext("VPN:IPsec:Advanced Settings"); ?></a>.<br />
583
	<?=gettext("IPsec can be set to prefer older SAs at"); ?> <a href="vpn_ipsec_settings.php"><?=gettext("VPN:IPsec:Advanced Settings"); ?></a>.
584
</div>
585

    
586
<script type="text/javascript">
587
//<![CDATA[
588
function show_phase2(id, buttonid) {
589
	document.getElementById(buttonid).innerHTML='';
590
	document.getElementById(id).style.display = "block";
591
	var visible = id + '-visible';
592
	document.getElementById(visible).value = "1";
593
}
594

    
595
events.push(function() {
596
	// Make rules sortable
597
	$('table tbody.p2-entries').sortable({
598
		cursor: 'grabbing',
599
		update: function(event, ui) {
600
			$('#order-store').removeAttr('disabled');
601
		}
602
	});
603

    
604
	$('[id^=Xmove_]').click(function (event) {
605
		$('#' + event.target.id.slice(1)).click();
606
	});
607

    
608
	$('[id^=Xdel_]').click(function (event) {
609
		if(confirm("<?=gettext('Are you sure you wish to delete this P1 entry?')?>")) {
610
			$('#' + event.target.id.slice(1)).click();
611
		}
612
	});
613

    
614
	$('[id^=Xdelp2_]').click(function (event) {
615
		if(confirm("<?=gettext('Are you sure you wish to delete this P2 entry?')?>")) {
616
			$('#' + event.target.id.slice(1)).click();
617
		}
618
	});
619
});
620
//]]>
621
</script>
622

    
623
<?php
624
include("foot.inc");
(218-218/234)