Project

General

Profile

Download (20.3 KB) Statistics
| Branch: | Tag: | Revision:
1 03b92764 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 15aea4cb Seth Mos
        interfaces_opt.php
5
	Copyright (C) 2007 Scott Ullrich
6
        All rights reserved.
7
8 5b237745 Scott Ullrich
	interfaces_opt.php
9
	part of m0n0wall (http://m0n0.ch/wall)
10 03b92764 Scott Ullrich
11 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13 03b92764 Scott Ullrich
14 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16 03b92764 Scott Ullrich
17 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19 03b92764 Scott Ullrich
20 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23 03b92764 Scott Ullrich
24 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
require("guiconfig.inc");
37
38
unset($index);
39
if ($_GET['index'])
40
	$index = $_GET['index'];
41
else if ($_POST['index'])
42
	$index = $_POST['index'];
43 03b92764 Scott Ullrich
44 5b237745 Scott Ullrich
if (!$index)
45
	exit;
46
47 6cec4795 Scott Ullrich
function remove_bad_chars($string) {
48 ab72b53b Scott Ullrich
	return preg_replace('/[^a-z|_|0-9]/i','',$string);
49 6cec4795 Scott Ullrich
}
50
51 d173230c Seth Mos
if (!is_array($config['gateways']['gateway_item']))
52
	$config['gateways']['gateway_item'] = array();
53
$a_gateways = &$config['gateways']['gateway_item'];
54
55 5b237745 Scott Ullrich
$optcfg = &$config['interfaces']['opt' . $index];
56 6cec4795 Scott Ullrich
$optcfg['descr'] = remove_bad_chars($optcfg['descr']);
57 fc959b55 Scott Ullrich
58 6cec4795 Scott Ullrich
$pconfig['descr'] = $optcfg['descr'];
59 5b237745 Scott Ullrich
$pconfig['bridge'] = $optcfg['bridge'];
60 03b92764 Scott Ullrich
61 5b237745 Scott Ullrich
$pconfig['enable'] = isset($optcfg['enable']);
62
63 0311dbd5 Scott Ullrich
$pconfig['blockpriv'] = isset($optcfg['blockpriv']);
64
$pconfig['blockbogons'] = isset($optcfg['blockbogons']);
65
$pconfig['spoofmac'] = $optcfg['spoofmac'];
66
$pconfig['mtu'] = $optcfg['mtu'];
67
68 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($optcfg['disableftpproxy']);
69 99586fca Scott Ullrich
70 5b237745 Scott Ullrich
/* Wireless interface? */
71
if (isset($optcfg['wireless'])) {
72
	require("interfaces_wlan.inc");
73
	wireless_config_init();
74
}
75
76 0311dbd5 Scott Ullrich
if ($optcfg['ipaddr'] == "dhcp") {
77
	$pconfig['type'] = "DHCP";
78 99586fca Scott Ullrich
	$pconfig['dhcphostname'] = $optcfg['dhcphostname'];
79 bc40d758 Seth Mos
	$pconfig['alias-address'] = $optcfg['alias-address'];
80
	$pconfig['alias-subnet'] = $optcfg['alias-subnet'];
81 0311dbd5 Scott Ullrich
} else {
82
	$pconfig['type'] = "Static";
83
	$pconfig['ipaddr'] = $optcfg['ipaddr'];
84
	$pconfig['subnet'] = $optcfg['subnet'];
85
	$pconfig['gateway'] = $optcfg['gateway'];
86
	$pconfig['pointtopoint'] = $optcfg['pointtopoint'];
87 860c4e80 Chris Buechler
	$pconfig['ap'] = $optcfg['ap'];
88
	$pconfig['phone'] = $optcfg['phone'];
89 0311dbd5 Scott Ullrich
}
90
91 5b237745 Scott Ullrich
if ($_POST) {
92
93
	unset($input_errors);
94
95 8698218d Scott Ullrich
	/* filter out spaces from descriptions  */
96 6cec4795 Scott Ullrich
	$POST['descr'] = remove_bad_chars($POST['descr']);
97 8698218d Scott Ullrich
98 ee968e4f Scott Ullrich
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
99 6fc5bf35 Scott Ullrich
		/* enumerate slbd gateways and make sure we are not creating a route loop */
100
		if(is_array($config['load_balancer']['lbpool'])) {
101
			foreach($config['load_balancer']['lbpool'] as $lbpool) {
102
				if($lbpool['type'] == "gateway") {
103
				    foreach ((array) $lbpool['servers'] as $server) {
104
			            $svr = split("\|", $server);
105 8bddc5b7 Scott Ullrich
			            if($svr[1] == $pconfig['gateway'])  {
106
			            		$_POST['gateway']  = $pconfig['gateway'];
107 de42a08e Scott Ullrich
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
108 3955baf1 Scott Ullrich
			            		break;
109 8bddc5b7 Scott Ullrich
			            }
110 6fc5bf35 Scott Ullrich
					}
111
				}
112 8bddc5b7 Scott Ullrich
			}
113
			foreach($config['filter']['rule'] as $rule) {
114 423cd2f4 Scott Ullrich
				if($rule['gateway'] == $_POST['gateway']) {
115 3955baf1 Scott Ullrich
	            		$input_errors[] = "Cannot change {$_POST['gateway']} gateway.  It is currently referenced by the filter rules via policy based routing.";
116
	            		break;
117 8bddc5b7 Scott Ullrich
				}
118
			}
119 6fc5bf35 Scott Ullrich
		}
120
	}
121
122 ee968e4f Scott Ullrich
	$pconfig = $_POST;
123
124 5b237745 Scott Ullrich
	/* input validation */
125
	if ($_POST['enable']) {
126 03b92764 Scott Ullrich
127 5b237745 Scott Ullrich
		/* description unique? */
128
		for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
129
			if ($i != $index) {
130
				if ($config['interfaces']['opt' . $i]['descr'] == $_POST['descr']) {
131
					$input_errors[] = "An interface with the specified description already exists.";
132
				}
133
			}
134
		}
135 03b92764 Scott Ullrich
136 5b237745 Scott Ullrich
		if ($_POST['bridge']) {
137
			/* double bridging? */
138
			for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
139
				if ($i != $index) {
140
					if ($config['interfaces']['opt' . $i]['bridge'] == $_POST['bridge']) {
141 62ce3b9a Scott Ullrich
						//$input_errors[] = "Optional interface {$i} " .
142
						//	"({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
143
						//	"the specified interface.";
144 5b237745 Scott Ullrich
					} else if ($config['interfaces']['opt' . $i]['bridge'] == "opt{$index}") {
145 62ce3b9a Scott Ullrich
						//$input_errors[] = "Optional interface {$i} " .
146
						//	"({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
147
						//	"this interface.";
148 5b237745 Scott Ullrich
					}
149
				}
150
			}
151
			if ($config['interfaces'][$_POST['bridge']]['bridge']) {
152 62ce3b9a Scott Ullrich
				//$input_errors[] = "The specified interface is already bridged to " .
153
				//	"another interface.";
154 5b237745 Scott Ullrich
			}
155
			/* captive portal on? */
156
			if (isset($config['captiveportal']['enable'])) {
157 c2c399a4 Scott Ullrich
				//$input_errors[] = "Interfaces cannot be bridged while the captive portal is enabled.";
158 5b237745 Scott Ullrich
			}
159
		} else {
160 e4065f5b Scott Ullrich
			if ($_POST['type'] <> "DHCP") {
161
				$reqdfields = explode(" ", "descr ipaddr subnet");
162
				$reqdfieldsn = explode(",", "Description,IP address,Subnet bit count");
163
				do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
164
				if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
165
					$input_errors[] = "A valid IP address must be specified.";
166
				}
167
				if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
168
					$input_errors[] = "A valid subnet bit count must be specified.";
169
				}
170 d173230c Seth Mos
				if ($_POST['gateway']) {
171
					$match = false;
172
					foreach($a_gateways as $gateway) {
173
						if(in_array($_POST['gateway'], $gateway)) {
174
							$match = true;
175
						}
176
					}
177
					if(!$match)
178
						$input_errors[] = "A valid gateway must be specified.";
179 e4065f5b Scott Ullrich
				}
180 92b17aed Scott Ullrich
			}
181 5b237745 Scott Ullrich
		}
182 bc40d758 Seth Mos
		if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) {
183
			$input_errors[] = "A valid alias IP address must be specified.";
184
		}
185
		if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
186
			$input_errors[] = "A valid alias subnet bit count must be specified.";
187
		}
188
189 3cb6ab88 Bill Marquette
	        if ($_POST['mtu'] && (($_POST['mtu'] < 576) || ($_POST['mtu'] > 1500))) {
190
			$input_errors[] = "The MTU must be between 576 and 1500 bytes.";
191 0138d492 Scott Ullrich
		}		
192 3a843b96 Scott Ullrich
		if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
193
			$input_errors[] = "A valid MAC address must be specified.";
194
		}		
195 5b237745 Scott Ullrich
	}
196 03b92764 Scott Ullrich
197 f691bc2f Scott Ullrich
	if($_POST['mtu']) {
198
		if($_POST['mtu'] < 24 or $_POST['mtu'] > 1501)
199
			$input_errors[] = "A valid MTU is required 24-1500.";
200
	}
201
	
202 5b237745 Scott Ullrich
	/* Wireless interface? */
203
	if (isset($optcfg['wireless'])) {
204
		$wi_input_errors = wireless_config_post();
205
		if ($wi_input_errors) {
206
			$input_errors = array_merge($input_errors, $wi_input_errors);
207
		}
208
	}
209 03b92764 Scott Ullrich
210 5b237745 Scott Ullrich
	if (!$input_errors) {
211 0311dbd5 Scott Ullrich
212 9a6757a1 Scott Ullrich
		$bridge = discover_bridge($optcfg['if'], filter_translate_type_to_real_interface($optcfg['bridge']));
213 0d429e43 Scott Ullrich
		if($bridge <> "-1") {
214 1665e79c Scott Ullrich
			destroy_bridge($bridge);
215 91e8aab2 Scott Ullrich
		}
216
217 99586fca Scott Ullrich
		unset($optcfg['dhcphostname']);
218 c1ec2c2f Scott Ullrich
		unset($optcfg['disableftpproxy']);
219
		
220
		/* per interface pftpx helper */
221
		if($_POST['disableftpproxy'] == "yes") {
222
			$optcfg['disableftpproxy'] = true;
223
			system_start_ftp_helpers();
224
		} else {			
225
			system_start_ftp_helpers();
226
		}		
227 99586fca Scott Ullrich
228 6cec4795 Scott Ullrich
		$optcfg['descr'] = remove_bad_chars($_POST['descr']);
229 5b237745 Scott Ullrich
		$optcfg['bridge'] = $_POST['bridge'];
230
		$optcfg['enable'] = $_POST['enable'] ? true : false;
231 0311dbd5 Scott Ullrich
232
		if ($_POST['type'] == "Static") {
233
			$optcfg['ipaddr'] = $_POST['ipaddr'];
234
			$optcfg['subnet'] = $_POST['subnet'];
235
			$optcfg['gateway'] = $_POST['gateway'];
236 860c4e80 Chris Buechler
			if (isset($optcfg['ispointtopoint'])) {
237 0311dbd5 Scott Ullrich
				$optcfg['pointtopoint'] = $_POST['pointtopoint'];
238 860c4e80 Chris Buechler
				$optcfg['ap'] = $_POST['ap'];
239
				$optcfg['phone'] = $_POST['phone'];
240
			}
241 0311dbd5 Scott Ullrich
		} else if ($_POST['type'] == "DHCP") {
242
			$optcfg['ipaddr'] = "dhcp";
243
			$optcfg['dhcphostname'] = $_POST['dhcphostname'];
244 bc40d758 Seth Mos
			$optcfg['alias-address'] = $_POST['alias-address'];
245
			$optcfg['alias-subnet'] = $_POST['alias-subnet'];
246 0311dbd5 Scott Ullrich
		}
247 a12d2145 Scott Ullrich
248 2dfb79a4 Scott Ullrich
		$optcfg['blockpriv'] = $_POST['blockpriv'] ? true : false;
249
		$optcfg['blockbogons'] = $_POST['blockbogons'] ? true : false;
250
		$optcfg['spoofmac'] = $_POST['spoofmac'];
251
		$optcfg['mtu'] = $_POST['mtu'];
252
253 5b237745 Scott Ullrich
		write_config();
254 1f8caa36 Scott Ullrich
		
255 824edb6c Scott Ullrich
		$savemsg = get_std_save_message($retval);
256 5b237745 Scott Ullrich
	}
257
}
258 7f43ca88 Scott Ullrich
259
260 d88c6a9f Scott Ullrich
$pgtitle = array("Interfaces","Optional {$index} (" . htmlspecialchars($optcfg['descr']) . ")");
261 7f43ca88 Scott Ullrich
include("head.inc");
262
263 5b237745 Scott Ullrich
?>
264 b9e255dd Bill Marquette
265 5b237745 Scott Ullrich
<script language="JavaScript">
266
<!--
267
function enable_change(enable_over) {
268 a23d7248 Scott Ullrich
	var endis;
269
	endis = !((document.iform.bridge.selectedIndex == 0) || enable_over);
270
	document.iform.ipaddr.disabled = endis;
271
	document.iform.subnet.disabled = endis;
272 5b237745 Scott Ullrich
}
273
function ipaddr_change() {
274 6846116e Scott Ullrich
	document.iform.subnet.selectedIndex = gen_bits_opt(document.iform.ipaddr.value);
275 5b237745 Scott Ullrich
}
276 0311dbd5 Scott Ullrich
function type_change(enable_change,enable_change_pptp) {
277
	switch (document.iform.type.selectedIndex) {
278
		case 0:
279 57e97d71 Scott Ullrich
			document.iform.ipaddr.type.disabled = 0;
280 0311dbd5 Scott Ullrich
			document.iform.ipaddr.disabled = 0;
281
			document.iform.subnet.disabled = 0;
282
			document.iform.gateway.disabled = 0;
283
			break;
284
		case 1:
285 57e97d71 Scott Ullrich
			document.iform.ipaddr.type.disabled = 1;
286 0311dbd5 Scott Ullrich
			document.iform.ipaddr.disabled = 1;
287
			document.iform.subnet.disabled = 1;
288
			document.iform.gateway.disabled = 1;
289
			break;
290
	}
291
}
292 15aea4cb Seth Mos
293
function show_mon_config() {
294
	document.getElementById("showmonbox").innerHTML='';
295
	aodiv = document.getElementById('showmon');
296
	aodiv.style.display = "block";
297
}
298
299 5b237745 Scott Ullrich
//-->
300
</script>
301 b9e255dd Bill Marquette
302 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
303
<?php include("fbegin.inc"); ?>
304
<?php if ($input_errors) print_input_errors($input_errors); ?>
305
<?php if ($savemsg) print_info_box($savemsg); ?>
306
<?php if ($optcfg['if']): ?>
307
            <form action="interfaces_opt.php" method="post" name="iform" id="iform">
308
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
309 7e45fdf4 Scott Ullrich
                <tr>
310 386e9c57 Seth Mos
                  <td colspan="2" valign="top" class="listtopic">Optional Interface Configuration</td>
311 7e45fdf4 Scott Ullrich
                </tr>	      
312 03b92764 Scott Ullrich
                <tr>
313 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
314
                  <td width="78%" class="vtable">
315 007be4f3 Scott Ullrich
			<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
316 5b237745 Scott Ullrich
                    <strong>Enable Optional <?=$index;?> interface</strong></td>
317 0311dbd5 Scott Ullrich
		</tr>
318 03b92764 Scott Ullrich
                <tr>
319 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncell">Description</td>
320 03b92764 Scott Ullrich
                  <td width="78%" class="vtable">
321 b5c78501 Seth Mos
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
322 5b237745 Scott Ullrich
					<br> <span class="vexpl">Enter a description (name) for the interface here.</span>
323 0311dbd5 Scott Ullrich
		  </td>
324
		</tr>
325
326
                <tr>
327
                  <td colspan="2" valign="top" height="16"></td>
328
                </tr>
329
                <tr>
330
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
331
                </tr>
332 860c4e80 Chris Buechler
		<?php if (isset($optcfg['pointtopoint'])): ?>
333
			<tr>
334
			  <td width="22%" valign="top" class="vncell">AP Hostname</td>
335
			  <td width="78%" class="vtable">
336
			    <input name="ap" type="text" class="formfld" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
337
			</td>
338
			</tr>
339
			<tr>
340
			  <td width="22%" valign="top" class="vncell">Phone Number</td>
341
			  <td width="78%" class="vtable">
342
			    <input name="phone" type="text" class="formfld" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
343
			  </td>
344
			</tr>
345
			<tr>
346
			  <td width="22%" valign="top" class="vncell">Remote IP</td>
347
			  <td width="78%" class="vtable">
348
			    <input name="gateway" type="text" class="formfld" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
349
			  </td>
350
			</tr>
351
352
			<input name="type" type="hidden" value="Static">
353
			<input name="ipaddr" type="hidden" value="0.0.0.0">
354
			<input name="subnet" type="hidden" value="32">
355
		<?php else: ?>
356 0311dbd5 Scott Ullrich
                <tr>
357
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
358 b5c78501 Seth Mos
                  <td class="vtable"> <select name="type" class="formselect" id="type" onchange="type_change()">
359 0311dbd5 Scott Ullrich
                      <?php $opts = split(" ", "Static DHCP");
360
				foreach ($opts as $opt): ?>
361
                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
362
                      <?=htmlspecialchars($opt);?>
363
                      </option>
364
                      <?php endforeach; ?>
365
                    </select></td>
366
                </tr>
367
                <tr>
368
                  <td valign="top" class="vncell">MAC address</td>
369 b5c78501 Seth Mos
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
370 0311dbd5 Scott Ullrich
		    <?php
371
			$ip = getenv('REMOTE_ADDR');
372
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
373
			$mac = str_replace("\n","",$mac);
374
		    ?>
375
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>   
376
		    <br>
377
                    This field can be used to modify (&quot;spoof&quot;) the MAC
378
                    address of the WAN interface<br>
379
                    (may be required with some cable connections)<br>
380
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
381
                    or leave blank</td>
382
                </tr>
383
                <tr>
384
                  <td valign="top" class="vncell">MTU</td>
385 b5c78501 Seth Mos
                  <td class="vtable"> <input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
386 0311dbd5 Scott Ullrich
                    <br>
387
                    If you enter a value in this field, then MSS clamping for
388
                    TCP connections to the value entered above minus 40 (TCP/IP
389
                    header size) will be in effect. If you leave this field blank,
390
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
391
                    connection types will be assumed.</td>
392
                </tr>
393
		
394 03b92764 Scott Ullrich
                <tr>
395 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
396 5b80d869 Scott Ullrich
		</tr>
397
		<tr>
398 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">IP configuration</td>
399 5b80d869 Scott Ullrich
		</tr>
400 6d6d0f14 Scott Ullrich
		<tr>
401 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Bridge with</td>
402
                  <td width="78%" class="vtable">
403 b5c78501 Seth Mos
			<select name="bridge" class="formselect" id="bridge" onChange="enable_change(false)">
404 5b237745 Scott Ullrich
				  	<option <?php if (!$pconfig['bridge']) echo "selected";?> value="">none</option>
405
                      <?php $opts = array('lan' => "LAN", 'wan' => "WAN");
406
					  	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
407
							if ($i != $index)
408
								$opts['opt' . $i] = "Optional " . $i . " (" .
409
									$config['interfaces']['opt' . $i]['descr'] . ")";
410
						}
411
					foreach ($opts as $opt => $optname): ?>
412 03b92764 Scott Ullrich
                      <option <?php if ($opt == $pconfig['bridge']) echo "selected";?> value="<?=htmlspecialchars($opt);?>">
413 5b237745 Scott Ullrich
                      <?=htmlspecialchars($optname);?>
414
                      </option>
415
                      <?php endforeach; ?>
416
                    </select> </td>
417 6d6d0f14 Scott Ullrich
		</tr>
418 03b92764 Scott Ullrich
                <tr>
419 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
420 03b92764 Scott Ullrich
                  <td width="78%" class="vtable">
421 b5c78501 Seth Mos
                    <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
422 5b237745 Scott Ullrich
                    /
423 b5c78501 Seth Mos
                	<select name="subnet" class="formselect" id="subnet">
424 21ab1cde Scott Ullrich
					<?php
425
					for ($i = 32; $i > 0; $i--) {
426
						if($i <> 31) {
427
							echo "<option value=\"{$i}\" ";
428
							if ($i == $pconfig['subnet']) echo "selected";
429
							echo ">" . $i . "</option>";
430
						}
431
					}
432
					?>                    </select>
433 5b237745 Scott Ullrich
				 </td>
434
				</tr>
435 007be4f3 Scott Ullrich
		<tr>
436 d173230c Seth Mos
		  <td valign="top" class="vncellreq">Gateway</td>
437
		  <td class="vtable"><select name="gateway" class="formselect" id="gateway">
438
			<?php
439 2be84cfa Seth Mos
			if(count($a_gateways) > 0) {
440
				foreach ($a_gateways as $gateway) {
441
					if($gateway['interface'] == "opt{$index}") {
442 d173230c Seth Mos
			?>
443
				<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
444
				<?=htmlspecialchars($gateway['name']);?>
445
				</option>
446
			<?php
447 2be84cfa Seth Mos
					}
448 d173230c Seth Mos
				}
449
			}
450
			?>
451 2be84cfa Seth Mos
			</select>Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br>
452 007be4f3 Scott Ullrich
		  </td>
453
		</tr>
454 860c4e80 Chris Buechler
		<?php endif;?>
455 3c393400 Scott Ullrich
                <tr>
456
                  <td colspan="2" valign="top" height="16"></td>
457
                </tr>
458
                <tr>
459 15aea4cb Seth Mos
                  <td colspan="2" valign="top" class="listtopic">Other</td>
460 3c393400 Scott Ullrich
                </tr>		
461
		<tr>
462
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
463
			<td width="78%" class="vtable">
464 0135299b Scott Ullrich
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
465 3c393400 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
466
				<br />
467
			</td>
468 15aea4cb Seth Mos
		</tr>
469 c435798f Scott Ullrich
				<?php /* Wireless interface? */
470
				if (isset($optcfg['wireless']))
471
					wireless_config_print();
472
				?>		
473 af539d78 Scott Ullrich
                <tr>
474
                  <td colspan="2" valign="top" height="16"></td>
475
                </tr>
476 99586fca Scott Ullrich
                <tr>
477
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
478
                </tr>
479
                <tr>
480
                  <td valign="top" class="vncell">Hostname</td>
481 b5c78501 Seth Mos
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
482 99586fca Scott Ullrich
                    <br>
483
                    The value in this field is sent as the DHCP client identifier
484
                    and hostname when requesting a DHCP lease. Some ISPs may require
485
                    this (for client identification).</td>
486
                </tr>
487 bc40d758 Seth Mos
		<tr>
488
		  <td width="100" valign="top" class="vncellreq">Alias IP address</td>
489 b5c78501 Seth Mos
		  <td class="vtable"> <input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
490 bc40d758 Seth Mos
		    <select name="alias-subnet" class="formselect" id="alias-subnet">
491
		        <?php
492
		        for ($i = 32; $i > 0; $i--) {
493
		                if($i <> 31) {
494
		                        echo "<option value=\"{$i}\" ";
495
		                        if ($i == $pconfig['alias-subnet']) echo "selected";
496
		                        echo ">" . $i . "</option>";
497
		                }
498
		        }
499
		        ?>
500
		    </select>
501
		    The value in this field is used as a fixed alias IP address by the
502
		    DHCP client.</td>
503
		</tr>
504 99586fca Scott Ullrich
                <tr>
505
                  <td colspan="2" valign="top" height="16"></td>
506
                </tr>		
507 c1ec2c2f Scott Ullrich
		<tr>
508 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
509 03b92764 Scott Ullrich
                  <td width="78%">
510
                    <input name="index" type="hidden" value="<?=$index;?>">
511
				  <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
512 5b237745 Scott Ullrich
                  </td>
513
                </tr>
514 03b92764 Scott Ullrich
                <tr>
515 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
516
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
517 c55a8ab9 Holger Bauer
                    </strong></span>be sure to add <a href="firewall_rules.php">firewall rules</a> to permit traffic
518
                    through the interface. You also need firewall rules for an interface in
519
                    bridged mode as the firewall acts as a filtering bridge.</span></td>
520 5b237745 Scott Ullrich
                </tr>
521
              </table>
522
</form>
523
<script language="JavaScript">
524
<!--
525
enable_change(false);
526
//-->
527
</script>
528
<?php else: ?>
529
<p><strong>Optional <?=$index;?> has been disabled because there is no OPT<?=$index;?> interface.</strong></p>
530
<?php endif; ?>
531
<?php include("fend.inc"); ?>
532
</body>
533
</html>
534 e4e8c30f Scott Ullrich
535
<?php
536
if ($_POST) {
537
538
	if (!$input_errors) {
539 2e70a096 Scott Ullrich
		
540
		ob_flush();
541
		flush();
542
		sleep(1);		
543
		
544 e4e8c30f Scott Ullrich
		interfaces_optional_configure_if($index);
545 fd4ce0e0 Scott Ullrich
		
546 610b1136 Scott Ullrich
		reset_carp();
547 f8a059cb Scott Ullrich
548
		/* load graphing functions */
549
		enable_rrd_graphing();	
550 e4e8c30f Scott Ullrich
		
551
		/* sync filter configuration */
552
		filter_configure();
553 8e11b23f Scott Ullrich
554
 		/* set up static routes */
555
		system_routing_configure();
556
557 e4e8c30f Scott Ullrich
	}
558
}
559 8e11b23f Scott Ullrich
?>