7 Commits
2.3.1 ... main

Author SHA1 Message Date
db3d54a835 Umstellung auf GET Methoden
Zusammenfassen von Anfragen
2023-10-27 23:05:48 +02:00
37e155a9b1 Vorbereitungen SSH Login 2023-09-23 16:17:39 +02:00
69e2ee972c README.md aktualisiert 2023-08-18 21:26:56 +02:00
c6fb90e562 Netzwerkdaten anzeigen 2023-08-04 21:30:36 +02:00
9f2d29c8fe PHP CLI in Cron prüfen 2023-05-03 15:17:04 +02:00
ec8a954b0b Auslesen von Netzwerkinformationen 2023-05-02 22:03:09 +02:00
f2938cf701 Installer angepasst für aktuelle Systeme 2023-04-21 09:17:10 +02:00
21 changed files with 550 additions and 616 deletions

View File

@@ -4,4 +4,4 @@
[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
Über das [Ticketsystem](https://git.schultes.dev/gregor/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

View File

@@ -1,67 +1,69 @@
<?php
define('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.'main/rpi.function.php') or die('Error: 0x0002');
(include_once LIBRARY_PATH.'api/api.class.php') or die('Error: 0x0003');
(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 . 'main/rpi.function.php') or die('Error: 0x0002');
(include_once LIBRARY_PATH . 'api/api.class.php') or die('Error: 0x0003');
$api = new API;
if (isset($_POST['data']))
{
if (isset($_POST['data'])) {
$datas = explode(';', $_POST['data']);
foreach ($datas as $data)
{
switch ($data)
{
case 'startTime':
$api->addData('startTime', formatTime(time() - rpi_getRuntime()));
break;
case 'runtime':
$api->addData('runtime', getDateFormat(rpi_getRuntime()));
break;
case 'cpuClock':
$api->addData('cpuClock', rpi_getCpuClock());
break;
case 'cpuLoad':
$api->addData('cpuLoad', rpi_getCpuLoad(true));
break;
case 'cpuTemp':
$api->addData('cpuTemp', numberFormat(rpi_getCoreTemprature()));
break;
case 'ramPercentage':
$ram = rpi_getMemoryUsage();
$api->addData('ramPercentage', $ram['percent']);
break;
case 'memoryUsed':
$memory = rpi_getMemoryInfo();
$api->addData('memoryUsed', sizeUnit($memory[count($memory)-1]['used']));
break;
case 'memoryFree':
$memory = rpi_getMemoryInfo();
$api->addData('memoryFree', sizeUnit($memory[count($memory)-1]['free']));
break;
case 'memoryTotal':
$memory = rpi_getMemoryInfo();
$api->addData('memoryTotal', sizeUnit($memory[count($memory)-1]['total']));
break;
case 'memoryPercent':
$memory = rpi_getMemoryInfo();
$api->addData('memoryPercent', $memory[count($memory)-1]['percent']);
break;
case 'devices':
$api->addData('devices', rpi_getUsbDevices());
break;
default:
$api->setError('error', 'Data for "'.$data.'" are not available.');
break 2;
}
}
}
else
setData($datas, $api);
} elseif (isset($_GET['data'])) {
$datas = explode(';', $_GET['data']);
setData($datas, $api);
} else
$api->setError('error', 'No data set.');
$api->display();
?>
function setData($datas, $api)
{
foreach ($datas as $data) {
switch ($data) {
case 'startTime':
$api->addData('startTime', formatTime(time() - rpi_getRuntime()));
break;
case 'runtime':
$api->addData('runtime', getDateFormat(rpi_getRuntime()));
break;
case 'cpuClock':
$api->addData('cpuClock', rpi_getCpuClock());
break;
case 'cpuLoad':
$api->addData('cpuLoad', rpi_getCpuLoad(false));
break;
case 'cpuTemp':
$api->addData('cpuTemp', numberFormat(rpi_getCoreTemprature()));
break;
case 'ramPercentage':
$ram = rpi_getMemoryUsage();
$api->addData('ramPercentage', $ram['percent']);
break;
case 'memoryUsed':
$memory = rpi_getMemoryInfo();
$api->addData('memoryUsed', sizeUnit($memory[count($memory) - 1]['used']));
break;
case 'memoryFree':
$memory = rpi_getMemoryInfo();
$api->addData('memoryFree', sizeUnit($memory[count($memory) - 1]['free']));
break;
case 'memoryTotal':
$memory = rpi_getMemoryInfo();
$api->addData('memoryTotal', sizeUnit($memory[count($memory) - 1]['total']));
break;
case 'memoryPercent':
$memory = rpi_getMemoryInfo();
$api->addData('memoryPercent', $memory[count($memory) - 1]['percent']);
break;
case 'devices':
$api->addData('devices', rpi_getUsbDevices());
break;
default:
$api->setError('error', 'Data for "' . $data . '" are not available.');
break 2;
}
}
}

View File

@@ -111,4 +111,3 @@ if (isset($_POST['logout']))
}
$api->display();
?>

View File

@@ -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();

View File

@@ -7,4 +7,3 @@ $apiVersions[0] = array('versioncode' => 1,
'date' => 1443909600);
echo json_encode(array('versions' => $apiVersions, 'latest' => $apiLatest));
?>

View File

@@ -1,13 +1,13 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'install/install.function.php') or die('Error: 0x0011');
(include_once LIBRARY_PATH . 'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH . 'install/install.function.php') or die('Error: 0x0011');
$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);
@@ -15,7 +15,7 @@ $phpZipArchive = array('status' => false);
$phpAllowUrlFopen = array('status' => false);
$filesFoldersExist = array('count' => 0, 'status' => true);
$filesFoldersPermission = array('count' => 0, 'status' => true);
$otherDistribution = array('version' => rpi_getDistribution(), 'status' => false);
$otherDistribution = array('version' => rpi_getDistribution(), 'status' => true);
$otherCookie = array('status' => false);
$error = false;
@@ -28,7 +28,7 @@ if (extension_loaded('ssh2'))
#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 php-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)
@@ -43,18 +43,14 @@ if (ini_get('allow_url_fopen') !== false)
// Dateien und Ordner
$filesFolders = fileFolderPermission();
foreach ($filesFolders as $file => $info)
{
if ($info['error'] === true)
{
if ($info['existsBool'] === false || $info['filesizeBool'] === false)
{
foreach ($filesFolders as $file => $info) {
if ($info['error'] === true) {
if ($info['existsBool'] === false || $info['filesizeBool'] === false) {
$filesFoldersExist['count'] += 1;
$filesFoldersExist['status'] = false;
}
if ($info['permissionBool'] === false || $info['userGroupBool'] === false)
{
if ($info['permissionBool'] === false || $info['userGroupBool'] === false) {
$filesFoldersPermission['count'] += 1;
$filesFoldersPermission['status'] = false;
}
@@ -62,8 +58,8 @@ foreach ($filesFolders as $file => $info)
}
// Sonstiges
if ($otherDistribution['version'] == 'Raspbian GNU/Linux 10' || $otherDistribution['version'] == 'Raspbian GNU/Linux 11' || $otherDistribution['version'] == 'Debian GNU/Linux 11')
$otherDistribution['status'] = true;
//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'] != '')
$otherCookie['status'] = true;
@@ -87,8 +83,7 @@ $tpl->assign('filesFoldersPermission', $filesFoldersPermission);
$tpl->assign('otherDistribution', $otherDistribution);
$tpl->assign('otherCookie', $otherCookie);
$tpl->assign('error', $error);
$tpl->assign('langUrl', (isset($_GET['lang']) && $_GET['lang'] != '') ? '&amp;lang='.$_GET['lang'] : '');
$tpl->assign('langUrl', (isset($_GET['lang']) && $_GET['lang'] != '') ? '&amp;lang=' . $_GET['lang'] : '');
$tpl->assign('configHelp', $config['url']['help']);
$tpl->draw('install_requirement');
?>

View File

@@ -650,7 +650,7 @@ class PiTpl
* @return bool
*/
public function msg($type, $title = NULL, $msg, $cancelable = true, $id = 0)
public function msg($type, $msg, $title = NULL, $cancelable = true, $id = 0)
{
if (!strlen($type) > 0 || !is_string($type) ||
!strlen($msg) > 0 || !is_string($msg)
@@ -943,4 +943,3 @@ class PiTpl
return true;
}
}
?>

View File

@@ -1,138 +1,102 @@
var is_loding = false;
function overviewStatusRefreshEffect(element)
{
element.css({'transition': 'background-color 0.5s', 'background-color': 'rgba(243, 255, 164, 1)'});
setTimeout(function(){
element.css({'background-color': 'transparent'});
function overviewStatusRefreshEffect(element) {
element.css({ 'transition': 'background-color 0.5s', 'background-color': 'rgba(243, 255, 164, 1)' });
setTimeout(function () {
element.css({ 'background-color': 'transparent' });
}, 800);
}
function showError()
{
function showError() {
jQuery('.error-msg-refresh-bar').remove();
jQuery('.flex-box-refresh div:eq(0)').after('<div class="red error-msg-refresh-bar" style="vertical-align: bottom; font-weight: bold;">' + _t('Fehler!') + '</div>');
jQuery('.refresh-bar').stop(false, true).css('width', 0);
jQuery('a[href=#refresh] img').removeClass('rotate-icon');
setTimeout('overviewStatusRefresh()', 3000);
}
function overviewStatusRefresh()
{
function overviewStatusRefresh() {
jQuery('.error-msg-refresh-bar').remove();
jQuery('.refresh-bar').animate({width: '100%'}, reload_timeout, 'linear', function(e)
{
var this_ = jQuery(this);
var runtime = jQuery('.flex-container > div:eq(2)');
var cpuClock = jQuery('.flex-container > div:eq(3)');
var cpuLoad = jQuery('.flex-container > div:eq(4)');
var cpuTemp = jQuery('.flex-container > div:eq(5)');
var ramPercentage = jQuery('.flex-container > div:eq(6)');
var memoryUsed = jQuery('.flex-container > div:eq(7)');
var memoryFree = jQuery('.flex-container > div:eq(8)');
var memoryTotal = jQuery('.flex-container > div:eq(9)');
jQuery('.refresh-bar').animate({ width: '100%' }, reload_timeout, 'linear', function (e) {
let this_ = jQuery(this);
let runtime = jQuery('.flex-container > div:eq(2)');
let cpuClock = jQuery('.flex-container > div:eq(3)');
let cpuLoad = jQuery('.flex-container > div:eq(4)');
let cpuTemp = jQuery('.flex-container > div:eq(5)');
let ramPercentage = jQuery('.flex-container > div:eq(6)');
let memoryUsed = jQuery('.flex-container > div:eq(7)');
let memoryFree = jQuery('.flex-container > div:eq(8)');
let memoryTotal = jQuery('.flex-container > div:eq(9)');
jQuery('a[href=#refresh] img').addClass('rotate-icon');
this_.animate({width: '88.8%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'runtime' }, function(data)
{
if (runtime.find('span').html() != data.data.runtime)
{
this_.animate({ width: '88.8%' }, 300, 'linear');
jQuery.get('api/v1/overview.php', { data: 'runtime;cpuClock;cpuLoad;cpuTemp;ramPercentage;memoryUsed;memoryFree;memoryTotal' }, function (data) {
if (runtime.find('span').html() != data.data.runtime) {
overviewStatusRefreshEffect(runtime);
runtime.find('span').html(data.data.runtime);
}
this_.animate({width: '77.7%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'cpuClock' }, function(data)
{
if (cpuClock.find('span').html() != data.data.cpuClock+' MHz')
{
overviewStatusRefreshEffect(cpuClock);
cpuClock.find('span').html(data.data.cpuClock+' MHz');
}
this_.animate({width: '66.6%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'cpuLoad' }, function(data)
{
if (cpuLoad.find('.progressbar div').html() != data.data.cpuLoad+'%')
{
overviewStatusRefreshEffect(cpuLoad);
cpuLoad.find('.progressbar').attr('data-text', data.data.cpuLoad+'%').find('div').css('width', data.data.cpuLoad+'%');
}
this_.animate({width: '55.5%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'cpuTemp' }, function(data)
{
if (cpuTemp.find('span').html() != data.data.cpuTemp+' °C')
{
overviewStatusRefreshEffect(cpuTemp);
cpuTemp.find('span').html(data.data.cpuTemp+' &deg;C');
}
this_.animate({width: '44.4%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'ramPercentage' }, function(data)
{
if (ramPercentage.find('.progressbar div').html() != data.data.ramPercentage+'%')
{
overviewStatusRefreshEffect(ramPercentage);
ramPercentage.find('.progressbar').attr('data-text', data.data.ramPercentage+'%').find('div').css('width', data.data.ramPercentage+'%');
}
this_.animate({width: '33.3%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'memoryUsed' }, function(data)
{
if (memoryUsed.find('span').html() != data.data.memoryUsed)
{
overviewStatusRefreshEffect(memoryUsed);
memoryUsed.find('span').html(data.data.memoryUsed);
}
this_.animate({width: '22.2%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'memoryFree' }, function(data)
{
if (memoryFree.find('span').html() != data.data.memoryFree)
{
overviewStatusRefreshEffect(memoryFree);
memoryFree.find('span').html(data.data.memoryFree);
}
this_.animate({width: '11.1%'}, 300, 'linear');
jQuery.post('api/v1/overview.php', { data: 'memoryTotal' }, function(data)
{
if (memoryTotal.find('span').html() != data.data.memoryTotal)
{
overviewStatusRefreshEffect(memoryTotal);
memoryTotal.find('span').html(data.data.memoryTotal);
}
this_.animate({width: '0%'}, 300, 'linear', function(e) {
is_loding = false;
jQuery('a[href=#refresh] img').removeClass('rotate-icon');
});
overviewStatusRefresh();
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
}).fail(function(e) { showError(); });
this_.animate({ width: '77.7%' }, 300, 'linear');
if (cpuClock.find('span').html() != data.data.cpuClock + ' MHz') {
overviewStatusRefreshEffect(cpuClock);
cpuClock.find('span').html(data.data.cpuClock + ' MHz');
}
this_.animate({ width: '66.6%' }, 300, 'linear');
if (cpuLoad.find('.progressbar div').html() != data.data.cpuLoad + '%') {
overviewStatusRefreshEffect(cpuLoad);
cpuLoad.find('.progressbar').attr('data-text', data.data.cpuLoad + '%').find('div').css('width', data.data.cpuLoad + '%');
}
this_.animate({ width: '55.5%' }, 300, 'linear');
if (cpuTemp.find('span').html() != data.data.cpuTemp + ' °C') {
overviewStatusRefreshEffect(cpuTemp);
cpuTemp.find('span').html(data.data.cpuTemp + ' &deg;C');
}
this_.animate({ width: '44.4%' }, 300, 'linear');
if (ramPercentage.find('.progressbar div').html() != data.data.ramPercentage + '%') {
overviewStatusRefreshEffect(ramPercentage);
ramPercentage.find('.progressbar').attr('data-text', data.data.ramPercentage + '%').find('div').css('width', data.data.ramPercentage + '%');
}
this_.animate({ width: '33.3%' }, 300, 'linear');
if (memoryUsed.find('span').html() != data.data.memoryUsed) {
overviewStatusRefreshEffect(memoryUsed);
memoryUsed.find('span').html(data.data.memoryUsed);
}
this_.animate({ width: '22.2%' }, 300, 'linear');
if (memoryFree.find('span').html() != data.data.memoryFree) {
overviewStatusRefreshEffect(memoryFree);
memoryFree.find('span').html(data.data.memoryFree);
}
this_.animate({ width: '11.1%' }, 300, 'linear');
if (memoryTotal.find('span').html() != data.data.memoryTotal) {
overviewStatusRefreshEffect(memoryTotal);
memoryTotal.find('span').html(data.data.memoryTotal);
}
this_.animate({ width: '0%' }, 300, 'linear', function (e) {
is_loding = false;
jQuery('a[href=#refresh] img').removeClass('rotate-icon');
});
overviewStatusRefresh();
}).fail(function (e) { showError(); });
});
}
jQuery(document).on('click', 'a[href=#refresh]', function(e)
{
jQuery(document).on('click', 'a[href=#refresh]', function (e) {
if (is_loding == false)
jQuery('.refresh-bar').stop(false, true);
return false;
});
jQuery(document).ready(function(e)
{
jQuery(document).ready(function (e) {
overviewStatusRefresh();
});

View File

@@ -22,7 +22,7 @@
<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 <br>Weiterentwickelt von <a href="https://www.schultes.dev">Gregor Schulte</a> 2021-2022</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.schultes.dev">Gregor Schulte</a> 2021-2023</div>
</div>
</div>
<script type="text/javascript">var errorHandler = '<?php echo $data['errorHandler']; ?>';</script>

View File

@@ -5,50 +5,53 @@
<div class="inner-header">
<span><?php _e('SSH-Login'); ?></span>
</div>
<?php if ($data['logged_in'] === false) { ?>
<form action="?s=ssh_login" method="post">
<div class="inner">
<strong class="red"><?php _e('Du bist noch nicht angemeldet. Dadurch kannst du einige Funktionen nicht nutzen.'); ?></strong>
</div>
<input type="radio" id="ssh-login-passwd" name="ssh-login" value="password" checked="checked" />
<label for="ssh-login-passwd">
<div class="inner-table">
<div class="ssh-login-table-clickable-area"></div>
<table class="table table-borderless">
<tr>
<th colspan="2"><strong><?php _e('Anmeldung &uuml;ber ein Passwort'); ?></strong><span> [<?php _e('Klicken zum aktivieren'); ?>]</span></th>
</tr>
<tr>
<td style="width: 30%;"><strong><?php _e('SSH-Port'); ?></strong></td>
<td><input type="text" name="port" style="width: 50px;" value="<?php echo $data['ssh_info']['port']; ?>" maxlength="5" /> <span class="small-info"><?php _e('Standard: %d', 22); ?></span></td>
</tr>
<tr>
<td><strong><?php _e('SSH-Benutzername'); ?></strong></td>
<td><input type="text" name="username" style="width: 40%;" value="<?php echo $data['ssh_info']['username']; ?>" /></td>
</tr>
<tr>
<td><strong><?php _e('SSH-Passwort'); ?></strong></td>
<td><input type="password" name="password" style="width: 40%;" /></td>
</tr>
<tr>
<td><strong><?php _e('SSH-Login speichern?'); ?></strong></td>
<td><input type="checkbox" name="remember-me" value="checked" id="ssh-login-passwd-checkbox" /><label for="ssh-login-passwd-checkbox" class="checkbox only-checkbox">&nbsp;</label> <span class="small_info"><?php _e('Speichert das Passwort, damit nicht nach jeder Session neu angemeldet werden muss.'); ?></span></td>
</tr>
</table>
<?php if ($data['logged_in'] === false) { ?>
<form action="?s=ssh_login" method="post">
<div class="inner">
<strong class="red"><?php _e('Du bist noch nicht angemeldet. Dadurch kannst du einige Funktionen nicht nutzen.'); ?></strong>
</div>
</label>
<div class="inner">
<div class="divider"><div></div><div><?php _e('ODER'); ?></div></div>
</div>
<input type="radio" id="ssh-login-pubkey" name="ssh-login" value="publickey" />
<label for="ssh-login-pubkey">
<div class="inner-table">
<div class="ssh-login-table-clickable-area"></div>
<table class="table table-borderless">
<tr>
<th colspan="2"><strong><?php _e('Anmeldung &uuml;ber einen Publickey'); ?></strong><span> [<?php _e('Klicken zum aktivieren'); ?>]</span></th>
</tr>
<tr>
<input type="radio" id="ssh-login-passwd" name="ssh-login" value="password" checked="checked" />
<label for="ssh-login-passwd">
<div class="inner-table">
<div class="ssh-login-table-clickable-area"></div>
<table class="table table-borderless">
<tr>
<th colspan="2"><strong><?php _e('Anmeldung &uuml;ber ein Passwort'); ?></strong><span> [<?php _e('Klicken zum aktivieren'); ?>]</span></th>
</tr>
<tr>
<td style="width: 30%;"><strong><?php _e('SSH-Port'); ?></strong></td>
<td><input type="text" name="port" style="width: 50px;" value="<?php echo $data['ssh_info']['port']; ?>" maxlength="5" /> <span class="small-info"><?php _e('Standard: %d', 22); ?></span></td>
</tr>
<tr>
<td><strong><?php _e('SSH-Benutzername'); ?></strong></td>
<td><input type="text" name="username" style="width: 40%;" value="<?php echo $data['ssh_info']['username']; ?>" /></td>
</tr>
<tr>
<td><strong><?php _e('SSH-Passwort'); ?></strong></td>
<td><input type="password" name="password" style="width: 40%;" /></td>
</tr>
<tr>
<td><strong><?php _e('SSH-Login speichern?'); ?></strong></td>
<td><input type="checkbox" name="remember-me" value="checked" id="ssh-login-passwd-checkbox" /><label for="ssh-login-passwd-checkbox" class="checkbox only-checkbox">&nbsp;</label> <span class="small_info"><?php _e('Speichert das Passwort, damit nicht nach jeder Session neu angemeldet werden muss.'); ?></span></td>
</tr>
</table>
</div>
</label>
<div class="inner">
<div class="divider">
<div></div>
<div><?php _e('ODER'); ?></div>
</div>
</div>
<input type="radio" id="ssh-login-pubkey" name="ssh-login" value="publickey" />
<label for="ssh-login-pubkey">
<div class="inner-table">
<div class="ssh-login-table-clickable-area"></div>
<table class="table table-borderless">
<tr>
<th colspan="2"><strong><?php _e('Anmeldung &uuml;ber einen Publickey'); ?></strong><span> [<?php _e('Klicken zum aktivieren'); ?>]</span></th>
</tr>
<tr>
<td style="width: 30%;"><strong><?php _e('SSH-Port'); ?></strong></td>
<td><input type="text" name="port_" style="width: 50px;" value="<?php echo $data['ssh_info']['port']; ?>" maxlength="5" /> <span class="small-info"><?php _e('Standard: 22'); ?></span></td>
</tr>
@@ -68,21 +71,21 @@
<td><strong><?php _e('SSH-Login speichern?'); ?></strong></td>
<td><input type="checkbox" name="remember-me_" value="checked" id="ssh-login-pubkey-checkbox" /><label for="ssh-login-pubkey-checkbox" class="checkbox only-checkbox">&nbsp;</label> <span class="small_info"><?php _e('Speichert das Passwort, damit nicht nach jeder Session neu angemeldet werden muss.'); ?></span></td>
</tr>
</table>
</table>
</div>
</label>
<div class="inner-end">
<input type="submit" name="submit" value="<?php _e('Anmelden'); ?>" />
</div>
</label>
<div class="inner-end">
<input type="submit" name="submit" value="<?php _e('Anmelden'); ?>" />
</form>
<?php } else { ?>
<div class="inner">
<strong class="green"><?php _e('Du bist bereits angemeldet mit dem Benutzer %s.', $data['ssh_info']['username']); ?></strong>
</div>
</form>
<?php } else { ?>
<div class="inner">
<strong class="green"><?php _e('Du bist bereits angemeldet mit dem Benutzer %s.', $data['ssh_info']['username']); ?></strong>
</div>
<div class="inner-end">
<a href="?s=ssh_login&amp;logout"><button><?php _e('Abmelden'); ?></button></a>
</div>
<?php } ?>
<div class="inner-end">
<a href="?s=ssh_login&amp;logout"><button><?php _e('Abmelden'); ?></button></a>
</div>
<?php } ?>
</div>
</div>
<div class="clear_both"></div>

View File

@@ -1,14 +1,26 @@
<?php if (!defined('PICONTROL')) exit(); ?>
<style>
.system_msg{color: #01a7db; font-style: italic;}
.user_name{font-weight:bold;}
.user_message{color: #FFFFFF;}
pre { margin: 0; }
.system_msg {
color: #01a7db;
font-style: italic;
}
.user_name {
font-weight: bold;
}
.user_message {
color: #FFFFFF;
}
pre {
margin: 0;
}
</style>
<script language="javascript" type="text/javascript">
var ip = '<?php echo $_SERVER['SERVER_ADDR']; ?>';
var port = <?php echo $data['port']; ?>;
var cookie = '<?php echo $data['cookie']; ?>';
var ip = '<?php echo $_SERVER['SERVER_ADDR']; ?>';
var port = <?php echo $data['port']; ?>;
var cookie = '<?php echo $data['cookie']; ?>';
</script>
<script language="javascript" type="text/javascript" src="public_html/js/terminal.websocket.js"></script>
<div class="sidebar">
@@ -19,9 +31,9 @@ var cookie = '<?php echo $data['cookie']; ?>';
<div class="inner">
<strong id="status"><?php _e('Lade...'); ?></strong><br /><br />
<select name="terminal">
<?php foreach ($data['ports'] as $index => $port) { ?>
<option style="background: <?php echo ($port['active'] === true) ? '#73CA3C' : '#E9492E'; ?>;" value="<?php echo $port['port']; ?>"<?php if ($data['port'] == $port['port']) echo ' selected="selected"'; ?>><?php _e('Terminal %d (%s)', $index+1, ($port['active'] === true) ? _t('Online') : _t('Offline')); ?></option>
<?php } ?>
<?php foreach ($data['ports'] as $index => $port) { ?>
<option style="background: <?php echo ($port['active'] === true) ? '#73CA3C' : '#E9492E'; ?>;" value="<?php echo $port['port']; ?>" <?php if ($data['port'] == $port['port']) echo ' selected="selected"'; ?>><?php _e('Terminal %d (%s)', $index + 1, ($port['active'] === true) ? _t('Online') : _t('Offline')); ?></option>
<?php } ?>
</select>
<div id="frame"></div>
</div>

View File

@@ -1,60 +1,51 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'network/network.function.php') or die('Error: 0x0011');
(include_once LIBRARY_PATH . 'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH . 'network/network.function.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('Netzwerk'));
if (isset($_GET['hostname']))
{
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (isset($_POST['hostname']) && trim($pHostname = trim($_POST['hostname'])) != '')
{
if (preg_match('/^([a-z][a-z0-9\-\.]*[^\-]){1,24}$/im', $pHostname))
{
if (isset($_GET['hostname'])) {
if (isset($_POST['submit']) && $_POST['submit'] != '') {
if (isset($_POST['hostname']) && trim($pHostname = trim($_POST['hostname'])) != '') {
if (preg_match('/^([a-z][a-z0-9\-\.]*[^\-]){1,24}$/im', $pHostname)) {
if (($status = editHostname($pHostname)) === true)
$tpl->msg('success', _t('Hostname gespeichert'), _t('Damit die &Auml;nderung wirksam wird, muss dein Raspberry Pi neu gestartet werden. <a href="%s">Jetzt neu starten.</a>', '?s=shutdown&restart'));
else
$tpl->msg('error', _t('Fehler'), _t('Fehler beim &Auml;ndern des Hostname! Fehlercode: %s', $status));
}
else
} else
$tpl->msg('error', _t('Fehler'), _t('Der Hostname ist ung&uuml;ltig! Er muss aus mindestens 1 bis 24 Zeichen bestehen und darf nur folgende Zeichen enthalten: A-Z a-z 0-9 -<br />Der Hostname darf nicht mit einem Bindestrich Anfangen oder Enden.'));
}
}
$tpl->assign('hostname', rpi_getHostname());
$tpl->draw('network_hostname');
}
else
{
} else {
$networkConnections = getAllNetworkConnections();
$networkCounts = unserialize(htmlspecialchars_decode(getConfig('main:network.overflowCount', 'a:0:{}')));
$counter = 0;
foreach ($networkConnections as $network)
{
foreach ($networkConnections as $network) {
$countSent = 0;
$countReceive = 0;
if (isset($networkCounts[$network['interface']]['sent']))
$countSent = $networkCounts[$network['interface']]['sent'];
if (isset($networkCounts[$network['interface']]['receive']))
$countReceive = $networkCounts[$network['interface']]['receive'];
$networkConnections[$counter]['sent'] = (4294967295 * $countSent) + $network['sent'];
$networkConnections[$counter]['receive'] = (4294967295 * $countReceive) + $network['receive'];
$counter += 1;
}
$tpl->assign('network_connections', $networkConnections);
$tpl->assign('hostname', rpi_getHostname());
$tpl->assign('wlan', scanAccessPoints($networkConnections, (isset($_GET['refresh_wlan'])) ? true : false));
$tpl->draw('network');
}
?>

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 php7.0-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '') ? true : false));
$tpl->assign('cronPHPCLI', ($cronPHPCLI = (trim(exec('dpkg -s php-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

@@ -3,33 +3,29 @@ if (PHP_SAPI != 'cli') exit();
const PICONTROL = true;
$doNotCheckForAuthentification = true;
(include_once realpath(dirname(__FILE__)).'/../init.php') or die('Error: 0x0000');
(include_once LIBRARY_PATH.'main/main.function.php') or die('Error: 0x0001');
(include_once realpath(dirname(__FILE__)) . '/../init.php') or die('Error: 0x0000');
(include_once LIBRARY_PATH . 'main/main.function.php') or die('Error: 0x0001');
$folder = CRON_PATH;
$fileArray = array();
foreach (@scandir($folder) as $file)
{
if ($file[0] != '.')
{
if (is_file($folder.'/'.$file) && $file != 'init.php')
foreach (@scandir($folder) as $file) {
if ($file[0] != '.') {
if (is_file($folder . '/' . $file) && $file != 'init.php')
$fileArray[] = $file;
}
}
foreach ($fileArray as $file)
{
foreach ($fileArray as $file) {
$timeOfFile = str_replace('-', '', substr($file, 0, 2));
$rest = date('i', time()) % $timeOfFile;
if (is_numeric($rest) && $rest == 0)
{
exec('/usr/bin/php -f "'.CRON_PATH.$file.'"');
if (is_numeric($rest) && $rest == 0) {
exec('/usr/bin/php -f "' . CRON_PATH . $file . '"');
set_time_limit(30);
usleep(500000);
}
}
if (trim(exec('dpkg -s php7.4-cli | grep Status: ')) != '' || trim(exec('dpkg -s php7.3-cli | grep Status: ')) != '')
if (trim(exec('dpkg -s php-cli | grep Status: ')) != '')
setConfig('cron:execution.cron', time());

View File

@@ -10,8 +10,8 @@ if (!isset($config))
'ssh_ip' => '127.0.0.1'
),
'version' => array(
'version' => '2.3.1',
'versioncode' => 36,
'version' => '2.3.3',
'versioncode' => 38,
'android_comp_level' => 25
),
'url' => array(
@@ -26,20 +26,20 @@ if (!isset($config))
);
}
defined('PICONTROL_PATH') or define('PICONTROL_PATH', realpath(dirname(__FILE__).'/../').'/');
defined('RESOURCE_PATH') or define('RESOURCE_PATH', realpath(dirname(__FILE__)).'/');
defined('LIBRARY_PATH') or define('LIBRARY_PATH', realpath(dirname(__FILE__).'/library/').'/');
defined('CONTENT_PATH') or define('CONTENT_PATH', realpath(dirname(__FILE__).'/content/').'/');
defined('CONFIG_PATH') or define('CONFIG_PATH', realpath(dirname(__FILE__).'/config/').'/');
defined('PLUGINS_PATH') or define('PLUGINS_PATH', realpath(dirname(__FILE__).'/plugins/').'/');
defined('UPDATE_PATH') or define('UPDATE_PATH', realpath(dirname(__FILE__).'/update/').'/');
defined('TEMPLATES_PATH') or define('TEMPLATES_PATH', realpath(dirname(__FILE__).'/../public_html/templates/').'/');
defined('TEMPLATES2_PATH') or define('TEMPLATES2_PATH',realpath(dirname(__FILE__).'/templates/').'/');
defined('LOG_PATH') or define('LOG_PATH', realpath(dirname(__FILE__).'/log/').'/');
defined('CRON_PATH') or define('CRON_PATH', realpath(dirname(__FILE__).'/cron/').'/');
defined('LANGUAGE_PATH') or define('LANGUAGE_PATH', realpath(dirname(__FILE__).'/languages/').'/');
defined('CACHE_PATH') or define('CACHE_PATH', realpath(dirname(__FILE__).'/cache/').'/');
defined('INSTALL_PATH') or define('INSTALL_PATH', realpath(dirname(__FILE__).'/../').'/install/');
defined('PICONTROL_PATH') || define('PICONTROL_PATH', realpath(dirname(__FILE__).'/../').'/');
defined('RESOURCE_PATH') || define('RESOURCE_PATH', realpath(dirname(__FILE__)).'/');
defined('LIBRARY_PATH') || define('LIBRARY_PATH', realpath(dirname(__FILE__).'/library/').'/');
defined('CONTENT_PATH') || define('CONTENT_PATH', realpath(dirname(__FILE__).'/content/').'/');
defined('CONFIG_PATH') || define('CONFIG_PATH', realpath(dirname(__FILE__).'/config/').'/');
defined('PLUGINS_PATH') || define('PLUGINS_PATH', realpath(dirname(__FILE__).'/plugins/').'/');
defined('UPDATE_PATH') || define('UPDATE_PATH', realpath(dirname(__FILE__).'/update/').'/');
defined('TEMPLATES_PATH') || define('TEMPLATES_PATH', realpath(dirname(__FILE__).'/../public_html/templates/').'/');
defined('TEMPLATES2_PATH') || define('TEMPLATES2_PATH',realpath(dirname(__FILE__).'/templates/').'/');
defined('LOG_PATH') || define('LOG_PATH', realpath(dirname(__FILE__).'/log/').'/');
defined('CRON_PATH') || define('CRON_PATH', realpath(dirname(__FILE__).'/cron/').'/');
defined('LANGUAGE_PATH') || define('LANGUAGE_PATH', realpath(dirname(__FILE__).'/languages/').'/');
defined('CACHE_PATH') || define('CACHE_PATH', realpath(dirname(__FILE__).'/cache/').'/');
defined('INSTALL_PATH') || define('INSTALL_PATH', realpath(dirname(__FILE__).'/../').'/install/');
$globalLanguage = isset($initConfig['language']) ? $initConfig['language'] : 'de';
$globalLanguageArray = array();
@@ -81,4 +81,3 @@ if (isset($_COOKIE['debug'], $_GET['s']) && $_COOKIE['debug'] == 'debug_mode')
if (!isset($doNotCheckForAuthentification))
(include LIBRARY_PATH.'main/authentification.php') or die('Nicht gefunden!');
?>

View File

@@ -0,0 +1,6 @@
<?php
namespace resources\library\api;
class StatisticController {
}

View File

@@ -393,60 +393,54 @@ function getImageFromSignal($signal)
function getAllNetworkConnections()
{
$shell_string = '';
$output = array();
$networkInterfaces = json_decode(shell_exec('ip -j addr'));
exec('/sbin/ifconfig | grep -E -o "^[[:alnum:][:punct:]]*" | grep -E -v "(lo)" | sed "s/:$//"', $networkInterfaces);
foreach ($networkInterfaces as $interface) {
if ($interface->ifname != 'lo') {
$wirelessOption = [];
$interfaceData = json_decode(shell_exec('ip -j -s link show ' . $interface->ifname));
foreach ($networkInterfaces as $interface)
$shell_string .= '/sbin/ifconfig ' . $interface . (($networkInterfaces[count($networkInterfaces) - 1] != $interface) ? ' && echo "-#-" && ' : '');
$streamInterfaces = explode('-#-', shell_exec($shell_string));
foreach ($streamInterfaces as $index => $streamInterface) {
$wirelessOption = '';
$interface = $networkInterfaces[$index];
preg_match('#inet(?:[ ]+(?:addr\:)?)([\w\.]+)#', $streamInterface, $ipAddress);
preg_match('#(?:HWaddr|ether) ([\w\:]+)#', $streamInterface, $macAddress);
preg_match('#RX(?:.*?)bytes[:| ]([\d]+)#', $streamInterface, $bytesReceived);
preg_match('#TX(?:.*?)bytes[:| ]([\d]+)#', $streamInterface, $bytesSent);
preg_match('#RX(?:.*?)packets[:| ]([\d]+)#', $streamInterface, $packetsReceived);
preg_match('#TX(?:.*?)packets[:| ]([\d]+)#', $streamInterface, $packetsSent);
$output0 = $interface;
if (substr($output0, 0, 4) == 'wlan') {
$streamWirelessInterface = shell_exec('/sbin/iwconfig ' . $output0);
if (0 == substr_count($streamWirelessInterface, 'Not-Associated')) {
$posConfig_start = @strpos($streamWirelessInterface, 'ESSID:"', 0) + 7;
$posConfig_end = @strpos($streamWirelessInterface, '"', $posConfig_start);
$wirelessOption['ssid'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
$posConfig_start = @strpos($streamWirelessInterface, 'Access Point:', 0) + 13;
$posConfig_end = @strpos($streamWirelessInterface, 'Bit Rate', $posConfig_start);
$wirelessOption['mac'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
$posConfig_start = @strpos($streamWirelessInterface, 'Signal level=', 0) + 13;
if (($posConfig_end = @strpos($streamWirelessInterface, '/100', $posConfig_start)) === false) {
$posConfig_end = @strpos($streamWirelessInterface, ' dBm', $posConfig_start);
$signal = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
if ($signal <= -100)
$wirelessOption['signal'] = 0;
elseif ($signal >= -50)
$wirelessOption['signal'] = 100;
else
$wirelessOption['signal'] = 2 * ($signal + 100);
} else
$wirelessOption['signal'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
foreach ($interface->addr_info as $addr) {
if ($addr->family == "inet")
$ipAddress = $addr->local;
}
}
$macAddress = $interface->address;
$bytesReceived = $interfaceData[0]->stats64->rx->bytes;
$bytesSent = $interfaceData[0]->stats64->tx->bytes;
$packetsReceived = $interfaceData[0]->stats64->rx->packets;
$packetsSent = $interfaceData[0]->stats64->tx->packets;
$output[] = array('interface' => $interface, 'mac' => strtoupper($macAddress[1]), 'ip' => (isset($ipAddress[1])) ? $ipAddress[1] : NULL, 'sent' => $bytesSent[1], 'receive' => $bytesReceived[1], 'option' => $wirelessOption, 'packets' => array('sent' => $packetsSent[1], 'received' => $packetsReceived[1]));
if (substr($interface->ifname, 0, 4) == 'wlan') {
$streamWirelessInterface = shell_exec('/sbin/iwconfig ' . $interface->ifname);
if (0 == substr_count($streamWirelessInterface, 'Not-Associated')) {
$posConfig_start = @strpos($streamWirelessInterface, 'ESSID:"', 0) + 7;
$posConfig_end = @strpos($streamWirelessInterface, '"', $posConfig_start);
$wirelessOption['ssid'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
$posConfig_start = @strpos($streamWirelessInterface, 'Access Point:', 0) + 13;
$posConfig_end = @strpos($streamWirelessInterface, 'Bit Rate', $posConfig_start);
$wirelessOption['mac'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
$posConfig_start = @strpos($streamWirelessInterface, 'Signal level=', 0) + 13;
if (($posConfig_end = @strpos($streamWirelessInterface, '/100', $posConfig_start)) === false) {
$posConfig_end = @strpos($streamWirelessInterface, ' dBm', $posConfig_start);
$signal = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
if ($signal <= -100)
$wirelessOption['signal'] = 0;
elseif ($signal >= -50)
$wirelessOption['signal'] = 100;
else
$wirelessOption['signal'] = 2 * ($signal + 100);
} else
$wirelessOption['signal'] = trim(substr($streamWirelessInterface, $posConfig_start, ($posConfig_end - $posConfig_start)));
}
}
$output[] = array('interface' => $interface->ifname, 'mac' => strtoupper($macAddress), 'ip' => (isset($ipAddress)) ? $ipAddress : NULL, 'sent' => $bytesSent, 'receive' => $bytesReceived, 'option' => $wirelessOption, 'packets' => array('sent' => $packetsSent, 'received' => $packetsReceived));
}
}
return $output;

View File

@@ -3,14 +3,12 @@ if (!defined('PICONTROL')) exit();
function rpi_getRuntime()
{
$runtime = trim(@shell_exec('cat /proc/uptime | awk -F \'.\' \'{print $1}\''));
return $runtime;
return trim(@shell_exec('cat /proc/uptime | awk -F \'.\' \'{print $1}\''));
}
function rpi_getHostname()
{
$host = trim(@shell_exec('cat /proc/sys/kernel/hostname'));
return $host;
return trim(@shell_exec('cat /proc/sys/kernel/hostname'));
}
function rpi_getHostAddr()
@@ -75,28 +73,27 @@ function rpi_getCPUType()
if (isset($match[1]))
return $match[1];
return NULL;
return null;
}
function rpi_getCpuModel()
{
$model = trim(@shell_exec('cat /proc/cpuinfo | grep -m 1 "Model" | cut -d ":" -f 2'));
return $model;
return trim(@shell_exec('cat /proc/cpuinfo | grep -m 1 "Model" | cut -d ":" -f 2'));
}
function rpi_getCPULoad($accurate = false, $mulitcore = false)
{
$return = NULL;
$return = null;
if ($accurate === true)
$file = shell_exec('cat /proc/stat; sleep 2; echo "##--##"; cat /proc/stat');
else
$file = shell_exec('cat /proc/stat; sleep 0.5; echo "##--##"; cat /proc/stat');
$file = shell_exec('cat /proc/stat; echo "##--##"; cat /proc/stat');
$file = explode('##--##', $file);
if (!isset($file[0], $file[1]))
return NULL;
return null;
preg_match_all('/^cpu[0-9]?(.*)$/im', $file[0], $prevCPUStrings);
preg_match_all('/^cpu[0-9]?(.*)$/im', $file[1], $curCPUStrings);
@@ -110,7 +107,7 @@ function rpi_getCPULoad($accurate = false, $mulitcore = false)
if (!isset($prevCPU[0], $curCPU[1]) || count($prevCPU) != 11 || count($curCPU) != 11)
return NULL;
return null;
$prevIdle = $prevCPU[4] + $prevCPU[5];
$curIdle = $curCPU[4] + $curCPU[5];
@@ -124,7 +121,7 @@ function rpi_getCPULoad($accurate = false, $mulitcore = false)
$total = $curTotal - $prevTotal;
$idle = $curIdle - $prevIdle;
if ($mulitcore == true)
if ($mulitcore)
$return[$prevCPU[0]] = (int) round(($total - $idle) / $total * 100);
else
$return = (int) round(($total - $idle) / $total * 100);
@@ -153,20 +150,17 @@ function rpi_getDistribution()
function rpi_getKernelVersion()
{
$kernel = trim(@shell_exec('cat /proc/version | cut -d " " -f 1,3'));
return $kernel;
return trim(@shell_exec('cat /proc/version | cut -d " " -f 1,3'));
}
function rpi_getCountRunningTasks()
{
$tasks = trim(@shell_exec('ps -auxeaf| wc -l'));
return $tasks;
return trim(@shell_exec('ps -auxeaf| wc -l'));
}
function rpi_getCountInstalledPackages()
{
$packages = trim(@shell_exec('dpkg --get-selections | grep -v deinstall | wc -l'));
return $packages;
return trim(@shell_exec('dpkg --get-selections | grep -v deinstall | wc -l'));
}
function rpi_getInstalledPackages()

View File

@@ -5,7 +5,9 @@ if (!defined('PICONTROL')) exit();
* Beschreibung. Mehr unter: http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.pkg.html
*/
class FileException extends Exception { }
class FileException extends Exception
{
}
class PiTpl
{
@@ -61,18 +63,16 @@ class PiTpl
$this->runtimeStart = microtime(true);
$lang = $globalLanguage;
$langFile = LANGUAGE_PATH.$lang.'.php';
$langFile = LANGUAGE_PATH . $lang . '.php';
if (empty($globalLanguageArray) && file_exists($langFile) === true && is_file($langFile) === true)
{
if (empty($globalLanguageArray) && file_exists($langFile) === true && is_file($langFile) === true) {
include $langFile;
$globalLanguageArray = $langArray;
}
foreach ($this->tplConfigs as $configFile)
{
if (file_exists(CONFIG_PATH.$configFile.$this->tplConfigSuffix) === true && is_file(CONFIG_PATH.$configFile.$this->tplConfigSuffix) === true)
$this->tplConfigArray[$configFile] = parse_ini_file(CONFIG_PATH.$configFile.$this->tplConfigSuffix, true);
foreach ($this->tplConfigs as $configFile) {
if (file_exists(CONFIG_PATH . $configFile . $this->tplConfigSuffix) === true && is_file(CONFIG_PATH . $configFile . $this->tplConfigSuffix) === true)
$this->tplConfigArray[$configFile] = parse_ini_file(CONFIG_PATH . $configFile . $this->tplConfigSuffix, true);
}
}
@@ -173,7 +173,7 @@ class PiTpl
$configPath = CONFIG_PATH;
if ($this->tplFolderPathPlugin != '')
$configPath = $this->tplFolderPathPlugin.'/resources/config/';
$configPath = $this->tplFolderPathPlugin . '/resources/config/';
if ($customFile !== NULL)
$configPath = $customFile;
@@ -183,11 +183,10 @@ class PiTpl
if (count($file) != 2)
return false;
$configFile = $configPath.$file[0].$this->tplConfigSuffix;
$configFile = $configPath . $file[0] . $this->tplConfigSuffix;
$md5 = substr(md5($configFile), 0, 6);
if (!isset($this->tplConfigArray[$md5]))
{
if (!isset($this->tplConfigArray[$md5])) {
if (file_exists($configFile) === true && is_file($configFile) === true)
$this->tplConfigArray[$md5] = parse_ini_file($configFile, true);
else
@@ -222,7 +221,7 @@ class PiTpl
$configPath = CONFIG_PATH;
if ($this->tplFolderPathPlugin != '')
$configPath = $this->tplFolderPathPlugin.'/resources/config/';
$configPath = $this->tplFolderPathPlugin . '/resources/config/';
if ($customFile !== NULL)
$configPath = $customFile;
@@ -232,11 +231,10 @@ class PiTpl
if (count($file) != 2)
return $default;
$configFile = $configPath.$file[0].$this->tplConfigSuffix;
$configFile = $configPath . $file[0] . $this->tplConfigSuffix;
$md5 = substr(md5($configFile), 0, 6);
if (!isset($this->tplConfigArray[$md5]))
{
if (!isset($this->tplConfigArray[$md5])) {
if (file_exists($configFile) === true && is_file($configFile) === true)
$this->tplConfigArray[$md5] = parse_ini_file($configFile, true);
else
@@ -278,7 +276,7 @@ class PiTpl
else
return false;
return writeConfig($this->tplConfigArray[$file[0]], CONFIG_PATH.$file[0].$this->tplConfigSuffix);
return writeConfig($this->tplConfigArray[$file[0]], CONFIG_PATH . $file[0] . $this->tplConfigSuffix);
}
/**
@@ -416,7 +414,7 @@ class PiTpl
if ($this->tplLoadHeader !== true)
return false;
$fileName = CONTENT_PATH.'html_header.php';
$fileName = CONTENT_PATH . 'html_header.php';
$this->tplLoadedHeader = true;
@@ -470,7 +468,7 @@ class PiTpl
if ($this->tplLoadFooter !== true)
return false;
$fileName = CONTENT_PATH.'html_footer.php';
$fileName = CONTENT_PATH . 'html_footer.php';
$this->tplLoadedFooter = true;
@@ -506,20 +504,18 @@ class PiTpl
$folderPath = $this->tplFolderPath;
if ($this->tplFolderPathPlugin != '')
$folderPath = $this->tplFolderPathPlugin.'/public_html/templates/';
$folderPath = $this->tplFolderPathPlugin . '/public_html/templates/';
if (strlen($tplFileName) >= 1 && is_string($tplFileName))
{
if (file_exists($folderPath.$tplFileName.$this->tplFileSuffix) !== true || is_file($folderPath.$tplFileName.$this->tplFileSuffix) !== true)
return self::tplError(self::_t('Datei "%s" existiert nicht oder ist keine g&uuml;ltige Datei.', $tplFileName), __LINE__-1);
if (strlen($tplFileName) >= 1 && is_string($tplFileName)) {
if (file_exists($folderPath . $tplFileName . $this->tplFileSuffix) !== true || is_file($folderPath . $tplFileName . $this->tplFileSuffix) !== true)
return self::tplError(self::_t('Datei "%s" existiert nicht oder ist keine g&uuml;ltige Datei.', $tplFileName), __LINE__ - 1);
}
self::drawMsg();
$data = $this->tplVariables;
if (strlen($tplFileName) >= 1 && is_string($tplFileName))
(include_once $folderPath.$tplFileName.$this->tplFileSuffix) or self::error(self::_t('Konnte Datei "%s" nicht &ouml;ffnen und auslesen.', $tplFileName), __LINE__);
if (strlen($tplFileName) >= 1 && is_string($tplFileName)) (include_once $folderPath . $tplFileName . $this->tplFileSuffix) or self::error(self::_t('Konnte Datei "%s" nicht &ouml;ffnen und auslesen.', $tplFileName), __LINE__);
// Optisch schöner
echo PHP_EOL;
@@ -545,7 +541,7 @@ class PiTpl
if (!strlen($errorMsg) > 0 || !is_string($errorMsg))
return false;
if (file_exists($this->tplFolderPath.'error'.$this->tplFileSuffix) !== true || is_file($this->tplFolderPath.'error'.$this->tplFileSuffix) !== true)
if (file_exists($this->tplFolderPath . 'error' . $this->tplFileSuffix) !== true || is_file($this->tplFolderPath . 'error' . $this->tplFileSuffix) !== true)
return false;
if ($errorCancel === true)
@@ -555,7 +551,7 @@ class PiTpl
$data['title'] = $errorTitle;
$data['msg'] = $errorMsg;
include $this->tplFolderPath.'error'.$this->tplFileSuffix;
include $this->tplFolderPath . 'error' . $this->tplFileSuffix;
if ($errorCancel === true)
if (self::drawFooter() === false)
@@ -623,12 +619,13 @@ class PiTpl
return false;
if (!headers_sent($filename, $linenum))
exit(header('Location: '.$url));
else
{
self::error(self::_t('Weiterleitung'),
'<strong class="red">'.self::_t('Header bereits gesendet. Redirect nicht m&ouml;glich, klicke daher stattdessen <a href="%s">diesen Link</a> an.', $url).'</strong>',
true);
exit(header('Location: ' . $url));
else {
self::error(
self::_t('Weiterleitung'),
'<strong class="red">' . self::_t('Header bereits gesendet. Redirect nicht m&ouml;glich, klicke daher stattdessen <a href="%s">diesen Link</a> an.', $url) . '</strong>',
true
);
}
return true;
@@ -644,7 +641,7 @@ class PiTpl
public function showDebug()
{
printf(PHP_EOL.'<!-- DEBUG - Start -->'.PHP_EOL.' <hr /><p>Ladezeit: %f<br />Fehler: %s</p>'.PHP_EOL.'<!-- DEBUG - End -->'.PHP_EOL, round(microtime(true)-$this->runtimeStart, 5), ($this->ifError) ? 'true' : 'false');
printf(PHP_EOL . '<!-- DEBUG - Start -->' . PHP_EOL . ' <hr /><p>Ladezeit: %f<br />Fehler: %s</p>' . PHP_EOL . '<!-- DEBUG - End -->' . PHP_EOL, round(microtime(true) - $this->runtimeStart, 5), ($this->ifError) ? 'true' : 'false');
return true;
}
@@ -661,18 +658,17 @@ class PiTpl
* @return bool
*/
public function msg($type, $title = NULL, $msg, $cancelable = true, $id = 0)
public function msg($type, $msg, $title = NULL, $cancelable = true, $id = 0)
{
if (!strlen($type) > 0 || !is_string($type) ||
if (
!strlen($type) > 0 || !is_string($type) ||
!strlen($msg) > 0 || !is_string($msg)
)
return false;
if ($id > 0)
{
if ($id > 0) {
$this->tplMsg[$id + 100] = array($type, $title, $msg, $cancelable);
}
else
} else
$this->tplMsg[] = array($type, $title, $msg, $cancelable);
return true;
@@ -699,18 +695,17 @@ class PiTpl
if (is_array($this->tplMsg) !== true || count($this->tplMsg) == 0)
return false;
if (file_exists($this->tplFolderPath.'msg'.$this->tplFileSuffix) !== true || is_file($this->tplFolderPath.'msg'.$this->tplFileSuffix) !== true)
if (file_exists($this->tplFolderPath . 'msg' . $this->tplFileSuffix) !== true || is_file($this->tplFolderPath . 'msg' . $this->tplFileSuffix) !== true)
return false;
foreach ($this->tplMsg as $key => $msg)
{
foreach ($this->tplMsg as $key => $msg) {
$data['id'] = $key;
$data['type'] = $msg[0];
$data['title'] = $msg[1];
$data['msg'] = $msg[2];
$data['cancelable'] = $msg[3];
(include $this->tplFolderPath.'msg'.$this->tplFileSuffix) or self::tplError(self::_t('Konnte Datei "%s" nicht &ouml;ffnen und auslesen.', $this->tplFolderPath.'msg'.$this->tplFileSuffix), __LINE__);
(include $this->tplFolderPath . 'msg' . $this->tplFileSuffix) or self::tplError(self::_t('Konnte Datei "%s" nicht &ouml;ffnen und auslesen.', $this->tplFolderPath . 'msg' . $this->tplFileSuffix), __LINE__);
}
return false;
@@ -726,13 +721,12 @@ class PiTpl
private function loadSSH()
{
set_include_path(LIBRARY_PATH.'terminal');
set_include_path(LIBRARY_PATH . 'terminal');
if (!class_exists('Net_SSH2'))
{
include(LIBRARY_PATH.'terminal/Net/SSH2.php');
include(LIBRARY_PATH.'terminal/File/ANSI.php');
include(LIBRARY_PATH.'terminal/Crypt/RSA.php');
if (!class_exists('Net_SSH2')) {
include(LIBRARY_PATH . 'terminal/Net/SSH2.php');
include(LIBRARY_PATH . 'terminal/File/ANSI.php');
include(LIBRARY_PATH . 'terminal/Crypt/RSA.php');
}
$ssh = NULL;
@@ -741,30 +735,28 @@ class PiTpl
return false;
$token = $_COOKIE['_pi-control_ssh'];
$token2 = $_COOKIE['_pi-control_ssh_'.$token];
$token2 = $_COOKIE['_pi-control_ssh_' . $token];
$sshType = getConfig('ssh:token_'.$token.'.type', 'password');
$sshPort = getConfig('ssh:token_'.$token.'.port', 22);
$sshUsername = getConfig('ssh:token_'.$token.'.username', 'root');
$sshPassword = getConfig('ssh:token_'.$token.'.password', '');
$sshPrivateKey = base64_decode(getConfig('ssh:token_'.$token.'.privateKey', ''));
$sshType = getConfig('ssh:token_' . $token . '.type', 'password');
$sshPort = getConfig('ssh:token_' . $token . '.port', 22);
$sshUsername = getConfig('ssh:token_' . $token . '.username', 'root');
$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);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$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 = openssl_encrypt(base64_decode($sshPassword), 'aes-256-cbc', $token2, 0, $iv);
$sshPassword = rtrim($sshPassword, "\0");
$ssh = new Net_SSH2('127.0.0.1', $sshPort);
if ($sshType == 'password')
{
if ($sshType == 'password') {
if (!$ssh->login($sshUsername, $sshPassword))
return false;
return false;
}
if ($sshType == 'publickey')
{
if ($sshType == 'publickey') {
$sshKey = new Crypt_RSA();
if ($sshPassword != '')
@@ -773,7 +765,7 @@ class PiTpl
$sshKey->loadKey($sshPrivateKey);
if (!$ssh->login($sshUsername, $sshKey))
return false;
return false;
}
if ($ssh === NULL)
@@ -804,7 +796,7 @@ class PiTpl
if (self::loadSSH() !== true)
if ($cancelIfError !== 0)
return self::error(_t('SSH-Zugriffsfehler'), _t('Kein SSH-Zugriff, diese Funktion steht aktuell nicht zur Verfügung!'), ($cancelIfError === 1) ? true : false);
#return self::error(_t('SSH-Zugriffsfehler'), _t('Kein SSH-Zugriff, bitte anmelden! <a href="%s">Jetzt anmelden.</a>', '?s=ssh_login'), ($cancelIfError === 1) ? true : false);
#return self::error(_t('SSH-Zugriffsfehler'), _t('Kein SSH-Zugriff, bitte anmelden! <a href="%s">Jetzt anmelden.</a>', '?s=ssh_login'), ($cancelIfError === 1) ? true : false);
if ($timeout != NULL)
$this->tplSSH->setTimeout($timeout);
@@ -833,11 +825,9 @@ class PiTpl
public function getSSHResource($cancelIfError = 0)
{
if ($this->tplSSH === NULL)
if (self::loadSSH() !== true)
{
if ($cancelIfError !== 0)
self::error(_t('SSH-Zugriffsfehler'), _t('Kein SSH-Zugriff, diese Funktion steht aktuell nicht zur Verfügung!'), ($cancelIfError === 1) ? true : false);
#self::error(_t('SSH-Zugriffsfehler'), _t('Kein SSH-Zugriff, bitte anmelden! <a href="%s">Jetzt anmelden.</a>', '?s=ssh_login'), ($cancelIfError === 1) ? true : false);
if (self::loadSSH() !== true) {
if ($cancelIfError !== 0)
self::error(_t('SSH-Zugriffsfehler'), _t('Kein SSH-Zugriff, bitte anmelden! <a href="%s">Jetzt anmelden.</a>', '?s=ssh_login'), ($cancelIfError === 1) ? true : false);
return false;
}
@@ -859,13 +849,12 @@ class PiTpl
$sshPort = getConfig('ssh:latest.port', 22);
$sshUsername = getConfig('ssh:latest.username', '');
if (isset($_COOKIE['_pi-control_ssh']) && $_COOKIE['_pi-control_ssh'] != '')
{
if (isset($_COOKIE['_pi-control_ssh']) && $_COOKIE['_pi-control_ssh'] != '') {
$token = $_COOKIE['_pi-control_ssh'];
$sshType = getConfig('ssh:token_'.$token.'.type', $sshType);
$sshPort = getConfig('ssh:token_'.$token.'.port', $sshPort);
$sshUsername = getConfig('ssh:token_'.$token.'.username', $sshUsername);
$sshType = getConfig('ssh:token_' . $token . '.type', $sshType);
$sshPort = getConfig('ssh:token_' . $token . '.port', $sshPort);
$sshUsername = getConfig('ssh:token_' . $token . '.username', $sshUsername);
}
return array('type' => $sshType, 'port' => $sshPort, 'username' => $sshUsername);
@@ -900,8 +889,7 @@ class PiTpl
if ($privateKey != '' && is_string($privateKey))
$SSHInfo['privateKey'] = $privateKey;
if ($password != '')
{
if ($password != '') {
if (isset($_COOKIE['_pi-control_ssh']) && $_COOKIE['_pi-control_ssh'] != '')
$this->logoutSSH();
@@ -915,30 +903,27 @@ class PiTpl
$SSHInfo['privateKey'] = $privateKey;
if (setConfig('ssh:token_'.$uniqid.'.created', time()) !== true) return false;
if (setConfig('ssh:token_'.$uniqid.'.type', $SSHInfo['type']) !== true) return false;
if (setConfig('ssh:token_'.$uniqid.'.port', $SSHInfo['port']) !== true) return false;
if (setConfig('ssh:token_'.$uniqid.'.username', $SSHInfo['username']) !== true) return false;
if (setConfig('ssh:token_'.$uniqid.'.password', $SSHInfo['password']) !== true) return false;
if (setConfig('ssh:token_'.$uniqid.'.privateKey', base64_encode($SSHInfo['privateKey'])) !== true) return false;
if (setConfig('ssh:token_' . $uniqid . '.created', time()) !== true) return false;
if (setConfig('ssh:token_' . $uniqid . '.type', $SSHInfo['type']) !== true) return false;
if (setConfig('ssh:token_' . $uniqid . '.port', $SSHInfo['port']) !== true) return false;
if (setConfig('ssh:token_' . $uniqid . '.username', $SSHInfo['username']) !== true) return false;
if (setConfig('ssh:token_' . $uniqid . '.password', $SSHInfo['password']) !== true) return false;
if (setConfig('ssh:token_' . $uniqid . '.privateKey', base64_encode($SSHInfo['privateKey'])) !== true) return false;
setConfig('ssh:latest.type', $SSHInfo['type']);
setConfig('ssh:latest.port', $SSHInfo['port']);
setConfig('ssh:latest.username', $SSHInfo['username']);
if ($rememberMe == false)
{
setcookie('_pi-control_ssh', $uniqid, time()+60*60*12);
setcookie('_pi-control_ssh_'.$uniqid, $uniqid2, time()+60*60*12);
}
else
{
setcookie('_pi-control_ssh', $uniqid, time()+60*60*24*30);
setcookie('_pi-control_ssh_'.$uniqid, $uniqid2, time()+60*60*24*30);
if ($rememberMe == false) {
setcookie('_pi-control_ssh', $uniqid, time() + 60 * 60 * 12);
setcookie('_pi-control_ssh_' . $uniqid, $uniqid2, time() + 60 * 60 * 12);
} else {
setcookie('_pi-control_ssh', $uniqid, time() + 60 * 60 * 24 * 30);
setcookie('_pi-control_ssh_' . $uniqid, $uniqid2, time() + 60 * 60 * 24 * 30);
}
$_COOKIE['_pi-control_ssh'] = $uniqid;
$_COOKIE['_pi-control_ssh_'.$uniqid] = $uniqid2;
$_COOKIE['_pi-control_ssh_' . $uniqid] = $uniqid2;
}
return true;
@@ -954,18 +939,16 @@ class PiTpl
public function logoutSSH()
{
if (isset($_COOKIE['_pi-control_ssh']) && $_COOKIE['_pi-control_ssh'] != '')
{
if (isset($_COOKIE['_pi-control_ssh']) && $_COOKIE['_pi-control_ssh'] != '') {
$token = $_COOKIE['_pi-control_ssh'];
removeConfig('ssh:token_'.$token);
setcookie('_pi-control_ssh', '', time()-60);
setcookie('_pi-control_ssh_'.$token, '', time()-60);
removeConfig('ssh:token_' . $token);
setcookie('_pi-control_ssh', '', time() - 60);
setcookie('_pi-control_ssh_' . $token, '', time() - 60);
$_COOKIE['_pi-control_ssh'] = '';
$_COOKIE['_pi-control_ssh_'.$token] = '';
$_COOKIE['_pi-control_ssh_' . $token] = '';
}
return true;
}
}
?>

View File

@@ -4,126 +4,103 @@ if (!defined('PICONTROL')) exit();
function checkTemperatureMonitoringEmailStatus()
{
global $tpl, $config;
$id = getConfig('main:monitoringCpuTemp.id', '');
$code = getConfig('main:monitoringCpuTemp.code', '');
$email = getConfig('main:monitoringCpuTemp.email', '');
$data = NULL;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $config['url']['temperatureMonitoring'].'?'.http_build_query(array('id' => $id, 'code' => $code, 'email' => $email)));
curl_setopt($curl, CURLOPT_URL, $config['url']['temperatureMonitoring'] . '?' . http_build_query(array('id' => $id, 'code' => $code, 'email' => $email)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
do
{
if (($data = curl_exec($curl)) === false)
{
do {
if (($data = curl_exec($curl)) === false) {
$info = curl_getinfo($curl);
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d (%s)', $info['http_code'], curl_error($curl)), true, 12);
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d (%s)', _t('Verbindungsfehler'), $info['http_code'], curl_error($curl)), true, 12);
break;
}
else
{
} else {
$info = curl_getinfo($curl);
if ($info['http_code'] == 404)
{
$tpl->msg('error', _t('Verbindungsfehler'), _t('Leider konnte keine Verbindung zum Server hergestellt werden, da dieser momentan vermutlich nicht erreichbar ist. Fehlercode: %d', $info['http_code']), true, 12);
if ($info['http_code'] == 404) {
$tpl->msg('error', _t('Leider konnte keine Verbindung zum Server hergestellt werden, da dieser momentan vermutlich nicht erreichbar ist. Fehlercode: %d', _t('Verbindungsfehler'), $info['http_code']), true, 12);
break;
} elseif ($info['http_code'] != 200) {
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $info['http_code']), _t('Verbindungsfehler'), true, 12);
break;
}
elseif ($info['http_code'] != 200)
{
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $info['http_code']), true, 12);
if ($data == '') {
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine leere Antwort.'), _t('Serverfehler'), true, 12);
break;
}
if ($data == '')
{
$tpl->msg('error', _t('Serverfehler'), _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine leere Antwort.'), true, 12);
break;
}
// Verarbeite Datenstring
$json = json_decode($data, true);
if (json_last_error() != JSON_ERROR_NONE || !isset($json['existing'], $json['email'], $json['code']))
{
$tpl->msg('error', _t('Verarbeitungsfehler'), _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine fehlerhafte Antwort.'), true, 12);
if (json_last_error() != JSON_ERROR_NONE || !isset($json['existing'], $json['email'], $json['code'])) {
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine fehlerhafte Antwort.'), _t('Verarbeitungsfehler'), true, 12);
break;
}
// Antwort in Ordnung
if ($json['existing'] == false || $json['email'] == false || $json['code'] == false)
setConfig('main:monitoringCpuTemp.code', '');
}
}
while (false);
} while (false);
curl_close($curl);
}
function checkTemperatureMonitoringEmailCode()
{
global $tpl, $config;
$id = getConfig('main:monitoringCpuTemp.id', '');
$email = getConfig('main:monitoringCpuTemp.email', '');
$data = NULL;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $config['url']['temperatureMonitoring'].'?'.http_build_query(array('id' => $id, 'code' => true, 'email' => $email)));
curl_setopt($curl, CURLOPT_URL, $config['url']['temperatureMonitoring'] . '?' . http_build_query(array('id' => $id, 'code' => true, 'email' => $email)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
do
{
if (($data = curl_exec($curl)) === false)
{
do {
if (($data = curl_exec($curl)) === false) {
$info = curl_getinfo($curl);
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d (%s)', $info['http_code'], curl_error($curl)), true, 12);
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d (%s)', _t('Verbindungsfehler'), $info['http_code'], curl_error($curl)), true, 12);
break;
}
else
{
} else {
$info = curl_getinfo($curl);
if ($info['http_code'] == 404)
{
$tpl->msg('error', _t('Verbindungsfehler'), _t('Leider konnte keine Verbindung zum Server hergestellt werden, da dieser momentan vermutlich nicht erreichbar ist. Fehlercode: %d', $info['http_code']), true, 12);
if ($info['http_code'] == 404) {
$tpl->msg('error', _t('Leider konnte keine Verbindung zum Server hergestellt werden, da dieser momentan vermutlich nicht erreichbar ist. Fehlercode: %d', _t('Verbindungsfehler'), $info['http_code']), true, 12);
break;
} elseif ($info['http_code'] != 200) {
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $info['http_code']), _t('Verbindungsfehler'), true, 12);
break;
}
elseif ($info['http_code'] != 200)
{
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zum Server ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $info['http_code']), true, 12);
if ($data == '') {
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine leere Antwort.'), _t('Serverfehler'), true, 12);
break;
}
if ($data == '')
{
$tpl->msg('error', _t('Serverfehler'), _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine leere Antwort.'), true, 12);
break;
}
// Verarbeite Datenstring
$json = json_decode($data, true);
if (json_last_error() != JSON_ERROR_NONE || !isset($json['existing'], $json['email'], $json['code']))
{
$tpl->msg('error', _t('Verarbeitungsfehler'), _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine fehlerhafte Antwort.'), true, 12);
if (json_last_error() != JSON_ERROR_NONE || !isset($json['existing'], $json['email'], $json['code'])) {
$tpl->msg('error', _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine fehlerhafte Antwort.'), _t('Verarbeitungsfehler'), true, 12);
break;
}
// Antwort in Ordnung
if ($json['code'] != false && strlen($json['code']) == 16)
{
if ($json['code'] != false && strlen($json['code']) == 16) {
setConfig('main:monitoringCpuTemp.code', $json['code']);
$tpl->msg('success', _t('E-Mail best&auml;tigt'), _t('Deine E-Mail wurde erfolgreich best&auml;tigt.'));
}
else
$tpl->msg('error', _t('Verarbeitungsfehler'), _t('Der Server konnte zugeh&ouml;rige Daten nicht finden. Versichere, dass du die E-Mail best&auml;tigt hast.'), true, 12);
$tpl->msg('success', _t('Deine E-Mail wurde erfolgreich best&auml;tigt.'), _t('E-Mail best&auml;tigt'));
} else
$tpl->msg('error', _t('Der Server konnte zugeh&ouml;rige Daten nicht finden. Versichere, dass du die E-Mail best&auml;tigt hast.'), _t('Verarbeitungsfehler'), true, 12);
}
}
while (false);
} while (false);
curl_close($curl);
}
?>

View File

@@ -127,7 +127,7 @@ class LogStatistic
if (!file_exists($this->file) || !is_file($this->file))
touch($this->file);
$this->stream = fopen($this->file, 'r+') or exit(_t('Konnte Log-Datei nicht &ouml;ffnen: %s', $this->file));
$this->stream = fopen($this->file, 'r+');# || exit(_t('Konnte Log-Datei nicht &ouml;ffnen: %s', $this->file));
}
}