Umbau der Statistik Ausgabe (each enfernt)

Optimierungen
This commit is contained in:
Gregor Schulte
2021-11-29 15:23:19 +01:00
parent b303dd00d6
commit c464f9e3a3
18 changed files with 580 additions and 545 deletions

124
.gitignore vendored
View File

@@ -1,50 +1,100 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# Node artifact files
node_modules/
dist/
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea
# Compiled Java class files
*.class
# Generated files
.idea/**/contentModel.xml
# Compiled Python bytecode
*.py[cod]
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Log files
*.log
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
Pi Control.iml
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# Package files
*.jar
# CMake
cmake-build-*/
# Maven
target/
dist/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# JetBrains IDE
.idea/
# File-based project format
*.iws
# Unit test reports
TEST*.xml
# IntelliJ
out/
# Generated by MacOS
.DS_Store
# mpeltonen/sbt-idea plugin
.idea_modules/
# Generated by Windows
Thumbs.db
# JIRA plugin
atlassian-ide-plugin.xml
# Applications
*.app
*.exe
*.war
# Cursive Clojure plugin
.idea/replstate.xml
# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### ZendFramework template
# Composer files
composer.phar
vendor/
# Local configs
config/autoload/*.local.php
# Binary gettext files
*.mo
# Data
data/logs/
data/cache/
data/sessions/
data/tmp/
temp/
#Doctrine 2
data/DoctrineORMModule/Proxy/
data/DoctrineORMModule/cache/
# Legacy ZF1
demos/
extras/documentation

View File

@@ -1,5 +1,5 @@
<?php
define('PICONTROL', true);
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');
@@ -86,4 +86,3 @@ else
}
$api->display();
?>

View File

@@ -1,5 +1,5 @@
<?php
define('PICONTROL', true);
const PICONTROL = true;
$doNotCheckForAuthentification = true;
(include_once realpath(dirname(__FILE__)).'/resources/init.php') or die('Error: 0x0000');

View File

@@ -41,12 +41,12 @@
<div class="inner-table">
<table class="table table-borderless table-form">
<tr>
<td style="width: 50%;"><?php _e('Version %s', '>= 5.5'); ?></td>
<td style="width: 50%;"><?php _e('Version %s', '>= 7.0'); ?></td>
<td class="<?php echo ($data['phpVersion']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpVersion']['status'] == true) ? '&#10004;' : '&#10006;'; echo ' '.$data['phpVersion']['version']; ?></td>
</tr>
<tr>
<td><?php _e('SSH2-Erweiterung installiert'); ?></td>
<td class="<?php echo ($data['phpSSH']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpSSH']['status'] == true) ? '&#10004;' : '&#10006; <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'?s=view&amp;i=11'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
<td class="<?php echo ($data['phpSSH']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpSSH']['status'] == true) ? '&#10004;' : '&#10006; <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'#phpssh'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
</tr>
<tr>
<td><?php _e('Mcrypt-Erweiterung installiert'); ?></td>
@@ -58,7 +58,7 @@
</tr>
<tr>
<td><?php _e('cURL-Erweiterung installiert'); ?></td>
<td class="<?php echo ($data['phpCURL']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpCURL']['status'] == true) ? '&#10004;' : '&#10006; <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'?s=view&amp;i=14'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
<td class="<?php echo ($data['phpCURL']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpCURL']['status'] == true) ? '&#10004;' : '&#10006; <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'#phpcurl'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
</tr>
<tr>
<td><?php _e('ZipArchive-Erweiterung installiert'); ?></td>

View File

@@ -19,7 +19,7 @@ $otherDistribution = array('version' => rpi_getDistribution(), 'status' => false
$otherCookie = array('status' => false);
$error = false;
if (version_compare(PHP_VERSION, '5.5.0') >= 0)
if (version_compare(PHP_VERSION, '7.0.0') >= 0)
$phpVersion['status'] = true;
if (extension_loaded('ssh2'))
@@ -28,7 +28,7 @@ if (extension_loaded('ssh2'))
//if (function_exists('mcrypt_encrypt') !== false)
$phpMcrypt['status'] = true;
if (trim(exec('dpkg -s php5-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.0-cli | grep Status: ')) || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '')
if (trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.4-cli | grep Status: ')) != '')
$phpCLI['status'] = true;
if (function_exists('curl_init') !== false)
@@ -62,7 +62,7 @@ foreach ($filesFolders as $file => $info)
}
// Sonstiges
if ($otherDistribution['version'] == 'Raspbian GNU/Linux 7' || $otherDistribution['version'] == 'Raspbian GNU/Linux 8' || $otherDistribution['version'] == 'Raspbian GNU/Linux 9' || $otherDistribution['version'] == 'Raspbian GNU/Linux 10')
if ($otherDistribution['version'] == 'Raspbian GNU/Linux 10' || $otherDistribution['version'] == 'Raspbian GNU/Linux 11')
$otherDistribution['status'] = true;
if (isset($_COOKIE['_pi-control_install_language']) && $_COOKIE['_pi-control_install_language'] != '')

View File

@@ -16,7 +16,7 @@ if (!isset($config))
'update' => 'https://pi-control.de/service/v1/update/',
'updateDownload' => 'https://pi-control.de/?service=update',
'updateNotification' => 'https://pi-control.de/?service=update_notification',
'help' => 'https://pi-control.de/help/'
'help' => 'https://www.die-schultes.eu/pi-control-hilfe/'
)
);
}

View File

@@ -14,17 +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('&Ouml;ffne im Play Store'); ?>"><?php _e('App im Play Store'); ?></a><br />
<a href="https://gitlab.com/pi-control" target="_blank"><?php _e('GitLab'); ?></a></td>
<td rowspan="2"><a href="https://willy-tech.de/" target="_blank"><?php _e('Mein Blog'); ?></a><br />
<a href="https://twitter.com/Willys_TechBlog" target="_blank"><?php _e('Twitter'); ?></a><br />
<a href="https://www.paypal.me/fritzsche" target="_blank"><?php _e('Spenden'); ?></a></td>
<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 />
<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;">&#10084;</span>', '<a href="https://willy-tech.de/" target="_blank">Willy Fritzsche</a>'); ?> 2013-2017</div>
<div id="footer-copyright"><?php _e('Mit %s entwickelt von %s.', '<span style="color: #F44336;">&#10084;</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>
</div>
<script type="text/javascript">var errorHandler = '<?php echo $data['errorHandler']; ?>';</script>

View File

@@ -38,7 +38,7 @@ $tpl->assign('configHelpFilesFolders', $config['url']['help'].'?s=view&amp;i=1'.
$tpl->assign('configHelpCron', $config['url']['help'].'?s=view&amp;i=10'.getURLLangParam());
$tpl->assign('cronEntry', $cronEntry);
$tpl->assign('cronMatch', $cronMatch);
$tpl->assign('cronPHPCLI', ($cronPHPCLI = (trim(exec('dpkg -s php5-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.0-cli | grep Status: ')) != '') ? true : false));
$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('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]));

View File

@@ -1,6 +1,6 @@
<?php
if (PHP_SAPI != 'cli') exit();
define('PICONTROL', true);
const PICONTROL = true;
$doNotCheckForAuthentification = true;
(include_once realpath(dirname(__FILE__)).'/../init.php') or die('Error: 0x0000');
@@ -13,4 +13,3 @@ $log->setFile(LOG_PATH.'statistic/coretemp.csv');
$log->setLimit(2016);
$log->add(array(time(), rpi_getCoreTemprature()));
$log->close();
?>

View File

@@ -1,6 +1,6 @@
<?php
if (PHP_SAPI != 'cli') exit();
define('PICONTROL', true);
const PICONTROL = true;
$doNotCheckForAuthentification = true;
(include_once realpath(dirname(__FILE__)).'/../init.php') or die('Error: 0x0000');
@@ -31,6 +31,5 @@ foreach ($fileArray as $file)
}
}
if (trim(exec('dpkg -s php5-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.0-cli | grep Status: ')) || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '')
if (trim(exec('dpkg -s php7.0-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '')
setConfig('cron:execution.cron', time());
?>

View File

@@ -10,7 +10,7 @@ if (!isset($config))
'ssh_ip' => '127.0.0.1'
),
'version' => array(
'version' => '2.1.2',
'version' => '2.2.0beta',
'versioncode' => 29,
'android_comp_level' => 25
),

View File

@@ -147,4 +147,3 @@ class API
return true;
}
}
?>

View File

@@ -35,4 +35,3 @@ function getCacheName($file)
return $file;
}
}
?>

View File

@@ -749,8 +749,10 @@ class PiTpl
$sshPassword = getConfig('ssh:token_'.$token.'.password', '');
$sshPrivateKey = base64_decode(getConfig('ssh:token_'.$token.'.privateKey', ''));
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$sshPassword = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $token2, base64_decode($sshPassword), MCRYPT_MODE_ECB, $iv);
#$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
#$sshPassword = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $token2, base64_decode($sshPassword), MCRYPT_MODE_ECB, $iv);
$sshPassword = openssl_encrypt(base64_decode($sshPassword), 'aes-256-cbc', $token2, 0, $iv);
$sshPassword = rtrim($sshPassword, "\0");
$ssh = new Net_SSH2('127.0.0.1', $sshPort);
@@ -904,8 +906,10 @@ class PiTpl
$uniqid = generateUniqId(16, false);
$uniqid2 = generateUniqId(32, false);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$SSHInfo['password'] = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $uniqid2, $password, MCRYPT_MODE_ECB, $iv));
#$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
#$SSHInfo['password'] = base64_encode(openssl_encrypt(MCRYPT_RIJNDAEL_256, $uniqid2, $password, MCRYPT_MODE_ECB, $iv));
$SSHInfo['password'] = openssl_encrypt($password, 'aes-256-cbc', $uniqid, 0, $iv);
$SSHInfo['privateKey'] = $privateKey;

View File

@@ -41,8 +41,7 @@ class LogStatistic
if ($moreThanOne === false)
fputcsv($this->stream, $entry);
else
{
else {
foreach ($entry as $item)
fputcsv($this->stream, $item);
}
@@ -84,8 +83,7 @@ class LogStatistic
if (!is_array(($entries = $this->getAll())))
return false;
if (count($entries) >= $this->limit)
{
if (count($entries) >= $this->limit) {
$unsetLineCount = count($entries) - $this->limit;
for ($i = 0; $i <= $unsetLineCount; $i++)
@@ -103,12 +101,10 @@ class LogStatistic
public function deleteLog()
{
if (is_file($this->file))
{
if (is_file($this->file)) {
if (unlink($this->file) or exit(_t('Konnte Log-Datei nicht l&ouml;schen: %s', $this->file)))
return true;
}
else
} else
return false;
}
@@ -155,29 +151,29 @@ class StatisticController
public function loadStatistics($folder = NULL)
{
$files = array();
if ($folder == NULL)
$possibleFolders = array(LOG_PATH);
else
$possibleFolders = array(LOG_PATH . $folder);
while (list($key, $folder) = each($possibleFolders))
{
foreach (@scandir($folder) as $file)
{
if ($file[0] != '.')
{
if (is_file($folder.'/'.$file) && substr($file, -4) == '.csv')
foreach ($possibleFolders as $folder) {
$this->statistics = array_merge($this->statistics, $this->loadStatisticsIterator($folder));
}
}
private function loadStatisticsIterator($folder)
{
$fileNames = array();
$files = array_diff(@scandir($folder), array('..', '.'));
foreach ($files as $file) {
$absolutePath = $folder . '/' . $file;
if (is_file($absolutePath) && substr($file, -4) == '.csv') {
$fileName = str_replace(LOG_PATH, '', $folder) . substr($file, 0, -4);
$this->statistics[substr(md5($fileName), 0, 8)] = $fileName;
}
elseif (is_dir($folder.$file))
$possibleFolders[] = $folder.$file.'/';
}
}
$fileNames[substr(md5($fileName), 0, 8)] = $fileName;
} elseif (is_dir($absolutePath))
$fileNames = array_merge($fileNames, $this->loadStatisticsIterator($folder . $file . '/'));
}
return $fileNames;
}
public function getStatisticID($name)
@@ -216,15 +212,12 @@ class StatisticController
if (!is_bool($isID))
return false;
if ($isID === true)
{
if ($isID === true) {
if ($this->getStatisticName($value) !== false)
return true;
else
return false;
}
elseif ($isID === false)
{
} elseif ($isID === false) {
if ($this->getStatisticID($value) !== false)
return true;
else
@@ -264,17 +257,14 @@ class StatisticBuilder
$this->raw = $name;
if (strpos($name, '/') !== false)
{
if (strpos($name, '/') !== false) {
$explodes = explode('/', strrev($name), 2);
$name = strrev($explodes[0]);
$prefix = strrev($explodes[1]) . '/';
}
if (!isset($statisticConfig[$name]) && isset($statisticConfig[substr($name, 0, strpos($name, '_'))]))
{
if (strpos($name, '_') !== false)
{
if (!isset($statisticConfig[$name]) && isset($statisticConfig[substr($name, 0, strpos($name, '_'))])) {
if (strpos($name, '_') !== false) {
$explodes = explode('_', strrev($name), 2);
$suffix = strrev($explodes[0]);
$name = strrev($explodes[1]);
@@ -295,10 +285,8 @@ class StatisticBuilder
$this->cycle = $statistic['cycle'];
$this->limits = $statistic['limits'];
foreach ($statistic['columns'] as $column)
{
foreach ($column as &$values)
{
foreach ($statistic['columns'] as $column) {
foreach ($column as &$values) {
if (is_string($values))
$values = _t($values);
}
@@ -348,7 +336,8 @@ class StatisticBuilder
public function getJSON()
{
$json = json_encode(array(
$json = json_encode(
array(
'id' => $this->getId(),
'label' => $this->label,
'unit' => $this->unit,
@@ -360,4 +349,3 @@ class StatisticBuilder
return $json;
}
}
?>

View File

@@ -1,5 +1,5 @@
<?php
define('PICONTROL', true);
const PICONTROL = true;
(include_once realpath(dirname(__FILE__)).'/../init.php') or die('Error: 0x0000');
(include_once LIBRARY_PATH.'main/tpl.class.php') or die('Error: 0x0001');