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

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

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

    
137
		$save = 1;
138

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
256
include("head.inc");
257

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

    
266
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
267

    
268
<?php
269
	if ($savemsg) {
270
		print_info_box($savemsg, 'success');
271
	}
272

    
273
	if (is_subsystem_dirty('ipsec')) {
274
		print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . gettext("You must apply the changes in order 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 Description")?></th>
293
						<th><?=gettext("Actions")?></th>
294
					</tr>
295
				</thead>
296
				<tbody class="p1-entries">
297
<?php $i = 0; foreach ($a_phase1 as $ph1ent): ?>
298
<?php
299
	$iconfn = "pass";
300

    
301
	$entryStatus = (isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
302

    
303
	if ($entryStatus == 'disabled') {
304
		$iconfn .= "_d";
305
	}
306
?>
307
					<tr id="fr<?=$i?>" onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>" ondblclick="document.location='vpn_ipsec_phase1.php?p1index=<?=$i?>'" class="<?= $entryStatus ?>">
308
						<td>
309
							<input type="checkbox" id="frc<?=$i?>" name="p1entry[]" value="<?=$i?>" onclick="fr_bgcolor('<?=$i?>')" />
310
							<a	class="fa fa-anchor" id="Xmove_<?=$i?>" title="<?=gettext("Move checked entries to here")?>"></a>
311
						</td>
312
						<td>
313
							<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>
314
						</td>
315
						<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>">
316
<?php
317
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == "ikev1")
318
				echo "V1";
319
			else
320
				echo "V2";
321
?>
322
						</td>
323
						<td>
324
<?php
325
			if ($ph1ent['interface']) {
326
				$iflabels = get_configured_interface_with_descr();
327

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

    
332
				$aliaslist = get_configured_ip_aliases_list();
333
				foreach ($aliaslist as $aliasip => $aliasif)
334
					$iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
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
					$iflabels[$name] = "GW Group {$name}";
343
				}
344
				$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
345
			}
346
			else
347
				$if = "WAN";
348

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

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

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

    
437
						$fr_c = $fr_prefix . "c" . $j;
438
						$fr_d = $fr_prefix . "d" . $j;
439

    
440
						$iconfn = "pass";
441
						$entryStatus = (isset($ph2ent['disabled']) || isset($ph1ent['disabled']) ? 'disabled' : 'enabled');
442

    
443
						if ($entryStatus == 'disabled')
444
							$iconfn .= "_d";
445

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

    
530
	<nav class="action-buttons">
531
<?php
532
/*
533
	if ($i !== 0): ?>
534
	<input type="submit" name="move_<?=$i?>" class="btn btn-default" value="<?=gettext("move selected phase1 entries to end")?>" />
535
<?php endif;
536
*/
537
?>
538
		<a href="vpn_ipsec_phase1.php" class="btn btn-success btn-sm">
539
			<i class="fa fa-plus icon-embed-btn"></i>
540
			<?=gettext("Add P1")?>
541
		</a>
542
<?php if ($i !== 0): ?>
543
		<button type="submit" name="del" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected P1s")?>">
544
			<i class="fa fa-trash icon-embed-btn"></i>
545
			<?=gettext("Delete P1s")?>
546
		</button>
547
<?php endif; ?>
548
	</nav>
549
</form>
550

    
551
<div id="infoblock">
552
	<?=print_info_box('<strong>' . gettext("Note:") . '</strong><br />' .
553
	gettext("You can check your IPsec status at ") . '<a href="diag_ipsec.php">' . gettext("Status:IPsec") . '</a>.<br />' .
554
	gettext("IPsec Debug Mode can be enabled at ") . '<a href="vpn_ipsec_settings.php">' .gettext("VPN:IPsec:Advanced Settings") . '</a>.<br />' .
555
	gettext("IPsec can be set to prefer older SAs at ") . '<a href="vpn_ipsec_settings.php">' . gettext("VPN:IPsec:Advanced Settings") . '</a>', info)?>
556
</div>
557

    
558
<script type="text/javascript">
559
//<![CDATA[
560
function show_phase2(id, buttonid) {
561
	document.getElementById(buttonid).innerHTML='';
562
	document.getElementById(id).style.display = "block";
563
	var visible = id + '-visible';
564
	document.getElementById(visible).value = "1";
565
}
566

    
567
events.push(function() {
568
	$('[id^=Xmove_]').click(function (event) {
569
		$('#' + event.target.id.slice(1)).click();
570
	});
571

    
572
	$('[id^=Xdel_]').click(function (event) {
573
		if(confirm("<?=gettext('Are you sure you wish to delete this P1 entry?')?>")) {
574
			$('#' + event.target.id.slice(1)).click();
575
		}
576
	});
577

    
578
	$('[id^=Xdelp2_]').click(function (event) {
579
		if(confirm("<?=gettext('Are you sure you wish to delete this P2 entry?')?>")) {
580
			$('#' + event.target.id.slice(1)).click();
581
		}
582
	});
583
});
584
//]]>
585
</script>
586

    
587
<?php
588
include("foot.inc");
(212-212/228)