Project

General

Profile

Download (20.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *  Some or all of this file is based on the m0n0wall project which is
9
 *  Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10
 *
11
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13
 *
14
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16
 *
17
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21
 *
22
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31
 *
32
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38
 *
39
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *	====================================================================
56
 *
57
 */
58

    
59
##|+PRIV
60
##|*IDENT=page-vpn-ipsec
61
##|*NAME=VPN: IPsec
62
##|*DESCR=Allow access to the 'VPN: IPsec' page.
63
##|*MATCH=vpn_ipsec.php*
64
##|-PRIV
65

    
66
require("guiconfig.inc");
67
require_once("functions.inc");
68
require_once("filter.inc");
69
require_once("shaper.inc");
70
require_once("ipsec.inc");
71
require_once("vpn.inc");
72

    
73
if (!is_array($config['ipsec']['phase1'])) {
74
	$config['ipsec']['phase1'] = array();
75
}
76

    
77
if (!is_array($config['ipsec']['phase2'])) {
78
	$config['ipsec']['phase2'] = array();
79
}
80

    
81
$a_phase1 = &$config['ipsec']['phase1'];
82
$a_phase2 = &$config['ipsec']['phase2'];
83

    
84
if ($_POST) {
85
	if ($_POST['apply']) {
86
		$retval = vpn_ipsec_configure();
87
		/* reload the filter in the background */
88
		filter_configure();
89
		$savemsg = get_std_save_message($retval);
90
		if ($retval >= 0) {
91
			if (is_subsystem_dirty('ipsec')) {
92
				clear_subsystem_dirty('ipsec');
93
			}
94
		}
95
	} else if (isset($_POST['del'])) {
96
		/* delete selected p1 entries */
97
		if (is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
98
			foreach ($_POST['p1entry'] as $p1entrydel) {
99
				unset($a_phase1[$p1entrydel]);
100
			}
101
			if (write_config()) {
102
				mark_subsystem_dirty('ipsec');
103
			}
104
		}
105
	} else if (isset($_POST['delp2'])) {
106
		/* delete selected p2 entries */
107
		if (is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
108
			foreach ($_POST['p2entry'] as $p2entrydel) {
109
				unset($a_phase2[$p2entrydel]);
110
			}
111
			if (write_config()) {
112
				mark_subsystem_dirty('ipsec');
113
			}
114
		}
115
	} else {
116
		/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
117

    
118
		// TODO: this. is. nasty.
119
		unset($delbtn, $delbtnp2, $movebtn, $movebtnp2, $togglebtn, $togglebtnp2);
120
		foreach ($_POST as $pn => $pd) {
121
			if (preg_match("/del_(\d+)/", $pn, $matches)) {
122
				$delbtn = $matches[1];
123
			} else if (preg_match("/delp2_(\d+)/", $pn, $matches)) {
124
				$delbtnp2 = $matches[1];
125
			} else if (preg_match("/move_(\d+)/", $pn, $matches)) {
126
				$movebtn = $matches[1];
127
			} else if (preg_match("/movep2_(\d+)/", $pn, $matches)) {
128
				$movebtnp2 = $matches[1];
129
			} else if (preg_match("/toggle_(\d+)/", $pn, $matches)) {
130
				$togglebtn = $matches[1];
131
			} else if (preg_match("/togglep2_(\d+)/", $pn, $matches)) {
132
				$togglebtnp2 = $matches[1];
133
			}
134
		}
135

    
136
		$save = 1;
137

    
138
		/* move selected p1 entries before this */
139
		if (isset($movebtn) && is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
140
			$a_phase1_new = array();
141

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

    
149
			/* copy all selected p1 entries */
150
			for ($i = 0; $i < count($a_phase1); $i++) {
151
				if ($i == $movebtn) {
152
					continue;
153
				}
154
				if (in_array($i, $_POST['p1entry'])) {
155
					$a_phase1_new[] = $a_phase1[$i];
156
				}
157
			}
158

    
159
			/* copy $movebtn p1 entry */
160
			if ($movebtn < count($a_phase1)) {
161
				$a_phase1_new[] = $a_phase1[$movebtn];
162
			}
163

    
164
			/* copy all p1 entries > $movebtn and not selected */
165
			for ($i = $movebtn+1; $i < count($a_phase1); $i++) {
166
				if (!in_array($i, $_POST['p1entry'])) {
167
					$a_phase1_new[] = $a_phase1[$i];
168
				}
169
			}
170
			if (count($a_phase1_new) > 0) {
171
				$a_phase1 = $a_phase1_new;
172
			}
173

    
174
		} else if (isset($movebtnp2) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
175
			/* move selected p2 entries before this */
176
			$a_phase2_new = array();
177

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

    
185
			/* copy all selected p2 entries */
186
			for ($i = 0; $i < count($a_phase2); $i++) {
187
				if ($i == $movebtnp2) {
188
					continue;
189
				}
190
				if (in_array($i, $_POST['p2entry'])) {
191
					$a_phase2_new[] = $a_phase2[$i];
192
				}
193
			}
194

    
195
			/* copy $movebtnp2 p2 entry */
196
			if ($movebtnp2 < count($a_phase2)) {
197
				$a_phase2_new[] = $a_phase2[$movebtnp2];
198
			}
199

    
200
			/* copy all p2 entries > $movebtnp2 and not selected */
201
			for ($i = $movebtnp2+1; $i < count($a_phase2); $i++) {
202
				if (!in_array($i, $_POST['p2entry'])) {
203
					$a_phase2_new[] = $a_phase2[$i];
204
				}
205
			}
206
			if (count($a_phase2_new) > 0) {
207
				$a_phase2 = $a_phase2_new;
208
			}
209

    
210
		} else if (isset($togglebtn)) {
211
			if (isset($a_phase1[$togglebtn]['disabled'])) {
212
				unset($a_phase1[$togglebtn]['disabled']);
213
			} else {
214
				$a_phase1[$togglebtn]['disabled'] = true;
215
			}
216
		} else if (isset($togglebtnp2)) {
217
			if (isset($a_phase2[$togglebtnp2]['disabled'])) {
218
				unset($a_phase2[$togglebtnp2]['disabled']);
219
			} else {
220
				$a_phase2[$togglebtnp2]['disabled'] = true;
221
			}
222
		} else if (isset($delbtn)) {
223
			/* remove static route if interface is not WAN */
224
			if ($a_phase1[$delbtn]['interface'] <> "wan") {
225
				mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']}");
226
			}
227

    
228
			/* remove all phase2 entries that match the ikeid */
229
			$ikeid = $a_phase1[$delbtn]['ikeid'];
230
			foreach ($a_phase2 as $p2index => $ph2tmp) {
231
				if ($ph2tmp['ikeid'] == $ikeid) {
232
					unset($a_phase2[$p2index]);
233
				}
234
			}
235
			unset($a_phase1[$delbtn]);
236

    
237
		} else if (isset($delbtnp2)) {
238
			unset($a_phase2[$delbtnp2]);
239

    
240
		} else {
241
			$save = 0;
242
		}
243

    
244
		if ($save === 1) {
245
			if (write_config()) {
246
				mark_subsystem_dirty('ipsec');
247
			}
248
		}
249
	}
250
}
251

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

    
255
include("head.inc");
256

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

    
265
<?php
266
	if ($savemsg) {
267
		print_info_box($savemsg, 'success');
268
	}
269

    
270
	if (is_subsystem_dirty('ipsec')) {
271
		print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."));
272
	}
273
?>
274

    
275
<form name="mainform" method="post">
276
	<div class="panel panel-default">
277
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IPsec tunnels')?></h2></div>
278
		<div class="panel-body table-responsive">
279
			<table class="table table-striped table-hover">
280
				<thead>
281
					<tr>
282
						<th>&nbsp;</th>
283
						<th>&nbsp;</th>
284
						<th><?=gettext("IKE")?></th>
285
						<th><?=gettext("Remote Gateway")?></th>
286
						<th><?=gettext("Mode")?></th>
287
						<th><?=gettext("P1 Protocol")?></th>
288
						<th><?=gettext("P1 Transforms")?></th>
289
						<th><?=gettext("P1 Description")?></th>
290
						<th><?=gettext("Actions")?></th>
291
					</tr>
292
				</thead>
293
				<tbody class="p1-entries">
294
<?php $i = 0; foreach ($a_phase1 as $ph1ent): ?>
295
<?php
296
	$iconfn = "pass";
297

    
298
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
299

    
300
	if ($entryStatus == 'disabled') {
301
		$iconfn .= "_d";
302
	}
303
?>
304
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
305
						<td>
306
							<input type="checkbox" id="frc<?=$i?>" onclick="fr_toggle(<?=$i?>)" name="p1entry[]" value="<?=$i?>"  />
307
							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
308
						</td>
309
						<td>
310
							<button value="toggle_<?=$i?>" name="toggle_<?=$i?>" title="<?=gettext("click to toggle enabled/disabled status")?>" class="btn btn-xs btn-default" type="submit"><?= ($entryStatus == 'disabled' ? 'enable' : 'disable') ?></button>
311
						</td>
312
						<td id="frd<?=$i?>">
313
<?php
314
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
315
				echo "V1";
316
			} else {
317
				echo "V2";
318
			}
319
?>
320
						</td>
321
						<td>
322
<?php
323
			if ($ph1ent['interface']) {
324
				$iflabels = get_configured_interface_with_descr();
325

    
326
				$carplist = get_configured_carp_interface_list();
327
				foreach ($carplist as $cif => $carpip) {
328
					$iflabels[$cif] = $carpip." (".get_vip_descr($carpip).")";
329
				}
330

    
331
				$aliaslist = get_configured_ip_aliases_list();
332
				foreach ($aliaslist as $aliasip => $aliasif) {
333
					$iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
334
				}
335

    
336
				$grouplist = return_gateway_groups_array();
337
				foreach ($grouplist as $name => $group) {
338
					if ($group[0]['vip'] != "") {
339
						$vipif = $group[0]['vip'];
340
					} else {
341
						$vipif = $group[0]['int'];
342
					}
343
					$iflabels[$name] = "GW Group {$name}";
344
				}
345
				$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
346
			} else {
347
				$if = "WAN";
348
			}
349

    
350
			if (!isset($ph1ent['mobile'])) {
351
				echo $if."<br />".$ph1ent['remote-gateway'];
352
			} else {
353
				echo $if."<br /><strong>" . gettext("Mobile Client") . "</strong>";
354
			}
355
?>
356
						</td>
357
						<td id="frd<?=$i?>">
358
					<?=$spans?>
359
					<?php
360
					if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1") {
361
						echo "{$ph1ent['mode']}";
362
					}
363
					?>
364
					<?=$spane?>
365
				</td>
366
				<td id="frd<?=$i?>">
367
					<?=$p1_ealgos[$ph1ent['encryption-algorithm']['name']]['name']?>
368
<?php
369
			if ($ph1ent['encryption-algorithm']['keylen']) {
370
				if ($ph1ent['encryption-algorithm']['keylen'] == "auto") {
371
					echo " (" . gettext("auto") . ")";
372
				} else {
373
					echo " ({$ph1ent['encryption-algorithm']['keylen']} " . gettext("bits") . ")";
374
				}
375
			}
376
?>
377
						</td>
378
						<td>
379
							<?=$p1_halgos[$ph1ent['hash-algorithm']]?>
380
						</td>
381
						<td>
382
							<?=htmlspecialchars($ph1ent['descr'])?>
383
						</td>
384
						<td style="cursor: pointer;">
385
<!--							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a> -->
386
							<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>
387
							<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?p1index=<?=$i?>" title="<?=gettext("Edit phase1 entry"); ?>"></a>
388
<?php if (!isset($ph1ent['mobile'])): ?>
389
							<a class="fa fa-clone" href="vpn_ipsec_phase1.php?dup=<?=$i?>" title="<?=gettext("Copy phase1 entry"); ?>"></a>
390
<?php endif; ?>
391
							<a	class="fa fa-trash no-confirm" id="Xdel_<?=$i?>" title="<?=gettext('Delete phase1 entry'); ?>"></a>
392
							<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>
393

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

    
411
				foreach ($a_phase2 as $ph2ent) {
412
					if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
413
						continue;
414
					}
415
					$phase2count++;
416
				}
417
				$fr_prefix = "frp2{$i}";
418
				$fr_header = $fr_prefix . "header";
419
?>
420
								<input type="button" onclick="show_phase2('tdph2-<?=$i?>','shph2but-<?=$i?>')" value="+" /> - <?php printf(gettext("Show %s Phase-2 entries"), $phase2count); ?>
421
							</div>
422
							<div id="tdph2-<?=$i?>" <?=($tdph2_visible != '1' ? 'style="display:none"' : '')?>>
423
								<table class="table table-striped table-hover">
424
									<thead>
425
										<tr>
426
											<th>&nbsp;</th>
427
											<th>&nbsp;</th>
428
											<th><?=gettext("Mode"); ?></th>
429
											<th><?=gettext("Local Subnet"); ?></th>
430
											<th><?=gettext("Remote Subnet"); ?></th>
431
											<th><?=gettext("P2 Protocol"); ?></th>
432
											<th><?=gettext("P2 Transforms"); ?></th>
433
											<th><?=gettext("P2 Auth Methods"); ?></th>
434
											<th><?=gettext("P2 actions")?></th>
435
										</tr>
436
									</thead>
437
									<tbody class="p2-entries">
438
<?php $j = 0; foreach ($a_phase2 as $ph2index => $ph2ent): ?>
439
<?php
440
						if ($ph2ent['ikeid'] != $ph1ent['ikeid']) {
441
							continue;
442
						}
443

    
444
						$fr_c = $fr_prefix . "c" . $j;
445
						$fr_d = $fr_prefix . "d" . $j;
446

    
447
						$iconfn = "pass";
448
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
449

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

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

    
561
<div class="infoblock">
562
	<?=print_info_box('<strong>' . gettext("Note:") . '</strong><br />' .
563
	gettext("You can check your IPsec status at ") . '<a href="status_ipsec.php">' . gettext("Status:IPsec") . '</a>.<br />' .
564
	gettext("IPsec Debug Mode can be enabled at ") . '<a href="vpn_ipsec_settings.php">' .gettext("VPN:IPsec:Advanced Settings") . '</a>.<br />' .
565
	gettext("IPsec can be set to prefer older SAs at ") . '<a href="vpn_ipsec_settings.php">' . gettext("VPN:IPsec:Advanced Settings") . '</a>', 'info', false)?>
566
</div>
567

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

    
577
events.push(function() {
578
	$('[id^=Xmove_]').click(function (event) {
579
		$('#' + event.target.id.slice(1)).click();
580
	});
581

    
582
	$('[id^=Xdel_]').click(function (event) {
583
		if (confirm("<?=gettext('Are you sure you wish to delete this P1 entry?')?>")) {
584
			$('#' + event.target.id.slice(1)).click();
585
		}
586
	});
587

    
588
	$('[id^=Xdelp2_]').click(function (event) {
589
		if (confirm("<?=gettext('Are you sure you wish to delete this P2 entry?')?>")) {
590
			$('#' + event.target.id.slice(1)).click();
591
		}
592
	});
593
});
594
//]]>
595
</script>
596

    
597
<?php
598
include("foot.inc");
(215-215/229)