Project

General

Profile

Download (21.4 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-2018 Rubicon Communications, LLC (Netgate)
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
 * Licensed under the Apache License, Version 2.0 (the "License");
14
 * you may not use this file except in compliance with the License.
15
 * You may obtain a copy of the License at
16
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * Unless required by applicable law or agreed to in writing, software
20
 * distributed under the License is distributed on an "AS IS" BASIS,
21
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
 * See the License for the specific language governing permissions and
23
 * limitations under the License.
24
 */
25

    
26
##|+PRIV
27
##|*IDENT=page-vpn-ipsec
28
##|*NAME=VPN: IPsec
29
##|*DESCR=Allow access to the 'VPN: IPsec' page.
30
##|*MATCH=vpn_ipsec.php*
31
##|-PRIV
32

    
33
require_once("guiconfig.inc");
34
require_once("functions.inc");
35
require_once("filter.inc");
36
require_once("shaper.inc");
37
require_once("ipsec.inc");
38
require_once("vpn.inc");
39

    
40
init_config_arr(array('ipsec', 'phase1'));
41
init_config_arr(array('ipsec', 'phase2'));
42
$a_phase1 = &$config['ipsec']['phase1'];
43
$a_phase2 = &$config['ipsec']['phase2'];
44

    
45

    
46
if ($_POST['apply']) {
47
	$ipsec_dynamic_hosts = vpn_ipsec_configure();
48
	/* reload the filter in the background */
49
	$retval = 0;
50
	$retval |= filter_configure();
51
	if ($ipsec_dynamic_hosts >= 0) {
52
		if (is_subsystem_dirty('ipsec')) {
53
			clear_subsystem_dirty('ipsec');
54
		}
55
	}
56
} else if (isset($_POST['del'])) {
57
	/* delete selected p1 entries */
58
	if (is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
59
		foreach ($_POST['p1entry'] as $p1entrydel) {
60
			unset($a_phase1[$p1entrydel]);
61
		}
62
		if (write_config(gettext("Deleted selected IPsec Phase 1 entries."))) {
63
			mark_subsystem_dirty('ipsec');
64
		}
65
	}
66
} else if (isset($_POST['delp2'])) {
67
	/* delete selected p2 entries */
68
	if (is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
69
		foreach ($_POST['p2entry'] as $p2entrydel) {
70
			if (is_interface_ipsec_vti_assigned($a_phase2[$p2entrydel])) {
71
				$input_errors[] = gettext("Cannot delete a VTI Phase 2 while the interface is assigned. Remove the interface assignment before deleting this P2.");
72
			} else {
73
				unset($a_phase2[$p2entrydel]);
74
			}
75
		}
76
		if (write_config(gettext("Deleted selected IPsec Phase 2 entries."))) {
77
			mark_subsystem_dirty('ipsec');
78
		}
79
	}
80
} else  {
81
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
82

    
83
	// TODO: this. is. nasty.
84
	unset($delbtn, $delbtnp2, $movebtn, $movebtnp2, $togglebtn, $togglebtnp2);
85
	foreach ($_POST as $pn => $pd) {
86
		if (preg_match("/del_(\d+)/", $pn, $matches)) {
87
			$delbtn = $matches[1];
88
		} else if (preg_match("/delp2_(\d+)/", $pn, $matches)) {
89
			$delbtnp2 = $matches[1];
90
		} else if (preg_match("/move_(\d+)/", $pn, $matches)) {
91
			$movebtn = $matches[1];
92
		} else if (preg_match("/movep2_(\d+)/", $pn, $matches)) {
93
			$movebtnp2 = $matches[1];
94
		} else if (preg_match("/toggle_(\d+)/", $pn, $matches)) {
95
			$togglebtn = $matches[1];
96
		} else if (preg_match("/togglep2_(\d+)/", $pn, $matches)) {
97
			$togglebtnp2 = $matches[1];
98
		}
99
	}
100

    
101
	$save = 1;
102

    
103
	/* move selected p1 entries before this */
104
	if (isset($movebtn) && is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
105
		$a_phase1_new = array();
106

    
107
		/* copy all p1 entries < $movebtn and not selected */
108
		for ($i = 0; $i < $movebtn; $i++) {
109
			if (!in_array($i, $_POST['p1entry'])) {
110
				$a_phase1_new[] = $a_phase1[$i];
111
			}
112
		}
113

    
114
		/* copy all selected p1 entries */
115
		for ($i = 0; $i < count($a_phase1); $i++) {
116
			if ($i == $movebtn) {
117
				continue;
118
			}
119
			if (in_array($i, $_POST['p1entry'])) {
120
				$a_phase1_new[] = $a_phase1[$i];
121
			}
122
		}
123

    
124
		/* copy $movebtn p1 entry */
125
		if ($movebtn < count($a_phase1)) {
126
			$a_phase1_new[] = $a_phase1[$movebtn];
127
		}
128

    
129
		/* copy all p1 entries > $movebtn and not selected */
130
		for ($i = $movebtn+1; $i < count($a_phase1); $i++) {
131
			if (!in_array($i, $_POST['p1entry'])) {
132
				$a_phase1_new[] = $a_phase1[$i];
133
			}
134
		}
135
		if (count($a_phase1_new) > 0) {
136
			$a_phase1 = $a_phase1_new;
137
		}
138

    
139
	} else if (isset($movebtnp2) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
140
		/* move selected p2 entries before this */
141
		$a_phase2_new = array();
142

    
143
		/* copy all p2 entries < $movebtnp2 and not selected */
144
		for ($i = 0; $i < $movebtnp2; $i++) {
145
			if (!in_array($i, $_POST['p2entry'])) {
146
				$a_phase2_new[] = $a_phase2[$i];
147
			}
148
		}
149

    
150
		/* copy all selected p2 entries */
151
		for ($i = 0; $i < count($a_phase2); $i++) {
152
			if ($i == $movebtnp2) {
153
				continue;
154
			}
155
			if (in_array($i, $_POST['p2entry'])) {
156
				$a_phase2_new[] = $a_phase2[$i];
157
			}
158
		}
159

    
160
		/* copy $movebtnp2 p2 entry */
161
		if ($movebtnp2 < count($a_phase2)) {
162
			$a_phase2_new[] = $a_phase2[$movebtnp2];
163
		}
164

    
165
		/* copy all p2 entries > $movebtnp2 and not selected */
166
		for ($i = $movebtnp2+1; $i < count($a_phase2); $i++) {
167
			if (!in_array($i, $_POST['p2entry'])) {
168
				$a_phase2_new[] = $a_phase2[$i];
169
			}
170
		}
171
		if (count($a_phase2_new) > 0) {
172
			$a_phase2 = $a_phase2_new;
173
		}
174

    
175
	} else if (isset($togglebtn)) {
176
		if (isset($a_phase1[$togglebtn]['disabled'])) {
177
			unset($a_phase1[$togglebtn]['disabled']);
178
		} else {
179
			if (ipsec_vti($a_phase1[$togglebtn])) {
180
				$input_errors[] = gettext("Cannot disable a Phase 1 with a child Phase 2 while the interface is assigned. Remove the interface assignment before disabling this P2.");
181
			} else {
182
				$a_phase1[$togglebtn]['disabled'] = true;
183
			}
184
		}
185
	} else if (isset($togglebtnp2)) {
186
		if (isset($a_phase2[$togglebtnp2]['disabled'])) {
187
			unset($a_phase2[$togglebtnp2]['disabled']);
188
		} else {
189
			if (is_interface_ipsec_vti_assigned($a_phase2[$togglebtnp2])) {
190
				$input_errors[] = gettext("Cannot disable a VTI Phase 2 while the interface is assigned. Remove the interface assignment before disabling this P2.");
191
			} else {
192
				$a_phase2[$togglebtnp2]['disabled'] = true;
193
			}
194
		}
195
	} else if (isset($delbtn)) {
196
		/* remove static route if interface is not WAN */
197
		if ($a_phase1[$delbtn]['interface'] <> "wan") {
198
			mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']}");
199
		}
200

    
201
		/* remove all phase2 entries that match the ikeid */
202
		$ikeid = $a_phase1[$delbtn]['ikeid'];
203
		$p1_has_vti = false;
204
		$delp2ids = array();
205
		foreach ($a_phase2 as $p2index => $ph2tmp) {
206
			if ($ph2tmp['ikeid'] == $ikeid) {
207
				if (is_interface_ipsec_vti_assigned($ph2tmp)) {
208
					$p1_has_vti = true;
209
				} else {
210
					$delp2ids[] = $p2index;
211
				}
212
			}
213
		}
214

    
215
		if ($p1_has_vti) {
216
			$input_errors[] = gettext("Cannot delete a Phase 1 which contains an active VTI Phase 2 with an interface assigned. Remove the interface assignment before deleting this P1.");
217
		} else {
218
			foreach ($delp2ids as $dp2idx) {
219
				unset($a_phase2[$dp2idx]);
220
			}
221
			unset($a_phase1[$delbtn]);
222
		}
223

    
224
	} else if (isset($delbtnp2)) {
225
		if (is_interface_ipsec_vti_assigned($a_phase2[$delbtnp2])) {
226
			$input_errors[] = gettext("Cannot delete a VTI Phase 2 while the interface is assigned. Remove the interface assignment before deleting this P2.");
227
		} else {
228
			unset($a_phase2[$delbtnp2]);
229
		}
230
	} else {
231
		$save = 0;
232
	}
233

    
234
	if ($save === 1) {
235
		if (write_config(gettext("Saved configuration changes for IPsec tunnels."))) {
236
			mark_subsystem_dirty('ipsec');
237
		}
238
	}
239
}
240

    
241

    
242
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Tunnels"));
243
$pglinks = array("", "@self", "@self");
244
$shortcut_section = "ipsec";
245

    
246
include("head.inc");
247

    
248
if ($input_errors) {
249
	print_input_errors($input_errors);
250
}
251

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

    
259
if ($_POST['apply']) {
260
	print_apply_result_box($retval);
261
}
262

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

    
268
<form name="mainform" method="post">
269
	<div class="panel panel-default">
270
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IPsec Tunnels')?></h2></div>
271
		<div class="panel-body table-responsive">
272
			<table class="table table-striped table-hover">
273
				<thead>
274
					<tr>
275
						<th>&nbsp;</th>
276
						<th>&nbsp;</th>
277
						<th><?=gettext("IKE")?></th>
278
						<th><?=gettext("Remote Gateway")?></th>
279
						<th><?=gettext("Mode")?></th>
280
						<th><?=gettext("P1 Protocol")?></th>
281
						<th><?=gettext("P1 Transforms")?></th>
282
						<th><?=gettext("P1 DH-Group")?></th>
283
						<th><?=gettext("P1 Description")?></th>
284
						<th><?=gettext("Actions")?></th>
285
					</tr>
286
				</thead>
287
				<tbody class="p1-entries">
288
<?php
289
$iflabels = get_configured_interface_with_descr(false, true);
290
$viplist = get_configured_vip_list();
291
foreach ($viplist as $vip => $address) {
292
	$iflabels[$vip] = $address;
293
	if (get_vip_descr($address)) {
294
		$iflabels[$vip] .= " (". get_vip_descr($address) .")";
295
	}
296
}
297
$grouplist = return_gateway_groups_array();
298
foreach ($grouplist as $name => $group) {
299
	if ($group[0]['vip'] != "") {
300
		$vipif = $group[0]['vip'];
301
	} else {
302
		$vipif = $group[0]['int'];
303
	}
304
	$iflabels[$name] = "GW Group {$name}";
305
}
306

    
307
$i = 0; foreach ($a_phase1 as $ph1ent):
308

    
309
	$iconfn = "pass";
310

    
311
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
312

    
313
	if ($entryStatus == 'disabled') {
314
		$iconfn .= "_d";
315
	}
316
?>
317
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
318
						<td>
319
							<input type="checkbox" id="frc<?=$i?>" onclick="fr_toggle(<?=$i?>)" name="p1entry[]" value="<?=$i?>"  />
320
							<a	class="fa fa-anchor icon-pointer" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
321
						</td>
322
						<td>
323
							<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>
324
						</td>
325
						<td id="frd<?=$i?>">
326
<?php
327
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
328
				echo "V1";
329
			} elseif ($ph1ent['iketype'] == "ikev2") {
330
				echo "V2";
331
			} elseif ($ph1ent['iketype'] == "auto") {
332
				echo "Auto";
333
			}
334
?>
335
						</td>
336
						<td>
337
<?php
338
			if ($ph1ent['interface']) {
339
				if (isset($iflabels[$ph1ent['interface']])) {
340
					$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
341
				} else {
342
					$if = sprintf("Interface not found: '%s'", $ph1ent['interface']);
343
				}
344
			} else {
345
				$if = "WAN";
346
			}
347

    
348
			if (!isset($ph1ent['mobile'])) {
349
				echo $if."<br />".$ph1ent['remote-gateway'];
350
			} else {
351
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
352
			}
353
?>
354
						</td>
355
						<td id="frd<?=$i?>">
356
					<?=$spans?>
357
					<?php
358
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" || $ph1ent['iketype'] == "auto") {
359
						echo "{$ph1ent['mode']}";
360
					}
361
					?>
362
					<?=$spane?>
363
				</td>
364
				<td id="frd<?=$i?>">
365
<?php
366
				$first = true;
367
				if (is_array($ph1ent['encryption']['item'])) {
368
					foreach($ph1ent['encryption']['item'] as $p1algo) {
369
						if (!$first) {
370
							echo "<br/>";
371
						}
372
						echo $p1_ealgos[$p1algo['encryption-algorithm']['name']]['name'];
373
						if ($p1algo['encryption-algorithm']['keylen']) {
374
							echo " ({$p1algo['encryption-algorithm']['keylen']} " . gettext("bits") . ")";
375
						}
376
						$first = false;
377
					}
378
				}
379
?>
380
						</td>
381
						<td>
382
<?php			$first = true;
383
				if (is_array($ph1ent['encryption']['item'])) {
384
					foreach($ph1ent['encryption']['item'] as $p1algo) {
385
						if (!$first) {
386
							echo "<br/>";
387
						}
388
						echo $p1_halgos[$p1algo['hash-algorithm']];
389
						$first = false;
390
					}
391
				}
392
				?>
393
						</td>
394
						<td>
395
<?php			$first = true;
396
				if (is_array($ph1ent['encryption']['item'])) {
397
					foreach($ph1ent['encryption']['item'] as $p1algo) {
398
						if (!$first) {
399
							echo "<br/>";
400
						}
401
						echo str_replace(" ","&nbsp;",$p1_dhgroups[$p1algo['dhgroup']]);
402
						$first = false;
403
					}
404
				}
405
				?>
406
						</td>
407
						<td>
408
							<?=htmlspecialchars($ph1ent['descr'])?>
409
						</td>
410
						<td style="cursor: pointer;">
411
<!--							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a> -->
412
							<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>
413
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?p1index=<?=$i?>" title="<?=gettext("Edit phase1 entry"); ?>"></a>
414
<?php if (!isset($ph1ent['mobile'])): ?>
415
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase1 entry"); ?>"></a>
416
<?php endif; ?>
417
							<a	class="fa fa-trash no-confirm" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase1 entry'); ?>"></a>
418
							<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>
419

    
420
						</td>
421
					</tr>
422
					<tr class="<?= $entryStatus ?>">
423
						<td colspan="2"></td>
424
						<td colspan="7" class="contains-table">
425
<?php
426
			if (isset($_REQUEST["tdph2-{$i}-visible"])) {
427
				$tdph2_visible = htmlspecialchars($_REQUEST["tdph2-{$i}-visible"]);
428
			} else {
429
				$tdph2_visible = 0;
430
			}
431
?>
432
							<input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" />
433
							<div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>>
434
<?php
435
				$phase2count=0;
436

    
437
				foreach ($a_phase2 as $ph2ent) {
438
					if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
439
						continue;
440
					}
441
					$phase2count++;
442
				}
443
				$fr_prefix = "frp2{$i}";
444
				$fr_header = $fr_prefix . "header";
445
?>
446
								<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>
447
							</div>
448
							<div id="tdph2-<?=$i?>" <?=($tdph2_visible != '1' ? 'style="display:none"' : '')?>>
449
								<table class="table table-striped table-hover">
450
									<thead>
451
										<tr>
452
											<th>&nbsp;</th>
453
											<th>&nbsp;</th>
454
											<th><?=gettext("Mode"); ?></th>
455
											<th><?=gettext("Local Subnet"); ?></th>
456
											<th><?=gettext("Remote Subnet"); ?></th>
457
											<th><?=gettext("P2 Protocol"); ?></th>
458
											<th><?=gettext("P2 Transforms"); ?></th>
459
											<th><?=gettext("P2 Auth Methods"); ?></th>
460
											<th><?=gettext("P2 actions")?></th>
461
										</tr>
462
									</thead>
463
									<tbody class="p2-entries">
464
<?php $j = 0; foreach ($a_phase2 as $ph2index => $ph2ent): ?>
465
<?php
466
						if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
467
							continue;
468
						}
469

    
470
						$fr_c = $fr_prefix . "c" . $j;
471
						$fr_d = $fr_prefix . "d" . $j;
472

    
473
						$iconfn = "pass";
474
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
475

    
476
						if ($entryStatus == 'disabled') {
477
							$iconfn .= "_d";
478
						}
479
?>
480
										<tr id="<?=$fr_prefix . $j?>" ondblclick="document.location='vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>'" class="<?= $entryStatus ?>">
481
											<td>
482
												<input type="checkbox" id="<?=$fr_c?>" name="p2entry[]" value="<?=$ph2index?>" onclick="fr_bgcolor('<?=$j?>', '<?=$fr_prefix?>')" />
483
												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button>
484
											</td>
485
											<td>
486
												<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>
487
											</td>
488
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
489
												<?=$ph2ent['mode']?>
490
											</td>
491
<?php if (($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6") or ($ph2ent['mode'] == "vti")): ?>
492
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
493
												<?=ipsec_idinfo_to_text($ph2ent['localid']); ?>
494
											</td>
495
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
496
												<?=ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
497
											</td>
498
		<?php else: ?>
499
											<td colspan="2"></td>
500
<?php endif; ?>
501
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
502
												<?=$p2_protos[$ph2ent['protocol']]; ?>
503
											</td>
504
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
505
<?php
506
								foreach ($ph2ent['encryption-algorithm-option'] as $k => $ph2ea) {
507
									if ($k) {
508
										echo ", ";
509
									}
510
									echo $p2_ealgos[$ph2ea['name']]['name'];
511
									if ($ph2ea['keylen']) {
512
										if ($ph2ea['keylen'] == "auto") {
513
											echo " (" . gettext("auto") . ")";
514
										} else {
515
											echo " ({$ph2ea['keylen']} " . gettext("bits") . ")";
516
										}
517
									}
518
								}
519
?>
520
											</td>
521
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
522
<?php
523
								if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) {
524
									foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) {
525
										if ($k) {
526
											echo ", ";
527
										}
528
										echo $p2_halgos[$ph2ha];
529
									}
530
								}
531
?>
532
											</td>
533
											<td style="cursor: pointer;">
534
<!--												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button> -->
535
												<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>" title="<?=gettext("Edit phase2 entry"); ?>"></a>
536
												<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>
537
												<a	class="fa fa-trash no-confirm" id="Xdelp2_<?=$ph2index?>" title="<?=gettext('Delete phase2 entry'); ?>"></a>
538
												<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>
539
											</td>
540
										</tr>
541
<?php $j++; endforeach; ?>
542
										<tr>
543
											<td></td>
544
											<td>
545
												<a class="btn btn-xs btn-success" href="vpn_ipsec_phase2.php?ikeid=<?=$ph1ent['ikeid']?><?php if (isset($ph1ent['mobile'])) echo "&amp;mobile=true"?>">
546
													<i class="fa fa-plus icon-embed-btn"></i>
547
													<?=gettext("Add P2")?>
548
												</a>
549
											</td>
550
											<td colspan="7"></td>
551
										</tr>
552
									</tbody>
553
								</table>
554
							</div>
555
						</td>
556
					</tr>
557
<?php
558
					$i++;
559
				endforeach;	 // $a_phase1 as $ph1ent
560
?>
561
				</tbody>
562
			</table>
563
		</div>
564
	</div>
565

    
566
	<nav class="action-buttons">
567
<?php
568
/*
569
	if ($i !== 0): ?>
570
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
571
<?php endif;
572
*/
573
?>
574
		<a href="vpn_ipsec_phase1.php" class="btn btn-success btn-sm"  usepost>
575
			<i class="fa fa-plus icon-embed-btn"></i>
576
			<?=gettext("Add P1")?>
577
		</a>
578
<?php if ($i !== 0): ?>
579
		<button type="submit" name="del" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected P1s")?>">
580
			<i class="fa fa-trash icon-embed-btn"></i>
581
			<?=gettext("Delete P1s")?>
582
		</button>
583
<?php endif; ?>
584
	</nav>
585
</form>
586

    
587
<div class="infoblock">
588
	<?php print_info_box(sprintf(gettext('The IPsec status can be checked at %1$s%2$s%3$s.'), '<a href="status_ipsec.php">', gettext("Status:IPsec"), '</a>') . '<br />' .
589
	sprintf(gettext('IPsec debug mode can be enabled at %1$s%2$s%3$s.'), '<a href="vpn_ipsec_settings.php">', gettext("VPN:IPsec:Advanced Settings"), '</a>') . '<br />' .
590
	sprintf(gettext('IPsec can be set to prefer older SAs at %1$s%2$s%3$s.'), '<a href="vpn_ipsec_settings.php">', gettext("VPN:IPsec:Advanced Settings"), '</a>'), 'info', false); ?>
591
</div>
592

    
593
<script type="text/javascript">
594
//<![CDATA[
595
function show_phase2(id, buttonid) {
596
	document.getElementById(buttonid).innerHTML='';
597
	document.getElementById(id).style.display = "block";
598
	var visible = id + '-visible';
599
	document.getElementById(visible).value = "1";
600
}
601

    
602
events.push(function() {
603
	$('[id^=Xmove_]').click(function (event) {
604
		// ToDo: We POST shift="yes" if the user has the shift key depressed, but that is not yet used
605
		// by the $_POST code. It is intended to allow the user to choose to move stuff to the row before or
606
		// after the clicked anchor icon
607
		if (event.shiftKey) {
608
			$('form').append('<input type="hidden" id="shift" name="shift" value="yes" />');
609
		}
610

    
611
		$('#' + event.target.id.slice(1)).click();
612
	});
613

    
614
	$('[id^=Xdel_]').click(function (event) {
615
		if (confirm("<?=gettext('Confirmation required to delete this P1 entry.')?>")) {
616
			$('#' + event.target.id.slice(1)).click();
617
		}
618
	});
619

    
620
	$('[id^=Xdelp2_]').click(function (event) {
621
		if (confirm("<?=gettext('Confirmation required to delete this P2 entry.')?>")) {
622
			$('#' + event.target.id.slice(1)).click();
623
		}
624
	});
625
});
626
//]]>
627
</script>
628

    
629
<?php
630
include("foot.inc");
(220-220/234)