Projet

Général

Profil

Télécharger (43,4 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_nat_edit.php @ bc0f669e

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
if (is_numericint($_GET['id']))
60
	$id = $_GET['id'];
61
if (isset($_POST['id']) && is_numericint($_POST['id']))
62
	$id = $_POST['id'];
63

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

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

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

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

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

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

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

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

    
109
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
110
	unset($id);
111

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

    
123
if ($_POST) {
124

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

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

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

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

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

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

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

    
188
	$pconfig = $_POST;
189

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

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

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

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

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

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

    
234
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
235
		$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']);
236
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
237
		$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']);
238
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
239
		$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']);
240
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
241
		$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']);
242

    
243
	if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
244
		$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']);
245
	}
246

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
379
		if ($need_filter_rule == true) {
380

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

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

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

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

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

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

    
422
			mark_subsystem_dirty('filter');
423
		}
424

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
927
	var oTextbox1 = new AutoSuggestControl(document.getElementById("localip"), new StateSuggestions(addressarray));
928
	var oTextbox2 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
929
	var oTextbox3 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
930
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
931
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
932
	var oTextbox6 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
933
	var oTextbox7 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
934
	var oTextbox8 = new AutoSuggestControl(document.getElementById("localbeginport_cust"), new StateSuggestions(customarray));
935
//]]>
936
</script>
937
<?php include("fend.inc"); ?>
938
</body>
939
</html>
(64-64/246)