Project

General

Profile

Download (20.2 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
			unset($a_phase2[$p2entrydel]);
81
		}
82
		if (write_config(gettext("Deleted selected IPsec Phase 2 entries."))) {
83
			mark_subsystem_dirty('ipsec');
84
		}
85
	}
86
} else  {
87
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
88

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

    
107
	$save = 1;
108

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

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

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

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

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

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

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

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

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

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

    
181
	} else if (isset($togglebtn)) {
182
		if (isset($a_phase1[$togglebtn]['disabled'])) {
183
			unset($a_phase1[$togglebtn]['disabled']);
184
		} else {
185
			$a_phase1[$togglebtn]['disabled'] = true;
186
		}
187
	} else if (isset($togglebtnp2)) {
188
		if (isset($a_phase2[$togglebtnp2]['disabled'])) {
189
			unset($a_phase2[$togglebtnp2]['disabled']);
190
		} else {
191
			$a_phase2[$togglebtnp2]['disabled'] = true;
192
		}
193
	} else if (isset($delbtn)) {
194
		/* remove static route if interface is not WAN */
195
		if ($a_phase1[$delbtn]['interface'] <> "wan") {
196
			mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']}");
197
		}
198

    
199
		/* remove all phase2 entries that match the ikeid */
200
		$ikeid = $a_phase1[$delbtn]['ikeid'];
201
		foreach ($a_phase2 as $p2index => $ph2tmp) {
202
			if ($ph2tmp['ikeid'] == $ikeid) {
203
				unset($a_phase2[$p2index]);
204
			}
205
		}
206
		unset($a_phase1[$delbtn]);
207

    
208
	} else if (isset($delbtnp2)) {
209
		unset($a_phase2[$delbtnp2]);
210

    
211
	} else {
212
		$save = 0;
213
	}
214

    
215
	if ($save === 1) {
216
		if (write_config(gettext("Saved configuration changes for IPsec tunnels."))) {
217
			mark_subsystem_dirty('ipsec');
218
		}
219
	}
220
}
221

    
222

    
223
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Tunnels"));
224
$pglinks = array("", "@self", "@self");
225
$shortcut_section = "ipsec";
226

    
227
include("head.inc");
228

    
229
$tab_array = array();
230
$tab_array[] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
231
$tab_array[] = array(gettext("Mobile Clients"), false, "vpn_ipsec_mobile.php");
232
$tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
233
$tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
234
display_top_tabs($tab_array);
235

    
236
if ($_POST['apply']) {
237
	print_apply_result_box($retval);
238
}
239

    
240
if (is_subsystem_dirty('ipsec')) {
241
	print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
242
}
243
?>
244

    
245
<form name="mainform" method="post">
246
	<div class="panel panel-default">
247
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IPsec Tunnels')?></h2></div>
248
		<div class="panel-body table-responsive">
249
			<table class="table table-striped table-hover">
250
				<thead>
251
					<tr>
252
						<th>&nbsp;</th>
253
						<th>&nbsp;</th>
254
						<th><?=gettext("IKE")?></th>
255
						<th><?=gettext("Remote Gateway")?></th>
256
						<th><?=gettext("Mode")?></th>
257
						<th><?=gettext("P1 Protocol")?></th>
258
						<th><?=gettext("P1 Transforms")?></th>
259
						<th><?=gettext("P1 DH-Group")?></th>
260
						<th><?=gettext("P1 Description")?></th>
261
						<th><?=gettext("Actions")?></th>
262
					</tr>
263
				</thead>
264
				<tbody class="p1-entries">
265
<?php
266
$iflabels = get_configured_interface_with_descr(false, true);
267
$viplist = get_configured_vip_list();
268
foreach ($viplist as $vip => $address) {
269
	$iflabels[$vip] = $address;
270
	if (get_vip_descr($address)) {
271
		$iflabels[$vip] .= " (". get_vip_descr($address) .")";
272
	}
273
}
274
$grouplist = return_gateway_groups_array();
275
foreach ($grouplist as $name => $group) {
276
	if ($group[0]['vip'] != "") {
277
		$vipif = $group[0]['vip'];
278
	} else {
279
		$vipif = $group[0]['int'];
280
	}
281
	$iflabels[$name] = "GW Group {$name}";
282
}
283

    
284
$i = 0; foreach ($a_phase1 as $ph1ent):
285

    
286
	$iconfn = "pass";
287

    
288
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
289

    
290
	if ($entryStatus == 'disabled') {
291
		$iconfn .= "_d";
292
	}
293
?>
294
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
295
						<td>
296
							<input type="checkbox" id="frc<?=$i?>" onclick="fr_toggle(<?=$i?>)" name="p1entry[]" value="<?=$i?>"  />
297
							<a	class="fa fa-anchor icon-pointer" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
298
						</td>
299
						<td>
300
							<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>
301
						</td>
302
						<td id="frd<?=$i?>">
303
<?php
304
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
305
				echo "V1";
306
			} elseif ($ph1ent['iketype'] == "ikev2") {
307
				echo "V2";
308
			} elseif ($ph1ent['iketype'] == "auto") {
309
				echo "Auto";
310
			}
311
?>
312
						</td>
313
						<td>
314
<?php
315
			if ($ph1ent['interface']) {
316
				if (isset($iflabels[$ph1ent['interface']])) {
317
					$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
318
				} else {
319
					$if = sprintf("Interface not found: '%s'", $ph1ent['interface']);
320
				}
321
			} else {
322
				$if = "WAN";
323
			}
324

    
325
			if (!isset($ph1ent['mobile'])) {
326
				echo $if."<br />".$ph1ent['remote-gateway'];
327
			} else {
328
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
329
			}
330
?>
331
						</td>
332
						<td id="frd<?=$i?>">
333
					<?=$spans?>
334
					<?php
335
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1" || $ph1ent['iketype'] == "auto") {
336
						echo "{$ph1ent['mode']}";
337
					}
338
					?>
339
					<?=$spane?>
340
				</td>
341
				<td id="frd<?=$i?>">
342
<?php
343
				$first = true;
344
				if (is_array($ph1ent['encryption']['item'])) {
345
					foreach($ph1ent['encryption']['item'] as $p1algo) {
346
						if (!$first) {
347
							echo "<br/>";
348
						}
349
						echo $p1_ealgos[$p1algo['encryption-algorithm']['name']]['name'];
350
						if ($p1algo['encryption-algorithm']['keylen']) {
351
							echo " ({$p1algo['encryption-algorithm']['keylen']} " . gettext("bits") . ")";
352
						}
353
						$first = false;
354
					}
355
				}
356
?>
357
						</td>
358
						<td>
359
<?php			$first = true;
360
				if (is_array($ph1ent['encryption']['item'])) {
361
					foreach($ph1ent['encryption']['item'] as $p1algo) {
362
						if (!$first) {
363
							echo "<br/>";
364
						}
365
						echo $p1_halgos[$p1algo['hash-algorithm']];
366
						$first = false;
367
					}
368
				}
369
				?>
370
						</td>
371
						<td>
372
<?php			$first = true;
373
				if (is_array($ph1ent['encryption']['item'])) {
374
					foreach($ph1ent['encryption']['item'] as $p1algo) {
375
						if (!$first) {
376
							echo "<br/>";
377
						}
378
						echo str_replace(" ","&nbsp;",$p1_dhgroups[$p1algo['dhgroup']]);
379
						$first = false;
380
					}
381
				}
382
				?>
383
						</td>
384
						<td>
385
							<?=htmlspecialchars($ph1ent['descr'])?>
386
						</td>
387
						<td style="cursor: pointer;">
388
<!--							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a> -->
389
							<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>
390
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?p1index=<?=$i?>" title="<?=gettext("Edit phase1 entry"); ?>"></a>
391
<?php if (!isset($ph1ent['mobile'])): ?>
392
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase1 entry"); ?>"></a>
393
<?php endif; ?>
394
							<a	class="fa fa-trash no-confirm" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase1 entry'); ?>"></a>
395
							<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>
396

    
397
						</td>
398
					</tr>
399
					<tr class="<?= $entryStatus ?>">
400
						<td colspan="2"></td>
401
						<td colspan="7" class="contains-table">
402
<?php
403
			if (isset($_REQUEST["tdph2-{$i}-visible"])) {
404
				$tdph2_visible = htmlspecialchars($_REQUEST["tdph2-{$i}-visible"]);
405
			} else {
406
				$tdph2_visible = 0;
407
			}
408
?>
409
							<input type="hidden" name="tdph2-<?=$i?>-visible" id="tdph2-<?=$i?>-visible" value="<?=$tdph2_visible?>" />
410
							<div id="shph2but-<?=$i?>" <?=($tdph2_visible == '1' ? 'style="display:none"' : '')?>>
411
<?php
412
				$phase2count=0;
413

    
414
				foreach ($a_phase2 as $ph2ent) {
415
					if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
416
						continue;
417
					}
418
					$phase2count++;
419
				}
420
				$fr_prefix = "frp2{$i}";
421
				$fr_header = $fr_prefix . "header";
422
?>
423
								<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>
424
							</div>
425
							<div id="tdph2-<?=$i?>" <?=($tdph2_visible != '1' ? 'style="display:none"' : '')?>>
426
								<table class="table table-striped table-hover">
427
									<thead>
428
										<tr>
429
											<th>&nbsp;</th>
430
											<th>&nbsp;</th>
431
											<th><?=gettext("Mode"); ?></th>
432
											<th><?=gettext("Local Subnet"); ?></th>
433
											<th><?=gettext("Remote Subnet"); ?></th>
434
											<th><?=gettext("P2 Protocol"); ?></th>
435
											<th><?=gettext("P2 Transforms"); ?></th>
436
											<th><?=gettext("P2 Auth Methods"); ?></th>
437
											<th><?=gettext("P2 actions")?></th>
438
										</tr>
439
									</thead>
440
									<tbody class="p2-entries">
441
<?php $j = 0; foreach ($a_phase2 as $ph2index => $ph2ent): ?>
442
<?php
443
						if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
444
							continue;
445
						}
446

    
447
						$fr_c = $fr_prefix . "c" . $j;
448
						$fr_d = $fr_prefix . "d" . $j;
449

    
450
						$iconfn = "pass";
451
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
452

    
453
						if ($entryStatus == 'disabled') {
454
							$iconfn .= "_d";
455
						}
456
?>
457
										<tr id="<?=$fr_prefix . $j?>" ondblclick="document.location='vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>'" class="<?= $entryStatus ?>">
458
											<td>
459
												<input type="checkbox" id="<?=$fr_c?>" name="p2entry[]" value="<?=$ph2index?>" onclick="fr_bgcolor('<?=$j?>', '<?=$fr_prefix?>')" />
460
												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button>
461
											</td>
462
											<td>
463
												<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>
464
											</td>
465
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
466
												<?=$ph2ent['mode']?>
467
											</td>
468
<?php if (($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == "tunnel6") or ($ph2ent['mode'] == "vti")): ?>
469
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
470
												<?=ipsec_idinfo_to_text($ph2ent['localid']); ?>
471
											</td>
472
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
473
												<?=ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
474
											</td>
475
		<?php else: ?>
476
											<td colspan="2"></td>
477
<?php endif; ?>
478
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
479
												<?=$p2_protos[$ph2ent['protocol']]; ?>
480
											</td>
481
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
482
<?php
483
								foreach ($ph2ent['encryption-algorithm-option'] as $k => $ph2ea) {
484
									if ($k) {
485
										echo ", ";
486
									}
487
									echo $p2_ealgos[$ph2ea['name']]['name'];
488
									if ($ph2ea['keylen']) {
489
										if ($ph2ea['keylen'] == "auto") {
490
											echo " (" . gettext("auto") . ")";
491
										} else {
492
											echo " ({$ph2ea['keylen']} " . gettext("bits") . ")";
493
										}
494
									}
495
								}
496
?>
497
											</td>
498
											<td id="<?=$fr_d?>" onclick="fr_toggle('<?=$j?>', '<?=$fr_prefix?>')">
499
<?php
500
								if (!empty($ph2ent['hash-algorithm-option']) && is_array($ph2ent['hash-algorithm-option'])) {
501
									foreach ($ph2ent['hash-algorithm-option'] as $k => $ph2ha) {
502
										if ($k) {
503
											echo ", ";
504
										}
505
										echo $p2_halgos[$ph2ha];
506
									}
507
								}
508
?>
509
											</td>
510
											<td style="cursor: pointer;">
511
<!--												<button class="fa fa-anchor button-icon" type="submit" name="movep2_<?=$j?>" value="movep2_<?=$j?>" title="<?=gettext("Move checked P2s here")?>"></button> -->
512
												<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid']?>" title="<?=gettext("Edit phase2 entry"); ?>"></a>
513
												<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>
514
												<a	class="fa fa-trash no-confirm" id="Xdelp2_<?=$ph2index?>" title="<?=gettext('Delete phase2 entry'); ?>"></a>
515
												<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>
516
											</td>
517
										</tr>
518
<?php $j++; endforeach; ?>
519
										<tr>
520
											<td></td>
521
											<td>
522
												<a class="btn btn-xs btn-success" href="vpn_ipsec_phase2.php?ikeid=<?=$ph1ent['ikeid']?><?php if (isset($ph1ent['mobile'])) echo "&amp;mobile=true"?>">
523
													<i class="fa fa-plus icon-embed-btn"></i>
524
													<?=gettext("Add P2")?>
525
												</a>
526
											</td>
527
											<td colspan="7"></td>
528
										</tr>
529
									</tbody>
530
								</table>
531
							</div>
532
						</td>
533
					</tr>
534
<?php
535
					$i++;
536
				endforeach;	 // $a_phase1 as $ph1ent
537
?>
538
				</tbody>
539
			</table>
540
		</div>
541
	</div>
542

    
543
	<nav class="action-buttons">
544
<?php
545
/*
546
	if ($i !== 0): ?>
547
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
548
<?php endif;
549
*/
550
?>
551
		<a href="vpn_ipsec_phase1.php" class="btn btn-success btn-sm"  usepost>
552
			<i class="fa fa-plus icon-embed-btn"></i>
553
			<?=gettext("Add P1")?>
554
		</a>
555
<?php if ($i !== 0): ?>
556
		<button type="submit" name="del" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected P1s")?>">
557
			<i class="fa fa-trash icon-embed-btn"></i>
558
			<?=gettext("Delete P1s")?>
559
		</button>
560
<?php endif; ?>
561
	</nav>
562
</form>
563

    
564
<div class="infoblock">
565
	<?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 />' .
566
	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 />' .
567
	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); ?>
568
</div>
569

    
570
<script type="text/javascript">
571
//<![CDATA[
572
function show_phase2(id, buttonid) {
573
	document.getElementById(buttonid).innerHTML='';
574
	document.getElementById(id).style.display = "block";
575
	var visible = id + '-visible';
576
	document.getElementById(visible).value = "1";
577
}
578

    
579
events.push(function() {
580
	$('[id^=Xmove_]').click(function (event) {
581
		// ToDo: We POST shift="yes" if the user has the shift key depressed, but that is not yet used
582
		// by the $_POST code. It is intended to allow the user to choose to move stuff to the row before or
583
		// after the clicked anchor icon
584
		if (event.shiftKey) {
585
			$('form').append('<input type="hidden" id="shift" name="shift" value="yes" />');
586
		}
587

    
588
		$('#' + event.target.id.slice(1)).click();
589
	});
590

    
591
	$('[id^=Xdel_]').click(function (event) {
592
		if (confirm("<?=gettext('Confirmation required to delete this P1 entry.')?>")) {
593
			$('#' + event.target.id.slice(1)).click();
594
		}
595
	});
596

    
597
	$('[id^=Xdelp2_]').click(function (event) {
598
		if (confirm("<?=gettext('Confirmation required to delete this P2 entry.')?>")) {
599
			$('#' + event.target.id.slice(1)).click();
600
		}
601
	});
602
});
603
//]]>
604
</script>
605

    
606
<?php
607
include("foot.inc");
(221-221/235)