diff --git a/resources/content/network.php b/resources/content/network.php
index dd65e1c..235270f 100644
--- a/resources/content/network.php
+++ b/resources/content/network.php
@@ -1,60 +1,51 @@
setHeaderTitle(_t('Netzwerk'));
-if (isset($_GET['hostname']))
-{
- if (isset($_POST['submit']) && $_POST['submit'] != '')
- {
- if (isset($_POST['hostname']) && trim($pHostname = trim($_POST['hostname'])) != '')
- {
- if (preg_match('/^([a-z][a-z0-9\-\.]*[^\-]){1,24}$/im', $pHostname))
- {
+if (isset($_GET['hostname'])) {
+ if (isset($_POST['submit']) && $_POST['submit'] != '') {
+ if (isset($_POST['hostname']) && trim($pHostname = trim($_POST['hostname'])) != '') {
+ if (preg_match('/^([a-z][a-z0-9\-\.]*[^\-]){1,24}$/im', $pHostname)) {
if (($status = editHostname($pHostname)) === true)
$tpl->msg('success', _t('Hostname gespeichert'), _t('Damit die Änderung wirksam wird, muss dein Raspberry Pi neu gestartet werden. Jetzt neu starten.', '?s=shutdown&restart'));
else
$tpl->msg('error', _t('Fehler'), _t('Fehler beim Ändern des Hostname! Fehlercode: %s', $status));
- }
- else
+ } else
$tpl->msg('error', _t('Fehler'), _t('Der Hostname ist ungültig! Er muss aus mindestens 1 bis 24 Zeichen bestehen und darf nur folgende Zeichen enthalten: A-Z a-z 0-9 -
Der Hostname darf nicht mit einem Bindestrich Anfangen oder Enden.'));
}
}
-
+
$tpl->assign('hostname', rpi_getHostname());
-
+
$tpl->draw('network_hostname');
-}
-else
-{
+} else {
$networkConnections = getAllNetworkConnections();
-
+
$networkCounts = unserialize(htmlspecialchars_decode(getConfig('main:network.overflowCount', 'a:0:{}')));
$counter = 0;
-
- foreach ($networkConnections as $network)
- {
+
+ foreach ($networkConnections as $network) {
$countSent = 0;
$countReceive = 0;
-
+
if (isset($networkCounts[$network['interface']]['sent']))
$countSent = $networkCounts[$network['interface']]['sent'];
-
+
if (isset($networkCounts[$network['interface']]['receive']))
$countReceive = $networkCounts[$network['interface']]['receive'];
-
+
$networkConnections[$counter]['sent'] = (4294967295 * $countSent) + $network['sent'];
$networkConnections[$counter]['receive'] = (4294967295 * $countReceive) + $network['receive'];
-
+
$counter += 1;
}
-
+
$tpl->assign('network_connections', $networkConnections);
$tpl->assign('hostname', rpi_getHostname());
$tpl->assign('wlan', scanAccessPoints($networkConnections, (isset($_GET['refresh_wlan'])) ? true : false));
-
+
$tpl->draw('network');
}
-?>
\ No newline at end of file
diff --git a/resources/content/settings/troubleshooting.php b/resources/content/settings/troubleshooting.php
index 07684e5..01d9dc6 100644
--- a/resources/content/settings/troubleshooting.php
+++ b/resources/content/settings/troubleshooting.php
@@ -38,7 +38,7 @@ $tpl->assign('configHelpFilesFolders', $config['url']['help'].'?s=view&i=1'.
$tpl->assign('configHelpCron', $config['url']['help'].'?s=view&i=10'.getURLLangParam());
$tpl->assign('cronEntry', $cronEntry);
$tpl->assign('cronMatch', $cronMatch);
-$tpl->assign('cronPHPCLI', ($cronPHPCLI = (trim(exec('dpkg -s php7.0-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '') ? true : false));
+$tpl->assign('cronPHPCLI', ($cronPHPCLI = (trim(exec('dpkg -s php-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '') ? true : false));
$tpl->assign('cronLastExecution', formatTime(getConfig('cron:execution.cron', 0)));
$tpl->assign('cronLastExecutionBool', ($cronLastExecutionBool = (getConfig('cron:execution.cron', 0) > time()-150) ? true : false));
$tpl->assign('cronLastExecutionLog', formatTime($lastExecutionLog[0]));
diff --git a/resources/library/main/main.function.php b/resources/library/main/main.function.php
index 2cf8f35..9e3b15c 100644
--- a/resources/library/main/main.function.php
+++ b/resources/library/main/main.function.php
@@ -393,60 +393,53 @@ function getImageFromSignal($signal)
function getAllNetworkConnections()
{
- $shell_string = '';
- $output = array();
+ $networkInterfaces = json_decode(shell_exec('ip -j addr'));
- exec('/sbin/ifconfig | grep -E -o "^[[:alnum:][:punct:]]*" | grep -E -v "(lo)" | sed "s/:$//"', $networkInterfaces);
+ foreach ($networkInterfaces as $interface) {
+ if ($interface->ifname != 'lo') {
+ $wirelessOption = [];
- foreach ($networkInterfaces as $interface)
- $shell_string .= '/sbin/ifconfig ' . $interface . (($networkInterfaces[count($networkInterfaces) - 1] != $interface) ? ' && echo "-#-" && ' : '');
-
- $streamInterfaces = explode('-#-', shell_exec($shell_string));
-
- foreach ($streamInterfaces as $index => $streamInterface) {
- $wirelessOption = '';
-
- $interface = $networkInterfaces[$index];
-
- preg_match('#inet(?:[ ]+(?:addr\:)?)([\w\.]+)#', $streamInterface, $ipAddress);
- preg_match('#(?:HWaddr|ether) ([\w\:]+)#', $streamInterface, $macAddress);
- preg_match('#RX(?:.*?)bytes[:| ]([\d]+)#', $streamInterface, $bytesReceived);
- preg_match('#TX(?:.*?)bytes[:| ]([\d]+)#', $streamInterface, $bytesSent);
- preg_match('#RX(?:.*?)packets[:| ]([\d]+)#', $streamInterface, $packetsReceived);
- preg_match('#TX(?:.*?)packets[:| ]([\d]+)#', $streamInterface, $packetsSent);
-
- $output0 = $interface;
-
- if (substr($output0, 0, 4) == 'wlan') {
- $streamWirelessInterface = shell_exec('/sbin/iwconfig ' . $output0);
-
- if (0 == substr_count($streamWirelessInterface, 'Not-Associated')) {
- $posConfig_start = @strpos($streamWirelessInterface, 'ESSID:"', 0) + 7;
- $posConfig_end = @strpos($streamWirelessInterface, '"', $posConfig_start);
- $wirelessOption['ssid'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
-
- $posConfig_start = @strpos($streamWirelessInterface, 'Access Point:', 0) + 13;
- $posConfig_end = @strpos($streamWirelessInterface, 'Bit Rate', $posConfig_start);
- $wirelessOption['mac'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
-
- $posConfig_start = @strpos($streamWirelessInterface, 'Signal level=', 0) + 13;
-
- if (($posConfig_end = @strpos($streamWirelessInterface, '/100', $posConfig_start)) === false) {
- $posConfig_end = @strpos($streamWirelessInterface, ' dBm', $posConfig_start);
- $signal = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
-
- if ($signal <= -100)
- $wirelessOption['signal'] = 0;
- elseif ($signal >= -50)
- $wirelessOption['signal'] = 100;
- else
- $wirelessOption['signal'] = 2 * ($signal + 100);
- } else
- $wirelessOption['signal'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
+ foreach ($interface->addr_info as $addr) {
+ if ($addr->family == "inet")
+ $ipAddress = $addr->local;
}
- }
+ $macAddress = $interface->address;
+ $bytesReceived = 0;
+ $bytesSent = 0;
+ $packetsReceived = 0;
+ $packetsSent = 0;
- $output[] = array('interface' => $interface, 'mac' => strtoupper($macAddress[1]), 'ip' => (isset($ipAddress[1])) ? $ipAddress[1] : NULL, 'sent' => $bytesSent[1], 'receive' => $bytesReceived[1], 'option' => $wirelessOption, 'packets' => array('sent' => $packetsSent[1], 'received' => $packetsReceived[1]));
+ if (substr($interface->ifname, 0, 4) == 'wlan') {
+ $streamWirelessInterface = shell_exec('/sbin/iwconfig ' . $interface->ifname);
+
+ if (0 == substr_count($streamWirelessInterface, 'Not-Associated')) {
+ $posConfig_start = @strpos($streamWirelessInterface, 'ESSID:"', 0) + 7;
+ $posConfig_end = @strpos($streamWirelessInterface, '"', $posConfig_start);
+ $wirelessOption['ssid'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
+
+ $posConfig_start = @strpos($streamWirelessInterface, 'Access Point:', 0) + 13;
+ $posConfig_end = @strpos($streamWirelessInterface, 'Bit Rate', $posConfig_start);
+ $wirelessOption['mac'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
+
+ $posConfig_start = @strpos($streamWirelessInterface, 'Signal level=', 0) + 13;
+
+ if (($posConfig_end = @strpos($streamWirelessInterface, '/100', $posConfig_start)) === false) {
+ $posConfig_end = @strpos($streamWirelessInterface, ' dBm', $posConfig_start);
+ $signal = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
+
+ if ($signal <= -100)
+ $wirelessOption['signal'] = 0;
+ elseif ($signal >= -50)
+ $wirelessOption['signal'] = 100;
+ else
+ $wirelessOption['signal'] = 2 * ($signal + 100);
+ } else
+ $wirelessOption['signal'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
+ }
+ }
+
+ $output[] = array('interface' => $interface->ifname, 'mac' => strtoupper($macAddress), 'ip' => (isset($ipAddress)) ? $ipAddress : NULL, 'sent' => $bytesSent, 'receive' => $bytesReceived, 'option' => $wirelessOption, 'packets' => array('sent' => $packetsSent, 'received' => $packetsReceived));
+ }
}
return $output;