Commit 3cc070df authored by Franco Fichtner's avatar Franco Fichtner

inc: replace another legacy PHP module function

parent 8842a552
...@@ -87,12 +87,14 @@ function interfaces_bring_up($interface) { ...@@ -87,12 +87,14 @@ function interfaces_bring_up($interface) {
/* /*
* Return the interface array * Return the interface array
*/ */
function get_interface_arr($flush = false) { function get_interface_arr($flush = false)
{
global $interface_arr_cache; global $interface_arr_cache;
/* If the cache doesn't exist, build it */ /* If the cache doesn't exist, build it */
if (!isset($interface_arr_cache) or $flush) if (!isset($interface_arr_cache) or $flush) {
$interface_arr_cache = pfSense_interface_listget(); $interface_arr_cache = legacy_interface_listget();
}
return $interface_arr_cache; return $interface_arr_cache;
} }
......
...@@ -26,6 +26,30 @@ ...@@ -26,6 +26,30 @@
POSSIBILITY OF SUCH DAMAGE. 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) function legacy_interface_create($ifs)
{ {
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' create'; $cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' create';
......
...@@ -877,22 +877,24 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") ...@@ -877,22 +877,24 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
); );
} }
switch($mode) { switch($mode) {
case "active": case 'active':
$upints = pfSense_interface_listget(IFF_UP); $upints = legacy_interface_listget('up');
break; break;
case "media": case 'media':
$intlist = pfSense_interface_listget(); $intlist = legacy_interface_listget();
$ifconfig = ""; $ifconfig = "";
exec("/sbin/ifconfig -a", $ifconfig); exec("/sbin/ifconfig -a", $ifconfig);
$regexp = '/(' . implode('|', $intlist) . '):\s/'; $regexp = '/(' . implode('|', $intlist) . '):\s/';
$ifstatus = preg_grep('/status:/', $ifconfig); $ifstatus = preg_grep('/status:/', $ifconfig);
foreach($ifstatus as $status) { foreach ($ifstatus as $status) {
$int = array_shift($intlist); $int = array_shift($intlist);
if(stristr($status, "active")) $upints[] = $int; if (stristr($status, 'active')) {
$upints[] = $int;
}
} }
break; break;
default: default:
$upints = pfSense_interface_listget(); $upints = legacy_interface_listget();
break; break;
} }
/* build interface list with netstat */ /* build interface list with netstat */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment