Projet

Général

Profil

Télécharger (32,7 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_nat_out_edit.php @ 67eec085

1
<?php
2
/* $Id$ */
3
/*
4
	firewall_nat_out_edit.php
5
	Copyright (C) 2004 Scott Ullrich
6
	All rights reserved.
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
/*
34
	pfSense_MODULE:	nat
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-firewall-nat-outbound-edit
39
##|*NAME=Firewall: NAT: Outbound: Edit page
40
##|*DESCR=Allow access to the 'Firewall: NAT: Outbound: Edit' page.
41
##|*MATCH=firewall_nat_out_edit.php*
42
##|-PRIV
43

    
44
require("guiconfig.inc");
45
require_once("filter.inc");
46
require("shaper.inc");
47

    
48
if (!is_array($config['nat']['outbound']))
49
	$config['nat']['outbound'] = array();
50

    
51
if (!is_array($config['nat']['outbound']['rule'])) {
52
	$config['nat']['outbound']['rule'] = array();
53
}
54

    
55
$a_out = &$config['nat']['outbound']['rule'];
56

    
57
if (!is_array($config['aliases']['alias']))
58
	$config['aliases']['alias'] = array();
59
$a_aliases = &$config['aliases']['alias'];
60

    
61
if (is_numericint($_GET['id']))
62
	$id = $_GET['id'];
63
if (isset($_POST['id']) && is_numericint($_POST['id']))
64
	$id = $_POST['id'];
65

    
66
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
67
	$after = $_GET['after'];
68
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
69
	$after = $_POST['after'];
70

    
71
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
72
        $id = $_GET['dup'];
73
        $after = $_GET['dup'];
74
}
75

    
76
if (isset($id) && $a_out[$id]) {
77
	if ( isset($a_out[$id]['created']) && is_array($a_out[$id]['created']) )
78
		$pconfig['created'] = $a_out[$id]['created'];
79

    
80
	if ( isset($a_out[$id]['updated']) && is_array($a_out[$id]['updated']) )
81
		$pconfig['updated'] = $a_out[$id]['updated'];
82

    
83
	$pconfig['protocol'] = $a_out[$id]['protocol'];
84
	list($pconfig['source'],$pconfig['source_subnet']) = explode('/', $a_out[$id]['source']['network']);
85
	if (!is_numeric($pconfig['source_subnet']))
86
		$pconfig['source_subnet'] = 32;
87
	$pconfig['sourceport'] = $a_out[$id]['sourceport'];
88
	address_to_pconfig($a_out[$id]['destination'], $pconfig['destination'],
89
		$pconfig['destination_subnet'], $pconfig['destination_not'],
90
		$none, $none);
91
	$pconfig['dstport'] = $a_out[$id]['dstport'];
92
	$pconfig['natport'] = $a_out[$id]['natport'];
93
	$pconfig['target'] = $a_out[$id]['target'];
94
	$pconfig['targetip'] = $a_out[$id]['targetip'];
95
	$pconfig['targetip_subnet'] = $a_out[$id]['targetip_subnet'];
96
	$pconfig['poolopts'] = $a_out[$id]['poolopts'];
97
	$pconfig['interface'] = $a_out[$id]['interface'];
98
	if (!$pconfig['interface']) {
99
		$pconfig['interface'] = "wan";
100
	}
101
	$pconfig['descr'] = $a_out[$id]['descr'];
102
	$pconfig['nonat'] = $a_out[$id]['nonat'];
103
	$pconfig['disabled'] = isset($a_out[$id]['disabled']);
104
	$pconfig['staticnatport'] = isset($a_out[$id]['staticnatport']);
105
	$pconfig['nosync'] = isset($a_out[$id]['nosync']);
106
} else {
107
	$pconfig['source_subnet'] = 24;
108
	$pconfig['destination'] = "any";
109
	$pconfig['destination_subnet'] = 24;
110
	$pconfig['interface'] = "wan";
111
}
112

    
113
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
114
	unset($id);
115

    
116
if ($_POST) {
117
	if ($_POST['destination_type'] == "any") {
118
		$_POST['destination'] = "any";
119
		$_POST['destination_subnet'] = 24;
120
	}
121
	if ($_POST['source_type'] == "any") {
122
		$_POST['source'] = "any";
123
		$_POST['source_subnet'] = 24;
124
	} elseif ($_POST['source_type'] == "(self)") {
125
		$_POST['source'] = "(self)";
126
		$_POST['source_subnet'] = 24;
127
	}
128

    
129
	unset($input_errors);
130
	$pconfig = $_POST;
131
	/*  run through $_POST items encoding HTML entties so that the user
132
	 *  cannot think he is slick and perform a XSS attack on the unwilling
133
	 */
134
	foreach ($_POST as $key => $value) {
135
		$temp = str_replace(">", "", $value);
136
		$newpost = htmlentities($temp);
137
		if($newpost <> $temp)
138
			$input_errors[] = sprintf(gettext("Invalid characters detected (%s).  Please remove invalid characters and save again."),$temp);
139
	}
140

    
141
	/* input validation */
142
	$reqdfields = explode(" ", "interface protocol source source_subnet destination destination_subnet");
143
	$reqdfieldsn = array(gettext("Interface"),gettext("Protocol"),gettext("Source"),gettext("Source bit count"),gettext("Destination"),gettext("Destination bit count"));
144

    
145
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
146

    
147
	$protocol_uses_ports = in_array($_POST['protocol'], explode(" ", "any tcp udp tcp/udp"));
148

    
149
	if ($_POST['source'])
150
		$_POST['source'] = trim($_POST['source']);
151
	if ($_POST['destination'])
152
		$_POST['destination'] = trim($_POST['destination']);
153
	if ($_POST['targetip'])
154
		$_POST['targetip'] = trim($_POST['targetip']);
155
	if ($_POST['sourceport'])
156
		$_POST['sourceport'] = trim($_POST['sourceport']);
157
	if ($_POST['dstport'])
158
		$_POST['dstport'] = trim($_POST['dstport']);
159
	if ($_POST['natport'])
160
		$_POST['natport'] = trim($_POST['natport']);
161

    
162
	if($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_portoralias($_POST['sourceport']))
163
		$input_errors[] = gettext("You must supply either a valid port or port alias for the source port entry.");
164

    
165
	if($protocol_uses_ports && $_POST['dstport'] <> "" && !is_portoralias($_POST['dstport']))
166
		$input_errors[] = gettext("You must supply either a valid port or port alias for the destination port entry.");
167

    
168
	if($protocol_uses_ports && $_POST['natport'] <> "" && !is_port($_POST['natport']) && !isset($_POST['nonat']))
169
		$input_errors[] = gettext("You must supply a valid port for the NAT port entry.");
170

    
171
	if (($_POST['source_type'] != "any") && ($_POST['source_type'] != "(self)")) {
172
		if ($_POST['source'] && !is_ipaddroralias($_POST['source']) && $_POST['source'] <> "any") {
173
			$input_errors[] = gettext("A valid source must be specified.");
174
		}
175
	}
176
	if ($_POST['source_subnet'] && !is_numericint($_POST['source_subnet'])) {
177
		$input_errors[] = gettext("A valid source bit count must be specified.");
178
	}
179
	if ($_POST['destination_type'] != "any") {
180
		if ($_POST['destination'] && !is_ipaddroralias($_POST['destination'])) {
181
			$input_errors[] = gettext("A valid destination must be specified.");
182
		}
183
	}
184
	if ($_POST['destination_subnet'] && !is_numericint($_POST['destination_subnet'])) {
185
		$input_errors[] = gettext("A valid destination bit count must be specified.");
186
	}
187
	if ($_POST['destination_type'] == "any") {
188
		if ($_POST['destination_not']) {
189
			$input_errors[] = gettext("Negating destination address of \"any\" is invalid.");
190
		}
191
	}
192

    
193
	if ($_POST['target'] && !is_ipaddr($_POST['target']) && !is_subnet($_POST['target']) && !is_alias($_POST['target']) && !isset($_POST['nonat']) && !($_POST['target'] == "other-subnet")) {
194
		$input_errors[] = gettext("A valid target IP address must be specified.");
195
	}
196

    
197
	if ($_POST['target'] == "other-subnet") {
198
		if (!is_ipaddr($_POST['targetip'])) {
199
			$input_errors[] = gettext("A valid target IP must be specified when using the 'Other Subnet' type.");
200
		}
201
		if (!is_numericint($_POST['targetip_subnet'])) {
202
			$input_errors[] = gettext("A valid target bit count must be specified when using the 'Other Subnet' type.");
203
		}
204
	}
205

    
206
	/* Verify Pool Options */
207
	$poolopts = "";
208
	if ($_POST['poolopts']) {
209
		if (is_subnet($_POST['target']) || ($_POST['target'] == "other-subnet"))
210
			$poolopts = $_POST['poolopts'];
211
		elseif (is_alias($_POST['target'])) {
212
			if (substr($_POST['poolopts'], 0, 11) == "round-robin")
213
				$poolopts = $_POST['poolopts'];
214
			else
215
				$input_errors[] = gettext("Only Round Robin pool options may be chosen when selecting an alias.");
216
		}
217
	}
218

    
219
	/* if user has selected any as source, set it here */
220
	if($_POST['source_type'] == "any") {
221
		$osn = "any";
222
	} else if($_POST['source_type'] == "(self)") {
223
		$osn = "(self)";
224
	} else if(is_alias($_POST['source'])) {
225
		$osn = $_POST['source'];
226
	} else {
227
		$osn = gen_subnet($_POST['source'], $_POST['source_subnet']) . "/" . $_POST['source_subnet'];
228
	}
229

    
230
	/* check for existing entries */
231
	if ($_POST['destination_type'] == "any") {
232
		$ext = "any";
233
	} else if(is_alias($_POST['destination'])) {
234
		$ext = $_POST['destination'];
235
	} else {
236
		$ext = gen_subnet($_POST['destination'], $_POST['destination_subnet']) . "/" . $_POST['destination_subnet'];
237
	}
238

    
239
	foreach ($a_out as $natent) {
240
		if (isset($id) && ($a_out[$id]) && ($a_out[$id] === $natent)) {
241
			continue;
242
		}
243

    
244
		if (!$natent['interface']) {
245
			$natent['interface'] == "wan";
246
		}
247
	}
248

    
249
	// Allow extending of the firewall edit page and include custom input validation 
250
	pfSense_handle_custom_code("/usr/local/pkg/firewall_aon/input_validation");
251

    
252
	if (!$input_errors) {
253
	        $natent = array();
254
		$natent['source']['network'] = $osn;
255
		$natent['sourceport'] = ($protocol_uses_ports) ? $_POST['sourceport'] : "";
256
		$natent['descr'] = $_POST['descr'];
257
		$natent['target'] = (!isset($_POST['nonat'])) ? $_POST['target'] : "";
258
		$natent['targetip'] = (!isset($_POST['nonat'])) ? $_POST['targetip'] : "";
259
		$natent['targetip_subnet'] = (!isset($_POST['nonat'])) ? $_POST['targetip_subnet'] : "";
260
		$natent['interface'] = $_POST['interface'];
261
		$natent['poolopts'] = $poolopts;
262

    
263
		/* static-port */
264
		if(isset($_POST['staticnatport']) && $protocol_uses_ports && !isset($_POST['nonat'])) {
265
			$natent['staticnatport'] = true;
266
		} else {
267
			unset($natent['staticnatport']);
268
		}
269
		
270
		if(isset($_POST['disabled'])) {
271
			$natent['disabled'] = true;
272
		} else {
273
			unset($natent['disabled']);
274
		}
275

    
276
		/* if user has selected not nat, set it here */
277
		if(isset($_POST['nonat'])) {
278
			$natent['nonat'] = true;
279
		} else {
280
			unset($natent['nonat']);
281
		}
282

    
283
		if ($_POST['protocol'] && $_POST['protocol'] != "any")
284
			$natent['protocol'] = $_POST['protocol'];
285
		else
286
			unset($natent['protocol']);
287

    
288
	        if ($ext == "any") {
289
			$natent['destination']['any'] = true;
290
		} else {
291
			$natent['destination']['address'] = $ext;
292
		}
293
		if($_POST['natport'] != "" && $protocol_uses_ports && !isset($_POST['nonat'])) {
294
	        	$natent['natport'] = $_POST['natport'];
295
		} else {
296
			unset($natent['natport']);
297
		}
298
		if($_POST['dstport'] != "" && $protocol_uses_ports) {
299
			$natent['dstport'] = $_POST['dstport'];
300
		} else {
301
			unset($natent['dstport']);
302
		}
303

    
304
		if($_POST['nosync'] == "yes") {
305
			$natent['nosync'] = true;
306
		} else {
307
			unset($natent['nosync']);
308
		}
309

    
310
		if (isset($_POST['destination_not']) && $ext != "any") {
311
			$natent['destination']['not'] = true;
312
		}
313

    
314
		if ( isset($a_out[$id]['created']) && is_array($a_out[$id]['created']) )
315
			$natent['created'] = $a_out[$id]['created'];
316

    
317
		$natent['updated'] = make_config_revision_entry();
318

    
319
		// Allow extending of the firewall edit page and include custom input validation 
320
		pfSense_handle_custom_code("/usr/local/pkg/firewall_aon/pre_write_config");
321

    
322
		if (isset($id) && $a_out[$id]) {
323
			$a_out[$id] = $natent;
324
		} else {
325
			$natent['created'] = make_config_revision_entry();
326
			if (is_numeric($after)) {
327
				array_splice($a_out, $after+1, 0, array($natent));
328
			} else {
329
				$a_out[] = $natent;
330
			}
331
		}
332

    
333
		if (write_config())
334
			mark_subsystem_dirty('natconf');
335
		header("Location: firewall_nat_out.php");
336
		exit;
337
	}
338
}
339

    
340
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Outbound"),gettext("Edit"));
341
$closehead = false;
342
include("head.inc");
343

    
344
?>
345

    
346
<script type="text/javascript" src="/javascript/suggestions.js"></script>
347
<script type="text/javascript" src="/javascript/autosuggest.js"></script>
348
<script type="text/javascript">
349
//<![CDATA[
350
var portsenabled = 1;
351
function staticportchange() {
352
	if(document.iform.staticnatport.checked) {
353
		document.iform.natport.value = "";
354
		document.iform.natport.disabled = 1;
355
	} else {
356
		document.iform.natport.disabled = 0;
357
	}
358
}
359
function typesel_change() {
360
	switch (document.iform.destination_type.selectedIndex) {
361
	case 1: // network
362
		document.iform.destination.disabled = 0;
363
		document.iform.destination_subnet.disabled = 0;
364
		break;
365
	default:
366
		document.iform.destination.value = "";
367
		document.iform.destination.disabled = 1;
368
		document.iform.destination_subnet.value = "24";
369
		document.iform.destination_subnet.disabled = 1;
370
		break;
371
	}
372
}
373
function sourcesel_change() {
374
	switch (document.iform.source_type.selectedIndex) {
375
	case 2: // network
376
		document.iform.source.disabled = 0;
377
		document.iform.source_subnet.disabled = 0;
378
		break;
379
	default:
380
		document.iform.source.value = "";
381
		document.iform.source.disabled = 1;
382
		document.iform.source_subnet.value = "24";
383
		document.iform.source_subnet.disabled = 1;
384
		break;
385
	}
386
}
387
function nonat_change() {
388
	if (document.iform.nonat.checked) {
389
		document.getElementById("transtable").style.display = 'none';
390
	} else {
391
		document.getElementById("transtable").style.display = '';
392
	}
393
}
394
function proto_change() {
395
	if (document.iform.protocol.selectedIndex >= 0 && document.iform.protocol.selectedIndex <= 3) {
396
		portsenabled = 1;
397
	} else {
398
		portsenabled = 0;
399
	}
400

    
401
	if (portsenabled) {
402
		document.getElementById("sport_tr").style.display = '';
403
		document.getElementById("dport_tr").style.display = '';
404
		document.getElementById("tport_tr").style.display = '';
405
		document.getElementById("tporttext_tr").style.display = '';
406
		document.getElementById("tportstatic_tr").style.display = '';
407
	} else {
408
		document.getElementById("sport_tr").style.display = 'none';
409
		document.getElementById("dport_tr").style.display = 'none';
410
		document.getElementById("tport_tr").style.display = 'none';
411
		document.getElementById("tporttext_tr").style.display = 'none';
412
		document.getElementById("tportstatic_tr").style.display = 'none';
413
	}
414
}
415
function poolopts_change() {
416
	if (jQuery('#target option:selected').text().substring(0,4) == "Host") {
417
		jQuery('#poolopts_tr').css('display','');
418
		jQuery('#target_network').css('display','none');
419
	} else if (jQuery('#target option:selected').text().substring(0,6) == "Subnet") {
420
		jQuery('#poolopts_tr').css('display','');
421
		jQuery('#target_network').css('display','none');
422
	} else if (jQuery('#target option:selected').text().substring(0,5) == "Other") {
423
		jQuery('#poolopts_tr').css('display','');
424
		jQuery('#target_network').css('display','');
425
	} else {
426
		jQuery('#poolopts').prop('selectedIndex',0);
427
		jQuery('#poolopts_tr').css('display','none');
428
		jQuery('#target_network').css('display','none');
429
		jQuery('#targetip').val('');
430
		jQuery('#targetip_subnet').val('0');
431
	}
432
}
433
//]]>
434
</script>
435
</head>
436

    
437
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
438
<?php include("fbegin.inc"); ?>
439
<?php if ($input_errors) print_input_errors($input_errors); ?>
440
<form action="firewall_nat_out_edit.php" method="post" name="iform" id="iform">
441
	<table width="100%" border="0" cellpadding="6" cellspacing="1" summary="firewall nat outbound edit">
442
		<tr>
443
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Advanced Outbound NAT entry");?></td>
444
		</tr>
445
<?php
446
		// Allow extending of the firewall edit page and include custom input validation 
447
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
448
?>
449
		<tr>
450
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
451
			<td width="78%" class="vtable">
452
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
453
				<strong><?=gettext("Disable this rule");?></strong><br />
454
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
455
			</td>
456
		</tr>
457
		<tr>
458
			<td width="22%" valign="top" class="vncell"><?=gettext("Do not NAT");?></td>
459
			<td width="78%" class="vtable">
460
				<input type="checkbox" name="nonat" id="nonat" onclick="nonat_change();" <?php if(isset($pconfig['nonat'])) echo " checked=\"checked\""; ?> />
461
				<span class="vexpl"><?=gettext("Enabling this option will disable NAT for traffic matching this rule and stop processing Outbound NAT rules.");?>
462
				<br /><?=gettext("Hint: in most cases, you won't use this option.");?></span>
463
			</td>
464
		</tr>
465
		<tr>
466
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
467
			<td width="78%" class="vtable">
468
				<select name="interface" class="formselect">
469
<?php
470
					$iflist = get_configured_interface_with_descr(false, true);
471
					foreach ($iflist as $if => $ifdesc)
472
						if(have_ruleint_access($if))
473
							$interfaces[$if] = $ifdesc;
474

    
475
					if ($config['l2tp']['mode'] == "server")
476
						if(have_ruleint_access("l2tp"))
477
							$interfaces['l2tp'] = "L2TP VPN";
478

    
479
					if ($config['pptpd']['mode'] == "server")
480
						if(have_ruleint_access("pptp"))
481
							$interfaces['pptp'] = "PPTP VPN";
482

    
483
					if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
484
						$interfaces['pppoe'] = "PPPoE VPN";
485

    
486
					/* add ipsec interfaces */
487
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
488
						if(have_ruleint_access("enc0"))
489
							$interfaces["enc0"] = "IPsec";
490

    
491
					/* add openvpn/tun interfaces */
492
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
493
						$interfaces["openvpn"] = "OpenVPN";
494

    
495
					foreach ($interfaces as $iface => $ifacename):
496
?>
497
						<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
498
							<?=htmlspecialchars($ifacename);?>
499
						</option>
500
<?php
501
					endforeach;
502
?>
503
				</select><br />
504
				<span class="vexpl"><?=gettext("Choose which interface this rule applies to.");?><br />
505
					<?=gettext("Hint: in most cases, you'll want to use WAN here.");?>
506
				</span>
507
			</td>
508
		</tr>
509
		<tr>
510
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
511
			<td width="78%" class="vtable">
512
				<select name="protocol" class="formselect" onchange="proto_change();">
513
<?php
514
				$protocols = explode(" ", "any TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP carp pfsync");
515
				foreach ($protocols as $proto):
516
?>
517
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['protocol']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
518
<?php
519
				endforeach;
520
?>
521
				</select><br />
522
				<span class="vexpl"><?=gettext("Choose which protocol this rule should match.");?><br />
523
<?php
524
					printf(gettext("Hint: in most cases, you should specify %s any %s here."),"<em>","</em>&nbsp;");
525
?>
526
				</span>
527
			</td>
528
		</tr>
529
		<tr>
530
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
531
			<td width="78%" class="vtable">
532
				<table border="0" cellspacing="1" cellpadding="1" summary="source">
533
					<tr>
534
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
535
						<td>
536
							<select name="source_type" class="formselect" onchange="sourcesel_change()">
537
								<option value="any" <?php if ($pconfig['source'] == "any") echo "selected=\"selected\""; ?>><?=gettext("any");?></option>
538
								<option value="(self)" <?PHP if ($pconfig['source'] == "(self)") echo "selected=\"selected\""; ?>><?=gettext("This Firewall (self)");?></option>
539
								<option value="network" <?php if (($pconfig['source'] != "any") && ($pconfig['source'] != "(self)")) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
540
							</select>
541
						</td>
542
					</tr>
543
					<tr>
544
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
545
						<td>
546
							<input name="source" type="text" autocomplete="off" class="formfldalias" id="source" size="20" value="<?=htmlspecialchars($pconfig['source']);?>" />/
547
							<select name="source_subnet" class="formfld" id="source_subnet">
548
<?php
549
							for ($i = 32; $i >= 0; $i--):
550
?>
551
								<option value="<?=$i;?>"<?php if ($i == $pconfig['source_subnet']) echo " selected=\"selected\""; ?>><?=$i;?></option>
552
<?php
553
							endfor;
554
?>
555
							</select>
556
						</td>
557
					</tr>
558
					<tr>
559
						<td>&nbsp;</td>
560
						<td>
561
							<span class="vexpl"><?=gettext("Enter the source network for the outbound NAT mapping.");?></span>
562
						</td>
563
					</tr>
564
					<tr name="sport_tr" id="sport_tr">
565
						<td><?=gettext("Source port:");?>&nbsp;&nbsp;</td>
566
						<td>
567
							<input name="sourceport" type="text" autocomplete="off" class="formfldalias" id="sourceport" size="5" value="<?=htmlspecialchars($pconfig['sourceport']);?>" />
568
							<?=gettext("(leave blank for any)");?>
569
						</td>
570
					</tr>
571
				</table>
572
			</td>
573
		</tr>
574
		<tr>
575
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
576
			<td width="78%" class="vtable">
577
				<input name="destination_not" type="checkbox" id="destination_not" value="yes" <?php if ($pconfig['destination_not']) echo "checked=\"checked\""; ?> />
578
				<strong><?=gettext("not");?></strong><br />
579
				<?=gettext("Use this option to invert the sense of the match.");?><br />
580
				<br />
581
				<table border="0" cellspacing="1" cellpadding="1" summary="destination">
582
					<tr>
583
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
584
						<td>
585
							<select name="destination_type" class="formselect" onchange="typesel_change()">
586
								<option value="any"<?php if ($pconfig['destination'] == "any") echo " selected=\"selected\""; ?>>
587
									<?=gettext("any");?>
588
								</option>
589
								<option value="network"<?php if ($pconfig['destination'] != "any") echo " selected=\"selected\""; ?>>
590
									<?=gettext("Network");?>
591
								</option>
592
							</select>
593
						</td>
594
					</tr>
595
					<tr>
596
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
597
						<td>
598
							<input name="destination" type="text" autocomplete="off" class="formfldalias" id="destination" size="20" value="<?=htmlspecialchars($pconfig['destination']);?>" />/
599
							<select name="destination_subnet" class="formselect" id="destination_subnet">
600
<?php
601
							for ($i = 32; $i >= 0; $i--):
602
?>
603
								<option value="<?=$i;?>"<?php if ($i == $pconfig['destination_subnet']) echo " selected=\"selected\""; ?>><?=$i;?></option>
604
<?php
605
							endfor;
606
?>
607
							</select>
608
						</td>
609
					</tr>
610
					<tr>
611
						<td>&nbsp;</td>
612
						<td>
613
							<span class="vexpl"><?=gettext("Enter the destination network for the outbound NAT mapping.");?></span>
614
						</td>
615
					</tr>
616
					<tr name="dport_tr" id="dport_tr">
617
						<td><?=gettext("Destination port:");?>&nbsp;&nbsp;</td>
618
						<td>
619
							<input name="dstport" type="text" autocomplete="off" class="formfldalias" id="dstport" size="5" value="<?=htmlspecialchars($pconfig['dstport']);?>" />
620
							<?=gettext("(leave blank for any)");?>
621
						</td>
622
					</tr>
623
				</table>
624
			</td>
625
		</tr>
626
		<tr name="transtable" id="transtable">
627
			<td width="22%" valign="top" class="vncell"><?=gettext("Translation");?></td>
628
			<td width="78%" class="vtable">
629
				<table border="0" cellspacing="1" cellpadding="1" summary="translation">
630
					<tr>
631
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
632
						<td>
633
							<select name="target" class="formselect" id="target" onchange="poolopts_change();">
634
								<option value=""<?php if (!$pconfig['target']) echo " selected=\"selected\""; ?>>
635
									<?=gettext("Interface address");?>
636
								</option>
637
<?php
638
								if (is_array($config['virtualip']['vip'])):
639
									foreach ($config['virtualip']['vip'] as $sn):
640
										if (isset($sn['noexpand']))
641
											continue;
642
										if ($sn['mode'] == "proxyarp" && $sn['type'] == "network"):
643
											$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
644
											$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
645
											$len = $end - $start;
646
?>
647
								<option value="<?=$sn['subnet'].'/'.$sn['subnet_bits'];?>" <?php if ($sn['subnet'].'/'.$sn['subnet_bits'] == $pconfig['target']) echo "selected=\"selected\""; ?>>
648
									<?=htmlspecialchars("Subnet: {$sn['subnet']}/{$sn['subnet_bits']} ({$sn['descr']})");?>
649
								</option>
650
<?php
651
											for ($i = 0; $i <= $len; $i++):
652
												$snip = long2ip32($start+$i);
653
?>
654
								<option value="<?=$snip;?>" <?php if ($snip == $pconfig['target']) echo "selected"; ?>>
655
									<?=htmlspecialchars("{$snip} ({$sn['descr']})");?>
656
								</option>
657
<?php
658
											endfor;
659
?>
660
<?php
661
										else:
662
?>
663
								<option value="<?=$sn['subnet'];?>" <?php if ($sn['subnet'] == $pconfig['target']) echo "selected=\"selected\""; ?>>
664
									<?=htmlspecialchars("{$sn['subnet']} ({$sn['descr']})");?>
665
								</option>
666
<?php
667
										endif;
668
									endforeach;
669
								endif;
670
								foreach ($a_aliases as $alias):
671
									if ($alias['type'] != "host")
672
										continue;
673
?>
674
								<option value="<?=$alias['name'];?>" <?php if ($alias['name'] == $pconfig['target']) echo "selected=\"selected\""; ?>>
675
									<?=htmlspecialchars("Host Alias: {$alias['name']} ({$alias['descr']})");?>
676
								</option>
677
<?php
678
								endforeach;
679
?>
680
								<option value="other-subnet"<?php if($pconfig['target'] == "other-subnet") echo " selected=\"selected\""; ?>>
681
									<?=gettext("Other Subnet (Enter Below)");?>
682
								</option>
683
							</select>
684
						</td>
685
					</tr>
686

    
687
					<tr id="target_network">
688
						<td><?=gettext("Other Subnet:");?>&nbsp;&nbsp;</td>
689
						<td>
690
							<input name="targetip" type="text" class="formfld unknown" id="targetip" size="20" value="<?=htmlspecialchars($pconfig['targetip']);?>" />/
691
							<select name="targetip_subnet" class="formfld" id="targetip_subnet">
692
<?php
693
							for ($i = 32; $i >= 0; $i--):
694
?>
695
								<option value="<?=$i;?>"<?php if ($i == $pconfig['targetip_subnet']) echo " selected=\"selected\""; ?>><?=$i;?></option>
696
<?php
697
							endfor;
698
?>
699
							</select>
700
						</td>
701
					</tr>
702

    
703
					<tr>
704
						<td>&nbsp;</td>
705
						<td>
706
							<span class="vexpl"><?=gettext("Packets matching this rule will be mapped to the IP address given here.");?><br />
707
								<?=gettext("If you want this rule to apply to another IP address rather than the IP address of the interface chosen above, ".
708
								"select it here (you will need to define ");?>
709
								<a href="firewall_virtual_ip.php"><?=gettext("Virtual IP");?></a>
710
								<?=gettext("addresses on the interface first).");?>
711
							</span><br />
712
						</td>
713
					</tr>
714
					<tr id="poolopts_tr">
715
						<td valign="top">Pool Options</td>
716
						<td>
717
							<select name="poolopts" id="poolopts">
718
								<option value="" <?php if ($pconfig['poolopts'] == "") echo "selected=\"selected\""; ?>>
719
									<?=htmlspecialchars("Default");?>
720
								</option>
721
								<option value="round-robin" <?php if ($pconfig['poolopts'] == "round-robin") echo "selected=\"selected\""; ?>>
722
									<?=htmlspecialchars("Round Robin");?>
723
								</option>
724
								<option value="round-robin sticky-address" <?php if ($pconfig['poolopts'] == "round-robin sticky-address") echo "selected=\"selected\""; ?>>
725
									<?=htmlspecialchars("Round Robin with Sticky Address");?>
726
								</option>
727
								<option value="random" <?php if ($pconfig['poolopts'] == "random") echo "selected=\"selected\""; ?>>
728
									<?=htmlspecialchars("Random");?>
729
								</option>
730
								<option value="random sticky-address" <?php if ($pconfig['poolopts'] == "random sticky-address") echo "selected=\"selected\""; ?>>
731
									<?=htmlspecialchars("Random with Sticky Address");?>
732
								</option>
733
								<option value="source-hash" <?php if ($pconfig['poolopts'] == "source-hash") echo "selected=\"selected\""; ?>>
734
									<?=htmlspecialchars("Source Hash");?>
735
								</option>
736
								<option value="bitmask" <?php if ($pconfig['poolopts'] == "bitmask") echo "selected=\"selected\""; ?>>
737
									<?=htmlspecialchars("Bitmask");?>
738
								</option>
739
							</select>
740
							<br />
741
							<span class="vexpl">
742
								<?=gettext("Only Round Robin types work with Host Aliases. Any type can be used with a Subnet.");?><br />
743
								* <?=gettext("Round Robin: Loops through the translation addresses.");?><br />
744
								* <?=gettext("Random: Selects an address from the translation address pool at random.");?><br />
745
								* <?=gettext("Source Hash: Uses a hash of the source address to determine the translation address, ensuring that the redirection address is always the same for a given source.");?><br />
746
								* <?=gettext("Bitmask: Applies the subnet mask and keeps the last portion identical; 10.0.1.50 -&gt; x.x.x.50.");?><br />
747
								* <?=gettext("Sticky Address: The Sticky Address option can be used with the Random and Round Robin pool types to ensure that a particular source address is always mapped to the same translation address.");?><br />
748
							</span><br />
749
						</td>
750
					</tr>
751
					<tr name="tport_tr" id="tport_tr">
752
						<td><?=gettext("Port:");?>&nbsp;&nbsp;</td>
753
						<td>
754
							<input name="natport" type="text" class="formfld unknown" id="natport" size="5" value="<?=htmlspecialchars($pconfig['natport']);?>" />
755
						</td>
756
					</tr>
757
					<tr name="tporttext_tr" id="tporttext_tr">
758
						<td>&nbsp;</td>
759
						<td>
760
							<span class="vexpl"><?=gettext("Enter the source port for the outbound NAT mapping.");?></span>
761
						</td>
762
					</tr>
763
					<tr name="tportstatic_tr" id="tportstatic_tr">
764
						<td><?=gettext("Static-port:");?>&nbsp;&nbsp;</td>
765
						<td><input onchange="staticportchange();" name="staticnatport" type="checkbox" class="formfld" id="staticnatport" size="5"<?php if($pconfig['staticnatport']) echo " checked=\"checked\"";?> /></td>
766
					</tr>
767
				</table>
768
			</td>
769
		</tr>
770
		<tr>
771
			<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
772
			<td width="78%" class="vtable">
773
				<input value="yes" name="nosync" type="checkbox" class="formfld" id="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br />
774
				<?=gettext("Hint: This prevents the rule on Master from automatically syncing to other CARP members. This does NOT prevent the rule from being overwritten on Slave.");?>
775
			</td>
776
		</tr>
777
		<tr>
778
			<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
779
			<td width="78%" class="vtable">
780
				<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
781
				<br />
782
				<span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed).");?></span>
783
			</td>
784
		</tr>
785
<?php
786
	$has_created_time = (isset($a_out[$id]['created']) && is_array($a_out[$id]['created']));
787
	$has_updated_time = (isset($a_out[$id]['updated']) && is_array($a_out[$id]['updated']));
788
	if ($has_created_time || $has_updated_time):
789
?>
790
		<tr>
791
			<td>&nbsp;</td>
792
		</tr>
793
		<tr>
794
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
795
		</tr>
796
<?php
797
		if ($has_created_time):
798
?>
799
		<tr>
800
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
801
			<td width="78%" class="vtable">
802
				<?= date(gettext("n/j/y H:i:s"), $a_out[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_out[$id]['created']['username'] ?></strong>
803
			</td>
804
		</tr>
805
<?php
806
		endif;
807

    
808
		if ($has_updated_time):
809
?>
810
		<tr>
811
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
812
			<td width="78%" class="vtable">
813
				<?= date(gettext("n/j/y H:i:s"), $a_out[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_out[$id]['updated']['username'] ?></strong>
814
			</td>
815
		</tr>
816
<?php
817
		endif;
818
	endif;
819
	// Allow extending of the firewall edit page and include custom input validation 
820
	pfSense_handle_custom_code("/usr/local/pkg/firewall_aon/htmlphplate");
821
?>
822
		<tr>
823
			<td width="22%" valign="top">&nbsp;</td>
824
			<td width="78%">
825
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="history.back()" />
826
<?php
827
			if (isset($id) && $a_out[$id]):
828
?>
829
				<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
830
<?php
831
			endif;
832
?>
833
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
834
			</td>
835
		</tr>
836
	</table>
837
</form>
838
<script type="text/javascript">
839
//<![CDATA[
840
	sourcesel_change();
841
	typesel_change();
842
	staticportchange();
843
	nonat_change();
844
	proto_change();
845
	poolopts_change();
846

    
847
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
848
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
849

    
850
	var oTextbox1 = new AutoSuggestControl(document.getElementById("source"), new StateSuggestions(addressarray));
851
	var oTextbox2 = new AutoSuggestControl(document.getElementById("sourceport"), new StateSuggestions(customarray));
852
	var oTextbox3 = new AutoSuggestControl(document.getElementById("destination"), new StateSuggestions(addressarray));
853
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dstport"), new StateSuggestions(customarray));
854
//]]>
855
</script>
856
<?php include("fend.inc"); ?>
857
</body>
858
</html>
(68-68/254)