Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f7e0f37528 | |||
| f803effbbd | |||
| fcceec8545 | |||
| 130dee67ea | |||
| 79c7fbc841 | |||
|
|
57608f3b2f | ||
|
|
1e60371abe | ||
|
|
79fc07e010 | ||
|
|
db683a5b19 | ||
|
|
3ebc78f14d | ||
|
|
588c82f4e8 | ||
|
|
22fa53e3a3 | ||
|
|
1257825709 | ||
|
|
6f819ed9f5 | ||
|
|
6adb4fe93e | ||
|
|
97d666a794 |
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>
|
||||
@@ -1,7 +0,0 @@
|
||||
# Pi Control
|
||||
|
||||
## Installation
|
||||
[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.
|
||||
@@ -1,88 +0,0 @@
|
||||
<?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');
|
||||
|
||||
$api = new API;
|
||||
|
||||
if (isset($_POST['id']))
|
||||
{
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
if (($name = $controller->getStatisticName($_POST['id'])) !== false)
|
||||
{
|
||||
if (isset($_POST['plugin']) && trim($_POST['plugin']) != '')
|
||||
pluginLanguage(trim($_POST['plugin']));
|
||||
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($name, (isset($_POST['plugin']) && trim($_POST['plugin']) != '') ? $_POST['plugin'] : NULL);
|
||||
$statistic = $builder->getArray();
|
||||
|
||||
$log = new LogStatistic();
|
||||
$log->setFile(LOG_PATH.$statistic['raw'].'.csv');
|
||||
|
||||
$arr = $info = array();
|
||||
|
||||
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']);
|
||||
|
||||
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)
|
||||
{
|
||||
if ($statistic['limits'][$type]['use'] == 'multiply')
|
||||
$arr[$type] = round($info[$type] * $statistic['limits'][$type]['value']);
|
||||
elseif ($statistic['limits'][$type]['use'] == 'fix')
|
||||
{
|
||||
if ($statistic['limits'][$type]['fix'] == true)
|
||||
$arr[$type] = $statistic['limits'][$type]['value'];
|
||||
else
|
||||
$arr[$type] = round($info[$type]);
|
||||
}
|
||||
}
|
||||
|
||||
$api->addData('statistic', $arr);
|
||||
}
|
||||
else
|
||||
$api->setError('error', 'Empty data.');
|
||||
}
|
||||
else
|
||||
$api->setError('error', 'Data not found.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$statistics = array();
|
||||
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
|
||||
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
foreach ($controller->getStatistics() as $statistic)
|
||||
{
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($statistic);
|
||||
|
||||
$array = $builder->getArray();
|
||||
if (!in_array($builder->getId(), $hiddenStatistics))
|
||||
$statistics[] = array('array' => $array);
|
||||
}
|
||||
|
||||
$api->addData('statistics', $statistics);
|
||||
$api->addData('hidden', $hiddenStatistics);
|
||||
}
|
||||
|
||||
$api->display();
|
||||
7
backend/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Pi Control
|
||||
|
||||
## Installation
|
||||
[Pi Control Installation](https://pi-control.de/install/)
|
||||
|
||||
## Bei Fragen oder Problemen
|
||||
Ü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
|
||||
101
backend/api/v1/statistic.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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');
|
||||
|
||||
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
||||
|
||||
if ($requestMethod == 'GET') {
|
||||
$log = new LogStatistic();
|
||||
$log->setFile(LOG_PATH . 'statistic/' . $_GET['statistic'] . '.csv');
|
||||
$data = array();
|
||||
$data['data'] = array();
|
||||
$limit = 2016;
|
||||
if (isset($_GET['limit'])) {
|
||||
$limit = $_GET['limit'];
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($log->getAll() as $row) {
|
||||
if ($i >= 2016 - $limit) {
|
||||
array_push($data['data'], array('time' => (int)$row[0], 'value' => (float)$row[1]));
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo json_encode($data);
|
||||
} else {
|
||||
$api = new API;
|
||||
|
||||
if (isset($_POST['id'])) {
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
if (($name = $controller->getStatisticName($_POST['id'])) !== false) {
|
||||
if (isset($_POST['plugin']) && trim($_POST['plugin']) != '')
|
||||
pluginLanguage(trim($_POST['plugin']));
|
||||
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($name, (isset($_POST['plugin']) && trim($_POST['plugin']) != '') ? $_POST['plugin'] : NULL);
|
||||
$statistic = $builder->getArray();
|
||||
|
||||
$log = new LogStatistic();
|
||||
$log->setFile(LOG_PATH . $statistic['raw'] . '.csv');
|
||||
$logData = $log->getAll();
|
||||
|
||||
$arr = $info = array();
|
||||
|
||||
foreach ($statistic['columns'] as $column) {
|
||||
$arr['cols'][] = array('id' => '', 'label' => _t($column['label']), 'type' => $column['type']);
|
||||
}
|
||||
|
||||
getRowsFromLog($arr, $info, $logData, $statistic['columns'], $statistic['cycle']);
|
||||
|
||||
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) {
|
||||
if ($statistic['limits'][$type]['use'] == 'multiply')
|
||||
$arr[$type] = round($info[$type] * $statistic['limits'][$type]['value']);
|
||||
elseif ($statistic['limits'][$type]['use'] == 'fix') {
|
||||
if ($statistic['limits'][$type]['fix'] == true)
|
||||
$arr[$type] = $statistic['limits'][$type]['value'];
|
||||
else
|
||||
$arr[$type] = round($info[$type]);
|
||||
}
|
||||
}
|
||||
|
||||
$api->addData('statistic', $arr);
|
||||
} else
|
||||
$api->setError('error', 'Empty data.');
|
||||
} else
|
||||
$api->setError('error', 'Data not found.');
|
||||
} else {
|
||||
$statistics = array();
|
||||
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
|
||||
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
foreach ($controller->getStatistics() as $statistic) {
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($statistic);
|
||||
|
||||
$array = $builder->getArray();
|
||||
if (!in_array($builder->getId(), $hiddenStatistics))
|
||||
$statistics[] = array('array' => $array);
|
||||
}
|
||||
|
||||
$api->addData('statistics', $statistics);
|
||||
$api->addData('hidden', $hiddenStatistics);
|
||||
}
|
||||
|
||||
$api->display();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 162 B After Width: | Height: | Size: 162 B |
|
Before Width: | Height: | Size: 194 B After Width: | Height: | Size: 194 B |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 883 B After Width: | Height: | Size: 883 B |
|
Before Width: | Height: | Size: 993 B After Width: | Height: | Size: 993 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 911 B After Width: | Height: | Size: 911 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 446 B |
|
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 259 B |
|
Before Width: | Height: | Size: 897 B After Width: | Height: | Size: 897 B |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -48,10 +48,10 @@
|
||||
<td><?php _e('SSH2-Erweiterung installiert'); ?></td>
|
||||
<td class="<?php echo ($data['phpSSH']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpSSH']['status'] == true) ? '✔' : '✖ <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'#phpssh'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!--<tr>
|
||||
<td><?php _e('Mcrypt-Erweiterung installiert'); ?></td>
|
||||
<td class="<?php echo ($data['phpMcrypt']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpMcrypt']['status'] == true) ? '✔' : '✖ <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'?s=view&i=12'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
|
||||
</tr>
|
||||
</tr>-->
|
||||
<tr>
|
||||
<td><?php _e('CLI-Erweiterung installiert'); ?></td>
|
||||
<td class="<?php echo ($data['phpCLI']['status'] == true) ? 'green' : 'red'; ?>"><?php echo ($data['phpCLI']['status'] == true) ? '✔' : '✖ <a style="color: inherit; text-decoration: underline" href="'.$data['configHelp'].'?s=view&i=13'.getURLLangParam().'" target="_blank">'._t('Anleitung zur Installation').'</a>'; ?></td>
|
||||
@@ -7,7 +7,7 @@ $tpl->setHeaderTitle(_t('Anforderungen'));
|
||||
|
||||
// PHP
|
||||
$phpVersion = array('version' => PHP_VERSION, 'status' => false);
|
||||
$phpSSH = array('status' => false);
|
||||
$phpSSH = array('status' => true);
|
||||
$phpMcrypt = array('status' => false);
|
||||
$phpCLI = array('status' => false);
|
||||
$phpCURL = array('status' => false);
|
||||
@@ -25,10 +25,10 @@ if (version_compare(PHP_VERSION, '7.0.0') >= 0)
|
||||
if (extension_loaded('ssh2'))
|
||||
$phpSSH['status'] = true;
|
||||
|
||||
//if (function_exists('mcrypt_encrypt') !== false)
|
||||
$phpMcrypt['status'] = true;
|
||||
#if (function_exists('mcrypt_encrypt') !== false)
|
||||
# $phpMcrypt['status'] = true;
|
||||
|
||||
if (trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.4-cli | grep Status: ')) != '')
|
||||
if (trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.4-cli | grep Status: ')) != '' || trim(exec('dpkg -s php8.0-cli | grep Status: ')) != '' || trim(exec('dpkg -s php8.1-cli | grep Status: ')) != '' || trim(exec('dpkg -s php8.2-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 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'] != '')
|
||||
@@ -71,7 +71,8 @@ else
|
||||
setCookie('_pi-control_install_language', $globalLanguage);
|
||||
|
||||
// Button
|
||||
if ($phpVersion['status'] === false || $phpSSH['status'] === false || $phpMcrypt['status'] === false || $phpCLI['status'] === false || $phpCURL['status'] === false || $phpZipArchive['status'] === false || $phpAllowUrlFopen['status'] === false || $filesFoldersExist['status'] === false || $filesFoldersPermission['status'] === false || $otherDistribution['status'] === false || $otherCookie['status'] === false)
|
||||
//if ($phpVersion['status'] === false || $phpSSH['status'] === false || $phpMcrypt['status'] === false || $phpCLI['status'] === false || $phpCURL['status'] === false || $phpZipArchive['status'] === false || $phpAllowUrlFopen['status'] === false || $filesFoldersExist['status'] === false || $filesFoldersPermission['status'] === false || $otherDistribution['status'] === false || $otherCookie['status'] === false)
|
||||
if ($phpVersion['status'] === false || $phpSSH['status'] === false || $phpCLI['status'] === false || $phpCURL['status'] === false || $phpZipArchive['status'] === false || $phpAllowUrlFopen['status'] === false || $filesFoldersExist['status'] === false || $filesFoldersPermission['status'] === false || $otherDistribution['status'] === false || $otherCookie['status'] === false)
|
||||
$error = true;
|
||||
|
||||
$tpl->assign('phpVersion', $phpVersion);
|
||||
@@ -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)
|
||||
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;
|
||||
}
|
||||
?>
|
||||