Project

General

Profile

Download (21.8 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-2020 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 = 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
			$rgateway = exec("/sbin/route -n get {$a_phase1[$delbtn]['remote-gateway']} | /usr/bin/awk '/gateway:/ {print $2;}'");
201
			mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']} " . escapeshellarg($rgateway));
202
		}
203

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

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

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

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

    
244

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

    
249
include("head.inc");
250

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

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

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

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

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

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

    
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?>" onclick="fr_toggle(<?=$i?>)" name="p1entry[]" value="<?=$i?>"  />
323
							<a	class="fa fa-anchor icon-pointer" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
324
						</td>
325
						<td>
326
							<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>
327
						</td>
328
						<td id="frd<?=$i?>">
329
<?php
330
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
331
				echo "V1";
332
			} elseif ($ph1ent['iketype'] == "ikev2") {
333
				echo "V2";
334
			} elseif ($ph1ent['iketype'] == "auto") {
335
				echo "Auto";
336
			}
337
?>
338
						</td>
339
						<td>
340
<?php
341
			if ($ph1ent['interface']) {
342
				if (isset($iflabels[$ph1ent['interface']])) {
343
					$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
344
				} else {
345
					$if = sprintf("Interface not found: '%s'", $ph1ent['interface']);
346
				}
347
			} else {
348
				$if = "WAN";
349
			}
350

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

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

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

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

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

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

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

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

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

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

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

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

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

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