Project

General

Profile

Download (21.7 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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

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

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

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

    
47

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

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

    
103
	$save = 1;
104

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

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

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

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

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

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

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

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

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

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

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

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

    
217
		if ($p1_has_vti) {
218
			$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.");
219
		} else {
220
			foreach ($delp2ids as $dp2idx) {
221
				unset($a_phase2[$dp2idx]);
222
			}
223
			unset($a_phase1[$delbtn]);
224
		}
225

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

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

    
243

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

    
248
include("head.inc");
249

    
250
if ($input_errors) {
251
	print_input_errors($input_errors);
252
}
253

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

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

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

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

    
309
$i = 0; foreach ($a_phase1 as $ph1ent):
310

    
311
	$iconfn = "pass";
312

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

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

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

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

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

    
472
						$fr_c = $fr_prefix . "c" . $j;
473
						$fr_d = $fr_prefix . "d" . $j;
474

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

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

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

    
589
<div class="infoblock">
590
	<?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 />' .
591
	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 />' .
592
	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); ?>
593
</div>
594

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

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

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

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

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

    
631
<?php
632
include("foot.inc");
(213-213/227)