diff --git a/emhttp/plugins/dynamix/Eth0.page b/emhttp/plugins/dynamix/Eth0.page index 035ca53de..445930af7 100644 --- a/emhttp/plugins/dynamix/Eth0.page +++ b/emhttp/plugins/dynamix/Eth0.page @@ -48,17 +48,17 @@ function locked($source, $port) { } function vlanID($cfg) { - return array_filter($cfg,function($key){return strpos($key,'VLANID:')===0;},ARRAY_FILTER_USE_KEY); + return array_filter($cfg, function($key){return strpos($key, 'VLANID:')===0;}, ARRAY_FILTER_USE_KEY); } function index($key) { - return filter_var($key,FILTER_SANITIZE_NUMBER_INT); + return filter_var($key, FILTER_SANITIZE_NUMBER_INT); } function metric($eth, $prot, $index) { $system = '/sys/class/net'; - $bridge = str_replace('eth','br',$eth); - $bond = str_replace('eth','bond',$eth); + $bridge = str_replace('eth','br', $eth); + $bond = str_replace('eth','bond', $eth); $port = file_exists("$system/$bridge") ? $bridge : (file_exists("$system/$bond") ? $bond : $eth); $metric = exec("ip -$prot route show default dev $port 2>/dev/null | grep -Pom1 ' metric \K\d+'"); if ($metric) return $metric + $index; @@ -67,8 +67,8 @@ function metric($eth, $prot, $index) { } // remove non-existing ethernet ports -foreach (glob("$docroot/webGui/Eth[1-9]*.page",GLOB_NOSORT) as $port) { - if (!in_array(strtolower(basename($port,'.page')), $ports)) { +foreach (glob("$docroot/webGui/Eth[1-9]*.page", GLOB_NOSORT) as $port) { + if (!in_array(strtolower(basename($port, '.page')), $ports)) { @unlink($port); $build = true; } @@ -78,8 +78,8 @@ foreach (glob("$docroot/webGui/Eth[1-9]*.page",GLOB_NOSORT) as $port) { foreach ($ports as $ethX) { $file = "$docroot/webGui/".ucfirst($ethX).".page"; if (!file_exists($file)) { - $X = filter_var($ethX,FILTER_SANITIZE_NUMBER_INT); - file_put_contents($file,str_replace(['parentname:nnn','tabX','bondX','brX','ethX'],['NetworkSettings:'.($X+100),'tab'.($X+1),'bond'.$X,'br'.$X,$ethX],file_get_contents($template))); + $X = filter_var($ethX, FILTER_SANITIZE_NUMBER_INT); + file_put_contents($file, str_replace(['parentname:nnn','tabX','bondX','brX','ethX'],['NetworkSettings:'.($X+100),'tab'.($X+1),'bond'.$X,'br'.$X,$ethX], file_get_contents($template))); $build = true; } } @@ -93,7 +93,7 @@ $no_eth0 = exec("ip -br link show eth0 | awk '{print \$2;exit}'")=='DOWN'; // get VLAN interfaces $vlan_eth0 = $sort_eth0 = []; if (isset($eth0)) foreach (vlanID($eth0) as $key => $val) {$vlan_eth0[] = index($key); $sort_eth0[] = (int)$val;} -array_multisort($sort_eth0,$vlan_eth0); +array_multisort($sort_eth0, $vlan_eth0); ?>