Compare commits
12 Commits
2.3.0
...
2.3.1beta3
| Author | SHA1 | Date | |
|---|---|---|---|
| 130dee67ea | |||
| 79c7fbc841 | |||
|
|
57608f3b2f | ||
|
|
1e60371abe | ||
|
|
79fc07e010 | ||
|
|
db683a5b19 | ||
|
|
3ebc78f14d | ||
|
|
588c82f4e8 | ||
|
|
22fa53e3a3 | ||
|
|
1257825709 | ||
|
|
6f819ed9f5 | ||
|
|
6adb4fe93e |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
.idea/**/shelf
|
||||
.idea
|
||||
.vscode
|
||||
pack.sh
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
@@ -99,3 +100,5 @@ data/DoctrineORMModule/cache/
|
||||
demos/
|
||||
extras/documentation
|
||||
|
||||
*.zip
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,4 +4,4 @@
|
||||
[Pi Control Installation](https://pi-control.de/install/)
|
||||
|
||||
## Bei Fragen oder Problemen
|
||||
Schreibe mir eine E-Mail an [support@pi-control.de](mailto:support@pi-control.de) oder nutze das Feedback in Pi Control.
|
||||
Über das [Ticketsystem](https://bugs.die-schultes.eu/projects/pi-control/issues) können Fehler gemeldet werden und im [Forum](https://bugs.die-schultes.eu/projects/pi-control/boards) gibt es Hilfe zu Fragen rund um Pi Control
|
||||
@@ -1,22 +1,20 @@
|
||||
<?php
|
||||
const PICONTROL = true;
|
||||
|
||||
(include_once realpath(dirname(__FILE__)).'/../../resources/init.php') or die('Error: 0x0000');
|
||||
(include_once LIBRARY_PATH.'main/main.function.php') or die('Error: 0x0001');
|
||||
(include_once LIBRARY_PATH.'statistic/statistic.class.php') or die('Error: 0x0002');
|
||||
(include_once LIBRARY_PATH.'statistic/statistic.function.php') or die('Error: 0x0003');
|
||||
(include_once LIBRARY_PATH.'api/api.class.php') or die('Error: 0x0004');
|
||||
(include_once LIBRARY_PATH.'plugin/plugin.function.php') or die('Error: 0x0005');
|
||||
(include_once realpath(dirname(__FILE__)) . '/../../resources/init.php') or die('Error: 0x0000');
|
||||
(include_once LIBRARY_PATH . 'main/main.function.php') or die('Error: 0x0001');
|
||||
(include_once LIBRARY_PATH . 'statistic/statistic.class.php') or die('Error: 0x0002');
|
||||
(include_once LIBRARY_PATH . 'statistic/statistic.function.php') or die('Error: 0x0003');
|
||||
(include_once LIBRARY_PATH . 'api/api.class.php') or die('Error: 0x0004');
|
||||
(include_once LIBRARY_PATH . 'plugin/plugin.function.php') or die('Error: 0x0005');
|
||||
|
||||
$api = new API;
|
||||
|
||||
if (isset($_POST['id']))
|
||||
{
|
||||
if (isset($_POST['id'])) {
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
if (($name = $controller->getStatisticName($_POST['id'])) !== false)
|
||||
{
|
||||
if (($name = $controller->getStatisticName($_POST['id'])) !== false) {
|
||||
if (isset($_POST['plugin']) && trim($_POST['plugin']) != '')
|
||||
pluginLanguage(trim($_POST['plugin']));
|
||||
|
||||
@@ -25,29 +23,28 @@ if (isset($_POST['id']))
|
||||
$statistic = $builder->getArray();
|
||||
|
||||
$log = new LogStatistic();
|
||||
$log->setFile(LOG_PATH.$statistic['raw'].'.csv');
|
||||
$log->setFile(LOG_PATH . $statistic['raw'] . '.csv');
|
||||
$logData = $log->getAll();
|
||||
|
||||
$arr = $info = array();
|
||||
|
||||
foreach ($statistic['columns'] as $column)
|
||||
foreach ($statistic['columns'] as $column) {
|
||||
$arr['cols'][] = array('id' => '', 'label' => _t($column['label']), 'type' => $column['type']);
|
||||
}
|
||||
|
||||
getRowsFromLog($arr, $info, $log->getAll(), $statistic['columns'], $statistic['cycle']);
|
||||
getRowsFromLog($arr, $info, $logData, $statistic['columns'], $statistic['cycle']);
|
||||
|
||||
if (isset($arr['rows']))
|
||||
{
|
||||
if (isset($arr['rows'])) {
|
||||
if (isset($_POST['type']) && $_POST['type'] == 'googleChart')
|
||||
$arr['rows'] = convertForGoogleChart($arr['rows']);
|
||||
|
||||
$arr['rows'] = array_slice($arr['rows'], -2016);
|
||||
$arr['periods'] = $info['periods'];
|
||||
|
||||
foreach (array('min', 'max') as $type)
|
||||
{
|
||||
foreach (array('min', 'max') as $type) {
|
||||
if ($statistic['limits'][$type]['use'] == 'multiply')
|
||||
$arr[$type] = round($info[$type] * $statistic['limits'][$type]['value']);
|
||||
elseif ($statistic['limits'][$type]['use'] == 'fix')
|
||||
{
|
||||
elseif ($statistic['limits'][$type]['use'] == 'fix') {
|
||||
if ($statistic['limits'][$type]['fix'] == true)
|
||||
$arr[$type] = $statistic['limits'][$type]['value'];
|
||||
else
|
||||
@@ -56,23 +53,18 @@ if (isset($_POST['id']))
|
||||
}
|
||||
|
||||
$api->addData('statistic', $arr);
|
||||
}
|
||||
else
|
||||
} else
|
||||
$api->setError('error', 'Empty data.');
|
||||
}
|
||||
else
|
||||
} else
|
||||
$api->setError('error', 'Data not found.');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$statistics = array();
|
||||
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
|
||||
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
foreach ($controller->getStatistics() as $statistic)
|
||||
{
|
||||
foreach ($controller->getStatistics() as $statistic) {
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($statistic);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ foreach ($filesFolders as $file => $info)
|
||||
}
|
||||
|
||||
// Sonstiges
|
||||
if ($otherDistribution['version'] == 'Raspbian GNU/Linux 10' || $otherDistribution['version'] == 'Raspbian GNU/Linux 11')
|
||||
if ($otherDistribution['version'] == 'Raspbian GNU/Linux 10' || $otherDistribution['version'] == 'Raspbian GNU/Linux 11' || $otherDistribution['version'] == 'Debian GNU/Linux 11')
|
||||
$otherDistribution['status'] = true;
|
||||
|
||||
if (isset($_COOKIE['_pi-control_install_language']) && $_COOKIE['_pi-control_install_language'] != '')
|
||||
|
||||
@@ -368,8 +368,15 @@ function urlIsPublic($url)
|
||||
$ip = gethostbyname($url);
|
||||
$long = ip2long($ip);
|
||||
|
||||
if (($long >= 167772160 && $long <= 184549375) || ($long >= -1408237568 && $long <= -1407188993) || ($long >= -1062731776 && $long <= -1062666241) || ($long >= 2130706432 && $long <= 2147483647) || $long == -1)
|
||||
return false;
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
if (($long >= 167772160 && $long <= 184549375) || ($long >= -1408237568 && $long <= -1407188993) || ($long >= -1062731776 && $long <= -1062666241) || ($long >= 2130706432 && $long <= 2147483647) || $long == -1) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (($long >= 3232235520 && $long <= 3232301055) || ($long >= 2886729728 && $long <= 2887778303) || ($long >= 167772160 && $long <= 184549375) || $long == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -614,4 +621,3 @@ function getURLLangParam($echo = false, $html = true, $first = false)
|
||||
|
||||
return $param;
|
||||
}
|
||||
?>
|
||||
@@ -1,22 +1,19 @@
|
||||
var dataSlider = [];
|
||||
var dataPeriods = [];
|
||||
|
||||
function statisticBuilder(builder, plugin)
|
||||
{
|
||||
var jsonData = jQuery.ajax({
|
||||
function statisticBuilder(builder, plugin) {
|
||||
jQuery.ajax({
|
||||
url: 'api/v1/statistic.php',
|
||||
method: 'POST',
|
||||
data: { id: builder.id, plugin: plugin, type: 'googleChart' },
|
||||
dataType: 'json',
|
||||
async: true
|
||||
}).done(function(data)
|
||||
{
|
||||
if (data.error != null)
|
||||
{
|
||||
}).done(function (data) {
|
||||
if (data.error != null) {
|
||||
if (data.error.message == 'Empty data.')
|
||||
jQuery('#chart_log_'+builder.id).html('<br /><br /><strong class="red">' + _t('Es sind noch keine Werte verfügbar. Werte werden alle %%s Minuten eingetragen.', builder.cycle) + '</strong>');
|
||||
jQuery('#chart_log_' + builder.id).html('<br /><br /><strong class="red">' + _t('Es sind noch keine Werte verfügbar. Werte werden alle %%s Minuten eingetragen.', builder.cycle) + '</strong>');
|
||||
else
|
||||
jQuery('#chart_log_'+builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehler: %%s', data.error.message) + '</strong>');
|
||||
jQuery('#chart_log_' + builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehler: %%s', data.error.message) + '</strong>');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -25,12 +22,12 @@ function statisticBuilder(builder, plugin)
|
||||
|
||||
var myData = new google.visualization.DataTable(data.data.statistic);
|
||||
|
||||
jQuery('#chart_log_'+builder.id).html('');
|
||||
var myDashboard = new google.visualization.Dashboard(document.getElementById('dashboard_log_'+builder.id));
|
||||
jQuery('#chart_log_' + builder.id).html('');
|
||||
var myDashboard = new google.visualization.Dashboard(document.getElementById('dashboard_log_' + builder.id));
|
||||
|
||||
dataSlider[builder.id] = new google.visualization.ControlWrapper({
|
||||
'controlType': 'DateRangeFilter',
|
||||
'containerId': 'chart_control_log_'+builder.id,
|
||||
'containerId': 'chart_control_log_' + builder.id,
|
||||
'options': {
|
||||
'filterColumnLabel': _t('Zeit'),
|
||||
'ui': {
|
||||
@@ -41,15 +38,13 @@ function statisticBuilder(builder, plugin)
|
||||
}
|
||||
});
|
||||
|
||||
var t = null;
|
||||
|
||||
var myLine = new google.visualization.ChartWrapper({
|
||||
'chartType' : 'AreaChart',
|
||||
'containerId' : 'chart_log_'+builder.id,
|
||||
'chartType': 'AreaChart',
|
||||
'containerId': 'chart_log_' + builder.id,
|
||||
'options': {
|
||||
vAxis: { title: builder.label, viewWindow: { max: data.data.statistic.max, min: data.data.statistic.min }, textPosition: 'in', textStyle: { fontSize: 11, color: '#AAAAAA' }, titleTextStyle: { fontSize: 11, color: '#AAAAAA' }, gridlines: { color: '#fff' } },
|
||||
vAxis: { title: builder.label, viewWindow: { max: data.data.statistic.max, min: data.data.statistic.min }, textPosition: 'in', textStyle: { fontSize: 11, color: '#AAAAAA' }, titleTextStyle: { fontSize: 11, color: '#AAAAAA' }, gridlines: { color: '#fff' } },
|
||||
dateFormat: 'dd.MM.yy HH:mm',
|
||||
hAxis: { format: 'dd.MM. HH:mm', textPosition: 'out', gridlines: { color: '#fff' } , textStyle: { fontSize: 11, color: '#AAAAAA' }},
|
||||
hAxis: { format: 'dd.MM. HH:mm', textPosition: 'out', gridlines: { color: '#fff' }, textStyle: { fontSize: 11, color: '#AAAAAA' } },
|
||||
focusTarget: 'category',
|
||||
crosshair: { orientation: 'vertical', trigger: 'both', color: '#AAAAAA', opacity: 0.4 },
|
||||
chartArea: { width: '100%', height: '80%', top: 0 },
|
||||
@@ -84,33 +79,42 @@ function statisticBuilder(builder, plugin)
|
||||
}
|
||||
});
|
||||
|
||||
var formatter = new google.visualization.NumberFormat({ suffix: ' '+builder.unit });
|
||||
var formatter = new google.visualization.NumberFormat({ suffix: ' ' + builder.unit });
|
||||
|
||||
for (var i = 1; i < builder.columns.length; i++)
|
||||
formatter.format(myData, i);
|
||||
|
||||
myDashboard.bind(dataSlider[builder.id], myLine);
|
||||
myDashboard.draw(myData);
|
||||
}).fail(function(xhr, textStatus)
|
||||
{
|
||||
jQuery('#chart_log_'+builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehlercode: %%s', xhr.status) + '</strong>');
|
||||
|
||||
setRange();
|
||||
}).fail(function (xhr, textStatus) {
|
||||
jQuery('#chart_log_' + builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehlercode: %%s', xhr.status) + '</strong>');
|
||||
});
|
||||
}
|
||||
|
||||
function changeRange(dropdown)
|
||||
{
|
||||
var days = Array('seven', 'six', 'five', 'four', 'three', 'two', 'one');
|
||||
function changeRange(dropdown) {
|
||||
var day = dropdown.value;
|
||||
window.localStorage.setItem("days", day);
|
||||
|
||||
if (days.indexOf(day) > -1)
|
||||
{
|
||||
for (var data in dataSlider)
|
||||
{
|
||||
if (typeof dataSlider[data] != 'undefined')
|
||||
{
|
||||
dataSlider[data].setState({'lowValue': new Date(dataPeriods[data][day])});
|
||||
setRange();
|
||||
}
|
||||
|
||||
function setRange() {
|
||||
var days = Array('seven', 'six', 'five', 'four', 'three', 'two', 'one');
|
||||
var day = window.localStorage.getItem("days");
|
||||
|
||||
if (days.indexOf(day) > -1) {
|
||||
for (var data in dataSlider) {
|
||||
if (typeof dataSlider[data] != 'undefined') {
|
||||
dataSlider[data].setState({ 'lowValue': new Date(dataPeriods[data][day]) });
|
||||
dataSlider[data].draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
if (window.localStorage.days)
|
||||
document.getElementById("range").value = window.localStorage.days;
|
||||
}, false);
|
||||
@@ -14,15 +14,15 @@
|
||||
<a href="https://willy-tech.de/kontakt/" target="_blank" data-lang="<?php echo $data['language']; ?>"><?php _e('Feedback'); ?></a><br />
|
||||
<a href="<?php echo $data['helpLink']; ?>" target="_blank"><?php _e('Hilfe'); ?></a><br />
|
||||
<a href="https://play.google.com/store/apps/details?id=de.willytech.picontrol" target="_blank" title="<?php _e('Öffne im Play Store'); ?>"><?php _e('App im Play Store'); ?></a><br />
|
||||
<a href="https://bitbucket.org/GSchulte/pi-control/" target="_blank"><?php _e('Git Repo'); ?></a></td>
|
||||
<td rowspan="2"><a href="https://www.die-schultes.eu/" target="_blank"><?php _e('Mein Blog'); ?></a><br />
|
||||
<a href="https://gitea.schultes.dev/gregor/pi-control" target="_blank"><?php _e('Git Repo'); ?></a></td>
|
||||
<td rowspan="2"><a href="https://www.schultes.dev/" target="_blank"><?php _e('Mein Blog'); ?></a><br />
|
||||
<td><?php echo $data['version']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?php _e('LIZENZ'); ?></strong><span><?php _e('Raspberry Pi ist ein Markenzeichen<br />der %s.', '<a href="https://www.raspberrypi.org/" target="_blank">Raspberry Pi Foundation</a>'); ?></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="footer-copyright"><?php _e('Mit %s entwickelt von %s.', '<span style="color: #F44336;">❤</span>', '<a href="https://willy-tech.de/" target="_blank">Willy Fritzsche</a>'); ?> 2013-2017 <br>Weiterentwickelt von <a href="https://www.die-schultes.eu">Gregor Schulte</a> 2021</div>
|
||||
<div id="footer-copyright"><?php _e('Mit %s entwickelt von %s.', '<span style="color: #F44336;">❤</span>', '<a href="https://willy-tech.de/" target="_blank">Willy Fritzsche</a>'); ?> 2013-2017 <br>Weiterentwickelt von <a href="https://www.schultes.dev">Gregor Schulte</a> 2021-2022</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">var errorHandler = '<?php echo $data['errorHandler']; ?>';</script>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<span><?php _e('Zeitraum'); ?></span>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<select onchange="changeRange(this)">
|
||||
<select id="range" onchange="changeRange(this)">
|
||||
<option name="" value="seven"><?php _e('Alles (7 Tage)'); ?></option>
|
||||
<option name="" value="six"><?php _e('Letzten 6 Tage'); ?></option>
|
||||
<option name="" value="five"><?php _e('Letzten 5 Tage'); ?></option>
|
||||
@@ -36,42 +36,43 @@
|
||||
<span><?php _e('Statistik'); ?></span>
|
||||
<?php showSettingsIcon('?s=settings&do=statistic'); ?>
|
||||
</div>
|
||||
<?php if ($data['msgInfo'] == 'invisible') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Alle Statistiken sind ausgeblendet!'); ?></div>
|
||||
</div>
|
||||
<?php } elseif ($data['msgInfo'] == 'empty') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Es sind noch keine Statistiken verfügbar. Werte werden alle 5 Minuten eingetragen.'); ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($data['msgInfo'] == 'invisible') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Alle Statistiken sind ausgeblendet!'); ?></div>
|
||||
</div>
|
||||
<?php } elseif ($data['msgInfo'] == 'empty') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Es sind noch keine Statistiken verfügbar. Werte werden alle 5 Minuten eingetragen.'); ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
<div class="order-3">
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
<div class="box google-controls" id="dashboard_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<div class="inner-header">
|
||||
<span><?php _e($statistic['array']['title']); ?></span>
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
<div class="box google-controls" id="dashboard_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<div class="inner-header">
|
||||
<span><?php _e($statistic['array']['title']); ?></span>
|
||||
</div>
|
||||
<div class="inner text-center padding-0" id="chart_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<img src="public_html/img/loader.svg" style="margin: 20px;" />
|
||||
</div>
|
||||
<div class="inner text-center" id="chart_control_log_<?php echo $statistic['array']['id']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="inner text-center padding-0" id="chart_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<img src="public_html/img/loader.svg" style="margin: 20px;" />
|
||||
</div>
|
||||
<div class="inner text-center" id="chart_control_log_<?php echo $statistic['array']['id']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
||||
<script type="text/javascript" src="public_html/js/statistic_builder.js"></script>
|
||||
<script type="text/javascript">
|
||||
google.load('visualization', '1', {packages:['controls']});
|
||||
google.load('visualization', '51', {
|
||||
packages: ['controls']
|
||||
});
|
||||
google.setOnLoadCallback(createTable);
|
||||
|
||||
function createTable()
|
||||
{
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
statisticBuilder(<?php echo $statistic['json']; ?>, null);
|
||||
<?php } ?>
|
||||
function createTable() {
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
statisticBuilder(<?php echo $statistic['json']; ?>, null);
|
||||
<?php } ?>
|
||||
}
|
||||
</script>
|
||||
@@ -10,13 +10,13 @@ if (!isset($config))
|
||||
'ssh_ip' => '127.0.0.1'
|
||||
),
|
||||
'version' => array(
|
||||
'version' => '2.3.0',
|
||||
'versioncode' => 31,
|
||||
'version' => '2.3.1beta3',
|
||||
'versioncode' => 34,
|
||||
'android_comp_level' => 25
|
||||
),
|
||||
'url' => array(
|
||||
'update' => 'https://pic.die-schultes.eu/service/v1/update/',
|
||||
'updateDownload' => 'https://www.die-schultes.eu/wp-content/uploads/',
|
||||
'update' => 'https://pic.schultes.dev/api/service/v2/update/',
|
||||
'updateDownload' => 'https://pic.schultes.dev/api/download/',
|
||||
'updateNotification' => 'https://pi-control.de/?service=update_notification',
|
||||
'plugin' => 'https://pi-control.de/service/v1/plugin/',
|
||||
'pluginDownload' => 'https://pi-control.de/?service=plugin',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -282,6 +282,17 @@ class StatisticBuilder
|
||||
$this->suffix = isset($suffix) ? $suffix : NULL;
|
||||
$this->label = _t($statistic['label']);
|
||||
$this->unit = $statistic['unit'];
|
||||
if ($statistic['unit'] == 'MB') {
|
||||
$log = new LogStatistic();
|
||||
$log->setFile(LOG_PATH . $this->raw . '.csv');
|
||||
$lastValue = $log->getLast();
|
||||
$log->close();
|
||||
|
||||
if ($lastValue && $lastValue[1] > 999999999) {
|
||||
$this->unit = 'GB';
|
||||
$this->label = 'GB';
|
||||
}
|
||||
}
|
||||
$this->cycle = $statistic['cycle'];
|
||||
$this->limits = $statistic['limits'];
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ $statisticConfig = array(
|
||||
'fix' => true
|
||||
),
|
||||
'max' => array(
|
||||
'value' => 1200,
|
||||
'value' => 2100,
|
||||
'use' => 'fix',
|
||||
'fix' => true
|
||||
)
|
||||
|
||||
@@ -25,10 +25,8 @@ function calculateEmptyRows(&$arr, $columns, $firstTime, $lastTime, $cycle)
|
||||
{
|
||||
$buffer = array();
|
||||
|
||||
if ($lastTime < (time() - ($cycle * 60)))
|
||||
{
|
||||
for ($i = 0; $i < ceil(((time() - ($cycle * 60)) - $lastTime) / ($cycle * 60)); $i++)
|
||||
{
|
||||
if ($lastTime < (time() - ($cycle * 60))) {
|
||||
for ($i = 0; $i < ceil(((time() - ($cycle * 60)) - $lastTime) / ($cycle * 60)); $i++) {
|
||||
$dummy = array($lastTime + (($i + 1) * ($cycle * 60)));
|
||||
|
||||
for ($j = 1; $j < count($columns); $j++)
|
||||
@@ -41,10 +39,8 @@ function calculateEmptyRows(&$arr, $columns, $firstTime, $lastTime, $cycle)
|
||||
|
||||
$buffer = array();
|
||||
|
||||
if (isset($arr['rows']) && count($arr['rows']) < (604800 / ($cycle * 60)))
|
||||
{
|
||||
for ($i = 0; $i < ((604800 / ($cycle * 60)) - count($arr['rows'])); $i++)
|
||||
{
|
||||
if (isset($arr['rows']) && count($arr['rows']) < (604800 / ($cycle * 60))) {
|
||||
for ($i = 0; $i < ((604800 / ($cycle * 60)) - count($arr['rows'])); $i++) {
|
||||
$dummy = array($firstTime - (($i + 1) * ($cycle * 60)));
|
||||
|
||||
for ($j = 1; $j < count($columns); $j++)
|
||||
@@ -63,31 +59,26 @@ function getRowsFromLog(&$arr, &$info, $log, $columns, $cycle)
|
||||
$leapyear = -1;
|
||||
$leapyearSkip = 0;
|
||||
|
||||
foreach ($log as $row)
|
||||
{
|
||||
foreach ($log as $row) {
|
||||
foreach ($row as &$data)
|
||||
$data = trim($data);
|
||||
|
||||
if ($leapyearSkip != 0)
|
||||
{
|
||||
if ($leapyearSkip != 0) {
|
||||
$leapyearSkip--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($leapyear != -1 && $leapyear > date('I', $row[0]))
|
||||
{
|
||||
if ($leapyear != -1 && $leapyear > date('I', $row[0])) {
|
||||
$leapyear = 0;
|
||||
$leapyearSkip = (60/$cycle)-1;
|
||||
$leapyearSkip = (60 / $cycle) - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
$leapyear = date('I', $row[0]);
|
||||
|
||||
if ($lastTime !== NULL && ($lastTime + ($cycle * 60) + 100) < $row[0])
|
||||
{
|
||||
if ($lastTime !== NULL && ($lastTime + ($cycle * 60) + 100) < $row[0]) {
|
||||
$skipped = round(($row[0] - ($lastTime + ($cycle * 60))) / ($cycle * 60));
|
||||
for ($i = 0; $i < $skipped; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $skipped; $i++) {
|
||||
$dummy = array($lastTime + (($i + 1) * ($cycle * 60)));
|
||||
|
||||
for ($j = 1; $j < count($columns); $j++)
|
||||
@@ -99,13 +90,15 @@ function getRowsFromLog(&$arr, &$info, $log, $columns, $cycle)
|
||||
|
||||
$dummy = array((int) $row[0]);
|
||||
|
||||
for ($i = 1; $i < count($columns); $i++)
|
||||
{
|
||||
for ($i = 1; $i < count($columns); $i++) {
|
||||
$rowFloat = 0;
|
||||
|
||||
if (isset($columns[$i]['division']))
|
||||
$rowFloat = (float) round(str_replace(array("\n", ','), array('', '.'), $row[$i]) / $columns[$i]['division'], 2);
|
||||
elseif (isset($columns[$i]['multiplication']))
|
||||
if (isset($columns[$i]['division'])) {
|
||||
if ((float)$log[count($log) - 1][1] > 999999999)
|
||||
$rowFloat = (float) round(str_replace(array("\n", ','), array('', '.'), $row[$i]) / $columns[$i]['division'] / 1024, 2);
|
||||
else
|
||||
$rowFloat = (float) round(str_replace(array("\n", ','), array('', '.'), $row[$i]) / $columns[$i]['division'], 2);
|
||||
} elseif (isset($columns[$i]['multiplication']))
|
||||
$rowFloat = (float) round(str_replace(array("\n", ','), array('', '.'), $row[$i]) * $columns[$i]['multiplication'], 2);
|
||||
else
|
||||
$rowFloat = (float) $row[$i];
|
||||
@@ -133,9 +126,8 @@ function getRowsFromLog(&$arr, &$info, $log, $columns, $cycle)
|
||||
|
||||
function convertForGoogleChart($rows)
|
||||
{
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
$dummy = array('c' => array(array('v' => 'Date('.date('Y,'.(date('m', $row[0])-1).',d,H,i', $row[0]).')')));
|
||||
foreach ($rows as $index => $row) {
|
||||
$dummy = array('c' => array(array('v' => 'Date(' . date('Y,' . (date('m', $row[0]) - 1) . ',d,H,i', $row[0]) . ')')));
|
||||
|
||||
unset($row[0]);
|
||||
|
||||
@@ -147,4 +139,3 @@ function convertForGoogleChart($rows)
|
||||
|
||||
return $rows;
|
||||
}
|
||||
?>
|
||||
@@ -253,7 +253,8 @@ class UpdateController
|
||||
|
||||
if (!class_exists('cURL'))
|
||||
(include LIBRARY_PATH.'curl/curl.class.php');
|
||||
$curl = new cURL($this->updateDownloadURL.'&'.http_build_query(array('file' => $version->getFilename())));
|
||||
|
||||
$curl = new cURL($this->updateDownloadURL . $version->getFilename());
|
||||
$curlStatus = $curl->downloadFile(UPDATE_PATH.'update.zip');
|
||||
|
||||
if (!is_bool($curlStatus))
|
||||
@@ -268,7 +269,7 @@ class UpdateController
|
||||
return $curl->getStatusCode();
|
||||
}
|
||||
|
||||
if (md5_file(UPDATE_PATH.'update.zip') !== $version->getChecksum())
|
||||
if (hash_file('sha256', UPDATE_PATH.'update.zip') !== $version->getChecksum())
|
||||
{
|
||||
unlink(UPDATE_PATH.'update.zip');
|
||||
return 1;
|
||||
@@ -439,4 +440,3 @@ class Update
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user