diff options
author | Ermal Luçi <eri@pfsense.org> | 2008-06-21 00:28:50 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2008-06-21 00:28:50 +0000 |
commit | b6db92176273cdd9b1dfbf6b44b42e55a35ee7af (patch) | |
tree | dd6c6916b9443469466dfa3f1c09cd70f0a9a002 /usr/local | |
parent | 19604f5d9680dad1a5e12d1bea8d7e5aa9f37193 (diff) | |
download | pfsense-b6db92176273cdd9b1dfbf6b44b42e55a35ee7af.zip pfsense-b6db92176273cdd9b1dfbf6b44b42e55a35ee7af.tar.gz |
Continue interface improvements.
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/www/fbegin.inc | 8 | ||||
-rwxr-xr-x | usr/local/www/interfaces_assign.php | 4 | ||||
-rwxr-xr-x | usr/local/www/interfaces_opt.php | 76 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/interfaces.widget.php | 13 |
4 files changed, 48 insertions, 53 deletions
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index 0b210df..d66560a 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -145,9 +145,11 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') { output_menu_item("/interfaces_lan.php", "LAN"); } ?> - <?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): if (!isset($config['interfaces']['opt' . $i]['ovpn'])): ?> - <?=output_menu_item("/interfaces_opt.php?index={$i}", htmlspecialchars($config['interfaces']['opt' . $i]['descr']))?> - <?php endif; endfor; ?> + <?php $opts = get_configured_interface_with_descr(true); + foreach ($opts as $oif => $odescr): + if (!isset($config['interfaces'][$oif]['ovpn'])): ?> + <?=output_menu_item("/interfaces_opt.php?optif={$oif}", htmlspecialchars($odescr))?> + <?php endif; endforeach; ?> <?php echo return_ext_menu("Interfaces"); ?> </ul> </li> diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index d58fc36..898d3e7 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -137,7 +137,7 @@ if ($_GET['act'] == "del") { $i = substr($id, 3); /* the number of the OPTn port being deleted */ unset($config['interfaces'][$id]['enable']); - interfaces_optional_configure_if($i); /* down the interface */ + interfaces_optional_configure_if($id); /* down the interface */ unset($config['interfaces'][$id]); /* delete the specified OPTn or LAN*/ @@ -338,4 +338,4 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) exec("/etc/rc.reboot"); } -?>
\ No newline at end of file +?> diff --git a/usr/local/www/interfaces_opt.php b/usr/local/www/interfaces_opt.php index b043948..5bcc65f 100755 --- a/usr/local/www/interfaces_opt.php +++ b/usr/local/www/interfaces_opt.php @@ -35,13 +35,13 @@ require("guiconfig.inc"); -unset($index); -if ($_GET['index']) - $index = $_GET['index']; -else if ($_POST['index']) - $index = $_POST['index']; +unset($optif); +if ($_GET['optif']) + $optif = $_GET['optif']; +else if ($_POST['optif']) + $optif = $_POST['optif']; -if (!$index) +if (!$optif) exit; function remove_bad_chars($string) { @@ -52,16 +52,15 @@ if (!is_array($config['gateways']['gateway_item'])) $config['gateways']['gateway_item'] = array(); $a_gateways = &$config['gateways']['gateway_item']; -$optcfg = &$config['interfaces']['opt' . $index]; +$optcfg = &$config['interfaces'][$optif]; $optcfg['descr'] = remove_bad_chars($optcfg['descr']); if (!is_array($config['aliases']['alias'])) $config['aliases']['alias'] = array(); -if(is_array($config['aliases']['alias'])) - foreach($config['aliases']['alias'] as $alias) - if($alias['name'] == $optcfg['descr']) - $input_errors[] = gettext("Sorry, an alias with the name {$optcfg['descr']} already exists."); +foreach($config['aliases']['alias'] as $alias) + if($alias['name'] == $optcfg['descr']) + $input_errors[] = gettext("Sorry, an alias with the name {$optcfg['descr']} already exists."); $pconfig['descr'] = $optcfg['descr']; $pconfig['bridge'] = $optcfg['bridge']; @@ -132,26 +131,26 @@ if ($_POST) { /* input validation */ if ($_POST['enable']) { + /* optional interface if list */ + $iflist = get_configured_interface_with_descr(true); + /* description unique? */ - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { - if ($i != $index) { - if ($config['interfaces']['opt' . $i]['descr'] == $_POST['descr']) { - $input_errors[] = "An interface with the specified description already exists."; - } - } + foreach ($iflist as $if => $ifdescr) { + if ($if != $optif && $ifdescr == $_POST['descr']) + $input_errors[] = "An interface with the specified description already exists."; } if ($_POST['bridge']) { /* double bridging? */ - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { - if ($i != $index) { - if ($config['interfaces']['opt' . $i]['bridge'] == $_POST['bridge']) { - //$input_errors[] = "Optional interface {$i} " . - // "({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " . + foreach($iflist as $oif => $oifname) { + if ($oif != $optif) { + if ($config['interfaces'][$oif]['bridge'] == $_POST['bridge']) { + //$input_errors[] = "Optional interface {$optif} " . + // "({$config['interfaces'][$oif]['descr']}) is already bridged to " . // "the specified interface."; - } else if ($config['interfaces']['opt' . $i]['bridge'] == "opt{$index}") { - //$input_errors[] = "Optional interface {$i} " . - // "({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " . + } else if ($config['interfaces'][$oif]['bridge'] == $optif) { + //$input_errors[] = "Optional interface {$optif} " . + // "({$config['interfaces'][$oif]['descr']}) is already bridged to " . // "this interface."; } } @@ -265,7 +264,7 @@ if ($_POST) { } -$pgtitle = array("Interfaces","Optional {$index} (" . htmlspecialchars($optcfg['descr']) . ")"); +$pgtitle = array("Interfaces","Optional {$optif} (" . htmlspecialchars($optcfg['descr']) . ")"); include("head.inc"); ?> @@ -321,7 +320,7 @@ function show_mon_config() { <td width="22%" valign="top" class="vtable"> </td> <td width="78%" class="vtable"> <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)"> - <strong>Enable Optional <?=$index;?> interface</strong></td> + <strong>Enable Optional <?=$optif;?> interface</strong></td> </tr> <tr> <td width="22%" valign="top" class="vncell">Description</td> @@ -410,15 +409,12 @@ function show_mon_config() { <td width="78%" class="vtable"> <select name="bridge" class="formselect" id="bridge" onChange="enable_change(false)"> <option <?php if (!$pconfig['bridge']) echo "selected";?> value="">none</option> - <?php $opts = array('lan' => "LAN", 'wan' => "WAN"); - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { - if ($i != $index) - $opts['opt' . $i] = "Optional " . $i . " (" . - $config['interfaces']['opt' . $i]['descr'] . ")"; - } - foreach ($opts as $opt => $optname): ?> - <option <?php if ($opt == $pconfig['bridge']) echo "selected";?> value="<?=htmlspecialchars($opt);?>"> - <?=htmlspecialchars($optname);?> + <?php $opts = get_configured_interface_with_descr(); + foreach ($opts as $opt => $optname): ?> + <option + <?php if ($opt != $optif && $opt == $pconfig['bridge']) + echo "selected";?> value="<?=htmlspecialchars($opt);?>"> + <?=htmlspecialchars($if ."(".$optname.")");?> </option> <?php endforeach; ?> </select> </td> @@ -446,7 +442,7 @@ function show_mon_config() { <?php if(count($a_gateways) > 0) { foreach ($a_gateways as $gateway) { - if($gateway['interface'] == "opt{$index}") { + if($gateway['interface'] == $optif) { ?> <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>> <?=htmlspecialchars($gateway['name']);?> @@ -515,7 +511,7 @@ function show_mon_config() { <tr> <td width="22%" valign="top"> </td> <td width="78%"> - <input name="index" type="hidden" value="<?=$index;?>"> + <input name="optif" type="hidden" value="<?=$optif;?>"> <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)"> </td> </tr> @@ -534,7 +530,7 @@ enable_change(false); //--> </script> <?php else: ?> -<p><strong>Optional <?=$index;?> has been disabled because there is no OPT<?=$index;?> interface.</strong></p> +<p><strong>Optional <?=$optif;?> has been disabled because there is no <?=strtoupper($optif);?> interface.</strong></p> <?php endif; ?> <?php include("fend.inc"); ?> </body> @@ -549,7 +545,7 @@ if ($_POST) { flush(); sleep(1); - interfaces_optional_configure_if($index); + interfaces_optional_configure_if($optif); reset_carp(); diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php index f8186ca..d85b08f 100644 --- a/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/usr/local/www/widgets/widgets/interfaces.widget.php @@ -35,14 +35,12 @@ require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once("/usr/local/www/widgets/include/interfaces.inc"); - $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; - }?> + $i = 0; + $ifdescrs = get_configured_interface_with_descr(); +?> <table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0"> <?php - $counter = 1; foreach ($ifdescrs as $ifdescr => $ifname){ $ifinfo = get_interface_info($ifdescr); $iswireless = is_interface_wireless($ifdescr); @@ -65,9 +63,8 @@ require_once("/usr/local/www/widgets/include/interfaces.inc"); <? } else if ($ifname == "LAN") { ?> <span onClick="location.href='/interfaces_lan.php'" style="cursor:pointer"> <? } else { ?> - <span onClick="location.href='/interfaces_opt.php?index=<?=$counter; ?>'" style="cursor:pointer"> + <span onClick="location.href='/interfaces_opt.php?optif=<?=$ifdescr; ?>'" style="cursor:pointer"> <? - $counter++; } ?> @@ -101,4 +98,4 @@ require_once("/usr/local/www/widgets/include/interfaces.inc"); </td></tr><?php }//end for each ?> - </table>
\ No newline at end of file + </table> |