function getIPs_from_ifcfg() { /* $p = '/etc/sysconfig/network-scripts/'; $l = lscandir($p); foreach($l as $t => $f) { if (stristr($f, "ifcfg-")) { if ($f === 'ifcfg-lo') { continue; } $c = file_get_contents($p.$f); $a = explode("\n", $c); foreach($a as $k => $v) { if (stristr($v, "IPADDR=")) { $i = explode("=", $v); $r[] = trim($i[1]); } } } } return $r; */ // instead mimic function, call function directly global $gbl, $sgbl, $login, $ghtml; $driverapp = $gbl->getSyncClass(null, null, 'ipaddress'); // print($driverapp); if ($driverapp === 'redhat') { $list = Ipaddress__Redhat::getCurrentIps(); } foreach ($list as $k => $v) { if ($v['ipaddr'] === '127.0.0.1') { continue; } $iplist[] = $v['ipaddr']; } return $iplist; }
function getIPs_from_ifcfg() { /* $p = '/etc/sysconfig/network-scripts/'; $l = lscandir($p); foreach($l as $t => $f) { if (stristr($f, "ifcfg-")) { if ($f === 'ifcfg-lo') { continue; } $c = file_get_contents($p.$f); $a = explode("\n", $c); foreach($a as $k => $v) { if (stristr($v, "IPADDR=")) { $i = explode("=", $v); $r[] = trim($i[1]); } } } } return $r; */ // instead mimic function, call function directly global $gbl, $sgbl, $login, $ghtml; $driverapp = $gbl->getSyncClass(null, null, 'ipaddress'); // Responds always as redhat on centos. // Project issue #735 // if ($driverapp === 'redhat' || $driverapp === 'centos') { $list = Ipaddress__Redhat::getCurrentIps(); // } $iplist = array(); // Initialize return value if (!empty($list)) { foreach ($list as $k => $v) { // Check ipaddr index $ip_address = isset($v['ipaddr']) ? $v['ipaddr'] : NULL; // Skip localhost IP or empty values if ($ip_address !== '127.0.0.1' && !empty($ip_address)) { $iplist[] = $ip_address; } } } return $iplist; }