<?php
class Netzlast {
private $data;
private $devices;
private $htDevice;
function __construct() {
$lines = explode( "\n", $RawData );
$htDevice['name'] = '';
$htDevice['traffic'] = -1;
$showAllDevices = false;
if ( isset( $_GET['device'] ) and
$_GET['device'] and
'all' !=$_GET['device'] ) {
$showDevices = explode( ',', $_GET['device'] );
} else {
$showAllDevices = true;
}
$devices = [];
foreach ( $lines as $line ) {
if ( $showAllDevices or
in_array ( $tupels[0], $showDevices ) ) {
$out[$tupels[0]] = [];
$out[$tupels[0]]['RX'] = $tupels[1];
$out[$tupels[0]]['TX'] = $tupels[9];
}
if ( ( 0 < $tupels[1] ) and ( $tupels[9] ) ) {
$devices[] = $tupels[0];
}
$traffic = $tupels[1] + $tupels[9];
if ( $traffic > $htDevice['traffic'] ) {
$htDevice['name'] = $tupels[0];
$htDevice['traffic'] = $traffic;
}
}
$this -> data = $out;
$this -> devices = $devices;
$this -> htDevice = $htDevice['name'];
}
function getNetzlastAsJson () {
}
function getNetzlastAsArray () {
return $this -> data;
}
function getDevicesAsJson () {
}
function getDevicesAsList () {
return implode( ',', $this -> devices );
}
function getDevicesAsArray () {
return $this -> devices;
}
function getHighTrafficDevice() {
return $this -> htDevice;
}
}