/dev/null",$ns); $eth = $_POST['port']; $vlan = $_POST['vlan']; $port = port($eth).($vlan ? ".$vlan" : ""); $v6on = trim(file_get_contents("/proc/sys/net/ipv6/conf/$port/disable_ipv6"))==='0'; $none = _('None'); $error = ""._('Missing').""; $note = in_array($eth,['eth0','wlan0']) && !$vlan ? $error : $none; $link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: ($eth=='wlan0' ? 'wifi' :'not present')).")"; $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); $ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show $port scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); $gw4 = exec("ip -4 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns4 = array_filter($ns,function($ns){return strpos($ns,':')===false;}); $domain = exec("grep -Pom1 'domain \K.*' /etc/resolv.conf 2>/dev/null") ?: '---'; if ($v6on) { $ipv6 = array_filter(explode(' ',exec("ip -6 -br addr show $port scope global -temporary 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); $gw6 = exec("ip -6 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns6 = array_filter($ns,function($ns){return strpos($ns,':')!==false;}); } echo ""; echo ""; echo ""; echo ""; if ($eth=='wlan0') { $ini = '/boot/config/wireless-networks.cfg'; $wifi = (array)@parse_ini_file($ini,true); $att1 = $att2 = $att3 = ''; foreach ($wifi as $network => $option) { if (isset($option['GROUP']) && $option['GROUP']=='active') { $att1 = $network; $att2 = $option['ATTR2']; $att3 = $option['ATTR3']; break; } } if ($att1) echo ""; if ($att2) echo ""; if ($att3) echo ""; } if (count($ipv4)) foreach ($ipv4 as $ip) { echo ""; } else { echo ""; } echo ""; if (count($dns4)) foreach ($dns4 as $dns) { echo ""; } else { echo ""; } if ($v6on) { if (count($ipv6)) foreach ($ipv6 as $ip) { echo ""; } else { echo ""; } echo ""; if (count($dns6)) foreach ($dns6 as $dns) { echo ""; } else { echo ""; } } echo ""; echo "
  
"._('Interface link').":$link
"._('Interface speed').":$speed
"._('Network').":$att1
"._('Health').":$att2
"._('Security').":$att3
"._('IPv4 address').":$ip
"._('IPv4 address').":$note
"._('IPv4 default gateway').":$gw4
"._('IPv4 DNS server').":$dns
"._('IPv4 DNS server').":$error
"._('IPv6 address').":$ip
"._('IPv6 address').":$note
"._('IPv6 default gateway').":$gw6
"._('IPv6 DNS server').":$dns
"._('IPv6 DNS server').":$error
"._('Domain name').":$domain
"; ?>