mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
inc: replace another legacy PHP module function
This commit is contained in:
parent
8842a55208
commit
3cc070df9e
@ -87,12 +87,14 @@ function interfaces_bring_up($interface) {
|
||||
/*
|
||||
* Return the interface array
|
||||
*/
|
||||
function get_interface_arr($flush = false) {
|
||||
function get_interface_arr($flush = false)
|
||||
{
|
||||
global $interface_arr_cache;
|
||||
|
||||
/* If the cache doesn't exist, build it */
|
||||
if (!isset($interface_arr_cache) or $flush)
|
||||
$interface_arr_cache = pfSense_interface_listget();
|
||||
if (!isset($interface_arr_cache) or $flush) {
|
||||
$interface_arr_cache = legacy_interface_listget();
|
||||
}
|
||||
|
||||
return $interface_arr_cache;
|
||||
}
|
||||
|
||||
@ -26,6 +26,30 @@
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function legacy_interface_listget($flag = '')
|
||||
{
|
||||
$cmd = '/sbin/ifconfig -l';
|
||||
$ifs = null;
|
||||
|
||||
if ($flag === 'up') {
|
||||
$cmd .= 'u';
|
||||
} else if ($flag === 'down') {
|
||||
$cmd .= 'd';
|
||||
}
|
||||
|
||||
exec($cmd . ' 2>&1', $out, $ret);
|
||||
if ($ret) {
|
||||
log_error('The command `' . $cmd . '\' failed to execute');
|
||||
return ($ifs);
|
||||
}
|
||||
|
||||
if (isset($out[0])) {
|
||||
$ifs = explode(' ', $out[0]);
|
||||
}
|
||||
|
||||
return ($ifs);
|
||||
}
|
||||
|
||||
function legacy_interface_create($ifs)
|
||||
{
|
||||
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' create';
|
||||
|
||||
@ -877,22 +877,24 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
|
||||
);
|
||||
}
|
||||
switch($mode) {
|
||||
case "active":
|
||||
$upints = pfSense_interface_listget(IFF_UP);
|
||||
case 'active':
|
||||
$upints = legacy_interface_listget('up');
|
||||
break;
|
||||
case "media":
|
||||
$intlist = pfSense_interface_listget();
|
||||
case 'media':
|
||||
$intlist = legacy_interface_listget();
|
||||
$ifconfig = "";
|
||||
exec("/sbin/ifconfig -a", $ifconfig);
|
||||
$regexp = '/(' . implode('|', $intlist) . '):\s/';
|
||||
$ifstatus = preg_grep('/status:/', $ifconfig);
|
||||
foreach($ifstatus as $status) {
|
||||
foreach ($ifstatus as $status) {
|
||||
$int = array_shift($intlist);
|
||||
if(stristr($status, "active")) $upints[] = $int;
|
||||
if (stristr($status, 'active')) {
|
||||
$upints[] = $int;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$upints = pfSense_interface_listget();
|
||||
$upints = legacy_interface_listget();
|
||||
break;
|
||||
}
|
||||
/* build interface list with netstat */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user