Project

General

Profile

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

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

    
65
require_once("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
if ($_POST) {
84
	if ($_POST['apply']) {
85
		$retval = vpn_ipsec_configure();
86
		/* reload the filter in the background */
87
		filter_configure();
88
		$savemsg = get_std_save_message($retval);
89
		if ($retval >= 0) {
90
			if (is_subsystem_dirty('ipsec')) {
91
				clear_subsystem_dirty('ipsec');
92
			}
93
		}
94
	} else if (isset($_POST['del'])) {
95
		/* delete selected p1 entries */
96
		if (is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
97
			foreach ($_POST['p1entry'] as $p1entrydel) {
98
				unset($a_phase1[$p1entrydel]);
99
			}
100
			if (write_config()) {
101
				mark_subsystem_dirty('ipsec');
102
			}
103
		}
104
	} else if (isset($_POST['delp2'])) {
105
		/* delete selected p2 entries */
106
		if (is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
107
			foreach ($_POST['p2entry'] as $p2entrydel) {
108
				unset($a_phase2[$p2entrydel]);
109
			}
110
			if (write_config()) {
111
				mark_subsystem_dirty('ipsec');
112
			}
113
		}
114
	} else {
115
		/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
116

    
117
		// TODO: this. is. nasty.
118
		unset($delbtn, $delbtnp2, $movebtn, $movebtnp2, $togglebtn, $togglebtnp2);
119
		foreach ($_POST as $pn => $pd) {
120
			if (preg_match("/del_(\d+)/", $pn, $matches)) {
121
				$delbtn = $matches[1];
122
			} else if (preg_match("/delp2_(\d+)/", $pn, $matches)) {
123
				$delbtnp2 = $matches[1];
124
			} else if (preg_match("/move_(\d+)/", $pn, $matches)) {
125
				$movebtn = $matches[1];
126
			} else if (preg_match("/movep2_(\d+)/", $pn, $matches)) {
127
				$movebtnp2 = $matches[1];
128
			} else if (preg_match("/toggle_(\d+)/", $pn, $matches)) {
129
				$togglebtn = $matches[1];
130
			} else if (preg_match("/togglep2_(\d+)/", $pn, $matches)) {
131
				$togglebtnp2 = $matches[1];
132
			}
133
		}
134

    
135
		$save = 1;
136

    
137
		/* move selected p1 entries before this */
138
		if (isset($movebtn) && is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
139
			$a_phase1_new = array();
140

    
141
			/* copy all p1 entries < $movebtn and not selected */
142
			for ($i = 0; $i < $movebtn; $i++) {
143
				if (!in_array($i, $_POST['p1entry'])) {
144
					$a_phase1_new[] = $a_phase1[$i];
145
				}
146
			}
147

    
148
			/* copy all selected p1 entries */
149
			for ($i = 0; $i < count($a_phase1); $i++) {
150
				if ($i == $movebtn) {
151
					continue;
152
				}
153
				if (in_array($i, $_POST['p1entry'])) {
154
					$a_phase1_new[] = $a_phase1[$i];
155
				}
156
			}
157

    
158
			/* copy $movebtn p1 entry */
159
			if ($movebtn < count($a_phase1)) {
160
				$a_phase1_new[] = $a_phase1[$movebtn];
161
			}
162

    
163
			/* copy all p1 entries > $movebtn and not selected */
164
			for ($i = $movebtn+1; $i < count($a_phase1); $i++) {
165
				if (!in_array($i, $_POST['p1entry'])) {
166
					$a_phase1_new[] = $a_phase1[$i];
167
				}
168
			}
169
			if (count($a_phase1_new) > 0) {
170
				$a_phase1 = $a_phase1_new;
171
			}
172

    
173
		} else if (isset($movebtnp2) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
174
			/* move selected p2 entries before this */
175
			$a_phase2_new = array();
176

    
177
			/* copy all p2 entries < $movebtnp2 and not selected */
178
			for ($i = 0; $i < $movebtnp2; $i++) {
179
				if (!in_array($i, $_POST['p2entry'])) {
180
					$a_phase2_new[] = $a_phase2[$i];
181
				}
182
			}
183

    
184
			/* copy all selected p2 entries */
185
			for ($i = 0; $i < count($a_phase2); $i++) {
186
				if ($i == $movebtnp2) {
187
					continue;
188
				}
189
				if (in_array($i, $_POST['p2entry'])) {
190
					$a_phase2_new[] = $a_phase2[$i];
191
				}
192
			}
193

    
194
			/* copy $movebtnp2 p2 entry */
195
			if ($movebtnp2 < count($a_phase2)) {
196
				$a_phase2_new[] = $a_phase2[$movebtnp2];
197
			}
198

    
199
			/* copy all p2 entries > $movebtnp2 and not selected */
200
			for ($i = $movebtnp2+1; $i < count($a_phase2); $i++) {
201
				if (!in_array($i, $_POST['p2entry'])) {
202
					$a_phase2_new[] = $a_phase2[$i];
203
				}
204
			}
205
			if (count($a_phase2_new) > 0) {
206
				$a_phase2 = $a_phase2_new;
207
			}
208

    
209
		} else if (isset($togglebtn)) {
210
			if (isset($a_phase1[$togglebtn]['disabled'])) {
211
				unset($a_phase1[$togglebtn]['disabled']);
212
			} else {
213
				$a_phase1[$togglebtn]['disabled'] = true;
214
			}
215
		} else if (isset($togglebtnp2)) {
216
			if (isset($a_phase2[$togglebtnp2]['disabled'])) {
217
				unset($a_phase2[$togglebtnp2]['disabled']);
218
			} else {
219
				$a_phase2[$togglebtnp2]['disabled'] = true;
220
			}
221
		} else if (isset($delbtn)) {
222
			/* remove static route if interface is not WAN */
223
			if ($a_phase1[$delbtn]['interface'] <> "wan") {
224
				mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']}");
225
			}
226

    
227
			/* remove all phase2 entries that match the ikeid */
228
			$ikeid = $a_phase1[$delbtn]['ikeid'];
229
			foreach ($a_phase2 as $p2index => $ph2tmp) {
230
				if ($ph2tmp['ikeid'] == $ikeid) {
231
					unset($a_phase2[$p2index]);
232
				}
233
			}
234
			unset($a_phase1[$delbtn]);
235

    
236
		} else if (isset($delbtnp2)) {
237
			unset($a_phase2[$delbtnp2]);
238

    
239
		} else {
240
			$save = 0;
241
		}
242

    
243
		if ($save === 1) {
244
			if (write_config()) {
245
				mark_subsystem_dirty('ipsec');
246
			}
247
		}
248
	}
249
}
250

    
251
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Tunnels"));
252
$shortcut_section = "ipsec";
253

    
254
include("head.inc");
255

    
256
$tab_array = array();
257
$tab_array[] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
258
$tab_array[] = array(gettext("Mobile Clients"), false, "vpn_ipsec_mobile.php");
259
$tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
260
$tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
261
display_top_tabs($tab_array);
262

    
263
	if ($savemsg) {
264
		print_info_box($savemsg, 'success');
265
	}
266

    
267
	if (is_subsystem_dirty('ipsec')) {
268
		print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
269
	}
270
?>
271

    
272
<form name="mainform" method="post">
273
	<div class="panel panel-default">
274
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IPsec Tunnels')?></h2></div>
275
		<div class="panel-body table-responsive">
276
			<table class="table table-striped table-hover">
277
				<thead>
278
					<tr>
279
						<th>&nbsp;</th>
280
						<th>&nbsp;</th>
281
						<th><?=gettext("IKE")?></th>
282
						<th><?=gettext("Remote Gateway")?></th>
283
						<th><?=gettext("Mode")?></th>
284
						<th><?=gettext("P1 Protocol")?></th>
285
						<th><?=gettext("P1 Transforms")?></th>
286
						<th><?=gettext("P1 Description")?></th>
287
						<th><?=gettext("Actions")?></th>
288
					</tr>
289
				</thead>
290
				<tbody class="p1-entries">
291
<?php $i = 0; foreach ($a_phase1 as $ph1ent): ?>
292
<?php
293
	$iconfn = "pass";
294

    
295
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
296

    
297
	if ($entryStatus == 'disabled') {
298
		$iconfn .= "_d";
299
	}
300
?>
301
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
302
						<td>
303
							<input type="checkbox" id="frc<?=$i?>" onclick="fr_toggle(<?=$i?>)" name="p1entry[]" value="<?=$i?>"  />
304
							<a	class="fa fa-anchor icon-pointer" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
305
						</td>
306
						<td>
307
							<button value="toggle_<?=$i?>" name="toggle_<?=$i?>" title="<?=gettext("click to toggle enabled/disabled status")?>" class="btn btn-xs btn-<?= ($entryStatus == 'disabled' ? 'success' : 'warning') ?>" type="submit"><?= ($entryStatus == 'disabled' ? 'Enable' : 'Disable') ?></button>
308
						</td>
309
						<td id="frd<?=$i?>">
310
<?php
311
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
312
				echo "V1";
313
			} elseif ($ph1ent['iketype'] == "ikev2") {
314
				echo "V2";
315
			} elseif ($ph1ent['iketype'] == "auto") {
316
				echo "Auto";
317
			}
318
?>
319
						</td>
320
						<td>
321
<?php
322
			if ($ph1ent['interface']) {
323
				$iflabels = get_configured_interface_with_descr();
324

    
325
				$viplist = get_configured_vip_list();
326
				foreach ($viplist as $vip => $address) {
327
					$iflabels[$vip] = $address;
328
					if (get_vip_descr($address)) {
329
						$iflabels[$vip] .= " (". get_vip_descr($address) .")";
330
					}
331
				}
332

    
333
				$grouplist = return_gateway_groups_array();
334
				foreach ($grouplist as $name => $group) {
335
					if ($group[0]['vip'] != "") {
336
						$vipif = $group[0]['vip'];
337
					} else {
338
						$vipif = $group[0]['int'];
339
					}
340
					$iflabels[$name] = "GW Group {$name}";
341
				}
342
				$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
343
			} else {
344
				$if = "WAN";
345
			}
346

    
347
			if (!isset($ph1ent['mobile'])) {
348
				echo $if."<br />".$ph1ent['remote-gateway'];
349
			} else {
350
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
351
			}
352
?>
353
						</td>
354
						<td id="frd<?=$i?>">
355
					<?=$spans?>
356
					<?php
357
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" || $ph1ent['iketype'] == "auto") {
358
						echo "{$ph1ent['mode']}";
359
					}
360
					?>
361
					<?=$spane?>
362
				</td>
363
				<td id="frd<?=$i?>">
364
					<?=$p1_ealgos[$ph1ent['encryption-algorithm']['name']]['name']?>
365
<?php
366
			if ($ph1ent['encryption-algorithm']['keylen']) {
367
				if ($ph1ent['encryption-algorithm']['keylen'] == "auto") {
368
					echo " (" . gettext("auto") . ")";
369
				} else {
370
					echo " ({$ph1ent['encryption-algorithm']['keylen']} " . gettext("bits") . ")";
371
				}
372
			}
373
?>
374
						</td>
375
						<td>
376
							<?=$p1_halgos[$ph1ent['hash-algorithm']]?>
377
						</td>
378
						<td>
379
							<?=htmlspecialchars($ph1ent['descr'])?>
380
						</td>
381
						<td style="cursor: pointer;">
382
<!--							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a> -->
383
							<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>
384
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?p1index=<?=$i?>" title="<?=gettext("Edit phase1 entry"); ?>"></a>
385
<?php if (!isset($ph1ent['mobile'])): ?>
386
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase1 entry"); ?>"></a>
387
<?php endif; ?>
388
							<a	class="fa fa-trash no-confirm" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase1 entry'); ?>"></a>
389
							<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>
390

    
391
						</td>
392
					</tr>
393
					<tr class="<?= $entryStatus ?>">
394
						<td colspan="2"></td>
395
						<td colspan="7" class="contains-table">
396
<?php
397
			if (isset($_POST["tdph2-{$i}-visible"])) {
398
				$tdph2_visible = htmlspecialchars($_POST["tdph2-{$i}-visible"]);
399
			} else {
400
				$tdph2_visible = 0;
401
			}
402
?>
403
							<input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" />
404
							<div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>>
405
<?php
406
				$phase2count=0;
407

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

    
441
						$fr_c = $fr_prefix . "c" . $j;
442
						$fr_d = $fr_prefix . "d" . $j;
443

    
444
						$iconfn = "pass";
445
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
446

    
447
						if ($entryStatus == 'disabled') {
448
							$iconfn .= "_d";
449
						}
450
?>
451
										<tr id="<?=$fr_prefix . $j?>" ondblclick="document.location='vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>'" class="<?= $entryStatus ?>">
452
											<td>
453
												<input type="checkbox" id="<?=$fr_c?>" name="p2entry[]" value="<?=$ph2index?>" onclick="fr_bgcolor('<?=$j?>', '<?=$fr_prefix?>')" />
454
												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button>
455
											</td>
456
											<td>
457
												<button value="togglep2_<?=$ph2index?>" name="togglep2_<?=$ph2index?>" title="<?=gettext("click to toggle enabled/disabled status")?>" class="btn btn-xs btn-<?= ($entryStatus == 'disabled'? 'success' : 'warning') ?>" type="submit"><?= ($entryStatus == 'disabled'? 'Enable' : 'Disable') ?></button>
458
											</td>
459
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
460
												<?=$ph2ent['mode']?>
461
											</td>
462
<?php if (($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6")): ?>
463
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
464
												<?=ipsec_idinfo_to_text($ph2ent['localid']); ?>
465
											</td>
466
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
467
												<?=ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
468
											</td>
469
		<?php else: ?>
470
											<td colspan="2"></td>
471
<?php endif; ?>
472
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
473
												<?=$p2_protos[$ph2ent['protocol']]; ?>
474
											</td>
475
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
476
<?php
477
								foreach ($ph2ent['encryption-algorithm-option'] as $k => $ph2ea) {
478
									if ($k) {
479
										echo ", ";
480
									}
481
									echo $p2_ealgos[$ph2ea['name']]['name'];
482
									if ($ph2ea['keylen']) {
483
										if ($ph2ea['keylen'] == "auto") {
484
											echo " (" . gettext("auto") . ")";
485
										} else {
486
											echo " ({$ph2ea['keylen']} " . gettext("bits") . ")";
487
										}
488
									}
489
								}
490
?>
491
											</td>
492
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
493
<?php
494
								if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) {
495
									foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) {
496
										if ($k) {
497
											echo ", ";
498
										}
499
										echo $p2_halgos[$ph2ha];
500
									}
501
								}
502
?>
503
											</td>
504
											<td style="cursor: pointer;">
505
<!--												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button> -->
506
												<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>" title="<?=gettext("Edit phase2 entry"); ?>"></a>
507
												<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>
508
												<a	class="fa fa-trash no-confirm" id="Xdelp2_<?=$ph2index?>" title="<?=gettext('Delete phase2 entry'); ?>"></a>
509
												<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>
510
											</td>
511
										</tr>
512
<?php $j++; endforeach; ?>
513
										<tr>
514
											<td></td>
515
											<td>
516
												<a class="btn btn-xs btn-success" href="vpn_ipsec_phase2.php?ikeid=<?=$ph1ent['ikeid']?><?php if (isset($ph1ent['mobile'])) echo "&amp;mobile=true"?>">
517
													<i class="fa fa-plus icon-embed-btn"></i>
518
													<?=gettext("Add P2")?>
519
												</a>
520
											</td>
521
											<td colspan="7"></td>
522
										</tr>
523
									</tbody>
524
								</table>
525
							</div>
526
						</td>
527
					</tr>
528
<?php
529
					$i++;
530
				endforeach;	 // $a_phase1 as $ph1ent
531
?>
532
				</tbody>
533
			</table>
534
		</div>
535
	</div>
536

    
537
	<nav class="action-buttons">
538
<?php
539
/*
540
	if ($i !== 0): ?>
541
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
542
<?php endif;
543
*/
544
?>
545
		<a href="vpn_ipsec_phase1.php" class="btn btn-success btn-sm">
546
			<i class="fa fa-plus icon-embed-btn"></i>
547
			<?=gettext("Add P1")?>
548
		</a>
549
<?php if ($i !== 0): ?>
550
		<button type="submit" name="del" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected P1s")?>">
551
			<i class="fa fa-trash icon-embed-btn"></i>
552
			<?=gettext("Delete P1s")?>
553
		</button>
554
<?php endif; ?>
555
	</nav>
556
</form>
557

    
558
<div class="infoblock">
559
	<?php print_info_box(sprintf(gettext("The IPsec status can be checked at %s%s%s."), '<a href="status_ipsec.php">', gettext("Status:IPsec"), '</a>') . '<br />' .
560
	sprintf(gettext("IPsec debug mode can be enabled at %s%s%s."), '<a href="vpn_ipsec_settings.php">', gettext("VPN:IPsec:Advanced Settings"), '</a>') . '<br />' .
561
	sprintf(gettext("IPsec can be set to prefer older SAs at %s%s%s."), '<a href="vpn_ipsec_settings.php">', gettext("VPN:IPsec:Advanced Settings"), '</a>'), 'info', false); ?>
562
</div>
563

    
564
<script type="text/javascript">
565
//<![CDATA[
566
function show_phase2(id, buttonid) {
567
	document.getElementById(buttonid).innerHTML='';
568
	document.getElementById(id).style.display = "block";
569
	var visible = id + '-visible';
570
	document.getElementById(visible).value = "1";
571
}
572

    
573
events.push(function() {
574
	$('[id^=Xmove_]').click(function (event) {
575
		// ToDo: We POST shift="yes" if the user has the shift key depressed, but that is not yet used
576
		// by the $_POST code. It is intended to allow the user to choose to move stuff to the row before or
577
		// after the clicked anchor icon
578
		if (event.shiftKey) {
579
			$('form').append('<input type="hidden" id="shift" name="shift" value="yes" />');
580
		}
581

    
582
		$('#' + event.target.id.slice(1)).click();
583
	});
584

    
585
	$('[id^=Xdel_]').click(function (event) {
586
		if (confirm("<?=gettext('Confirmation required to delete this P1 entry.')?>")) {
587
			$('#' + event.target.id.slice(1)).click();
588
		}
589
	});
590

    
591
	$('[id^=Xdelp2_]').click(function (event) {
592
		if (confirm("<?=gettext('Confirmation required to delete this P2 entry.')?>")) {
593
			$('#' + event.target.id.slice(1)).click();
594
		}
595
	});
596
});
597
//]]>
598
</script>
599

    
600
<?php
601
include("foot.inc");
(211-211/225)