Installer angepasst für aktuelle Systeme
This commit is contained in:
@@ -8,73 +8,94 @@ const PICONTROL = true;
|
||||
(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;
|
||||
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
||||
|
||||
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']);
|
||||
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;
|
||||
|
||||
getRowsFromLog($arr, $info, $logData, $statistic['columns'], $statistic['cycle']);
|
||||
if (isset($_POST['id'])) {
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
if (isset($arr['rows'])) {
|
||||
if (isset($_POST['type']) && $_POST['type'] == 'googleChart')
|
||||
$arr['rows'] = convertForGoogleChart($arr['rows']);
|
||||
if (($name = $controller->getStatisticName($_POST['id'])) !== false) {
|
||||
if (isset($_POST['plugin']) && trim($_POST['plugin']) != '')
|
||||
pluginLanguage(trim($_POST['plugin']));
|
||||
|
||||
$arr['rows'] = array_slice($arr['rows'], -2016);
|
||||
$arr['periods'] = $info['periods'];
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($name, (isset($_POST['plugin']) && trim($_POST['plugin']) != '') ? $_POST['plugin'] : NULL);
|
||||
$statistic = $builder->getArray();
|
||||
|
||||
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]);
|
||||
}
|
||||
$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']);
|
||||
}
|
||||
|
||||
$api->addData('statistic', $arr);
|
||||
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', 'Empty data.');
|
||||
} else
|
||||
$api->setError('error', 'Data not found.');
|
||||
} else {
|
||||
$statistics = array();
|
||||
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
|
||||
$api->setError('error', 'Data not found.');
|
||||
} else {
|
||||
$statistics = array();
|
||||
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
|
||||
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
$controller = new StatisticController();
|
||||
$controller->loadStatistics();
|
||||
|
||||
foreach ($controller->getStatistics() as $statistic) {
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($statistic);
|
||||
foreach ($controller->getStatistics() as $statistic) {
|
||||
$builder = new StatisticBuilder();
|
||||
$builder->loadFromFile($statistic);
|
||||
|
||||
$array = $builder->getArray();
|
||||
if (!in_array($builder->getId(), $hiddenStatistics))
|
||||
$statistics[] = array('array' => $array);
|
||||
$array = $builder->getArray();
|
||||
if (!in_array($builder->getId(), $hiddenStatistics))
|
||||
$statistics[] = array('array' => $array);
|
||||
}
|
||||
|
||||
$api->addData('statistics', $statistics);
|
||||
$api->addData('hidden', $hiddenStatistics);
|
||||
}
|
||||
|
||||
$api->addData('statistics', $statistics);
|
||||
$api->addData('hidden', $hiddenStatistics);
|
||||
$api->display();
|
||||
}
|
||||
|
||||
$api->display();
|
||||
|
||||
Reference in New Issue
Block a user