Korrekturen
URLs angepasst Statistik Einheit automatisch ändern (MB -> GB)
This commit is contained in:
@@ -32,7 +32,7 @@ function rpi_getCoreTemprature()
|
||||
$file = @shell_exec('cat /sys/class/thermal/thermal_zone0/temp');
|
||||
|
||||
if ($file != false)
|
||||
return round((trim($file)/1000), 2);
|
||||
return round((trim($file) / 1000), 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ function rpi_getCpuClock()
|
||||
$file = shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq');
|
||||
|
||||
if ($file !== false)
|
||||
return (int) round(trim($file)/1000);
|
||||
return (int) round(trim($file) / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ function rpi_getCpuMinClock()
|
||||
$file = shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq');
|
||||
|
||||
if ($file !== false)
|
||||
return (int) round(trim($file)/1000);
|
||||
return (int) round(trim($file) / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ function rpi_getCpuMaxClock()
|
||||
$file = shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq');
|
||||
|
||||
if ($file !== false)
|
||||
return (int) round(trim($file)/1000);
|
||||
return (int) round(trim($file) / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ function rpi_getCPUType()
|
||||
|
||||
function rpi_getCpuModel()
|
||||
{
|
||||
$model = trim(@shell_exec('cat /proc/cpuinfo | grep -m 1 "model name" | tr -d " " | cut -d ":" -f 2'));
|
||||
$model = trim(@shell_exec('cat /proc/cpuinfo | grep -m 1 "Model" | cut -d ":" -f 2'));
|
||||
return $model;
|
||||
}
|
||||
|
||||
@@ -101,8 +101,7 @@ function rpi_getCPULoad($accurate = false, $mulitcore = false)
|
||||
preg_match_all('/^cpu[0-9]?(.*)$/im', $file[0], $prevCPUStrings);
|
||||
preg_match_all('/^cpu[0-9]?(.*)$/im', $file[1], $curCPUStrings);
|
||||
|
||||
for ($i = 0; $i < count($prevCPUStrings[0]); $i++)
|
||||
{
|
||||
for ($i = 0; $i < count($prevCPUStrings[0]); $i++) {
|
||||
$prevCPU = preg_split('/\s+/', $prevCPUStrings[0][$i]);
|
||||
$curCPU = preg_split('/\s+/', $curCPUStrings[0][$i]);
|
||||
|
||||
@@ -138,8 +137,7 @@ function rpi_getDistribution()
|
||||
{
|
||||
$distribution = trim(@shell_exec('cat /etc/issue | cut -d " " -f 1-3'));
|
||||
|
||||
if ($distribution == '')
|
||||
{
|
||||
if ($distribution == '') {
|
||||
$distributionString = @shell_exec('cat /etc/*-release | grep PRETTY_NAME');
|
||||
|
||||
preg_match('/.*="([\w\s\d\/]*).*"/i', $distributionString, $match);
|
||||
@@ -175,7 +173,9 @@ function rpi_getInstalledPackages()
|
||||
{
|
||||
@exec('dpkg -l | grep ^ii', $packages);
|
||||
|
||||
$packages = array_map(function($package) { return preg_split('/[\s]+/', $package, 5); }, $packages);
|
||||
$packages = array_map(function ($package) {
|
||||
return preg_split('/[\s]+/', $package, 5);
|
||||
}, $packages);
|
||||
return $packages;
|
||||
}
|
||||
|
||||
@@ -217,8 +217,7 @@ function rpi_getRpiRevision()
|
||||
* +- Memory
|
||||
*/
|
||||
|
||||
if (isset($match[1]))
|
||||
{
|
||||
if (isset($match[1])) {
|
||||
if ($match[1][0] == '1' || $match[1][0] == '2')
|
||||
$match[1] = substr($match[1], 1);
|
||||
|
||||
@@ -226,13 +225,14 @@ function rpi_getRpiRevision()
|
||||
return $revision[hexdec($match[1])];
|
||||
elseif (strlen($match[1]) == 6 && $match[1][0] != 'a' && $match[1][0] != '9')
|
||||
return $revision[hexdec(substr($match[1], -4))];
|
||||
elseif (strlen($match[1]) == 6)
|
||||
{
|
||||
return array('revision' => $match[1],
|
||||
elseif (strlen($match[1]) == 6) {
|
||||
return array(
|
||||
'revision' => $match[1],
|
||||
'model' => $revision_model[hexdec(substr($match[1], 3, 2))],
|
||||
'pcb' => '1.'.hexdec(substr($match[1], -1)),
|
||||
'pcb' => '1.' . hexdec(substr($match[1], -1)),
|
||||
'memory' => $revision_memory[bindec(substr(decbin(hexdec(substr($match[1], 0, 1))), 1))],
|
||||
'manufacturer' => $revision_manufacturer[hexdec(substr($match[1], 1, 1))]);
|
||||
'manufacturer' => $revision_manufacturer[hexdec(substr($match[1], 1, 1))]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,15 +250,14 @@ function rpi_getRpiSerial()
|
||||
function rpi_getMemorySplit()
|
||||
{
|
||||
$rev = $this->getRpiRevision();
|
||||
if ($rev >= 7)
|
||||
{
|
||||
if ($rev >= 7) {
|
||||
// 512 MB
|
||||
$config = @shell_exec('cat /boot/config.txt');
|
||||
preg_match('#gpu_mem=([0-9]+)#i', $config, $match);
|
||||
$total = intval($match[1]);
|
||||
|
||||
if ($total == 16)
|
||||
return array('system' => '496 MiB', 'video' => '16 MiB');
|
||||
return array('system' => '1991 MiB', 'video' => '16 MiB');
|
||||
elseif ($total == 32)
|
||||
return array('system' => '480 MiB', 'video' => '32 MiB');
|
||||
elseif ($total == 64)
|
||||
@@ -280,29 +279,21 @@ function rpi_getMemorySplit()
|
||||
elseif ($total > 192 && $total <= 224)
|
||||
return array('system' => '224 MiB', 'video' => '32 MiB');
|
||||
|
||||
return array('system' => '240 MiB', 'video' => '16 MiB');
|
||||
return array('system' => '1991 MiB', 'video' => '16 MiB');
|
||||
}
|
||||
|
||||
function rpi_getMemoryUsage()
|
||||
{
|
||||
exec('free -bo 2>/dev/null || free -b', $data);
|
||||
exec('free -b', $data);
|
||||
list($type, $total, $used, $free, $shared, $buffers, $available) = preg_split('#\s+#', $data[1]);
|
||||
$usage = (int) round(($total - $available) / $total * 100);
|
||||
|
||||
if (strpos($data[0], 'available') !== false) {
|
||||
list($type, $total, $used, $free, $shared, $buffers, $available) = preg_split('#\s+#', $data[1]);
|
||||
$usage = (int) round(($total - $available) / $total * 100);
|
||||
|
||||
return array('percent' => $usage, 'total' => $total, 'free' => $available, 'used' => ($total - $available));
|
||||
}
|
||||
|
||||
list($type, $total, $used, $free, $shared, $buffers, $cached) = preg_split('#\s+#', $data[1]);
|
||||
$usage = (int) round(($used - $buffers - $cached) / $total * 100);
|
||||
|
||||
return array('percent' => $usage, 'total' => $total, 'free' => ($free + $buffers + $cached), 'used' => ($used - $buffers - $cached));
|
||||
return array('percent' => $usage, 'total' => $total, 'free' => $available, 'used' => ($total - $available));
|
||||
}
|
||||
|
||||
function rpi_getSwapUsage()
|
||||
{
|
||||
exec('free -bo 2>/dev/null || free -b', $data);
|
||||
exec('free -b', $data);
|
||||
list($type, $total, $used, $free) = preg_split('#\s+#', $data[2]);
|
||||
$usage = (int) round($used / $total * 100);
|
||||
|
||||
@@ -326,30 +317,27 @@ function rpi_getMemoryInfo()
|
||||
$totalSize = 0;
|
||||
$usedSize = 0;
|
||||
|
||||
foreach ($data as $row)
|
||||
{
|
||||
foreach ($data as $row) {
|
||||
list($device, $type, $blocks, $use, $available, $used, $mountpoint) = preg_split('#[\s%]+#i', $row);
|
||||
|
||||
if (multiArraySearch($devices, 'device', $device) === false)
|
||||
{
|
||||
if (multiArraySearch($devices, 'device', $device) === false) {
|
||||
$totalSize += $blocks * 1024;
|
||||
$usedSize += $use * 1024;
|
||||
}
|
||||
|
||||
$devices[] = array(
|
||||
'device' => $device,
|
||||
'type' => $type,
|
||||
'total' => $blocks * 1024,
|
||||
'used' => $use * 1024,
|
||||
'free' => $available * 1024,
|
||||
'percent' => (int) round(($use * 100 / $blocks)),
|
||||
'mountpoint' => $mountpoint
|
||||
'device' => $device,
|
||||
'type' => $type,
|
||||
'total' => $blocks * 1024,
|
||||
'used' => $use * 1024,
|
||||
'free' => $available * 1024,
|
||||
'percent' => (int) round(($use * 100 / $blocks)),
|
||||
'mountpoint' => $mountpoint
|
||||
);
|
||||
}
|
||||
|
||||
usort($devices, function($a, $b)
|
||||
{
|
||||
return strcasecmp($a['device'], $b['device']);
|
||||
usort($devices, function ($a, $b) {
|
||||
return strcasecmp($a['device'], $b['device']);
|
||||
});
|
||||
|
||||
$devices[] = array('total' => $totalSize, 'used' => $usedSize, 'free' => $totalSize - $usedSize, 'percent' => (int) round(($usedSize * 100 / $totalSize)));
|
||||
@@ -362,14 +350,13 @@ function rpi_getUsbDevices()
|
||||
exec('lsusb', $data);
|
||||
$devices = array();
|
||||
|
||||
foreach ($data as $row)
|
||||
{
|
||||
foreach ($data as $row) {
|
||||
preg_match('#[0-9a-f]{4}:[0-9a-f]{4}\s+(.+)#i', $row, $match);
|
||||
|
||||
if (count($match) == 2)
|
||||
$devices[] = trim($match[1]);
|
||||
else
|
||||
$devices[] = '<'._t('Unbekannt').'>';
|
||||
$devices[] = '<' . _t('Unbekannt') . '>';
|
||||
}
|
||||
|
||||
return $devices;
|
||||
@@ -387,7 +374,7 @@ function rpi_getAllUsers()
|
||||
foreach ($data as $key => $row)
|
||||
$tmp[$key] = $row[$field];
|
||||
$args[$n] = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
$args[] = &$data;
|
||||
call_user_func_array('array_multisort', $args);
|
||||
@@ -400,44 +387,43 @@ function rpi_getAllUsers()
|
||||
$usersLoggedIn = array();
|
||||
$usersAll = array();
|
||||
|
||||
foreach ($dataLoggedIn as $row)
|
||||
{
|
||||
foreach ($dataLoggedIn as $row) {
|
||||
$split = preg_split('/\s+/i', $row);
|
||||
|
||||
if (count($split) == 6)
|
||||
$usersLoggedIn[$split[0]][] = array('port' => $split[1], 'lastLogin' => strtotime($split[2].' '.$split[3].' '.$split[4]), 'lastLoginAddress' => $split[5]);
|
||||
$usersLoggedIn[$split[0]][] = array('port' => $split[1], 'lastLogin' => strtotime($split[2] . ' ' . $split[3] . ' ' . $split[4]), 'lastLoginAddress' => $split[5]);
|
||||
}
|
||||
|
||||
foreach ($dataAllUsers as $row)
|
||||
{
|
||||
foreach ($dataAllUsers as $row) {
|
||||
$userLastLoginInformation = '';
|
||||
$userLastLoginInformation = shell_exec('/usr/bin/last -i -f /var/log/wtmp | grep -m 1 "^'.$row.' "');
|
||||
$userLastLoginInformation = shell_exec('/usr/bin/last -i -f /var/log/wtmp | grep -m 1 "^' . $row . ' "');
|
||||
|
||||
if ($userLastLoginInformation == '')
|
||||
$userLastLoginInformation = shell_exec('/usr/bin/last -i -f /var/log/wtmp.1 | grep -m 1 "^'.$row.' "');
|
||||
$userLastLoginInformation = shell_exec('/usr/bin/last -i -f /var/log/wtmp.1 | grep -m 1 "^' . $row . ' "');
|
||||
|
||||
if ($userLastLoginInformation != '')
|
||||
{
|
||||
if ($userLastLoginInformation != '') {
|
||||
$split = preg_split('/\s+/i', $userLastLoginInformation);
|
||||
|
||||
$usersAll[] = array('username' => $row,
|
||||
'userId' => exec('id -u '.escapeshellarg($row)),
|
||||
'groupId' => exec('id -g '.escapeshellarg($row)),
|
||||
'port' => $split[1],
|
||||
'lastLoginAddress' => $split[2],
|
||||
'lastLogin' => strtotime($split[4].' '.$split[5].' '.$split[6]),
|
||||
'isLoggedIn' => isset($usersLoggedIn[$row]) ? true : false,
|
||||
'loggedIn' => isset($usersLoggedIn[$row]) ? $usersLoggedIn[$row] : array());
|
||||
}
|
||||
else
|
||||
{
|
||||
$usersAll[] = array('username' => $row,
|
||||
'userId' => exec('id -u '.escapeshellarg($row)),
|
||||
'groupId' => exec('id -g '.escapeshellarg($row)),
|
||||
'port' => '',
|
||||
'lastLoginAddress' => '',
|
||||
'lastLogin' => 0,
|
||||
'isLoggedIn' => isset($usersLoggedIn[$row]) ? true : false);
|
||||
$usersAll[] = array(
|
||||
'username' => $row,
|
||||
'userId' => exec('id -u ' . escapeshellarg($row)),
|
||||
'groupId' => exec('id -g ' . escapeshellarg($row)),
|
||||
'port' => $split[1],
|
||||
'lastLoginAddress' => $split[2],
|
||||
'lastLogin' => strtotime($split[4] . ' ' . $split[5] . ' ' . $split[6]),
|
||||
'isLoggedIn' => isset($usersLoggedIn[$row]) ? true : false,
|
||||
'loggedIn' => isset($usersLoggedIn[$row]) ? $usersLoggedIn[$row] : array()
|
||||
);
|
||||
} else {
|
||||
$usersAll[] = array(
|
||||
'username' => $row,
|
||||
'userId' => exec('id -u ' . escapeshellarg($row)),
|
||||
'groupId' => exec('id -g ' . escapeshellarg($row)),
|
||||
'port' => '',
|
||||
'lastLoginAddress' => '',
|
||||
'lastLogin' => 0,
|
||||
'isLoggedIn' => isset($usersLoggedIn[$row]) ? true : false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,4 +431,3 @@ function rpi_getAllUsers()
|
||||
|
||||
return $usersAll;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user