Project

General

Profile

Download (23.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-2023 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

    
45
$items_deleted = false;
46

    
47
if ($_POST['apply']) {
48
	$ipsec_dynamic_hosts = ipsec_configure();
49
	ipsec_reload_package_hook();
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
			config_del_path('ipsec/phase1/' . $p1entrydel);
63
			$items_deleted = true;
64
		}
65
		if (write_config(gettext("Deleted selected IPsec Phase 1 entries."))) {
66
			mark_subsystem_dirty('ipsec');
67
		}
68
	}
69
} else if (isset($_POST['delp2'])) {
70
	/* delete selected p2 entries */
71
	if (is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
72
		foreach ($_POST['p2entry'] as $p2entrydel) {
73
			if (is_interface_ipsec_vti_assigned(config_get_path('ipsec/phase2/' . $p2entrydel)) && (config_get_path('ipsec/phase2/' . $p2entrydel . '/mode') == 'vti')) {
74
				$input_errors[] = gettext("Cannot delete a VTI Phase 2 while the interface is assigned. Remove the interface assignment before deleting this P2.");
75
			} else {
76
				config_del_path('ipsec/phase2/' . $p2entrydel);
77
				$items_deleted = true;
78
			}
79
		}
80
		if (write_config(gettext("Deleted selected IPsec Phase 2 entries."))) {
81
			mark_subsystem_dirty('ipsec');
82
		}
83
	}
84
} else  {
85
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
86

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

    
105
	$save = 1;
106

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

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

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

    
128
		/* copy $movebtn p1 entry */
129
		if ($movebtn < count(config_get_path('ipsec/phase1', []))) {
130
			$a_phase1_new[] = config_get_path('ipsec/phase1/' . $movebtn);
131
		}
132

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

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

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

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

    
164
		/* copy $movebtnp2 p2 entry */
165
		if ($movebtnp2 < count(config_get_path('ipsec/phase2', []))) {
166
			$a_phase2_new[] = config_get_path('ipsec/phase2/' . $movebtnp2);
167
		}
168

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

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

    
198
				if ($p1_has_vti) {
199
					$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.");
200
				} else {
201
					foreach ($disablep2ids as $dp2idx) {
202
						config_set_path('ipsec/phase2/' . $togglebtnp2 . '/disabled', true);
203
					}
204
					config_set_path('ipsec/phase1/' . $togglebtn . '/disabled', true);
205
				}
206
			} else {
207
				config_set_path('ipsec/phase1/' . $togglebtn . '/disabled', true);
208
			}
209
		}
210
	} else if (isset($togglebtnp2)) {
211
		if (config_path_enabled('ipsec/phase2/' . $togglebtnp2,  'disabled')) {
212
			config_del_path('ipsec/phase2/' . $togglebtnp2 . '/disabled');
213
		} else {
214
			if (is_interface_ipsec_vti_assigned(config_get_path('ipsec/phase2/' . $togglebtnp2)) && (config_get_path('ipsec/phase2/' . $togglebtnp2 . '/mode') == 'vti')) {
215
				$input_errors[] = gettext("Cannot disable a VTI Phase 2 while the interface is assigned. Remove the interface assignment before disabling this P2.");
216
			} else {
217
				config_set_path('ipsec/phase2/' . $togglebtnp2 . '/disabled', true);
218
			}
219
		}
220
	} else if (isset($delbtn)) {
221
		/* remove static route if interface is not WAN */
222
		if (config_get_path('ipsec/phase1/' . $delbtn . '/interface') <> "wan") {
223
			route_del(config_get_path('ipsec/phase1/' . $delbtn . '/remote-gateway'));
224
		}
225

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

    
240
		if ($p1_has_vti) {
241
			$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.");
242
		} else {
243
			foreach ($delp2ids as $dp2idx) {
244
				config_del_path('ipsec/phase2/' . $dp2idx);
245
			}
246
			config_del_path('ipsec/phase1/' . $delbtn);
247
			$items_deleted = true;
248
		}
249

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

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

    
268
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Tunnels"));
269
$pglinks = array("", "@self", "@self");
270
$shortcut_section = "ipsec";
271

    
272
include("head.inc");
273

    
274
if ($input_errors) {
275
	print_input_errors($input_errors);
276
}
277

    
278
$tab_array = array();
279
$tab_array[] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
280
$tab_array[] = array(gettext("Mobile Clients"), false, "vpn_ipsec_mobile.php");
281
$tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
282
$tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
283
display_top_tabs($tab_array);
284

    
285
if ($_POST['apply']) {
286
	print_apply_result_box($retval);
287
}
288

    
289
if (is_subsystem_dirty('ipsec')) {
290
	print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
291
}
292
?>
293

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

    
334
$i = 0; foreach (config_get_path('ipsec/phase1', []) as $ph1ent):
335

    
336
	$iconfn = "pass";
337

    
338
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
339

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

    
378
			if (!isset($ph1ent['mobile'])) {
379
				echo $if."<br />".$ph1ent['remote-gateway'];
380
			} else {
381
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
382
			}
383
?>
384
						</td>
385
						<td id="frd<?=$i?>">
386
					<?=$spans?>
387
					<?php
388
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" || $ph1ent['iketype'] == "auto") {
389
						echo "{$ph1ent['mode']}";
390
					}
391
					?>
392
					<?=$spane?>
393
				</td>
394
				<td id="frd<?=$i?>">
395
<?php
396
				$first = true;
397
				foreach(array_get_path($ph1ent, 'encryption/item', []) as $p1algo) {
398
					if (!$first) {
399
						echo "<br/>";
400
					}
401

    
402
					echo array_get_path($p1_ealgos, array_get_path($p1algo, 'encryption-algorithm/name', '') . '/name', '');
403
					if (array_get_path($p1algo, 'encryption-algorithm/keylen')) {
404
						echo " (" . array_get_path($p1algo, 'encryption-algorithm/keylen') . " " . gettext("bits") . ")";
405
					}
406
					$first = false;
407
				}
408
?>
409
						</td>
410
						<td>
411
<?php			$first = true;
412
				foreach(array_get_path($ph1ent, 'encryption/item', []) as $p1algo) {
413
					if (!$first) {
414
						echo "<br/>";
415
					}
416
					echo $p1_halgos[$p1algo['hash-algorithm']];
417
					if (isset($ph1ent['prfselect_enable'])) {
418
						echo " / PRF" . $p1_halgos[$p1algo['prf-algorithm']];
419
					}
420
					$first = false;
421
				}
422
				?>
423
						</td>
424
						<td>
425
<?php			$first = true;
426
				foreach(array_get_path($ph1ent, 'encryption/item', []) as $p1algo) {
427
					if (!$first) {
428
						echo "<br/>";
429
					}
430
					echo str_replace(" ","&nbsp;",$p1_dhgroups[$p1algo['dhgroup']]);
431
					$first = false;
432
				}
433
				?>
434
						</td>
435
						<td>
436
							<?=htmlspecialchars($ph1ent['descr'])?>
437
						</td>
438
						<td style="cursor: pointer;">
439
<!--							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a> -->
440
							<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>
441
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?ikeid=<?=$ph1ent['ikeid']?>" title="<?=gettext("Edit phase 1 entry"); ?>"></a>
442
<?php if (!isset($ph1ent['mobile'])): ?>
443
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase 1 entry"); ?>"></a>
444
<?php endif; ?>
445
							<a	class="fa fa-trash no-confirm" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase 1 entry'); ?>"></a>
446
							<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>
447

    
448
						</td>
449
					</tr>
450
					<tr class="<?= $entryStatus ?>">
451
						<td colspan="1"></td>
452
						<td colspan="10" class="contains-table">
453
<?php
454
			if (isset($_REQUEST["tdph2-{$i}-visible"])) {
455
				$tdph2_visible = htmlspecialchars($_REQUEST["tdph2-{$i}-visible"]);
456
			} else {
457
				$tdph2_visible = 0;
458
			}
459
?>
460
							<input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" />
461
							<div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>>
462
<?php
463
				$phase2count=0;
464

    
465
				foreach (config_get_path('ipsec/phase2') as $ph2ent) {
466
					if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
467
						continue;
468
					}
469
					$phase2count++;
470
				}
471
				$fr_prefix = "frp2{$i}";
472
				$fr_header = $fr_prefix . "header";
473
?>
474
								<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>
475
							</div>
476
							<div id="tdph2-<?=$i?>" <?=($tdph2_visible != '1' ? 'style="display:none"' : '')?>>
477
								<table class="table table-striped table-hover">
478
									<thead>
479
										<tr>
480
											<th>&nbsp;</th>
481
											<th>&nbsp;</th>
482
											<th><?=gettext("ID"); ?></th>
483
											<th><?=gettext("Mode"); ?></th>
484
											<th><?=gettext("Local Subnet"); ?></th>
485
											<th><?=gettext("Remote Subnet"); ?></th>
486
											<th><?=gettext("P2 Protocol"); ?></th>
487
											<th><?=gettext("P2 Transforms"); ?></th>
488
											<th><?=gettext("P2 Auth Methods"); ?></th>
489
											<th><?=gettext("Description"); ?></th>
490
											<th><?=gettext("P2 actions")?></th>
491
										</tr>
492
									</thead>
493
									<tbody class="p2-entries">
494
<?php $j = 0; foreach (config_get_path('ipsec/phase2') as $ph2index => $ph2ent): ?>
495
<?php
496
						if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
497
							continue;
498
						}
499

    
500
						$fr_c = $fr_prefix . "c" . $j;
501
						$fr_d = $fr_prefix . "d" . $j;
502

    
503
						$iconfn = "pass";
504
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
505

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

    
600
	<nav class="action-buttons">
601
<?php
602
/*
603
	if ($i !== 0): ?>
604
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
605
<?php endif;
606
*/
607
?>
608
		<a href="vpn_ipsec_phase1.php" class="btn btn-success btn-sm"  usepost>
609
			<i class="fa fa-plus icon-embed-btn"></i>
610
			<?=gettext("Add P1")?>
611
		</a>
612
<?php if ($i !== 0): ?>
613
		<button type="submit" name="del" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected P1s")?>">
614
			<i class="fa fa-trash icon-embed-btn"></i>
615
			<?=gettext("Delete P1s")?>
616
		</button>
617
<?php endif; ?>
618
	</nav>
619
</form>
620

    
621
<div class="infoblock">
622
	<?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 />' .
623
	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 />' .
624
	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); ?>
625
</div>
626

    
627
<script type="text/javascript">
628
//<![CDATA[
629
function show_phase2(id, buttonid) {
630
	document.getElementById(buttonid).innerHTML='';
631
	document.getElementById(id).style.display = "block";
632
	var visible = id + '-visible';
633
	document.getElementById(visible).value = "1";
634
}
635

    
636
events.push(function() {
637
	$('[id^=Xmove_]').click(function (event) {
638
		// ToDo: We POST shift="yes" if the user has the shift key depressed, but that is not yet used
639
		// by the $_POST code. It is intended to allow the user to choose to move stuff to the row before or
640
		// after the clicked anchor icon
641
		if (event.shiftKey) {
642
			$('form').append('<input type="hidden" id="shift" name="shift" value="yes" />');
643
		}
644

    
645
		$('#' + event.target.id.slice(1)).click();
646
	});
647

    
648
	$('[id^=Xdel_]').click(function (event) {
649
		if (confirm("<?=gettext('Confirmation required to delete this P1 entry.')?>")) {
650
			$('#' + event.target.id.slice(1)).click();
651
		}
652
	});
653

    
654
	$('[id^=Xdelp2_]').click(function (event) {
655
		if (confirm("<?=gettext('Confirmation required to delete this P2 entry.')?>")) {
656
			$('#' + event.target.id.slice(1)).click();
657
		}
658
	});
659
});
660
//]]>
661
</script>
662

    
663
<?php
664
include("foot.inc");
(214-214/228)