Project

General

Profile

Download (21.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * vpn_ipsec.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * originally based on m0n0wall (http://m0n0.ch/wall)
10
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
 * All rights reserved.
12
 *
13
 * Licensed under the Apache License, Version 2.0 (the "License");
14
 * you may not use this file except in compliance with the License.
15
 * You may obtain a copy of the License at
16
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * Unless required by applicable law or agreed to in writing, software
20
 * distributed under the License is distributed on an "AS IS" BASIS,
21
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
 * See the License for the specific language governing permissions and
23
 * limitations under the License.
24
 */
25

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

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

    
40
if(!is_array($config['ipsec'])){
41
	$config['ipsec'] = array();
42
}
43

    
44
if (!is_array($config['ipsec']['phase1'])) {
45
	$config['ipsec']['phase1'] = array();
46
}
47

    
48
if (!is_array($config['ipsec']['phase2'])) {
49
	$config['ipsec']['phase2'] = array();
50
}
51

    
52
$a_phase1 = &$config['ipsec']['phase1'];
53
$a_phase2 = &$config['ipsec']['phase2'];
54

    
55

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

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

    
111
	$save = 1;
112

    
113
	/* move selected p1 entries before this */
114
	if (isset($movebtn) && is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
115
		$a_phase1_new = array();
116

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

    
124
		/* copy all selected p1 entries */
125
		for ($i = 0; $i < count($a_phase1); $i++) {
126
			if ($i == $movebtn) {
127
				continue;
128
			}
129
			if (in_array($i, $_POST['p1entry'])) {
130
				$a_phase1_new[] = $a_phase1[$i];
131
			}
132
		}
133

    
134
		/* copy $movebtn p1 entry */
135
		if ($movebtn < count($a_phase1)) {
136
			$a_phase1_new[] = $a_phase1[$movebtn];
137
		}
138

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

    
149
	} else if (isset($movebtnp2) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
150
		/* move selected p2 entries before this */
151
		$a_phase2_new = array();
152

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

    
160
		/* copy all selected p2 entries */
161
		for ($i = 0; $i < count($a_phase2); $i++) {
162
			if ($i == $movebtnp2) {
163
				continue;
164
			}
165
			if (in_array($i, $_POST['p2entry'])) {
166
				$a_phase2_new[] = $a_phase2[$i];
167
			}
168
		}
169

    
170
		/* copy $movebtnp2 p2 entry */
171
		if ($movebtnp2 < count($a_phase2)) {
172
			$a_phase2_new[] = $a_phase2[$movebtnp2];
173
		}
174

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

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

    
211
		/* remove all phase2 entries that match the ikeid */
212
		$ikeid = $a_phase1[$delbtn]['ikeid'];
213
		$p1_has_vti = false;
214
		$delp2ids = array();
215
		foreach ($a_phase2 as $p2index => $ph2tmp) {
216
			if ($ph2tmp['ikeid'] == $ikeid) {
217
				if (is_interface_ipsec_vti_assigned($ph2tmp)) {
218
					$p1_has_vti = true;
219
				} else {
220
					$delp2ids[] = $p2index;
221
				}
222
			}
223
		}
224

    
225
		if ($p1_has_vti) {
226
			$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.");
227
		} else {
228
			foreach ($delp2ids as $dp2idx) {
229
				unset($a_phase2[$dp2idx]);
230
			}
231
			unset($a_phase1[$delbtn]);
232
		}
233

    
234
	} else if (isset($delbtnp2)) {
235
		if (is_interface_ipsec_vti_assigned($a_phase2[$delbtnp2])) {
236
			$input_errors[] = gettext("Cannot delete a VTI Phase 2 while the interface is assigned. Remove the interface assignment before deleting this P2.");
237
		} else {
238
			unset($a_phase2[$delbtnp2]);
239
		}
240
	} else {
241
		$save = 0;
242
	}
243

    
244
	if ($save === 1) {
245
		if (write_config(gettext("Saved configuration changes for IPsec tunnels."))) {
246
			mark_subsystem_dirty('ipsec');
247
		}
248
	}
249
}
250

    
251

    
252
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Tunnels"));
253
$pglinks = array("", "@self", "@self");
254
$shortcut_section = "ipsec";
255

    
256
include("head.inc");
257

    
258
if ($input_errors) {
259
	print_input_errors($input_errors);
260
}
261

    
262
$tab_array = array();
263
$tab_array[] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
264
$tab_array[] = array(gettext("Mobile Clients"), false, "vpn_ipsec_mobile.php");
265
$tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
266
$tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
267
display_top_tabs($tab_array);
268

    
269
if ($_POST['apply']) {
270
	print_apply_result_box($retval);
271
}
272

    
273
if (is_subsystem_dirty('ipsec')) {
274
	print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
275
}
276
?>
277

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

    
317
$i = 0; foreach ($a_phase1 as $ph1ent):
318

    
319
	$iconfn = "pass";
320

    
321
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
322

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

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

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

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

    
480
						$fr_c = $fr_prefix . "c" . $j;
481
						$fr_d = $fr_prefix . "d" . $j;
482

    
483
						$iconfn = "pass";
484
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
485

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

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

    
597
<div class="infoblock">
598
	<?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 />' .
599
	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 />' .
600
	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); ?>
601
</div>
602

    
603
<script type="text/javascript">
604
//<![CDATA[
605
function show_phase2(id, buttonid) {
606
	document.getElementById(buttonid).innerHTML='';
607
	document.getElementById(id).style.display = "block";
608
	var visible = id + '-visible';
609
	document.getElementById(visible).value = "1";
610
}
611

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

    
621
		$('#' + event.target.id.slice(1)).click();
622
	});
623

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

    
630
	$('[id^=Xdelp2_]').click(function (event) {
631
		if (confirm("<?=gettext('Confirmation required to delete this P2 entry.')?>")) {
632
			$('#' + event.target.id.slice(1)).click();
633
		}
634
	});
635
});
636
//]]>
637
</script>
638

    
639
<?php
640
include("foot.inc");
(220-220/234)