Project

General

Profile

Download (23.1 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-2022 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
$items_deleted = false;
47

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

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

    
106
	$save = 1;
107

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

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

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

    
129
		/* copy $movebtn p1 entry */
130
		if ($movebtn < count($a_phase1)) {
131
			$a_phase1_new[] = $a_phase1[$movebtn];
132
		}
133

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

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

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

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

    
165
		/* copy $movebtnp2 p2 entry */
166
		if ($movebtnp2 < count($a_phase2)) {
167
			$a_phase2_new[] = $a_phase2[$movebtnp2];
168
		}
169

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

    
180
	} else if (isset($togglebtn)) {
181
		if (isset($a_phase1[$togglebtn]['disabled'])) {
182
			unset($a_phase1[$togglebtn]['disabled']);
183
		} else {
184
			if (ipsec_vti($a_phase1[$togglebtn], false, false)) {
185
				/* disable all phase2 entries that match the ikeid */
186
				$ikeid = $a_phase1[$toggelebtn]['ikeid'];
187
				$p1_has_vti = false;
188
				$disablep2ids = array();
189
				foreach ($a_phase2 as $p2index => $ph2tmp) {
190
					if ($ph2tmp['ikeid'] == $ikeid) {
191
						if (is_interface_ipsec_vti_assigned($ph2tmp)) {
192
							$p1_has_vti = true;
193
						} else {
194
							$disablep2ids[] = $p2index;
195
						}
196
					}
197
				}
198

    
199
				if ($p1_has_vti) {
200
					$input_errors[] = gettext("Cannot disable a Phase 1 which contains an active VTI Phase 2 with an interface assigned. Remove the interface assignment before deleting this P1.");
201
				} else {
202
					foreach ($disablep2ids as $dp2idx) {
203
						$a_phase2[$togglebtnp2]['disabled'] = true;
204
					}
205
					$a_phase1[$togglebtn]['disabled'] = true;
206
				}
207
			} else {
208
				$a_phase1[$togglebtn]['disabled'] = true;
209
			}
210
		}
211
	} else if (isset($togglebtnp2)) {
212
		if (isset($a_phase2[$togglebtnp2]['disabled'])) {
213
			unset($a_phase2[$togglebtnp2]['disabled']);
214
		} else {
215
			if (is_interface_ipsec_vti_assigned($a_phase2[$togglebtnp2]) && ($a_phase2[$togglebtnp2]['mode'] == 'vti')) {
216
				$input_errors[] = gettext("Cannot disable a VTI Phase 2 while the interface is assigned. Remove the interface assignment before disabling this P2.");
217
			} else {
218
				$a_phase2[$togglebtnp2]['disabled'] = true;
219
			}
220
		}
221
	} else if (isset($delbtn)) {
222
		/* remove static route if interface is not WAN */
223
		if ($a_phase1[$delbtn]['interface'] <> "wan") {
224
			route_del($a_phase1[$delbtn]['remote-gateway']);
225
		}
226

    
227
		/* remove all phase2 entries that match the ikeid */
228
		$ikeid = $a_phase1[$delbtn]['ikeid'];
229
		$p1_has_vti = false;
230
		$delp2ids = array();
231
		foreach ($a_phase2 as $p2index => $ph2tmp) {
232
			if ($ph2tmp['ikeid'] == $ikeid) {
233
				if (is_interface_ipsec_vti_assigned($ph2tmp)) {
234
					$p1_has_vti = true;
235
				} else {
236
					$delp2ids[] = $p2index;
237
				}
238
			}
239
		}
240

    
241
		if ($p1_has_vti) {
242
			$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.");
243
		} else {
244
			foreach ($delp2ids as $dp2idx) {
245
				unset($a_phase2[$dp2idx]);
246
			}
247
			unset($a_phase1[$delbtn]);
248
			$items_deleted = true;
249
		}
250

    
251
	} else if (isset($delbtnp2)) {
252
		if (is_interface_ipsec_vti_assigned($a_phase2[$delbtnp2]) && ($a_phase2[$delbtnp2]['mode'] == 'vti')) {
253
			$input_errors[] = gettext("Cannot delete a VTI Phase 2 while the interface is assigned. Remove the interface assignment before deleting this P2.");
254
		} else {
255
			unset($a_phase2[$delbtnp2]);
256
			$items_deleted = true;
257
		}
258
	} else {
259
		$save = 0;
260
	}
261

    
262
	if ($save === 1) {
263
		if (write_config(gettext("Saved configuration changes for IPsec tunnels."))) {
264
			mark_subsystem_dirty('ipsec');
265
		}
266
	}
267
}
268

    
269
if ($items_deleted) {
270
	/*
271
	 * Reindex entries if changes were made since index values could have shifted.
272
	 * https://redmine.pfsense.org/issues/11552
273
	 */
274
	$a_phase1 = array_values($a_phase1);
275
	$a_phase2 = array_values($a_phase2);
276
}
277

    
278
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Tunnels"));
279
$pglinks = array("", "@self", "@self");
280
$shortcut_section = "ipsec";
281

    
282
include("head.inc");
283

    
284
if ($input_errors) {
285
	print_input_errors($input_errors);
286
}
287

    
288
$tab_array = array();
289
$tab_array[] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
290
$tab_array[] = array(gettext("Mobile Clients"), false, "vpn_ipsec_mobile.php");
291
$tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
292
$tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
293
display_top_tabs($tab_array);
294

    
295
if ($_POST['apply']) {
296
	print_apply_result_box($retval);
297
}
298

    
299
if (is_subsystem_dirty('ipsec')) {
300
	print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
301
}
302
?>
303

    
304
<form name="mainform" method="post">
305
	<div class="panel panel-default">
306
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IPsec Tunnels')?></h2></div>
307
		<div class="panel-body table-responsive">
308
			<table class="table table-striped table-hover">
309
				<thead>
310
					<tr>
311
						<th>&nbsp;</th>
312
						<th>&nbsp;</th>
313
						<th><?=gettext("ID")?></th>
314
						<th><?=gettext("IKE")?></th>
315
						<th><?=gettext("Remote Gateway")?></th>
316
						<th><?=gettext("Mode")?></th>
317
						<th><?=gettext("P1 Protocol")?></th>
318
						<th><?=gettext("P1 Transforms")?></th>
319
						<th><?=gettext("P1 DH-Group")?></th>
320
						<th><?=gettext("P1 Description")?></th>
321
						<th><?=gettext("Actions")?></th>
322
					</tr>
323
				</thead>
324
				<tbody class="p1-entries">
325
<?php
326
$iflabels = get_configured_interface_with_descr(false, true);
327
$viplist = get_configured_vip_list();
328
foreach ($viplist as $vip => $address) {
329
	$iflabels[$vip] = $address;
330
	if (get_vip_descr($address)) {
331
		$iflabels[$vip] .= " (". get_vip_descr($address) .")";
332
	}
333
}
334
$grouplist = return_gateway_groups_array();
335
foreach ($grouplist as $name => $group) {
336
	if ($group[0]['vip'] != "") {
337
		$vipif = $group[0]['vip'];
338
	} else {
339
		$vipif = $group[0]['int'];
340
	}
341
	$iflabels[$name] = "GW Group {$name}";
342
}
343

    
344
$i = 0; foreach ($a_phase1 as $ph1ent):
345

    
346
	$iconfn = "pass";
347

    
348
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
349

    
350
	if ($entryStatus == 'disabled') {
351
		$iconfn .= "_d";
352
	}
353
?>
354
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
355
						<td>
356
							<input type="checkbox" id="frc<?=$i?>" onclick="fr_toggle(<?=$i?>)" name="p1entry[]" value="<?=$i?>"  />
357
							<a	class="fa fa-anchor icon-pointer" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
358
						</td>
359
						<td>
360
							<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>
361
						</td>
362
						<td>
363
							<?= htmlspecialchars($ph1ent['ikeid']) ?>
364
						</td>
365
						<td id="frd<?=$i?>">
366
<?php
367
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
368
				echo "V1";
369
			} elseif ($ph1ent['iketype'] == "ikev2") {
370
				echo "V2";
371
			} elseif ($ph1ent['iketype'] == "auto") {
372
				echo "Auto";
373
			}
374
?>
375
						</td>
376
						<td>
377
<?php
378
			if ($ph1ent['interface']) {
379
				if (isset($iflabels[$ph1ent['interface']])) {
380
					$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
381
				} else {
382
					$if = sprintf("Interface not found: '%s'", $ph1ent['interface']);
383
				}
384
			} else {
385
				$if = "WAN";
386
			}
387

    
388
			if (!isset($ph1ent['mobile'])) {
389
				echo $if."<br />".$ph1ent['remote-gateway'];
390
			} else {
391
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
392
			}
393
?>
394
						</td>
395
						<td id="frd<?=$i?>">
396
					<?=$spans?>
397
					<?php
398
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" || $ph1ent['iketype'] == "auto") {
399
						echo "{$ph1ent['mode']}";
400
					}
401
					?>
402
					<?=$spane?>
403
				</td>
404
				<td id="frd<?=$i?>">
405
<?php
406
				$first = true;
407
				if (is_array($ph1ent['encryption']['item'])) {
408
					foreach($ph1ent['encryption']['item'] as $p1algo) {
409
						if (!$first) {
410
							echo "<br/>";
411
						}
412
						echo $p1_ealgos[$p1algo['encryption-algorithm']['name']]['name'];
413
						if ($p1algo['encryption-algorithm']['keylen']) {
414
							echo " ({$p1algo['encryption-algorithm']['keylen']} " . gettext("bits") . ")";
415
						}
416
						$first = false;
417
					}
418
				}
419
?>
420
						</td>
421
						<td>
422
<?php			$first = true;
423
				if (is_array($ph1ent['encryption']['item'])) {
424
					foreach($ph1ent['encryption']['item'] as $p1algo) {
425
						if (!$first) {
426
							echo "<br/>";
427
						}
428
						echo $p1_halgos[$p1algo['hash-algorithm']];
429
						if (isset($ph1ent['prfselect_enable'])) {
430
							echo " / PRF" . $p1_halgos[$p1algo['prf-algorithm']];
431
						}
432
						$first = false;
433
					}
434
				}
435
				?>
436
						</td>
437
						<td>
438
<?php			$first = true;
439
				if (is_array($ph1ent['encryption']['item'])) {
440
					foreach($ph1ent['encryption']['item'] as $p1algo) {
441
						if (!$first) {
442
							echo "<br/>";
443
						}
444
						echo str_replace(" ","&nbsp;",$p1_dhgroups[$p1algo['dhgroup']]);
445
						$first = false;
446
					}
447
				}
448
				?>
449
						</td>
450
						<td>
451
							<?=htmlspecialchars($ph1ent['descr'])?>
452
						</td>
453
						<td style="cursor: pointer;">
454
<!--							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a> -->
455
							<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>
456
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?ikeid=<?=$ph1ent['ikeid']?>" title="<?=gettext("Edit phase 1 entry"); ?>"></a>
457
<?php if (!isset($ph1ent['mobile'])): ?>
458
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase 1 entry"); ?>"></a>
459
<?php endif; ?>
460
							<a	class="fa fa-trash no-confirm" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase 1 entry'); ?>"></a>
461
							<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>
462

    
463
						</td>
464
					</tr>
465
					<tr class="<?= $entryStatus ?>">
466
						<td colspan="1"></td>
467
						<td colspan="10" class="contains-table">
468
<?php
469
			if (isset($_REQUEST["tdph2-{$i}-visible"])) {
470
				$tdph2_visible = htmlspecialchars($_REQUEST["tdph2-{$i}-visible"]);
471
			} else {
472
				$tdph2_visible = 0;
473
			}
474
?>
475
							<input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" />
476
							<div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>>
477
<?php
478
				$phase2count=0;
479

    
480
				foreach ($a_phase2 as $ph2ent) {
481
					if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
482
						continue;
483
					}
484
					$phase2count++;
485
				}
486
				$fr_prefix = "frp2{$i}";
487
				$fr_header = $fr_prefix . "header";
488
?>
489
								<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>
490
							</div>
491
							<div id="tdph2-<?=$i?>" <?=($tdph2_visible != '1' ? 'style="display:none"' : '')?>>
492
								<table class="table table-striped table-hover">
493
									<thead>
494
										<tr>
495
											<th>&nbsp;</th>
496
											<th>&nbsp;</th>
497
											<th><?=gettext("ID"); ?></th>
498
											<th><?=gettext("Mode"); ?></th>
499
											<th><?=gettext("Local Subnet"); ?></th>
500
											<th><?=gettext("Remote Subnet"); ?></th>
501
											<th><?=gettext("P2 Protocol"); ?></th>
502
											<th><?=gettext("P2 Transforms"); ?></th>
503
											<th><?=gettext("P2 Auth Methods"); ?></th>
504
											<th><?=gettext("Description"); ?></th>
505
											<th><?=gettext("P2 actions")?></th>
506
										</tr>
507
									</thead>
508
									<tbody class="p2-entries">
509
<?php $j = 0; foreach ($a_phase2 as $ph2index => $ph2ent): ?>
510
<?php
511
						if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
512
							continue;
513
						}
514

    
515
						$fr_c = $fr_prefix . "c" . $j;
516
						$fr_d = $fr_prefix . "d" . $j;
517

    
518
						$iconfn = "pass";
519
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
520

    
521
						if ($entryStatus == 'disabled') {
522
							$iconfn .= "_d";
523
						}
524
?>
525
										<tr id="<?=$fr_prefix . $j?>" ondblclick="document.location='vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>'" class="<?= $entryStatus ?>">
526
											<td>
527
												<input type="checkbox" id="<?=$fr_c?>" name="p2entry[]" value="<?=$ph2index?>" onclick="fr_bgcolor('<?=$j?>', '<?=$fr_prefix?>')" />
528
												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button>
529
											</td>
530
											<td>
531
												<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>
532
											</td>
533
											<td>
534
												<?= htmlspecialchars($ph2ent['reqid']) ?>
535
											</td>
536
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
537
												<?=$ph2ent['mode']?>
538
											</td>
539
<?php if (($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6") or ($ph2ent['mode'] == "vti")): ?>
540
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
541
												<?=ipsec_idinfo_to_text($ph2ent['localid']); ?>
542
											</td>
543
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
544
												<?=ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
545
											</td>
546
		<?php else: ?>
547
											<td colspan="2"></td>
548
<?php endif; ?>
549
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
550
												<?=$p2_protos[$ph2ent['protocol']]; ?>
551
											</td>
552
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
553
<?php
554
								foreach ($ph2ent['encryption-algorithm-option'] as $k => $ph2ea) {
555
									if ($k) {
556
										echo ", ";
557
									}
558
									echo $p2_ealgos[$ph2ea['name']]['name'];
559
									if ($ph2ea['keylen']) {
560
										if ($ph2ea['keylen'] == "auto") {
561
											echo " (" . gettext("auto") . ")";
562
										} else {
563
											echo " ({$ph2ea['keylen']} " . gettext("bits") . ")";
564
										}
565
									}
566
								}
567
?>
568
											</td>
569
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
570
<?php
571
								if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) {
572
									foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) {
573
										if ($k) {
574
											echo ", ";
575
										}
576
										echo $p2_halgos[$ph2ha];
577
									}
578
								}
579
?>
580
											<td><?= htmlspecialchars($ph2ent['descr']) ?></td>
581
											</td>
582
											<td style="cursor: pointer;">
583
<!--												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button> -->
584
												<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>" title="<?=gettext("Edit phase 2 entry"); ?>"></a>
585
												<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>
586
												<a	class="fa fa-trash no-confirm" id="Xdelp2_<?=$ph2index?>" title="<?=gettext('Delete phase 2 entry'); ?>"></a>
587
												<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>
588
											</td>
589
										</tr>
590
<?php $j++; endforeach; ?>
591
										<tr>
592
											<td></td>
593
											<td>
594
												<a class="btn btn-xs btn-success" href="vpn_ipsec_phase2.php?ikeid=<?=$ph1ent['ikeid']?><?php if (isset($ph1ent['mobile'])) echo "&amp;mobile=true"?>">
595
													<i class="fa fa-plus icon-embed-btn"></i>
596
													<?=gettext("Add P2")?>
597
												</a>
598
											</td>
599
											<td colspan="9"></td>
600
										</tr>
601
									</tbody>
602
								</table>
603
							</div>
604
						</td>
605
					</tr>
606
<?php
607
					$i++;
608
				endforeach;	 // $a_phase1 as $ph1ent
609
?>
610
				</tbody>
611
			</table>
612
		</div>
613
	</div>
614

    
615
	<nav class="action-buttons">
616
<?php
617
/*
618
	if ($i !== 0): ?>
619
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
620
<?php endif;
621
*/
622
?>
623
		<a href="vpn_ipsec_phase1.php" class="btn btn-success btn-sm"  usepost>
624
			<i class="fa fa-plus icon-embed-btn"></i>
625
			<?=gettext("Add P1")?>
626
		</a>
627
<?php if ($i !== 0): ?>
628
		<button type="submit" name="del" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected P1s")?>">
629
			<i class="fa fa-trash icon-embed-btn"></i>
630
			<?=gettext("Delete P1s")?>
631
		</button>
632
<?php endif; ?>
633
	</nav>
634
</form>
635

    
636
<div class="infoblock">
637
	<?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 />' .
638
	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 />' .
639
	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); ?>
640
</div>
641

    
642
<script type="text/javascript">
643
//<![CDATA[
644
function show_phase2(id, buttonid) {
645
	document.getElementById(buttonid).innerHTML='';
646
	document.getElementById(id).style.display = "block";
647
	var visible = id + '-visible';
648
	document.getElementById(visible).value = "1";
649
}
650

    
651
events.push(function() {
652
	$('[id^=Xmove_]').click(function (event) {
653
		// ToDo: We POST shift="yes" if the user has the shift key depressed, but that is not yet used
654
		// by the $_POST code. It is intended to allow the user to choose to move stuff to the row before or
655
		// after the clicked anchor icon
656
		if (event.shiftKey) {
657
			$('form').append('<input type="hidden" id="shift" name="shift" value="yes" />');
658
		}
659

    
660
		$('#' + event.target.id.slice(1)).click();
661
	});
662

    
663
	$('[id^=Xdel_]').click(function (event) {
664
		if (confirm("<?=gettext('Confirmation required to delete this P1 entry.')?>")) {
665
			$('#' + event.target.id.slice(1)).click();
666
		}
667
	});
668

    
669
	$('[id^=Xdelp2_]').click(function (event) {
670
		if (confirm("<?=gettext('Confirmation required to delete this P2 entry.')?>")) {
671
			$('#' + event.target.id.slice(1)).click();
672
		}
673
	});
674
});
675
//]]>
676
</script>
677

    
678
<?php
679
include("foot.inc");
(214-214/228)