From cbe3ea96403e554822bd4675cb5565d20ab55fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=C3=A7i?= Date: Sat, 21 Jun 2008 14:44:30 +0000 Subject: [PATCH] Continue interface improvements --- usr/local/www/diag_arp.php | 8 +++----- usr/local/www/diag_backup.php | 2 ++ usr/local/www/diag_logs_filter.php | 6 ++++-- usr/local/www/diag_logs_filter_dynamic.php | 8 +++++--- usr/local/www/diag_packet_capture.php | 9 ++------- usr/local/www/diag_ping.php | 9 ++------- usr/local/www/firewall_aliases_edit.php | 6 ++++-- usr/local/www/firewall_nat_1to1_edit.php | 8 +++----- usr/local/www/firewall_nat_edit.php | 14 ++++---------- usr/local/www/firewall_nat_out.php | 18 ++++-------------- usr/local/www/firewall_nat_out_edit.php | 5 +---- usr/local/www/firewall_rules.php | 15 ++++----------- 12 files changed, 38 insertions(+), 70 deletions(-) diff --git a/usr/local/www/diag_arp.php b/usr/local/www/diag_arp.php index f93cc54463..5d699dd59e 100755 --- a/usr/local/www/diag_arp.php +++ b/usr/local/www/diag_arp.php @@ -193,11 +193,9 @@ foreach ($leases as $value) { exec("/usr/sbin/arp -an",$rawdata); $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']; -} + +/* if list */ +$ifdescrs = get_configured_interface_with_descr(); foreach ($ifdescrs as $key =>$interface) { $hwif[$config['interfaces'][$key]['if']] = $interface; diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php index 165c20385d..5dde859c66 100755 --- a/usr/local/www/diag_backup.php +++ b/usr/local/www/diag_backup.php @@ -171,6 +171,8 @@ if ($_POST) { if($config['system']['gateway'] <> "") $config['interfaces']['wan']['gateway'] = $config['system']['gateway']; unset($config['shaper']); + /* optional if list */ + $ifdescrs = get_configured_interface_list(true); /* build an interface collection */ for ($j = 1; isset ($config['interfaces']['opt' . $j]); $j++) $ifdescrs['opt' . $j] = "opt" . $j; diff --git a/usr/local/www/diag_logs_filter.php b/usr/local/www/diag_logs_filter.php index c1a3b6b427..9654859b66 100755 --- a/usr/local/www/diag_logs_filter.php +++ b/usr/local/www/diag_logs_filter.php @@ -67,8 +67,10 @@ function conv_clog($logfile, $tail = 50) { $iftable = array(); $iftable[$config['interfaces']['lan']['if']] = "LAN"; $iftable[get_real_wan_interface()] = "WAN"; - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) - $iftable[$config['interfaces']['opt' . $i]['if']] = $config['interfaces']['opt' . $i]['descr']; + /* optional if list */ + $iflist = get_configured_interface_with_descr(true); + foreach ($iflist as $if => $ifdesc) + $iftable[$config['interfaces'][$if]['if']] = $ifdesc; $sor = isset($config['syslog']['reverse']) ? "-r" : ""; diff --git a/usr/local/www/diag_logs_filter_dynamic.php b/usr/local/www/diag_logs_filter_dynamic.php index 81ffd3f528..b9262b245e 100755 --- a/usr/local/www/diag_logs_filter_dynamic.php +++ b/usr/local/www/diag_logs_filter_dynamic.php @@ -62,8 +62,10 @@ function conv_clog_filter($logfile, $tail = 50) { $iftable = array(); $iftable[$config['interfaces']['lan']['if']] = "LAN"; $iftable[get_real_wan_interface()] = "WAN"; - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) - $iftable[$config['interfaces']['opt' . $i]['if']] = $config['interfaces']['opt' . $i]['descr']; + /* optional if list */ + $iflist = get_configured_interface_with_descr(true); + foreach ($iflist as $if => $ifdesc) + $iftable[$config['interfaces'][$if]['if']] = $ifdesc; $sor = isset($config['syslog']['reverse']) ? "-r" : ""; @@ -473,4 +475,4 @@ function handle_ajax() { } } -?> \ No newline at end of file +?> diff --git a/usr/local/www/diag_packet_capture.php b/usr/local/www/diag_packet_capture.php index c795a1aa45..d07d3e263a 100644 --- a/usr/local/www/diag_packet_capture.php +++ b/usr/local/www/diag_packet_capture.php @@ -119,14 +119,9 @@ include("head.inc"); ?> Interface - 'WAN', 'lan' => 'LAN'); - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { - if (isset($config['interfaces']['opt' . $i]['enable']) && - !$config['interfaces']['opt' . $i]['bridge']) - $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr']; - } + $ifacename): ?> - diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index 402fd875e3..a6f5d2e7f3 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -51,8 +51,10 @@ if (isset($id) && $a_aliases[$id]) { $pconfig['address'] = $a_aliases[$id]['address']; $pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']); - for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) - if($config['interfaces']['opt' . $i]['descr'] == $pconfig['descr']) + /* optional if list */ + $iflist = get_configured_interface_with_descr(true, true); + foreach ($iflist as $if => $ifdesc) + if($ifdesc == $pconfig['descr']) $input_errors[] = "Sorry, an interface is already named {$pconfig['descr']}."; $addresses = explode(' ', $pconfig['address']); diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php index d00c4eb32d..66f140b8e2 100755 --- a/usr/local/www/firewall_nat_1to1_edit.php +++ b/usr/local/www/firewall_nat_1to1_edit.php @@ -144,11 +144,9 @@ include("head.inc"); $ifdesc) + if(have_ruleint_access($if)) + $interfaces[$if] = $ifdesc; if ($config['pptpd']['mode'] == "server") if(have_ruleint_access("pptp")) diff --git a/usr/local/www/firewall_nat_out.php b/usr/local/www/firewall_nat_out.php index 9cfffcde00..99fc3f7706 100755 --- a/usr/local/www/firewall_nat_out.php +++ b/usr/local/www/firewall_nat_out.php @@ -79,25 +79,15 @@ if (isset($_POST['save']) && $_POST['save'] == "Save") { * user has enabled advanced outbound nat -- lets automatically create entries * for all of the interfaces to make life easier on the pip-o-chap */ - $ifdescrs = array('lan'); - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) - $ifdescrs[] = "opt" . $j; - foreach($ifdescrs as $if) { - if($if <> "lan" and $if <> "wan") { - /* interface is an optional. is it enabled? */ - if(!isset($config['interfaces'][$if]['enabled'])) { - continue; - } - } + $ifdescrs = get_configured_interface_with_descr(); + + foreach($ifdescrs as $if => $ifdesc) { $natent = array(); $osn = gen_subnet($config['interfaces'][$if]['ipaddr'], $config['interfaces'][$if]['subnet']); $natent['source']['network'] = $osn . "/" . $config['interfaces'][$if]['subnet']; $natent['sourceport'] = ""; - $int_description = $config['interfaces'][$if]['descr']; - if($if == "lan") - $int_description = "LAN"; - $natent['descr'] = "Auto created rule for {$int_description}"; + $natent['descr'] = "Auto created rule for {$ifdesc}"; $natent['target'] = ""; $natent['interface'] = "wan"; $natent['destination']['any'] = true; diff --git a/usr/local/www/firewall_nat_out_edit.php b/usr/local/www/firewall_nat_out_edit.php index 66f776390a..f032cfcc73 100755 --- a/usr/local/www/firewall_nat_out_edit.php +++ b/usr/local/www/firewall_nat_out_edit.php @@ -301,10 +301,7 @@ function sourcesel_change() {