Project

General

Profile

Download (42.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_nat_edit.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

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

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

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

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

    
35
##|+PRIV
36
##|*IDENT=page-firewall-nat-portforward-edit
37
##|*NAME=Firewall: NAT: Port Forward: Edit page
38
##|*DESCR=Allow access to the 'Firewall: NAT: Port Forward: Edit' page.
39
##|*MATCH=firewall_nat_edit.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require_once("itemid.inc");
44
require_once("filter.inc");
45
require("shaper.inc");
46

    
47
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
48
$ifdisp = get_configured_interface_with_descr();
49
foreach ($ifdisp as $kif => $kdescr) {
50
	$specialsrcdst[] = "{$kif}";
51
	$specialsrcdst[] = "{$kif}ip";
52
}
53

    
54
if (!is_array($config['nat']['rule'])) {
55
	$config['nat']['rule'] = array();
56
}
57
$a_nat = &$config['nat']['rule'];
58

    
59
$id = $_GET['id'];
60
if (isset($_POST['id']))
61
	$id = $_POST['id'];
62

    
63
$after = $_GET['after'];
64

    
65
if (isset($_POST['after']))
66
	$after = $_POST['after'];
67

    
68
if (isset($_GET['dup'])) {
69
        $id = $_GET['dup'];
70
        $after = $_GET['dup'];
71
}
72

    
73
if (isset($id) && $a_nat[$id]) {
74
	if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
75
		$pconfig['created'] = $a_nat[$id]['created'];
76

    
77
	if ( isset($a_nat[$id]['updated']) && is_array($a_nat[$id]['updated']) )
78
		$pconfig['updated'] = $a_nat[$id]['updated'];
79

    
80
	$pconfig['disabled'] = isset($a_nat[$id]['disabled']);
81
	$pconfig['nordr'] = isset($a_nat[$id]['nordr']);
82
	address_to_pconfig($a_nat[$id]['source'], $pconfig['src'],
83
		$pconfig['srcmask'], $pconfig['srcnot'],
84
		$pconfig['srcbeginport'], $pconfig['srcendport']);
85

    
86
	address_to_pconfig($a_nat[$id]['destination'], $pconfig['dst'],
87
		$pconfig['dstmask'], $pconfig['dstnot'],
88
		$pconfig['dstbeginport'], $pconfig['dstendport']);
89

    
90
	$pconfig['proto'] = $a_nat[$id]['protocol'];
91
	$pconfig['localip'] = $a_nat[$id]['target'];
92
	$pconfig['localbeginport'] = $a_nat[$id]['local-port'];
93
	$pconfig['descr'] = $a_nat[$id]['descr'];
94
	$pconfig['interface'] = $a_nat[$id]['interface'];
95
	$pconfig['associated-rule-id'] = $a_nat[$id]['associated-rule-id'];
96
	$pconfig['nosync'] = isset($a_nat[$id]['nosync']);
97
	$pconfig['natreflection'] = $a_nat[$id]['natreflection'];
98

    
99
	if (!$pconfig['interface'])
100
		$pconfig['interface'] = "wan";
101
} else {
102
	$pconfig['interface'] = "wan";
103
	$pconfig['src'] = "any";
104
	$pconfig['srcbeginport'] = "any";
105
	$pconfig['srcendport'] = "any";
106
}
107

    
108
if (isset($_GET['dup']))
109
	unset($id);
110

    
111
/*  run through $_POST items encoding HTML entties so that the user
112
 *  cannot think he is slick and perform a XSS attack on the unwilling
113
 */
114
unset($input_errors);
115
foreach ($_POST as $key => $value) {
116
	$temp = $value;
117
	$newpost = htmlentities($temp);
118
	if($newpost <> $temp)
119
		$input_errors[] = sprintf(gettext("Invalid characters detected %s. Please remove invalid characters and save again."), $temp);
120
}
121

    
122
if ($_POST) {
123

    
124
	if(strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") {
125
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
126
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
127
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
128
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
129

    
130
		if ($_POST['srcbeginport'] == "any") {
131
			$_POST['srcbeginport'] = 0;
132
			$_POST['srcendport'] = 0;
133
		} else {
134
			if (!$_POST['srcendport'])
135
				$_POST['srcendport'] = $_POST['srcbeginport'];
136
		}
137
		if ($_POST['srcendport'] == "any")
138
			$_POST['srcendport'] = $_POST['srcbeginport'];
139

    
140
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
141
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
142
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
143
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
144

    
145
		if ($_POST['dstbeginport'] == "any") {
146
			$_POST['dstbeginport'] = 0;
147
			$_POST['dstendport'] = 0;
148
		} else {
149
			if (!$_POST['dstendport'])
150
				$_POST['dstendport'] = $_POST['dstbeginport'];
151
		}
152
		if ($_POST['dstendport'] == "any")
153
			$_POST['dstendport'] = $_POST['dstbeginport'];
154

    
155
		if ($_POST['localbeginport_cust'] && !$_POST['localbeginport'])
156
			$_POST['localbeginport'] = trim($_POST['localbeginport_cust']);
157

    
158
		/* Make beginning port end port if not defined and endport is */
159
		if (!$_POST['srcbeginport'] && $_POST['srcendport'])
160
			$_POST['srcbeginport'] = $_POST['srcendport'];
161
		if (!$_POST['dstbeginport'] && $_POST['dstendport'])
162
			$_POST['dstbeginport'] = $_POST['dstendport'];
163
	} else {
164
		$_POST['srcbeginport'] = 0;
165
		$_POST['srcendport'] = 0;
166
		$_POST['dstbeginport'] = 0;
167
		$_POST['dstendport'] = 0;
168
	}
169

    
170
	if (is_specialnet($_POST['srctype'])) {
171
		$_POST['src'] = $_POST['srctype'];
172
		$_POST['srcmask'] = 0;
173
	} else if ($_POST['srctype'] == "single") {
174
		$_POST['srcmask'] = 32;
175
	}
176
	if (is_specialnet($_POST['dsttype'])) {
177
		$_POST['dst'] = $_POST['dsttype'];
178
		$_POST['dstmask'] = 0;
179
	} else if ($_POST['dsttype'] == "single") {
180
		$_POST['dstmask'] = 32;
181
	} else if (is_ipaddr($_POST['dsttype'])) {
182
		$_POST['dst'] = $_POST['dsttype'];
183
		$_POST['dstmask'] = 32;
184
		$_POST['dsttype'] = "single";
185
	}
186

    
187
	$pconfig = $_POST;
188

    
189
	/* input validation */
190
	if(strtoupper($_POST['proto']) == "TCP" or strtoupper($_POST['proto']) == "UDP" or strtoupper($_POST['proto']) == "TCP/UDP") {
191
		$reqdfields = explode(" ", "interface proto dstbeginport dstendport");
192
		$reqdfieldsn = array(gettext("Interface"),gettext("Protocol"),gettext("Destination port from"),gettext("Destination port to"));
193
	} else {
194
		$reqdfields = explode(" ", "interface proto");
195
		$reqdfieldsn = array(gettext("Interface"),gettext("Protocol"));
196
	}
197

    
198
	if ($_POST['srctype'] == "single" || $_POST['srctype'] == "network") {
199
		$reqdfields[] = "src";
200
		$reqdfieldsn[] = gettext("Source address");
201
	}
202
	if ($_POST['dsttype'] == "single" || $_POST['dsttype'] == "network") {
203
		$reqdfields[] = "dst";
204
		$reqdfieldsn[] = gettext("Destination address");
205
	}
206
	if (!isset($_POST['nordr'])) {
207
		$reqdfields[] = "localip";
208
		$reqdfieldsn[] = gettext("Redirect target IP");
209
	}
210

    
211
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
212

    
213
	if (!$_POST['srcbeginport']) {
214
		$_POST['srcbeginport'] = 0;
215
		$_POST['srcendport'] = 0;
216
	}
217
	if (!$_POST['dstbeginport']) {
218
		$_POST['dstbeginport'] = 0;
219
		$_POST['dstendport'] = 0;
220
	}
221

    
222
	if ($_POST['src'])
223
		$_POST['src'] = trim($_POST['src']);
224
	if ($_POST['dst'])
225
		$_POST['dst'] = trim($_POST['dst']);
226
	if ($_POST['localip'])
227
		$_POST['localip'] = trim($_POST['localip']);
228

    
229
	if (!isset($_POST['nordr']) && ($_POST['localip'] && !is_ipaddroralias($_POST['localip']))) {
230
		$input_errors[] = sprintf(gettext("\"%s\" is not a valid redirect target IP address or host alias."), $_POST['localip']);
231
	}
232

    
233
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
234
		$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcbeginport']);
235
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
236
		$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcendport']);
237
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
238
		$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstbeginport']);
239
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
240
		$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstendport']);
241

    
242
	if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
243
		$input_errors[] = sprintf(gettext("A valid redirect target port must be specified. It must be a port alias or integer between 1 and 65535."), $_POST['localbeginport']);
244
	}
245

    
246
	/* if user enters an alias and selects "network" then disallow. */
247
	if( ($_POST['srctype'] == "network" && is_alias($_POST['src']) ) 
248
	 || ($_POST['dsttype'] == "network" && is_alias($_POST['dst']) ) ) {
249
		$input_errors[] = gettext("You must specify single host or alias for alias entries.");
250
	}
251

    
252
	if (!is_specialnet($_POST['srctype'])) {
253
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
254
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."), $_POST['src']);
255
		}
256
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
257
			$input_errors[] = gettext("A valid source bit count must be specified.");
258
		}
259
	}
260
	if (!is_specialnet($_POST['dsttype'])) {
261
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
262
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."), $_POST['dst']);
263
		}
264
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
265
			$input_errors[] = gettext("A valid destination bit count must be specified.");
266
		}
267
	}
268

    
269
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
270
		/* swap */
271
		$tmp = $_POST['srcendport'];
272
		$_POST['srcendport'] = $_POST['srcbeginport'];
273
		$_POST['srcbeginport'] = $tmp;
274
	}
275
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
276
		/* swap */
277
		$tmp = $_POST['dstendport'];
278
		$_POST['dstendport'] = $_POST['dstbeginport'];
279
		$_POST['dstbeginport'] = $tmp;
280
	}
281

    
282
	if (!$input_errors) {
283
		if (!isset($_POST['nordr']) && ($_POST['dstendport'] - $_POST['dstbeginport'] + $_POST['localbeginport']) > 65535)
284
			$input_errors[] = gettext("The target port range must be an integer between 1 and 65535.");
285
	}
286

    
287
	/* check for overlaps */
288
	foreach ($a_nat as $natent) {
289
		if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent))
290
			continue;
291
		if ($natent['interface'] != $_POST['interface'])
292
			continue;
293
		if ($natent['destination']['address'] != $_POST['dst'])
294
			continue;
295
		if (($natent['proto'] != $_POST['proto']) && ($natent['proto'] != "tcp/udp") && ($_POST['proto'] != "tcp/udp"))
296
			continue;
297

    
298
		list($begp,$endp) = explode("-", $natent['destination']['port']);
299
		if (!$endp)
300
			$endp = $begp;
301

    
302
		if (!(   (($_POST['beginport'] < $begp) && ($_POST['endport'] < $begp))
303
		      || (($_POST['beginport'] > $endp) && ($_POST['endport'] > $endp)))) {
304

    
305
			$input_errors[] = gettext("The destination port range overlaps with an existing entry.");
306
			break;
307
		}
308
	}
309

    
310
	// Allow extending of the firewall edit page and include custom input validation 
311
	pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/input_validation");
312

    
313
	if (!$input_errors) {
314
		$natent = array();
315

    
316
		$natent['disabled'] = isset($_POST['disabled']) ? true:false;
317
		$natent['nordr'] = isset($_POST['nordr']) ? true:false;
318

    
319
		if ($natent['nordr']) {
320
			$_POST['associated-rule-id'] = '';
321
			$_POST['filter-rule-association'] = '';
322
		}
323

    
324
		pconfig_to_address($natent['source'], $_POST['src'],
325
			$_POST['srcmask'], $_POST['srcnot'],
326
			$_POST['srcbeginport'], $_POST['srcendport']);
327

    
328
		pconfig_to_address($natent['destination'], $_POST['dst'],
329
			$_POST['dstmask'], $_POST['dstnot'],
330
			$_POST['dstbeginport'], $_POST['dstendport']);
331

    
332
		$natent['protocol'] = $_POST['proto'];
333

    
334
		if (!$natent['nordr']) {
335
			$natent['target'] = $_POST['localip'];
336
			$natent['local-port'] = $_POST['localbeginport'];
337
		}
338
		$natent['interface'] = $_POST['interface'];
339
		$natent['descr'] = $_POST['descr'];
340
		$natent['associated-rule-id'] = $_POST['associated-rule-id'];
341

    
342
		if($_POST['filter-rule-association'] == "pass")
343
			$natent['associated-rule-id'] = "pass";
344

    
345
		if($_POST['nosync'] == "yes")
346
			$natent['nosync'] = true;
347
		else
348
			unset($natent['nosync']);
349

    
350
		if ($_POST['natreflection'] == "enable" || $_POST['natreflection'] == "purenat" || $_POST['natreflection'] == "disable")
351
			$natent['natreflection'] = $_POST['natreflection'];
352
		else
353
			unset($natent['natreflection']);
354

    
355
		// If we used to have an associated filter rule, but no-longer should have one
356
		if (!empty($a_nat[$id]) && ( empty($natent['associated-rule-id']) || $natent['associated-rule-id'] != $a_nat[$id]['associated-rule-id'] ) ) {
357
			// Delete the previous rule
358
			delete_id($a_nat[$id]['associated-rule-id'], $config['filter']['rule']);
359
			mark_subsystem_dirty('filter');
360
		}
361

    
362
		$need_filter_rule = false;
363
		// Updating a rule with a filter rule associated
364
		if (!empty($natent['associated-rule-id']))
365
			$need_filter_rule = true;
366
		// Create a rule or if we want to create a new one
367
		if( $natent['associated-rule-id']=='new' ) {
368
			$need_filter_rule = true;
369
			unset( $natent['associated-rule-id'] );
370
			$_POST['filter-rule-association']='add-associated';
371
		}
372
		// If creating a new rule, where we want to add the filter rule, associated or not
373
		else if( isset($_POST['filter-rule-association']) &&
374
			($_POST['filter-rule-association']=='add-associated' ||
375
			$_POST['filter-rule-association']=='add-unassociated') )
376
			$need_filter_rule = true;
377

    
378
		if ($need_filter_rule == true) {
379

    
380
			/* auto-generate a matching firewall rule */
381
			$filterent = array();
382
			unset($filterentid);
383
			// If a rule already exists, load it
384
			if (!empty($natent['associated-rule-id'])) {
385
				$filterentid = get_id($natent['associated-rule-id'], $config['filter']['rule']);
386
				if ($filterentid === false)
387
					$filterent['associated-rule-id'] = $natent['associated-rule-id'];
388
				else
389
					$filterent =& $config['filter']['rule'][$filterentid];
390
			}
391
			pconfig_to_address($filterent['source'], $_POST['src'],
392
				$_POST['srcmask'], $_POST['srcnot'],
393
				$_POST['srcbeginport'], $_POST['srcendport']);
394

    
395
			// Update interface, protocol and destination
396
			$filterent['interface'] = $_POST['interface'];
397
			$filterent['protocol'] = $_POST['proto'];
398
			$filterent['destination']['address'] = $_POST['localip'];
399

    
400
			$dstpfrom = $_POST['localbeginport'];
401
			$dstpto = $dstpfrom + $_POST['dstendport'] - $_POST['dstbeginport'];
402

    
403
			if ($dstpfrom == $dstpto)
404
				$filterent['destination']['port'] = $dstpfrom;
405
			else
406
				$filterent['destination']['port'] = $dstpfrom . "-" . $dstpto;
407

    
408
			/*
409
			 * Our firewall filter description may be no longer than
410
			 * 63 characters, so don't let it be.
411
			 */
412
			$filterent['descr'] = substr("NAT " . $_POST['descr'], 0, 62);
413

    
414
			// If this is a new rule, create an ID and add the rule
415
			if( $_POST['filter-rule-association']=='add-associated' ) {
416
				$filterent['associated-rule-id'] = $natent['associated-rule-id'] = get_unique_id();
417
				$filterent['created'] = make_config_revision_entry(null, gettext("NAT Port Forward"));
418
				$config['filter']['rule'][] = $filterent;
419
			}
420

    
421
			mark_subsystem_dirty('filter');
422
		}
423

    
424
		if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
425
			$natent['created'] = $a_nat[$id]['created'];
426

    
427
		$natent['updated'] = make_config_revision_entry();
428

    
429
		// Allow extending of the firewall edit page and include custom input validation 
430
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_write_config");
431

    
432
		// Update the NAT entry now
433
		if (isset($id) && $a_nat[$id])
434
			$a_nat[$id] = $natent;
435
		else {
436
			$natent['created'] = make_config_revision_entry();
437
			if (is_numeric($after))
438
				array_splice($a_nat, $after+1, 0, array($natent));
439
			else
440
				$a_nat[] = $natent;
441
		}
442

    
443
		if (write_config())
444
			mark_subsystem_dirty('natconf');
445

    
446
		header("Location: firewall_nat.php");
447
		exit;
448
	}
449
}
450

    
451
$closehead = false;
452
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Port Forward"),gettext("Edit"));
453
include("head.inc");
454

    
455
?>
456
<link type="text/css" rel="stylesheet" href="/javascript/chosen/chosen.css" />
457
</head>
458

    
459
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
460
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
461
<?php
462
include("fbegin.inc"); ?>
463
<?php if ($input_errors) print_input_errors($input_errors); ?>
464
            <form action="firewall_nat_edit.php" method="post" name="iform" id="iform">
465
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall nat edit">
466
				<tr>
467
					<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Redirect entry"); ?></td>
468
				</tr>
469
<?php
470
		// Allow extending of the firewall edit page and include custom input validation 
471
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/htmlphpearly");
472
?>
473
		<tr>
474
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
475
			<td width="78%" class="vtable">
476
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
477
				<strong><?=gettext("Disable this rule"); ?></strong><br />
478
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list."); ?></span>
479
			</td>
480
		</tr>
481
                <tr>
482
                  <td width="22%" valign="top" class="vncell"><?=gettext("No RDR (NOT)"); ?></td>
483
                  <td width="78%" class="vtable">
484
                    <input type="checkbox" name="nordr" id="nordr" onclick="nordr_change();" <?php if($pconfig['nordr']) echo "checked=\"checked\""; ?> />
485
                    <span class="vexpl"><?=gettext("Enabling this option will disable redirection for traffic matching this rule."); ?>
486
                    <br/><?=gettext("Hint: this option is rarely needed, don't use this unless you know what you're doing."); ?></span>
487
                  </td>
488
                </tr>
489
		<tr>
490
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
491
                  <td width="78%" class="vtable">
492
					<select name="interface" class="formselect" onchange="dst_change(this.value,iface_old,document.iform.dsttype.value);iface_old = document.iform.interface.value;typesel_change();">
493
						<?php
494

    
495
						$iflist = get_configured_interface_with_descr(false, true);
496
						// Allow extending of the firewall edit interfaces 
497
						pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_interfaces_edit");
498
						foreach ($iflist as $if => $ifdesc)
499
							if(have_ruleint_access($if))
500
								$interfaces[$if] = $ifdesc;
501

    
502
						if ($config['l2tp']['mode'] == "server")
503
							if(have_ruleint_access("l2tp"))
504
								$interfaces['l2tp'] = "L2TP VPN";
505

    
506
						if ($config['pptpd']['mode'] == "server")
507
							if(have_ruleint_access("pptp"))
508
								$interfaces['pptp'] = "PPTP VPN";
509

    
510
						if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
511
							$interfaces['pppoe'] = "PPPoE VPN";
512

    
513
						/* add ipsec interfaces */
514
						if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
515
							if(have_ruleint_access("enc0"))
516
								$interfaces["enc0"] = "IPsec";
517

    
518
						/* add openvpn/tun interfaces */
519
						if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
520
							$interfaces["openvpn"] = "OpenVPN";
521

    
522
						foreach ($interfaces as $iface => $ifacename): ?>
523
						<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
524
						<?=htmlspecialchars($ifacename);?>
525
						</option>
526
						<?php endforeach; ?>
527
					</select><br/>
528
                     <span class="vexpl"><?=gettext("Choose which interface this rule applies to."); ?><br/>
529
                     <?=gettext("Hint: in most cases, you'll want to use WAN here."); ?></span></td>
530
                </tr>
531
                <tr>
532
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol"); ?></td>
533
                  <td width="78%" class="vtable">
534
                    <select name="proto" class="formselect" onchange="proto_change(); check_for_aliases();">
535
                      <?php $protocols = explode(" ", "TCP UDP TCP/UDP GRE ESP ICMP"); foreach ($protocols as $proto): ?>
536
                      <option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
537
                      <?php endforeach; ?>
538
                    </select> <br/> <span class="vexpl"><?=gettext("Choose which IP protocol " .
539
                    "this rule should match."); ?><br/>
540
                    <?=gettext("Hint: in most cases, you should specify"); ?> <em><?=gettext("TCP"); ?></em> &nbsp;<?=gettext("here."); ?></span></td>
541
                </tr>
542
		<tr id="showadvancedboxsrc" name="showadvancedboxsrc">
543
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source"); ?></td>
544
			<td width="78%" class="vtable">
545
				<input type="button" onclick="show_source()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source address and port range"); ?>
546
			</td>
547
		</tr>
548
		<tr style="display: none;" id="srctable" name="srctable">
549
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source"); ?></td>
550
			<td width="78%" class="vtable">
551
				<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
552
				<strong><?=gettext("not"); ?></strong>
553
				<br />
554
				<?=gettext("Use this option to invert the sense of the match."); ?>
555
				<br />
556
				<br />
557
				<table border="0" cellspacing="0" cellpadding="0" summary="type">
558
					<tr>
559
						<td><?=gettext("Type:"); ?>&nbsp;&nbsp;</td>
560
						<td>
561
							<select name="srctype" class="formselect" onchange="typesel_change()">
562
<?php
563
								$sel = is_specialnet($pconfig['src']); ?>
564
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any"); ?></option>
565
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected=\"selected\""; $sel = 1; } ?>><?=gettext("Single host or alias"); ?></option>
566
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network"); ?></option>
567
								<?php if(have_ruleint_access("pptp")): ?>
568
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients"); ?></option>
569
								<?php endif; ?>
570
								<?php if(have_ruleint_access("pppoe")): ?>
571
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients"); ?></option>
572
								<?php endif; ?>
573
								 <?php if(have_ruleint_access("l2tp")): ?>
574
                                                                <option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients"); ?></option>
575
                                 <?php endif; ?>
576
<?php
577
								foreach ($ifdisp as $ifent => $ifdesc): ?>
578
								<?php if(have_ruleint_access($ifent)): ?>
579
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net"); ?></option>
580
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected=\"selected\""; } ?>>
581
										<?=$ifdesc?> <?=gettext("address");?>
582
									</option>
583
								<?php endif; ?>
584
<?php 							endforeach; ?>
585
							</select>
586
						</td>
587
					</tr>
588
					<tr>
589
						<td><?=gettext("Address:"); ?>&nbsp;&nbsp;</td>
590
						<td>
591
							<input autocomplete='off' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>" /> /
592
							<select name="srcmask" class="formselect" id="srcmask">
593
<?php						for ($i = 31; $i > 0; $i--): ?>
594
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
595
<?php 						endfor; ?>
596
							</select>
597
						</td>
598
					</tr>
599
				</table>
600
			</td>
601
		</tr>
602
		<tr style="display:none" id="sprtable" name="sprtable">
603
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range"); ?></td>
604
			<td width="78%" class="vtable">
605
				<table border="0" cellspacing="0" cellpadding="0" summary="source port range">
606
					<tr>
607
						<td><?=gettext("from:"); ?>&nbsp;&nbsp;</td>
608
						<td>
609
							<select name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
610
								<option value="">(<?=gettext("other"); ?>)</option>
611
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any"); ?></option>
612
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
613
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
614
<?php 							endforeach; ?>
615
							</select>
616
							<input autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo htmlspecialchars($pconfig['srcbeginport']); ?>" />
617
						</td>
618
					</tr>
619
					<tr>
620
						<td><?=gettext("to:"); ?></td>
621
						<td>
622
							<select name="srcendport" class="formselect" onchange="ext_change()">
623
								<option value="">(<?=gettext("other"); ?>)</option>
624
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any"); ?></option>
625
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
626
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
627
<?php							endforeach; ?>
628
							</select>
629
							<input autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo htmlspecialchars($pconfig['srcendport']); ?>" />
630
						</td>
631
					</tr>
632
				</table>
633
				<br />
634
				<span class="vexpl"><?=gettext("Specify the source port or port range for this rule"); ?>. <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be 'any')"); ?>.</b> <br /> <?=gettext("Hint: you can leave the"); ?> <em>'<?=gettext("to"); ?>'</em> <?=gettext("field empty if you only want to filter a single port."); ?></span><br/>
635
			</td>
636
		</tr>
637
		<tr>
638
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination"); ?></td>
639
			<td width="78%" class="vtable">
640
				<input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
641
				<strong><?=gettext("not"); ?></strong>
642
					<br />
643
				<?=gettext("Use this option to invert the sense of the match."); ?>
644
					<br />
645
					<br />
646
				<table border="0" cellspacing="0" cellpadding="0" summary="type">
647
					<tr>
648
						<td><?=gettext("Type:"); ?>&nbsp;&nbsp;</td>
649
						<td>
650
							<select name="dsttype" class="formselect" onchange="typesel_change()">
651
<?php
652
								$sel = is_specialnet($pconfig['dst']); ?>
653
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any"); ?></option>
654
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected=\"selected\""; $sel = 1; } ?>><?=gettext("Single host or alias"); ?></option>
655
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network"); ?></option>
656
								<?php if(have_ruleint_access("pptp")): ?>
657
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients"); ?></option>
658
								<?php endif; ?>
659
								<?php if(have_ruleint_access("pppoe")): ?>
660
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients"); ?></option>
661
								<?php endif; ?>
662
								<?php if(have_ruleint_access("l2tp")): ?>
663
                                                                <option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients"); ?></option>
664
                                                                <?php endif; ?>
665

    
666
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
667
								<?php if(have_ruleint_access($if)): ?>
668
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net"); ?></option>
669
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected=\"selected\""; } ?>>
670
										<?=$ifdesc;?> <?=gettext("address");?>
671
									</option>
672
								<?php endif; ?>
673
<?php 							endforeach; ?>
674

    
675
<?php							if (is_array($config['virtualip']['vip'])):
676
									foreach ($config['virtualip']['vip'] as $sn):
677
										if (isset($sn['noexpand']))
678
											continue;
679
										if ($sn['mode'] == "proxyarp" && $sn['type'] == "network"):
680
											$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
681
											$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
682
											$len = $end - $start;
683
											for ($i = 0; $i <= $len; $i++):
684
												$snip = long2ip32($start+$i);
685
?>
686
												<option value="<?=$snip;?>" <?php if ($snip == $pconfig['dst']) echo "selected=\"selected\""; ?>><?=htmlspecialchars("{$snip} ({$sn['descr']})");?></option>
687
<?php										endfor;
688
										else:
689
?>
690
											<option value="<?=$sn['subnet'];?>" <?php if ($sn['subnet'] == $pconfig['dst']) echo "selected=\"selected\""; ?>><?=htmlspecialchars("{$sn['subnet']} ({$sn['descr']})");?></option>
691
<?php									endif;
692
									endforeach;
693
								endif;
694
?>
695
							</select>
696
						</td>
697
					</tr>
698
					<tr>
699
						<td><?=gettext("Address:"); ?>&nbsp;&nbsp;</td>
700
						<td>
701
							<input autocomplete='off' name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>" />
702
							/
703
							<select name="dstmask" class="formselect" id="dstmask">
704
<?php
705
							for ($i = 31; $i > 0; $i--): ?>
706
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
707
<?php						endfor; ?>
708
							</select>
709
						</td>
710
					</tr>
711
				</table>
712
			</td>
713
		</tr>
714
		<tr id="dprtr" name="dprtr">
715
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range"); ?> </td>
716
			<td width="78%" class="vtable">
717
				<table border="0" cellspacing="0" cellpadding="0" summary="destination port range">
718
					<tr>
719
						<td><?=gettext("from:"); ?>&nbsp;&nbsp;</td>
720
						<td>
721
							<select name="dstbeginport" id="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
722
								<option value="">(<?=gettext("other"); ?>)</option>
723
<?php 							$bfound = 0;
724
								foreach ($wkports as $wkport => $wkportdesc): ?>
725
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected=\"selected\""; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
726
<?php 							endforeach; ?>
727
							</select>
728
							<input autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo htmlspecialchars($pconfig['dstbeginport']); ?>" />
729
						</td>
730
					</tr>
731
					<tr>
732
						<td><?=gettext("to:"); ?></td>
733
						<td>
734
							<select name="dstendport" id="dstendport" class="formselect" onchange="ext_change()">
735
								<option value="">(<?=gettext("other"); ?>)</option>
736
<?php							$bfound = 0;
737
								foreach ($wkports as $wkport => $wkportdesc): ?>
738
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
739
<?php 							endforeach; ?>
740
							</select>
741
							<input autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo htmlspecialchars($pconfig['dstendport']); ?>" />
742
						</td>
743
					</tr>
744
				</table>
745
				<br />
746
				<span class="vexpl">
747
					<?=gettext("Specify the port or port range for the destination of the packet for this mapping."); ?>
748
					<br />
749
					<?=gettext("Hint: you can leave the"); ?> <em>'<?=gettext("to"); ?>'</em> <?=gettext("field empty if you only want to map a single port"); ?>
750
				</span>
751
			</td>
752
		</tr>
753
                <tr name="localiptable" id="localiptable">
754
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Redirect target IP"); ?></td>
755
                  <td width="78%" class="vtable">
756
                    <input autocomplete='off' name="localip" type="text" class="formfldalias" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>" />
757
                    <br/> <span class="vexpl"><?=gettext("Enter the internal IP address of " .
758
                    "the server on which you want to map the ports."); ?><br/>
759
                    <?=gettext("e.g."); ?> <em>192.168.1.12</em></span></td>
760
                </tr>
761
                <tr name="lprtr" id="lprtr">
762
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Redirect target port"); ?></td>
763
                  <td width="78%" class="vtable">
764
                    <select name="localbeginport" id="localbeginport" class="formselect" onchange="ext_change();check_for_aliases();">
765
                      <option value="">(<?=gettext("other"); ?>)</option>
766
                      <?php $bfound = 0; foreach ($wkports as $wkport => $wkportdesc): ?>
767
                      <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['localbeginport']) {
768
							echo "selected=\"selected\"";
769
							$bfound = 1;
770
						}?>>
771
					  <?=htmlspecialchars($wkportdesc);?>
772
					  </option>
773
                      <?php endforeach; ?>
774
                    </select> <input onchange="check_for_aliases();" autocomplete='off' class="formfldalias" name="localbeginport_cust" id="localbeginport_cust" type="text" size="5" value="<?php if (!$bfound) echo htmlspecialchars($pconfig['localbeginport']); ?>" />
775
                    <br/>
776
                    <span class="vexpl"><?=gettext("Specify the port on the machine with the " .
777
                    "IP address entered above. In case of a port range, specify " .
778
                    "the beginning port of the range (the end port will be calculated " .
779
                    "automatically)."); ?><br/>
780
                    <?=gettext("Hint: this is usually identical to the 'from' port above"); ?></span></td>
781
                </tr>
782
                <tr>
783
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
784
                  <td width="78%" class="vtable">
785
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
786
                    <br/> <span class="vexpl"><?=gettext("You may enter a description here " .
787
                    "for your reference (not parsed)."); ?></span></td>
788
                </tr>
789
				<tr>
790
					<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync"); ?></td>
791
					<td width="78%" class="vtable">
792
						<input type="checkbox" value="yes" name="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br/>
793
						<?=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.");?>
794
					</td>
795
				</tr>
796
				<tr>
797
					<td width="22%" valign="top" class="vncell"><?=gettext("NAT reflection"); ?></td>
798
					<td width="78%" class="vtable">
799
						<select name="natreflection" class="formselect">
800
						<option value="default" <?php if ($pconfig['natreflection'] != "enable" && $pconfig['natreflection'] != "purenat" && $pconfig['natreflection'] != "disable") echo "selected=\"selected\""; ?>><?=gettext("Use system default"); ?></option>
801
						<option value="enable" <?php if ($pconfig['natreflection'] == "enable") echo "selected=\"selected\""; ?>><?=gettext("Enable (NAT + Proxy)"); ?></option>
802
						<option value="purenat" <?php if ($pconfig['natreflection'] == "purenat") echo "selected=\"selected\""; ?>><?=gettext("Enable (Pure NAT)"); ?></option>
803
						<option value="disable" <?php if ($pconfig['natreflection'] == "disable") echo "selected=\"selected\""; ?>><?=gettext("Disable"); ?></option>
804
						</select>
805
					</td>
806
				</tr>
807
				<?php if (isset($id) && $a_nat[$id] && !isset($_GET['dup'])): ?>
808
				<tr name="assoctable" id="assoctable">
809
					<td width="22%" valign="top" class="vncell"><?=gettext("Filter rule association"); ?></td>
810
					<td width="78%" class="vtable">
811
						<select name="associated-rule-id">
812
							<option value=""><?=gettext("None"); ?></option>
813
							<option value="pass" <?php if($pconfig['associated-rule-id'] == "pass") echo " selected=\"selected\""; ?>><?=gettext("Pass"); ?></option>
814
							<?php
815
							$linkedrule = "";
816
							if (is_array($config['filter']['rule'])) {
817
							      filter_rules_sort();
818
							      foreach ($config['filter']['rule'] as $filter_id => $filter_rule) {
819
								if (isset($filter_rule['associated-rule-id'])) {
820
									echo "<option value=\"{$filter_rule['associated-rule-id']}\"";
821
									if ($filter_rule['associated-rule-id']==$pconfig['associated-rule-id']) {
822
										echo " selected=\"selected\"";
823
										$linkedrule = "<br /><a href=\"firewall_rules_edit.php?id={$filter_id}\">" . gettext("View the filter rule") . "</a><br/>";
824
									}
825
									echo ">". htmlspecialchars('Rule ' . $filter_rule['descr']) . "</option>\n";
826

    
827
								}
828
							      }
829
							}
830
							if (isset($pconfig['associated-rule-id']))
831
								echo "<option value=\"new\">" . gettext("Create new associated filter rule") . "</option>\n";
832
						echo "</select>\n";
833
						echo $linkedrule;
834
						?>
835
					</td>
836
				</tr>
837
				<?php endif; ?>
838
                <?php if ((!(isset($id) && $a_nat[$id])) || (isset($_GET['dup']))): ?>
839
                <tr name="assoctable" id="assoctable">
840
                  <td width="22%" valign="top" class="vncell"><?=gettext("Filter rule association"); ?></td>
841
                  <td width="78%" class="vtable">
842
                    <select name="filter-rule-association" id="filter-rule-association">
843
						<option value=""><?=gettext("None"); ?></option>
844
						<option value="add-associated" selected="selected"><?=gettext("Add associated filter rule"); ?></option>
845
						<option value="add-unassociated"><?=gettext("Add unassociated filter rule"); ?></option>
846
						<option value="pass"><?=gettext("Pass"); ?></option>
847
					</select>
848
					<br/><br/><?=gettext("NOTE: The \"pass\" selection does not work properly with Multi-WAN. It will only work on an interface containing the default gateway.")?>
849
				  </td>
850
                </tr><?php endif; ?>
851
<?php
852
		// Allow extending of the firewall edit page and include custom input validation 
853
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/htmlphplate");
854
?>
855
<?php
856
$has_created_time = (isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']));
857
$has_updated_time = (isset($a_nat[$id]['updated']) && is_array($a_nat[$id]['updated']));
858
?>
859
		<?php if ($has_created_time || $has_updated_time): ?>
860
		<tr>
861
			<td>&nbsp;</td>
862
		</tr>
863
		<tr>
864
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
865
		</tr>
866
		<?php if ($has_created_time): ?>
867
		<tr>
868
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
869
			<td width="78%" class="vtable">
870
				<?= date(gettext("n/j/y H:i:s"), $a_nat[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_nat[$id]['created']['username'] ?></strong>
871
			</td>
872
		</tr>
873
		<?php endif; ?>
874
		<?php if ($has_updated_time): ?>
875
		<tr>
876
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
877
			<td width="78%" class="vtable">
878
				<?= date(gettext("n/j/y H:i:s"), $a_nat[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_nat[$id]['updated']['username'] ?></strong>
879
			</td>
880
		</tr>
881
		<?php endif; ?>
882
		<?php endif; ?>
883
				<tr>
884
                  <td width="22%" valign="top">&nbsp;</td>
885
                  <td width="78%">&nbsp;</td>
886
				</tr>
887
                <tr>
888
                  <td width="22%" valign="top">&nbsp;</td>
889
                  <td width="78%">
890
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
891
                    <?php if (isset($id) && $a_nat[$id]): ?>
892
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
893
                    <?php endif; ?>
894
                    <input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
895
                  </td>
896
                </tr>
897
              </table>
898
</form>
899
<script type="text/javascript">
900
//<![CDATA[
901
	ext_change();
902
	dst_change(document.iform.interface.value,'<?=htmlspecialchars($pconfig['interface'])?>','<?=htmlspecialchars($pconfig['dst'])?>');
903
	var iface_old = document.iform.interface.value;
904
	typesel_change();
905
	proto_change();
906
	<?php if ($pconfig['srcnot'] || $pconfig['src'] != "any" || $pconfig['srcbeginport'] != "any" || $pconfig['srcendport'] != "any"): ?>
907
	show_source();
908
	<?php endif; ?>
909
	nordr_change();
910
//]]>
911
</script>
912
<script type="text/javascript">
913
//<![CDATA[
914
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
915
	var customarray  = <?= json_encode(get_alias_list("port")) ?>;
916

    
917
	var oTextbox1 = new AutoSuggestControl(document.getElementById("localip"), new StateSuggestions(addressarray));
918
	var oTextbox2 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
919
	var oTextbox3 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
920
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
921
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
922
	var oTextbox6 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
923
	var oTextbox7 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
924
	var oTextbox8 = new AutoSuggestControl(document.getElementById("localbeginport_cust"), new StateSuggestions(customarray));
925
//]]>
926
</script>
927
<?php include("fend.inc"); ?>
928
</body>
929
</html>
(64-64/246)