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) {
/*
* 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 */
......
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