Init Repo

This commit is contained in:
Gregor Schulte
2021-06-15 11:08:34 +02:00
parent d0b72a118d
commit b303dd00d6
330 changed files with 93268 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'cache/cache.class.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('Detaillierte &Uuml;bersicht'));
$cpu = rpi_getCPULoad(true, true);
$ram = rpi_getMemoryUsage();
$memory = rpi_getMemoryInfo();
$tpl->assign('time', date('d.m.Y H:i:s', time()));
$tpl->assign('timezone', date('e (P)', time()));
$tpl->assign('run_time', getDateFormat(rpi_getRuntime()));
$tpl->assign('start_time', formatTime(time() - rpi_getRuntime()));
$tpl->assign('serial', rpi_getRpiSerial());
$tpl->assign('revision', rpi_getRpiRevision());
$tpl->assign('distribution', rpi_getDistribution());
$tpl->assign('kernel', rpi_getKernelVersion());
$tpl->assign('webserver', $_SERVER['SERVER_SOFTWARE']);
$tpl->assign('php', PHP_VERSION);
$tpl->assign('whoami', exec('whoami'));
$tpl->assign('cpu_clock', rpi_getCpuClock().' MHz');
$tpl->assign('cpu_max_clock', rpi_getCpuMaxClock().' MHz');
$tpl->assign('cpu_load', $cpu['cpu']);
$tpl->assign('cpu_loads', (count($cpu) == 1) ? array() : array_slice($cpu, 1));
$tpl->assign('cpu_type', rpi_getCPUType());
$tpl->assign('cpu_model', rpi_getCpuModel());
$tpl->assign('cpu_temp', numberFormat(rpi_getCoreTemprature()).' &deg;C');
$tpl->assign('ram_percentage', $ram['percent'].'%');
$tpl->assign('memory', $memory);
$tpl->assign('memory_count', count($memory));
$tpl->assign('runningTasksCount', rpi_getCountRunningTasks());
$tpl->assign('installedPackagesCount', rpi_getCountInstalledPackages());
$tpl->draw('detailed_overview');
?>

View File

@@ -0,0 +1,45 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('Plugins entdecken'));
$showList = true;
$plugins = pluginList();
$onlinePlugins = getOnlinePlugins();
$availableUpdates = checkPluginUpdate($plugins, $onlinePlugins);
if (!is_array($onlinePlugins))
{
$tpl->error(_t('Fehler beim Abrufen'), _t('Leider ist beim Abrufen der Plugins ein Fehler aufgetreten. Fehlercode: %s', $onlinePlugins));
$showList = false;
}
if (isset($_GET['id']) && $_GET['id'] != '')
{
if (isset($onlinePlugins[$_GET['id']]))
{
$showList = false;
include_once 'discover_plugins_info.php';
}
else
$tpl->msg('error', _t('Plugin nicht gefunden'), _t('Das von dir gesuchte Plugin konnte nicht gefunden werden.'));
}
if ($showList == true)
{
$disabledPluginsCount = 0;
foreach ($plugins as $plugin)
{
if ($plugin['disabled'] == true)
$disabledPluginsCount += 1;
}
$tpl->assign('plugins', $plugins);
$tpl->assign('onlinePlugins', $onlinePlugins);
$tpl->assign('availableUpdates', $availableUpdates);
$tpl->assign('disabledPluginsCount', $disabledPluginsCount);
$tpl->draw('discover_plugins');
}
?>

View File

@@ -0,0 +1,31 @@
<?php
if (!defined('PICONTROL')) exit();
$pluginId = $_GET['id'];
$tpl->setHeaderTitle($onlinePlugins[$pluginId]['name'].' - '._t('Plugins entdecken'));
if (isset($_GET['status']) && $_GET['status'] == '')
{
$gPlugin = $plugins[$pluginId];
include_once 'settings/plugins_status.php';
$plugins = pluginList();
}
if (isset($_GET['install']) && $_GET['install'] == '')
$tpl->redirect('?i=download_plugin&id='.$pluginId);
if (isset($_GET['installed']) && $_GET['installed'] == '')
$tpl->msg('success', _t('Plugin installiert'), _t('Das Plugin wurde erfolgreich installiert.'));
if (isset($_GET['update']) && $_GET['update'] == '')
$tpl->redirect('?i=update_plugin&id='.$pluginId);
if (isset($_GET['updated']) && $_GET['updated'] == '')
$tpl->msg('success', _t('Plugin aktualisiert'), _t('Das Plugin wurde erfolgreich aktualisiert.'));
$tpl->assign('plugin', isset($plugins[$pluginId]) ? $plugins[$pluginId] : array());
$tpl->assign('onlinePlugin', $onlinePlugins[$pluginId]);
$tpl->draw('discover_plugins_info');
?>

View File

@@ -0,0 +1,14 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl = new PiTpl;
global $globalLanguage;
$tpl->assign('errorHandler', urlencode(base64_encode(json_encode($tplErrorHandler))));
$tpl->assign('version', $tplConfig['version']['version']);
$tpl->assign('helpLink', $tplConfig['url']['help'].getURLLangParam(false, true, true));
$tpl->assign('language', $globalLanguage);
$tpl->draw('html_footer');
?>

View File

@@ -0,0 +1,67 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl = new PiTpl;
$tpl->assign('title', (isset($data['title']) && $data['title'] != '') ? $data['title'] : 'Pi Control');
$pluginHeaderNavi = array();
$pluginHeaderNaviString = '';
if (file_exists(PLUGINS_PATH) && is_dir(PLUGINS_PATH))
{
foreach (pluginList(false) as $plugin)
{
if (is_array($plugin))
$pluginHeaderNavi[] = array('name' => $plugin['name'], 'id' => $plugin['id']);
}
if (empty($pluginHeaderNavi))
$pluginHeaderNaviString = '<strong class="red">'._t('Keine Plugins!').'</strong>';
if ((getConfig('cron:updateCheck.plugins', 0)+86400) < time() || (isset($_GET['s']) && $_GET['s'] == 'discover_plugins'))
{
$availableUpdates = checkPluginUpdate();
if (isset($availableUpdates) && is_array($availableUpdates) && !empty($availableUpdates))
setConfig('cron:updateCheck.plugins', time()-86400);
else
setConfig('cron:updateCheck.plugins', time());
}
if ((getConfig('cron:updateCheck.picontrol', 0)+86400) < time() || (isset($_GET['s'], $_GET['do']) && $_GET['s'] == 'settings' && $_GET['do'] == 'update'))
{
$picontrolUpdate = checkUpdate();
if (!is_array($picontrolUpdate))
setConfig('cron:updateCheck.picontrol', time());
else
setConfig('cron:updateCheck.picontrol', time()-86400);
}
}
else
$pluginHeaderNaviString = '<strong class="red">'._t('Pluginordner nicht gefunden!').'</strong>';
$referer = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
if ($referer != '')
$referer = '&referer='.urlencode($referer);
// Uebersetzung
$jsTranslations = $data['jsTranslations'];
$jsTranslations[] = 'Leider ist ein unerwarteter Fehler aufgetreten. Bitte schließe das Feedback-Fenster und versuche es erneut. Andernfalls, schreibe mir unter <a href="%%s" target="_blank">Kontakt</a>.';
$jsTranslations[] = 'Schließen';
$jsTranslations[] = 'F&uuml;r das Feedback m&uuml;ssen noch einige Daten gesammelt werden.';
$jsTranslations[] = 'Diagnosedaten wurden gesammelt. Beim Klick auf den folgenden Button wird ein neues Fenster ge&ouml;ffnet.';
$jsTranslations[] = 'Feedback &ouml;ffnen';
$tpl->assign('jsTranslations', getTranslatedArrayForJs($jsTranslations));
$tpl->assign('naviPlugins', !empty($pluginHeaderNavi) ? array_sort($pluginHeaderNavi, 'name', SORT_ASC) : $pluginHeaderNaviString);
$tpl->assign('naviPluginsUpdates', (isset($availableUpdates) && !empty($availableUpdates)) ? $availableUpdates : NULL);
$tpl->assign('updatePicontrol', isset($picontrolUpdate) ? $picontrolUpdate : '');
$tpl->assign('cronExecutionFault', (getConfig('cron:execution.cron', 0)+140 < time()) ? true : false);
$tpl->assign('username', getConfig('user:user_'.getConfig('login:token_'.$_COOKIE['_pi-control_login'].'.username', '').'.username', ''));
$tpl->assign('referer', $referer);
$tpl->assign('headerInfo', getInfoForHeaderBar());
$tpl->draw('html_header');
?>

View File

@@ -0,0 +1,13 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'main/rpi.function.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Installierte Pakete'));
$packages = rpi_getInstalledPackages();
$tpl->assign('installedPackages', $packages);
$tpl->assign('installedPackagesCount', count($packages));
$tpl->draw('installed_packages');
?>

126
resources/content/login.php Normal file
View File

@@ -0,0 +1,126 @@
<?php
if (!defined('PICONTROL')) exit();
$doNotCheckForAuthentification = true;
(include_once realpath(dirname(__FILE__)).'/../init.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'main/tpl.class.php') or die('Error: 0x0011');
(include_once LIBRARY_PATH.'main/main.function.php') or die('Error: 0x0012');
$tpl = new PiTpl;
$tpl->setTpl($tpl);
$tpl->setTplFolder(TEMPLATES_PATH);
$tpl->setDrawHeader(false);
$tpl->setDrawFooter(false, $config);
$externalAccess = (urlIsPublic($_SERVER['REMOTE_ADDR']) && getConfig('main:access.external', 'false') == 'false') ? false : true;
$nextTry = getConfig('login:login.nextTry');
if ($externalAccess === false)
$tpl->assign('errorMsg', _t('Der Zugang steht nur im lokalem Netzwerk (LAN) zur Verf&uuml;gung!'));
elseif ($nextTry > time())
$tpl->assign('errorMsg', _t('Login noch f&uuml;r %d Sekunden gesperrt!', $nextTry-time()));
if (isset($_POST['submit'], $_POST['username'], $_POST['password']) && $externalAccess === true)
{
if (trim($_POST['username']) != '' && $_POST['password'] != '')
{
$pUsername = strtolower(trim($_POST['username']));
$pPassword = $_POST['password'];
$try = getConfig('login:login.try');
do
{
if ($nextTry > time())
break;
if (($userinfo = getConfig('user:user_'.$pUsername, 0)) === 0)
break;
if (!is_array($userinfo))
break;
if (strtolower($userinfo['username']) != $pUsername || password_verify($pPassword, $userinfo['password']) !== true)
break;
setConfig('login:login.try', 0);
setConfig('login:login.nextTry', 0);
$uniqid = generateUniqId(32, false);
if (setConfig('login:token_'.$uniqid.'.created', time()) !== true) break;
if (setConfig('login:token_'.$uniqid.'.username', $pUsername) !== true) break;
if (setConfig('login:token_'.$uniqid.'.address', $_SERVER['REMOTE_ADDR']) !== true) break;
if (setConfig('user:user_'.$pUsername.'.last_login', time()) !== true) break;
if (isset($_POST['rememberMe']) && $_POST['rememberMe'] == 'checked')
{
setConfig('login:token_'.$uniqid.'.remember_me', 'true');
setcookie('_pi-control_login', $uniqid, time()+60*60*24*30);
}
else
setcookie('_pi-control_login', $uniqid, time()+60*60*12);
if (isset($_POST['referer']) && $_POST['referer'] != '')
header('Location: ?'.urldecode($_POST['referer']));
else
header('Location: ?s=overview');
exit();
}
while (false);
if ($nextTry > time())
{
$tpl->assign('errorMsg', _t('Fehler bei der Anmeldung!<br />Login noch f&uuml;r %d Sekunden gesperrt!', $nextTry-time()));
}
elseif ($try == 5)
{
$tpl->assign('errorMsg', _t('Fehler bei der Anmeldung!<br />Zu viele Fehlversuche. Login f&uuml;r %d Sekunden gesperrt!', 30));
setConfig('login:login.nextTry', time() + 30);
}
elseif ($try == 6)
{
$tpl->assign('errorMsg', _t('Fehler bei der Anmeldung!<br />Zu viele Fehlversuche. Login f&uuml;r %d Minute gesperrt!', 1));
setConfig('login:login.nextTry', time() + 60);
}
elseif ($try == 7)
{
$tpl->assign('errorMsg', _t('Fehler bei der Anmeldung!<br />Zu viele Fehlversuche. Login f&uuml;r %d Minuten gesperrt!', 2));
setConfig('login:login.nextTry', time() + 120);
}
elseif ($try >= 8)
{
$tpl->assign('errorMsg', _t('Fehler bei der Anmeldung!<br />Zu viele Fehlversuche. Login f&uuml;r %d Minuten gesperrt!', 5));
setConfig('login:login.nextTry', time() + 300);
}
else
{
$tpl->assign('errorMsg', _t('Fehler bei der Anmeldung!'));
}
setConfig('login:login.try', $try + 1);
}
}
if (isset($_GET['logout']))
{
if (isset($_COOKIE['_pi-control_login']))
{
$uniqid = $_COOKIE['_pi-control_login'];
removeConfig('login:token_'.$uniqid);
setcookie('_pi-control_login', '', time()-60);
}
if (isset($_GET['referer']) && $_GET['referer'] != '')
header('Location: ?i=login&referer='.urlencode($_GET['referer']));
else
header('Location: ?i=login');
exit();
}
$tpl->assign('referer', isset($_GET['referer']) ? $_GET['referer'] : (isset($_POST['referer']) ? urlencode($_POST['referer']) : ''));
$tpl->assign('externalAccess', $externalAccess);
$tpl->draw('login');
?>

View File

@@ -0,0 +1,53 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'log/log.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'log/log.class.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('Logdateien'));
if (isset($_POST['open_file']))
{
$tpl->redirect('?s=logs&view='.urlencode($_POST['relative_path'].$_POST['filename']));
}
if (isset($_GET['view']) && ($view = trim(urldecode($_GET['view']))) != '')
{
$logController = new LogController('/var/log');
$log = $logController->getLogFromRelativePath($view);
if (!$log instanceof LogEntry) {
$tpl->error(_t('Logdatei nicht gefunden'), _t('Leider konnte die angegebene Logdatei nicht gefunden oder ge&ouml;ffnet werden!'));
}
else
{
if ($log->getFilesize() > 10240000) {
$tpl->assign('filesizeError', true);
} else {
set_time_limit(60);
$readLog = $logController->readLog($log->getPath());
$tpl->assign('logOutput', $readLog['output']);
$tpl->assign('logLines', $readLog['lines']);
}
$tpl->assign('log', $log);
$tpl->draw('logs_view');
}
}
elseif (isset($_GET['download']))
{
$tpl->redirect('api/v1/logs_download.php?log='.$_GET['download']);
}
else
{
$logController = new LogController('/var/log/');
$tpl->assign('logs', $logController->getAll());
$tpl->assign('sshAvailable', $logController->isSshAvailable());
$tpl->draw('logs');
}
?>

11
resources/content/msg.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl = new PiTpl;
$tpl->assign('type', $data['type']);
$tpl->assign('title', $data['title']);
$tpl->assign('msg', $data['msg']);
$tpl->assign('cancelable', $data['cancelable']);
$tpl->draw('msg');
?>

View File

@@ -0,0 +1,60 @@
<?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');
$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 (($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
$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
{
$networkConnections = getAllNetworkConnections();
$networkCounts = unserialize(htmlspecialchars_decode(getConfig('main:network.overflowCount', 'a:0:{}')));
$counter = 0;
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

@@ -0,0 +1,44 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'network/network.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'network/network.class.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Netzwerkkonfiguration'));
$jsTranslations = array();
$jsTranslations[] = 'Das Interface wird neu gestartet...';
$jsTranslations[] = 'Das Interface wurde neu gestartet.';
$jsTranslations[] = 'Es ist ein unerwarteter Fehler aufgetreten!';
$jsTranslations[] = 'Es ist ein Fehler aufgetreten! Vermutlich wurde die Verbindung getrennt.';
$jsTranslations[] = 'Es kann nur ein Interface zeitgleich neu gestartet werden.';
$networkInterface = new NetworkInterface($tpl);
if (isset($_GET['msg']) && $_GET['msg'] == 'add')
$tpl->msg('success', _t('Interface hinzugef&uuml;gt'), _t('Interface wurde erfolgreich hinzugef&uuml;gt. Damit diese Einstellungen jedoch wirksam werden, muss das Interface neu gestartet werden.'));
elseif (isset($_GET['msg']) && $_GET['msg'] == 'delete')
$tpl->msg('success', _t('Interface gel&ouml;scht'), _t('Interface wurde erfolgreich gel&ouml;scht.'));
if (isset($_GET['add']) && $_GET['add'] == '')
include_once 'network_configuration_add.php';
elseif (isset($_GET['edit']) && $_GET['edit'] != '' && $networkInterface->existsInterface(urldecode($_GET['edit'])))
include_once 'network_configuration_edit.php';
elseif (isset($_GET['delete']) && $_GET['delete'] != '' && $networkInterface->existsInterface(urldecode($_GET['delete'])))
include_once 'network_configuration_delete.php';
elseif (isset($_GET['edit']) || isset($_GET['delete']))
{
$tpl->msg('error', _t('Interface nicht verf&uuml;gbar'), _t('Es wurde kein Interface mit dem angegebenen Namen gefunden!'), false);
$tpl->assign('interfaces', $networkInterface->getInterfaces());
$tpl->assign('jsTranslations', $jsTranslations);
$tpl->draw('network_configuration');
}
else
{
$tpl->assign('interfaces', $networkInterface->getInterfaces());
$tpl->assign('jsTranslations', $jsTranslations);
$tpl->draw('network_configuration');
}
?>

View File

@@ -0,0 +1,60 @@
<?php
if (!defined('PICONTROL')) exit();
// Fehler vorbeugen
$tpl->getSSHResource(1);
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (isset($_POST['interface'], $_POST['protocol'], $_POST['method'], $_POST['checksum']) && ($pInterface = trim($_POST['interface'])) != '' && ($pProtocol = trim($_POST['protocol'])) != '' && ($pMethod = trim($_POST['method'])) != '' && ($pChecksum = trim($_POST['checksum'])) != '' && in_array($_POST['protocol'], array('inet', 'inet6', 'ipx')) && in_array($_POST['method'], array('dhcp', 'static', 'manual')))
{
if ($pChecksum == $networkInterface->getInterfaceHash())
{
$newInterface = array('protocol' => $pProtocol, 'method' => $pMethod);
if ($pMethod == 'static')
{
if (isset($_POST['address']) && ($pAddress = trim($_POST['address'])) != '')
$newInterface['iface']['address'] = $pAddress;
else
$newInterface['iface']['address'] = NULL;
if (isset($_POST['netmask']) && ($pNetmask = trim($_POST['netmask'])) != '')
$newInterface['iface']['netmask'] = $pNetmask;
else
$newInterface['iface']['netmask'] = NULL;
if (isset($_POST['gateway']) && ($pGateway = trim($_POST['gateway'])) != '')
$newInterface['iface']['gateway'] = $pGateway;
else
$newInterface['iface']['gateway'] = NULL;
}
if ($networkInterface->existsInterface($pInterface) === true)
$tpl->msg('error', _t('Fehler'), _t('Leider konnte das Interface nicht gespeichert werden. Der Name f&uuml;r dieses Interface ist bereits vergeben.'), true, 10);
if ($tpl->msgExists(10) === false)
{
if ($networkInterface->addInterface($pInterface, $newInterface) === true)
$tpl->redirect('?s=network_configuration&edit='.urlencode($pInterface).'&msg=add');
else
$tpl->msg('error', _t('Fehler'), _t('Leider konnte das Interface nicht gespeichert werden. Es ist w&auml;hrend der &Uuml;bertragung ein Fehler aufgetreten.'));
}
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider wurde die Konfigurationsdatei zwischenzeitlich ver&auml;ndert, versuche es deshalb noch einmal.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte vergebe eine Interfacebezeichnung, ein Protokoll und eine Methode!'));
}
$tpl->assign('checksum', $networkInterface->getInterfaceHash());
$tpl->assign('interfaceName', isset($_POST['interface']) ? $_POST['interface'] : '');
$tpl->assign('interfaceProtocol', isset($_POST['protocol']) ? $_POST['protocol'] : '');
$tpl->assign('interfaceMethod', isset($_POST['method']) ? $_POST['method'] : '');
$tpl->assign('interfaceAddress', isset($_POST['address']) ? $_POST['address'] : '');
$tpl->assign('interfaceNetmask', isset($_POST['netmask']) ? $_POST['netmask'] : '');
$tpl->assign('interfaceGateway', isset($_POST['gateway']) ? $_POST['gateway'] : '');
$tpl->draw('network_configuration_add');
?>

View File

@@ -0,0 +1,29 @@
<?php
if (!defined('PICONTROL')) exit();
$interfaceName = urldecode($_GET['delete']);
// Fehler vorbeugen
$tpl->getSSHResource(1);
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (isset($_POST['checksum']) && ($pChecksum = trim($_POST['checksum'])) != '')
{
if ($pChecksum == $networkInterface->getInterfaceHash())
{
if ($networkInterface->deleteInterface($interfaceName) === true)
$tpl->redirect('?s=network_configuration&msg=delete');
else
$tpl->msg('error', _t('Fehler'), _t('Leider konnte das Interface nicht gel&ouml;scht werden. Es ist w&auml;hrend der &Uuml;bertragung ein Fehler aufgetreten.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider wurde die Konfigurationsdatei zwischenzeitlich ver&auml;ndert, versuche es deshalb noch einmal.'));
}
}
$tpl->assign('checksum', $networkInterface->getInterfaceHash());
$tpl->assign('interfaceName', $interfaceName);
$tpl->draw('network_configuration_delete');
?>

View File

@@ -0,0 +1,69 @@
<?php
if (!defined('PICONTROL')) exit();
$interfaceName = urldecode($_GET['edit']);
$interface = $networkInterface->getInterface($interfaceName);
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (isset($_POST['interface'], $_POST['protocol'], $_POST['method'], $_POST['checksum']) && ($pInterface = trim($_POST['interface'])) != '' && ($pProtocol = trim($_POST['protocol'])) != '' && ($pMethod = trim($_POST['method'])) != '' && ($pChecksum = trim($_POST['checksum'])) != '' && in_array($_POST['protocol'], array('inet', 'inet6', 'ipx')) && in_array($_POST['method'], array('dhcp', 'static', 'manual')))
{
if ($pChecksum == $networkInterface->getInterfaceHash())
{
$newInterfaceName = NULL;
$newInterface = array('protocol' => $pProtocol, 'method' => $pMethod);
if ($pMethod == 'static')
{
if (isset($_POST['address']) && ($pAddress = trim($_POST['address'])) != '')
$newInterface['iface']['address'] = $pAddress;
else
$newInterface['iface']['address'] = NULL;
if (isset($_POST['netmask']) && ($pNetmask = trim($_POST['netmask'])) != '')
$newInterface['iface']['netmask'] = $pNetmask;
else
$newInterface['iface']['netmask'] = NULL;
if (isset($_POST['gateway']) && ($pGateway = trim($_POST['gateway'])) != '')
$newInterface['iface']['gateway'] = $pGateway;
else
$newInterface['iface']['gateway'] = NULL;
}
else
$newInterface['iface'] = NULL;
if ($pInterface != $interfaceName && $networkInterface->existsInterface($pInterface) == false)
$newInterfaceName = $pInterface;
elseif ($pInterface != $interfaceName)
$tpl->msg('error', _t('Fehler'), _t('Leider konnte das Interface nicht gespeichert werden. Der Name f&uuml;r dieses Interface ist bereits vergeben.'), true, 10);
if ($tpl->msgExists(10) === false)
{
if ($networkInterface->editInterface($interfaceName, $newInterface, $newInterfaceName) === true)
$tpl->msg('success', _t('Interface gespeichert'), _t('Interface wurde erfolgreich gespeichert. Damit diese Einstellungen jedoch wirksam werden, muss das Interface neu gestartet werden.'));
else
$tpl->msg('error', _t('Fehler'), _t('Leider konnte das Interface nicht gespeichert werden. Es ist w&auml;hrend der &Uuml;bertragung ein Fehler aufgetreten.'));
$interfaceName = $pInterface;
}
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider wurde die Konfigurationsdatei zwischenzeitlich ver&auml;ndert, versuche es deshalb noch einmal.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte vergebe eine Interfacebezeichnung, ein Protokoll und eine Methode!'));
}
$interfaces = $networkInterface->getInterfaces();
$tpl->assign('checksum', $networkInterface->getInterfaceHash());
$tpl->assign('interfaceName', $interfaceName);
$tpl->assign('interfaceProtocol', isset($networkInterface->getInterface($interfaceName)['protocol']) ? $networkInterface->getInterface($interfaceName)['protocol'] : '');
$tpl->assign('interfaceMethod', isset($networkInterface->getInterface($interfaceName)['method']) ? $networkInterface->getInterface($interfaceName)['method'] : '');
$tpl->assign('interfaceAddress', isset($networkInterface->getInterface($interfaceName)['iface']['address']) ? $networkInterface->getInterface($interfaceName)['iface']['address'] : '');
$tpl->assign('interfaceNetmask', isset($networkInterface->getInterface($interfaceName)['iface']['netmask']) ? $networkInterface->getInterface($interfaceName)['iface']['netmask'] : '');
$tpl->assign('interfaceGateway', isset($networkInterface->getInterface($interfaceName)['iface']['gateway']) ? $networkInterface->getInterface($interfaceName)['iface']['gateway'] : '');
$tpl->draw('network_configuration_edit');
?>

View File

@@ -0,0 +1,21 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('WLAN-Verbindung herstellen'));
$jsTranslations = array();
$jsTranslations[] = 'Das Passwort sollte mindestens 8 Zeichen betragen.';
$jsTranslations[] = 'Verbindung wird getrennt...';
$jsTranslations[] = 'Verbindung wird wieder hergestellt...';
$jsTranslations[] = 'Ermittle IP-Adresse von Verbindung...';
$jsTranslations[] = 'Verbindung mit "%%s" war erfolgreich.';
$jsTranslations[] = 'IP-Adresse';
$tpl->assign('jsVariables', 'var _interface = \''.urldecode($_GET['interface']).'\'; var _ssid = \''.urldecode($_GET['ssid']).'\';');
$tpl->assign('interface', urldecode($_GET['interface']));
$tpl->assign('ssid', urldecode($_GET['ssid']));
$tpl->assign('encryption', urldecode($_GET['encryption']));
$tpl->assign('jsTranslations', $jsTranslations);
$tpl->draw('network_connect');
?>

View File

@@ -0,0 +1,34 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'cache/cache.class.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('&Uuml;bersicht'));
$ram = rpi_getMemoryUsage();
$memory = rpi_getMemoryInfo();
$weather = new Cache('weather', 'getWeather');
$usbDevices = new Cache('usb_devices', 'rpi_getUsbDevices');
$weather->load();
$usbDevices->load();
$tpl->assign('js_variables', 'var reload_timeout = '.(getConfig('main:overview.interval', 30)*1000).';');
$tpl->assign('show_weather', (getConfig('main:weather.activation', 'false') == 'true') ? true : false);
$tpl->assign('weather', (getConfig('main:weather.activation', 'false') == 'true') ? $weather->getContent() : '');
$tpl->assign('weather_cache_hint', $weather->displayHint());
$tpl->assign('run_time', getDateFormat(rpi_getRuntime()));
$tpl->assign('start_time', formatTime(time() - rpi_getRuntime()));
$tpl->assign('cpu_clock', rpi_getCpuClock().' MHz');
$tpl->assign('cpu_load', rpi_getCPULoad().'%');
$tpl->assign('cpu_type', rpi_getCPUType());
$tpl->assign('cpu_temp', numberFormat(rpi_getCoreTemprature()).' &deg;C');
$tpl->assign('ram_percentage', $ram['percent'].'%');
$tpl->assign('memory', end($memory));
$tpl->assign('usb_devices', (getConfig('main:overview.showDevices', 'true') == 'true') ? $usbDevices->getContent() : '');
$tpl->assign('usb_devices_cache_hint', $usbDevices->displayHint());
$tpl->assign('jsTranslations', array('Fehler!'));
$tpl->draw('overview');
?>

View File

@@ -0,0 +1,62 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('Plugins'));
$plugins = pluginList();
$pluginLoaded = false;
if (isset($_GET['id']))
{
if (isset($plugins[$_GET['id']]))
{
$plugin = $plugins[$_GET['id']];
if ($plugin['disabled'] == false)
{
if ($plugin['compatible'] == true)
{
$pluginLoaded = true;
$tpl->setTplFolderPlugin('resources/plugins/'.$plugin['id']);
define('PLUGIN_ID', $plugin['id']);
define('PLUGIN_PATH', PLUGINS_PATH.$plugin['id'].'/');
define('PLUGIN_PUBLIC_PATH', str_replace(PICONTROL_PATH, '', PLUGINS_PATH.$plugin['id'].'/'));
$tpl->setHeaderTitle(_t($plugin['name']));
if (file_exists(PLUGIN_PATH.'resources/library/main/sites.php') && is_file(PLUGIN_PATH.'resources/library/main/sites.php'))
include PLUGIN_PATH.'resources/library/main/sites.php';
if (isset($_GET['settings']))
{
if ($plugin['settings'] === true)
include PLUGIN_PATH.'resources/content/settings/settings.php';
else
$tpl->msg('error', _t('Fehler beim Laden des Plugins'), _t('Das gesuchte Plugin unterst&uuml;tzt momentan keine Einstellungen.'), false);
}
elseif (isset($pluginSite, $_GET['do']) && isset($pluginSite[$_GET['do']]) && file_exists(PLUGIN_PATH.'resources/content/'.$pluginSite[$_GET['do']]))
include PLUGIN_PATH.'resources/content/'.$pluginSite[$_GET['do']];
else
include PLUGIN_PATH.'resources/content/index.php';
$tpl->setTplFolderPlugin('');
}
else
$tpl->msg('error', _t('Plugin ist inkompatibel'), _t('Das gesuchte Plugin kann aktuell nicht ge&ouml;ffnet werden, da es inkompatibel ist. Bitte aktualisiere dein Pi Control, um das Plugin weiterhin verwenden zu k&ouml;nnen.'), true);
}
else
$tpl->msg('error', _t('Plugin ist deaktiviert'), _t('Das gesuchte Plugin kann aktuell nicht ge&ouml;ffnet werden, da es deaktiviert ist.'));
}
else
$tpl->msg('error', _t('Plugin nicht gefunden'), _t('Das gesuchte Plugin kann aktuell nicht gefunden werden oder es existiert nicht.'));
}
if ($pluginLoaded === false)
{
$plugins = array_filter($plugins, function($plugin) { if ($plugin['disabled'] == true) return false; return true; });
$tpl->assign('plugins', $plugins);
$tpl->draw('plugins');
}
?>

View File

@@ -0,0 +1,49 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'process/process.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'process/process.class.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('Prozesse'));
$processController = new ProcessController;
if (isset($_POST['terminate'], $_POST['pid'], $_POST['startTime']) && $_POST['terminate'] != '' && ($pid = $_POST['pid']) != '' && ($startTime = $_POST['startTime']) != '')
{
if ($pid > 0)
{
if (ProcessController::isPidWithStartTimeExists($pid, $startTime))
{
if ($processController->terminatePid($pid, $startTime))
$tpl->msg('success', _t('Prozess beendet'), _t('Der Prozess mit der ID %s wurde erfolgreich beendet.', $pid));
else
$tpl->msg('error', _t('Fehler'), _t('Der Prozess mit der ID %s konnte nicht beendet werden.', $pid));
}
else
$tpl->msg('error', _t('Fehler'), _t('Der Prozess mit der ID %s konnte nicht gefunden werden.', $pid));
}
}
elseif (isset($_POST['kill'], $_POST['pid'], $_POST['startTime']) && $_POST['kill'] != '' && ($pid = $_POST['pid']) != '' && ($startTime = $_POST['startTime']) != '')
{
if ($pid > 0)
{
if (ProcessController::isPidWithStartTimeExists($pid, $startTime))
{
if ($processController->killPid($pid, $startTime))
$tpl->msg('success', _t('Prozess abgew&uuml;rgt'), _t('Der Prozess mit der ID %s wurde erfolgreich abgew&uuml;rgt.', $pid));
else
$tpl->msg('error', _t('Fehler'), _t('Der Prozess mit der ID %s konnte nicht abgew&uuml;rgt werden.', $pid));
}
else
$tpl->msg('error', _t('Fehler'), _t('Der Prozess mit der ID %s konnte nicht gefunden werden.', $pid));
}
}
$tpl->assign('processCount', $processController->getCount());
$tpl->assign('processCountRunning', $processController->getCountRunning());
$tpl->assign('processes', $processController->getProcesses());
$tpl->assign('sshAvailable', ($tpl->getSSHResource() instanceof Net_SSH2) ? true : false);
$tpl->draw('processes');
?>

View File

@@ -0,0 +1,41 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'cron/cron.class.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'cache/cache.class.php') or die('Error: 0x0011');
(include_once LIBRARY_PATH.'curl/curl.class.php') or die('Error: 0x0012');
$tpl->setHeaderTitle(_t('Einstellungen'));
switch ((isset($_GET['do']) ? $_GET['do'] : ''))
{
case 'overview':
include_once CONTENT_PATH.'settings/overview.php';
break;
case 'pi-control':
include_once CONTENT_PATH.'settings/pi-control.php';
break;
case 'update':
include_once CONTENT_PATH.'settings/update.php';
break;
case 'plugins':
include_once CONTENT_PATH.'settings/plugins.php';
break;
case 'troubleshooting':
include_once CONTENT_PATH.'settings/troubleshooting.php';
break;
case 'statistic':
include_once CONTENT_PATH.'settings/statistic.php';
break;
case 'notification':
include_once CONTENT_PATH.'settings/notification.php';
break;
case 'user':
include_once CONTENT_PATH.'settings/user.php';
break;
case 'cache':
include_once CONTENT_PATH.'settings/cache.php';
break;
default:
$tpl->draw('settings');
}
?>

View File

@@ -0,0 +1,45 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'cache/cache.function.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Cache'));
if (isset($_GET['clear']) && $_GET['clear'] != '')
{
$clearCache = new Cache;
$clearCache->setName($_GET['clear']);
if ($clearCache->clear() === true)
$tpl->msg('success', _t('Cache geleert'), _t('Der Cache wurder erfolgreich geleert.'));
else
$tpl->msg('error', _t('Fehler'), _t('Leider konnte der Cache nicht geleert werden!'));
if (isset($_GET['redirect']) && $_GET['redirect'] != '')
$tpl->redirect('?'.urldecode($_GET['redirect']));
}
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
setConfig('cache:activation.cache', (isset($_POST['activation']) && $_POST['activation'] == 'checked') ? 'true' : 'false');
$list = getCacheList();
foreach ($list as $name => $info)
{
if (isset($_POST['text-'.$name]) && $_POST['text-'.$name] != '' && $_POST['text-'.$name] >= 1 && $_POST['text-'.$name] <= 9999)
setConfig('cache:lifetime.'.$name, $_POST['text-'.$name]);
else
$tpl->msg('error', _t('Fehler'), _t('Bitte vergebe f&uuml;r die Speicherzeit eine g&uuml;ltige Zahl zwischen 1 und 9999.'), true, 10);
setConfig('cache:activation.'.$name, (isset($_POST['cb-'.$name]) && $_POST['cb-'.$name] == 'checked') ? 'true' : 'false');
}
if ($tpl->msgExists(10) === false)
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
$tpl->assign('cache-activation', (getConfig('cache:activation.cache', 'false') == 'true') ? true : false);
$tpl->assign('cache-files', getCacheList(true));
$tpl->draw('settings/cache');
?>

View File

@@ -0,0 +1,142 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('Benachrichtigung'));
$cron = new Cron;
$cron->setName('notification');
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (isset($_POST['token']) && ($token = trim($_POST['token'])) != '' && ((isset($_POST['event-pi-control-version']) && $_POST['event-pi-control-version'] == 'checked') || (isset($_POST['event-cpu-temperature'], $_POST['event-cpu-temperature-maximum']) && $_POST['event-cpu-temperature'] == 'checked') || (isset($_POST['event-memory-used'], $_POST['event-memory-used-text']) && $_POST['event-memory-used'] == 'checked')))
{
$cpu_temperature_maximum = trim($_POST['event-cpu-temperature-maximum']);
$memory_used_text = trim($_POST['event-memory-used-text']);
if (strlen($token) >= 32 && strlen($token) <= 46)
setConfig('main:notificationPB.token', $token);
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist der angegebene Zugangstoken ung&uuml;ltig!'), true, 10);
if ($cpu_temperature_maximum != '' && $cpu_temperature_maximum >= 40 && $cpu_temperature_maximum <= 90)
setConfig('main:notificationPB.cpuTemperatureMaximum', $cpu_temperature_maximum);
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist die angegebene Temperatur ung&uuml;ltig!'), true, 11);
if ($memory_used_text != '' && $memory_used_text >= 1 && $memory_used_text <= 100)
setConfig('main:notificationPB.memoryUsedLimit', $memory_used_text);
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist der angegebene Prozentsatz ung&uuml;ltig!'), true, 12);
if ($tpl->msgExists(10) === false)
setConfig('main:notificationPB.picontrolVersionEnabled', (isset($_POST['event-pi-control-version'])) ? 'true' : 'false');
if ($tpl->msgExists(11) === false)
setConfig('main:notificationPB.cpuTemperatureEnabled', (isset($_POST['event-cpu-temperature'])) ? 'true' : 'false');
if ($tpl->msgExists(12) === false)
setConfig('main:notificationPB.memoryUsedEnabled', (isset($_POST['event-memory-used'])) ? 'true' : 'false');
if (isset($_POST['activation']) && $_POST['activation'] == 'checked' && (getConfig('main:notificationPB.picontrolVersionEnabled', false) == true || getConfig('main:notificationPB.cpuTemperatureEnabled', false) == true || getConfig('main:notificationPB.memoryUsedEnabled', false) == true))
{
if ($cron->isExists() === false)
{
$cron->setInterval(1);
$cron->setSource(TEMPLATES2_PATH.'notification.tmp.php');
if ($cron->save() === true)
{
$tpl->msg('success', _t('Benachrichtigung aktiviert'), _t('Die Benachrichtigung wurde aktiviert.'));
setConfig('main:notificationPB.enabled', 'true');
}
else
$tpl->msg('error', _t('Fehler'), _t('Konnte die Benachrichtigung nicht aktivieren!'));
}
}
else
{
if ($cron->isExists() === true)
{
$cron->getInterval();
if ($cron->delete() === true)
{
$tpl->msg('success', _t('Benachrichtigung deaktiviert'), _t('Die Benachrichtigung wurde deaktiviert.'));
setConfig('main:notificationPB.enabled', 'false');
}
else
$tpl->msg('error', _t('Fehler'), _t('Konnte die Benachrichtigung nicht deaktivieren!'));
}
}
if ($tpl->msgExists(10) === false && $tpl->msgExists(11) === false && $tpl->msgExists(12) === false)
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'));
}
elseif (isset($_POST['token']) && ($token = trim($_POST['token'])) == '')
{
setConfig('main:notificationPB.token', '');
$tpl->msg('success', _t('Token entfernt'), _t('Der Token wurde erfolgreich entfernt.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte f&uuml;lle alle n&ouml;tigen Felder aus und w&auml;hle mindestens eine der Aktionen!'));
}
$token = getConfig('main:notificationPB.token', '');
if ($token != '')
{
if (isset($_POST['submit-test-notification']) && $_POST['submit-test-notification'] != '')
{
$curl = new cURL('https://api.pushbullet.com/v2/pushes', HTTP_POST);
$curl->addHeader(array('Authorization: Bearer '.$token, 'Content-Type: application/json'));
$curl->setParameterRaw(json_encode(array('type' => 'note', 'title' => 'Pi Control', 'body' => _t('Dein Pi Control "%s" hat dir eine Testbenachrichtigung gesendet.', getConfig('main:main.label', 'Raspberry Pi')))));
$curl->execute();
if ($curl->getStatusCode() != 200)
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zu Pushbullet ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $curl->getStatusCode()));
}
$curl = new cURL('https://api.pushbullet.com/v2/users/me');
$curl->addHeader(array('Authorization: Bearer '.$token));
$curl->execute();
if (in_array($curl->getStatusCode(), array(200, 400, 401, 403, 404, 429)))
{
if ($curl->getResult($dataMe) == JSON_ERROR_NONE)
{
if (isset($dataMe['error']))
$tpl->msg('error', 'Pushbullet', _t('Pushbullet meldet einen Fehler mit einer Anfrage: %s', $dataMe['error']['message']));
else
{
$curl = new cURL('https://api.pushbullet.com/v2/devices');
$curl->addHeader(array('Authorization: Bearer '.$token));
$curl->execute();
if (in_array($curl->getStatusCode(), array(200, 400, 401, 403, 404, 429)))
{
if ($curl->getResult($dataDevices) == JSON_ERROR_NONE)
{
if (isset($dataDevices['error']))
$tpl->msg('error', 'Pushbullet', _t('Pushbullet meldet einen Fehler mit einer Anfrage: %s', $dataDevices['error']['message']));
}
}
else
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zu Pushbullet ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $curl->getStatusCode()));
}
}
}
else
$tpl->msg('error', _t('Verbindungsfehler'), _t('Bei der Verbindung zu Pushbullet ist ein unerwarteter Fehler aufgetreten. Fehlercode: %d', $curl->getStatusCode()));
}
$tpl->assign('activation', (getConfig('main:notificationPB.enabled', 'false') == 'true') ? true : false);
$tpl->assign('token', $token);
$tpl->assign('me', (isset($dataMe)) ? $dataMe : '');
$tpl->assign('devices', (isset($dataDevices)) ? $dataDevices : '');
$tpl->assign('pi-control-enabled', (getConfig('main:notificationPB.picontrolVersionEnabled', 'false') == 'true') ? true : false);
$tpl->assign('cpu-temperature-enabled', (getConfig('main:notificationPB.cpuTemperatureEnabled', 'false') == 'true') ? true : false);
$tpl->assign('cpu-temperature-maximum', getConfig('main:notificationPB.cpuTemperatureMaximum', 65));
$tpl->assign('memory-used-enabled', (getConfig('main:notificationPB.memoryUsedEnabled', 'false') == 'true') ? true : false);
$tpl->assign('memory-used-limit', getConfig('main:notificationPB.memoryUsedLimit', 80));
$tpl->draw('settings/notification');
?>

View File

@@ -0,0 +1,107 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('Einstellungen zur &Uuml;bersicht'));
if (isset($_POST['submit-main']) && $_POST['submit-main'] != '')
{
if (isset($_POST['overview-interval']) && is_numeric($_POST['overview-interval']) && $_POST['overview-interval'] >= 1 && $_POST['overview-interval'] <= 9999)
{
setConfig('main:overview.interval', $_POST['overview-interval']);
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte vergebe f&uuml;r den Intervall einen Wert zwischen 1 und 9999.'), true, 10);
if (isset($_POST['show-devices']) && $_POST['show-devices'] == 'checked')
setConfig('main:overview.showDevices', 'true');
else
setConfig('main:overview.showDevices', 'false');
}
if (isset($_POST['submit-weather']) && $_POST['submit-weather'] != '')
{
if (isset($_POST['weather-service'], $_POST['weather-location-country'], $_POST['weather-location-type']) &&
in_array($_POST['weather-service'], array('openweathermap', 'yahoo', 'wunderground', 'darksky', 'yr')) &&
in_array($_POST['weather-location-country'], array('germany', 'austria', 'swiss', 'uk')) &&
((isset($_POST['weather-service-token']) && in_array($_POST['weather-service'], array('openweathermap', 'wunderground', 'darksky')) && ($pWeatherServiceToken = trim($_POST['weather-service-token'])) != '') || in_array($_POST['weather-service'], array('yahoo', 'yr'))) &&
(($_POST['weather-location-type'] == 'postcode' && isset($_POST['weather-location-postcode-text']) && $_POST['weather-location-postcode-text'] != '') || ($_POST['weather-location-type'] == 'city' && isset($_POST['weather-location-city-text']) && ($cityText = trim($_POST['weather-location-city-text'])) != '') || ($_POST['weather-location-type'] == 'coordinates' && isset($_POST['weather-location-coordinates-latitude-text'], $_POST['weather-location-coordinates-longitude-text']) && ($coordinatesLatitudeText = trim($_POST['weather-location-coordinates-latitude-text'])) != '' && ($coordinatesLongitudeText = trim($_POST['weather-location-coordinates-longitude-text'])) != '')))
{
setConfig('main:weather.service', $_POST['weather-service']);
setConfig('main:weather.country', $_POST['weather-location-country']);
setConfig('main:weather.type', $_POST['weather-location-type']);
if (isset($pWeatherServiceToken) && ((strlen($pWeatherServiceToken) == 32 && in_array($_POST['weather-service'], array('openweathermap', 'darksky'))) || (strlen($pWeatherServiceToken) == 16 && in_array($_POST['weather-service'], array('wunderground')))))
setConfig('main:weather.serviceToken', $pWeatherServiceToken);
elseif (in_array($_POST['weather-service'], array('openweathermap', 'wunderground', 'darksky')))
$tpl->msg('error', _t('Fehler'), _t('Leider ist der angegebene API-Schl&uuml;ssel zu kurz!'), true, 10);
else
setConfig('main:weather.serviceToken', '');
if ($_POST['weather-location-type'] == 'postcode')
{
if (in_array($_POST['weather-location-country'], array('germany', 'austria', 'swiss')))
{
if (in_array(strlen($_POST['weather-location-postcode-text']), array(4, 5)) && $_POST['weather-location-postcode-text'] >= 1 && $_POST['weather-location-postcode-text'] <= 99999)
setConfig('main:weather.postcode', $_POST['weather-location-postcode-text']);
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist die angegebene Postleitzahl ung&uuml;ltig!'), true, 10);
}
elseif (in_array($_POST['weather-location-country'], array('uk')))
{
if (in_array(strlen($_POST['weather-location-postcode-text']), array(5, 6, 7, 8)) && preg_match('/^([A-Z]{1,2}[0-9][A-Z]?[0-9]?)( )?([0-9]{1}[A-Z]{2})$/', $_POST['weather-location-postcode-text']))
setConfig('main:weather.postcode', $_POST['weather-location-postcode-text']);
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist die angegebene Postleitzahl ung&uuml;ltig!'), true, 10);
}
}
elseif ($_POST['weather-location-type'] == 'city')
{
if (strlen($cityText) >= 3 && preg_match('/^[A-Za-zÄÖÜäöü \(\)\.\-\/]+$/', $cityText))
setConfig('main:weather.city', $cityText);
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist der angegebene Stadtname ung&uuml;ltig!'), true, 10);
}
elseif ($_POST['weather-location-type'] == 'coordinates')
{
if (preg_match('/^-?[0-9]{1,2}([\.|,][0-9]{1,6})?$/', $coordinatesLatitudeText) && preg_match('/^-?[0-9]{1,2}([\.|,][0-9]{1,6})?$/', $coordinatesLongitudeText))
{
setConfig('main:weather.latitude', str_replace(',', '.', $coordinatesLatitudeText));
setConfig('main:weather.longitude', str_replace(',', '.', $coordinatesLongitudeText));
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider sind die angegebenen Koordinaten ung&uuml;ltig!'), true, 10);
}
if ($tpl->msgExists(10) === false)
{
setConfig('main:weather.activation', (isset($_POST['weather-activation']) && $_POST['weather-activation'] == 'checked') ? 'true' : 'false');
if ($_POST['weather-service'] == 'yr')
setConfig('main:weather.yrCache', '');
if ($_POST['weather-service'] == 'wunderground')
setConfig('main:weather.wundergroundCache', '');
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'));
}
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte f&uuml;lle alle ben&ouml;tigten Felder aus!'));
}
$tpl->assign('main-overview-interval', getConfig('main:overview.interval', '30'));
$tpl->assign('main-show-devices', getConfig('main:overview.showDevices', 'true'));
$tpl->assign('weather-activation', (getConfig('main:weather.activation', 'false') == 'true') ? true : false);
$tpl->assign('weather-service', getConfig('main:weather.service', 'openweathermap'));
$tpl->assign('weather-service-token', getConfig('main:weather.serviceToken', ''));
$tpl->assign('weather-country', getConfig('main:weather.country', 'germany'));
$tpl->assign('weather-type', getConfig('main:weather.type', 'postcode'));
$tpl->assign('weather-city', getConfig('main:weather.city', ''));
$tpl->assign('weather-postcode', getConfig('main:weather.postcode', ''));
$tpl->assign('weather-coordinates-latitude', getConfig('main:weather.latitude', ''));
$tpl->assign('weather-coordinates-longitude', getConfig('main:weather.longitude', ''));
$tpl->assign('weather-info', getWeather());
$tpl->draw('settings/overview');
?>

View File

@@ -0,0 +1,251 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'pi-control/pi-control.function.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Einstellungen zum Pi Control'));
if (isset($_GET['msg']) && $_GET['msg'] == 'theme')
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.<br /><br />Tipp: Um die Theme-&Auml;nderung wirksam zu machen, leere deinen Browser-Cache mit Strg + F5 (Windows) / &#8997;&#8984; + E (OS X / Safari) / &#8679;&#8984; + R (OS X / Chrome)'));
elseif (isset($_GET['msg']) && $_GET['msg'] == 'main')
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'));
if (isset($_POST['submit-main']) && $_POST['submit-main'] != '')
{
$redirect = 0;
if (isset($_POST['theme-color']) && in_array($_POST['theme-color'], array('red', 'pink', 'purple', 'deepPurple', 'indigo', 'blue', 'lightBlue', 'cyan', 'teal', 'green', 'lightGreen', 'lime', 'yellow', 'amber', 'orange', 'deepOrange', 'brown', 'grey', 'blueGrey')) === true)
{
if (getConfig('main:theme.color', 'blue') != $_POST['theme-color'])
$redirect += 1;
setConfig('main:theme.color', $_POST['theme-color']);
setConfig('main:theme.colorChanged', time());
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
if (isset($_POST['pi-control-language']) && in_array($_POST['pi-control-language'], array('de', 'en')) === true)
{
if (getConfig('init:language', 'de') != $_POST['pi-control-language'])
$redirect += 2;
setConfig('init:language', $_POST['pi-control-language']);
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
if (isset($_POST['pi-control-header-info']) && in_array($_POST['pi-control-header-info'], array('disable', 'label', 'label-ip', 'label-hostname', 'ip', 'hostname')) === true)
{
setConfig('main:headerInfo.type', $_POST['pi-control-header-info']);
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
if (isset($_POST['external-access']) && $_POST['external-access'] == 'checked')
{
setConfig('main:access.external', 'true');
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
else
{
setConfig('main:access.external', 'false');
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
if (isset($_POST['pi-control-label']) && ($pLabel = trim($_POST['pi-control-label'])) != '')
{
if (preg_match('/^[a-z][a-z0-9_\-\+\/\.\(\)\[\] ]{2,32}$/i', $pLabel) === 1)
{
setConfig('main:main.label', $pLabel);
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'), true, 10);
}
else
{
$redirect = 0;
$tpl->msg('error', _t('Fehler'), _t('Leider ist die Bezeichnung ung&uuml;ltig! Die Bezeichnung muss aus 2 bis 32 Zeichen bestehen. Das erste Zeichen muss ein Buchstabe sein und es sind nur folgende Zeichen erlaubt: A-Z 0-9 _ - + / . ( ) [ ] "Leerzeichen"'), true, 10);
}
}
else
{
$redirect = 0;
$tpl->msg('error', _t('Fehler'), _t('Bitte vergebe f&uuml;r dein Pi Control eine Bezeichnung!'), true, 10);
}
if ($redirect == 1 || $redirect == 3)
header('Location: ?s=settings&do=pi-control&msg=theme');
elseif ($redirect == 2)
header('Location: ?s=settings&do=pi-control&msg=main');
}
elseif (isset($_POST['submit-temperature']) && $_POST['submit-temperature'] != '')
{
$cron = new Cron;
$cron->setName('coretemp_monitoring');
if (isset($_POST['temperature-maximum']) && $_POST['temperature-maximum'] >= 40 && $_POST['temperature-maximum'] <= 90 && ((isset($_POST['temperature-action-email']) && $_POST['temperature-action-email'] == 'checked') || (isset($_POST['temperature-action-shell']) && $_POST['temperature-action-shell'] == 'checked')))
{
setConfig('main:monitoringCpuTemp.maximum', $_POST['temperature-maximum']);
setConfig('main:monitoringCpuTemp.emailEnabled', isset($_POST['temperature-action-email']) ? 'true' : 'false');
setConfig('main:monitoringCpuTemp.shellEnabled', isset($_POST['temperature-action-shell']) ? 'true' : 'false');
$pActionEmail = trim($_POST['temperature-action-email-text']);
$pActionShell = trim($_POST['temperature-action-shell-text']);
if (isset($_POST['temperature-action-email']))
{
if (!filter_var($pActionEmail, FILTER_VALIDATE_EMAIL) || !strlen($pActionEmail) >= 6)
$tpl->msg('error', _t('Fehler'), _t('Bitte gebe eine g&uuml;ltige E-Mailadresse an.'), true, 10);
}
if ($tpl->msgExists(10) === false)
setConfig('main:monitoringCpuTemp.email', $pActionEmail);
if (isset($_POST['temperature-action-shell']))
{
if ($pActionShell == '')
$tpl->msg('error', _t('Fehler'), _t('Bitte gebe einen g&uuml;ltigen Shell Befehl an.'), true, 11);
}
if ($tpl->msgExists(11) === false)
setConfig('main:monitoringCpuTemp.shell', base64_encode($pActionShell));
if (getConfig('main:monitoringCpuTemp.id', '') == '')
{
$uniqid = generateUniqId();
setConfig('main:monitoringCpuTemp.id', $uniqid);
}
if (isset($_POST['temperature-action-email']) && $tpl->msgExists(10) === false)
checkTemperatureMonitoringEmailStatus();
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte w&auml;hle mindestens eine Aktion.'), true, 10);
if (isset($_POST['temperature-activation']) && $_POST['temperature-activation'] == 'checked')
{
if ($cron->isExists() === false)
{
$cron->setInterval(1);
$cron->setSource(TEMPLATES2_PATH.'coretemp_monitoring.tmp.php');
if ($cron->save() === true)
$tpl->msg('success', _t('Temperatur&uuml;berwachung aktiviert'), _t('Die Temperatur&uuml;berwachung wurde aktiviert.'));
else
$tpl->msg('error', _t('Fehler'), _t('Konnte die Temperatur&uuml;berwachung nicht aktivieren!'));
}
}
else
{
if ($cron->isExists() === true)
{
//$cron->readFile();
$cron->setInterval($cron->getInterval());
if ($cron->delete() === true)
$tpl->msg('success', _t('Temperatur&uuml;berwachung deaktiviert'), _t('Die Temperatur&uuml;berwachung wurde deaktiviert.'));
else
$tpl->msg('error', _t('Fehler'), _t('Konnte die Temperatur&uuml;berwachung nicht deaktivieren!'));
}
}
if ($tpl->msgExists(10) === false && $tpl->msgExists(11) === false)
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'));
}
if (isset($_POST['submit-temperature-confirmation']) && $_POST['submit-temperature-confirmation'] != '')
{
$id = getConfig('main:monitoringCpuTemp.id', '');
$code = getConfig('main:monitoringCpuTemp.code', '');
$email = getConfig('main:monitoringCpuTemp.email', '');
$label = getConfig('main:main.label', '');
if ($id == '' || $email == '' || $label == '')
$tpl->msg('error', _t('Fehler'), _t('Leider ist ein Fehler aufgetreten. Bitte wiederhole die Vergabe der Bezeichnung und der E-Mailadresse.'));
else
{
$fields = array('type' => 'add', 'id' => $id, 'email' => $email, 'label' => $label, 'referer' => $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], 'lang' => $globalLanguage);
$data = NULL;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $config['url']['temperatureMonitoring']);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POST, count($fields));
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
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)));
break;
}
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']));
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']));
break;
}
if ($data == '')
{
$tpl->msg('error', _t('Serverfehler'), _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine leere Antwort.'));
break;
}
// Verarbeite Datenstring
$json = json_decode($data, true);
if (json_last_error() != JSON_ERROR_NONE && (!isset($json['existing'], $json['sent']) || !isset($json['type'], $json['title'], $json['msg'], $json['skip'])))
{
$tpl->msg('error', _t('Verarbeitungsfehler'), _t('Bei der Verbindung zum Server ist ein Fehler aufgetreten. Der Server sendet eine fehlerhafte Antwort.'));
break;
}
if (isset($json['type'], $json['title'], $json['msg'], $json['skip']))
{
$tpl->msg($json['type'], $json['title'], $json['msg'], true, 10);
if ($json['skip'] === true)
break;
}
// Antwort in Ordnung
$tpl->msg('success', _t('E-Mail gesendet'), _t('Eine E-Mail mit einem Best&auml;tigungslink wurde an <strong>%s</strong> versandt. In der E-Mail ist ein Link, der angeklickt bzw. ge&ouml;ffnet werden muss. Sollte die E-Mail nach sp&auml;testens 10 Minuten nicht angekommen sein, schaue in deinem Spam-Ordner nach. Ansonsten wiederhole den Vorgang.', $email));
}
}
while (false);
curl_close($curl);
}
}
if (isset($_GET['mail_check']) && $_GET['mail_check'] == '')
{
checkTemperatureMonitoringEmailCode();
}
$cron = new Cron;
$cron->setName('coretemp_monitoring');
$tpl->assign('main-theme-color', getConfig('main:theme.color', 'blue'));
$tpl->assign('main-pi-control-label', getConfig('main:main.label', 'Raspberry Pi'));
$tpl->assign('main-pi-control-language', getConfig('init:language', 'de'));
$tpl->assign('main-pi-control-header-info', getConfig('main:headerInfo.type', 'disable'));
$tpl->assign('main-external-access', getConfig('main:access.external', 'false'));
$tpl->assign('temperature-activation', $cron->isExists());
$tpl->assign('temperature-maximum', getConfig('main:monitoringCpuTemp.maximum', 60));
$tpl->assign('temperature-action-email', (getConfig('main:monitoringCpuTemp.emailEnabled', 'false') == 'true') ? true : false);
$tpl->assign('temperature-action-email-text', getConfig('main:monitoringCpuTemp.email', ''));
$tpl->assign('temperature-action-email-status', (getConfig('main:monitoringCpuTemp.code', '') == '') ? 0 : 1);
$tpl->assign('temperature-action-shell', (getConfig('main:monitoringCpuTemp.shellEnabled', 'false') == 'true') ? true : false);
$tpl->assign('temperature-action-shell-text', htmlentities(base64_decode(getConfig('main:monitoringCpuTemp.shell', ''))));
$tpl->assign('temperature-last-execution', (getConfig('cron:execution.monitoringCpuTemp', 0)-time()+3600 > 0) ? getDateFormat(getConfig('cron:execution.monitoringCpuTemp', 0)-time()+3600) : '');
$tpl->assign('whoami', exec('whoami'));
$tpl->assign('configHelp', $config['url']['help'].'?s=view&amp;i=8'.getURLLangParam());
$tpl->draw('settings/pi-control');
?>

View File

@@ -0,0 +1,24 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('Einstellungen zu Plugins'));
$showList = true;
if (isset($_GET['status']) && $_GET['status'] != '' && ($gPlugin = pluginConfig($_GET['status'])) != false)
include_once 'plugins_status.php';
elseif (isset($_GET['delete']) && $_GET['delete'] != '' && ($gPlugin = pluginConfig($_GET['delete'])) != false)
{
$showList = false;
include_once 'plugins_delete.php';
}
if ($showList == true)
{
$plugins = pluginList();
$tpl->assign('plugins', $plugins);
$tpl->draw('settings/plugins');
}
?>

View File

@@ -0,0 +1,23 @@
<?php
if (!defined('PICONTROL')) exit();
$plugin = $gPlugin;
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (deletePlugin($plugin['id']) == true)
{
$tpl->msg('success', _t('Plugin gel&ouml;scht'), _t('Das Plugin "%s" wurde erfolgreich gel&ouml;scht.', _t($plugin['name'])));
$showList = true;
}
else
$tpl->msg('error', _t('Fehler'), _t('Das Plugin "%s" konnte nicht gel&ouml;scht werden.', _t($plugin['name'])));
}
if ($showList == false)
{
$tpl->assign('plugin', $plugin);
$tpl->draw('settings/plugin_delete');
}
?>

View File

@@ -0,0 +1,20 @@
<?php
if (!defined('PICONTROL')) exit();
$plugin = $gPlugin;
if ($plugin['disabled'] == true)
{
if (setPluginStatus($plugin['id'], true) == true)
$tpl->msg('success', _t('Plugin aktiviert'), _t('Das Plugin "%s" wurde erfolgreich aktiviert.', $plugin['name']));
else
$tpl->msg('error', _t('Fehler'), _t('Das Plugin "%s" konnte nicht aktiviert werden.', $plugin['name']));
}
elseif ($plugin['disabled'] == false)
{
if (setPluginStatus($plugin['id'], false) == true)
$tpl->msg('success', _t('Plugin deaktiviert'), _t('Das Plugin "%s" wurde erfolgreich deaktiviert.', $plugin['name']));
else
$tpl->msg('error', _t('Fehler'), _t('Das Plugin "%s" konnte nicht deaktiviert werden.', $plugin['name']));
}
?>

View File

@@ -0,0 +1,73 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'statistic/statistic.class.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Einstellungen zur Statistik'));
$statistics = array();
$statisticIDs = array();
$controller = new StatisticController();
$controller->loadStatistics('statistic/');
foreach ($controller->getStatistics() as $statistic)
{
$builder = new StatisticBuilder();
$builder->loadFromFile($statistic);
$array = $builder->getArray();
$statistics[$builder->getId()] = array('array' => $array);
$statisticIDs[] = $array['id'];
}
if (!isset($_GET['reset']) && (!isset($_GET['download'])))
{
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
if (isset($_POST['submit']))
{
$hiddenStatistics = array_values(array_diff($statisticIDs, (isset($_POST['check'])) ? $_POST['check'] : array()));
if (setConfig('main:statistic.hidden', htmlspecialchars(serialize($hiddenStatistics))) !== false)
$tpl->msg('success', _t('Einstellungen gespeichert'), _t('Die Einstellungen wurden erfolgreich gespeichert.'));
else
$tpl->msg('error', _t('Fehler'), _t('Konnte Wert nicht in Konfigurationsdatei speichern!'));
}
foreach ($statistics as &$statistic)
{
$array = $statistic['array'];
$statistic += array('visible' => (!in_array($array['id'], $hiddenStatistics)) ? true : false);
}
$tpl->assign('statistics', $statistics);
$tpl->draw('settings/statistic');
}
elseif (isset($_GET['reset']))
{
if (!isset($statistics[$_GET['reset']]))
$tpl->msg('error', _t('Fehler'), _t('Der Verlauf konnte nicht gefunden werden: %s', $_GET['reset']));
if (isset($_GET['confirm']) && $_GET['confirm'] == '')
{
if (isset($statistics[$_GET['reset']]))
{
if (($logFile = fopen(LOG_PATH.$statistics[$_GET['reset']]['array']['raw'].'.csv', 'w')) !== false)
{
$tpl->msg('success', _t('Verlauf zur&uuml;ckgesetzt'), _t('Verlauf wurde erfolgreich zur&uuml;ckgesetzt.'));
fclose($logFile);
}
else
$tpl->msg('error', _t('Fehler'), _t('Verlauf konnte nicht zur&uuml;ckgesetzt werden.'));
}
}
$tpl->assign('log', $_GET['reset']);
$tpl->assign('label', $statistics[$_GET['reset']]['array']['title']);
$tpl->draw('settings/statistic_reset');
}
elseif (isset($_GET['download']))
$tpl->redirect('api/v1/statistic_download.php?id='.$_GET['download']);
?>

View File

@@ -0,0 +1,55 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'troubleshooting/troubleshooting.function.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Problembehandlung'));
// Dateien und Ordner
$filesFolders = fileFolderPermission();
$filesFoldersError = false;
foreach ($filesFolders as $file => $info)
{
if ($info['error'] === true)
{
$filesFoldersError = true;
break;
}
}
// Cron
$cronEntry = '* * * * * '.exec('whoami').' php -f "'.CRON_PATH.'init.php" >/dev/null 2>&1 # By Pi Control';
exec('cat /etc/crontab', $crontab);
$cronMatch = preg_match('/^\*\s\*\s\*\s\*\s\*\s'.preg_quote(exec('whoami')).'\sphp \-f "'.preg_quote(CRON_PATH, '/').'init\.php"( )?(# By Pi Control)?/im', implode(PHP_EOL, $crontab));
$lastExecutionLog = array(
(file_exists(LOG_PATH.'statistic/coretemp.csv')) ? filemtime(LOG_PATH.'statistic/coretemp.csv') : 1,
(file_exists(LOG_PATH.'statistic/cpuload.csv')) ? filemtime(LOG_PATH.'statistic/cpuload.csv') : 1,
(file_exists(LOG_PATH.'statistic/ram.csv')) ? filemtime(LOG_PATH.'statistic/ram.csv') : 1,
(file_exists(LOG_PATH.'statistic/network_eth0.csv')) ? filemtime(LOG_PATH.'statistic/network_eth0.csv') : 1
);
rsort($lastExecutionLog);
$tpl->assign('filesFolders', $filesFolders);
$tpl->assign('filesFoldersError', $filesFoldersError);
$tpl->assign('configHelpFilesFolders', $config['url']['help'].'?s=view&amp;i=1'.getURLLangParam());
$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('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]));
$tpl->assign('cronLastExecutionLogBool', ($cronLastExecutionLogBool = ($lastExecutionLog[0] > time()-330) ? true : false));
$tpl->assign('cronPermission', $filesFolders['resources/cron/init.php']['permission']);
$tpl->assign('cronPermissionBool',($cronPermissionBool = $filesFolders['resources/cron/init.php']['permissionBool']));
$tpl->assign('cronUserGroup', $filesFolders['resources/cron/init.php']['userGroup']);
$tpl->assign('cronUserGroupBool', ($cronUserGroupBool = $filesFolders['resources/cron/init.php']['userGroupBool']));
$tpl->assign('cronCharacterEncoding', trim(exec('file /etc/crontab -b')));
$tpl->assign('cronCharacterEncodingBool', ($cronCharacterEncodingBool = trim(exec('file /etc/crontab -b') == 'ASCII text') ? true : false));
$tpl->assign('cronError', ($cronMatch !== 1) ? 1 : (($cronPHPCLI !== true || $cronLastExecutionBool !== true || $cronLastExecutionLogBool !== true || $cronPermissionBool !== true || $cronUserGroupBool !== true || $cronCharacterEncodingBool !== true ) ? 2 : 0));
$tpl->draw('settings/troubleshooting');
?>

View File

@@ -0,0 +1,52 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'troubleshooting/troubleshooting.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'update/update.class.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('Aktualisierung'));
$updateController = new UpdateController();
$updateController->setStage(getConfig('main:update.stage', 'release'));
$updateStatus = $updateController->fetchData();
if ($updateStatus === true)
$updateStatus = $updateController->getNextUpdate();
if (isset($_POST['update']) && $_POST['update'] != '')
$tpl->redirect('?i=update');
if (isset($_GET['complete']))
{
checkUpdate();
$tpl->msg('success', _t('Pi Control auf Version %s aktualisiert', $config['version']['version']), _t('Dein Pi Control wurde erfolgreich aktualisiert und ist nun einsatzbereit. Sollten Probleme auftreten, klicke einfach unten auf "Feedback" und schreibe mir. Viel Spaß!<br /><br />Tipp: Leere deinen Browser-Cache mit Strg + F5 (Windows) / &#8997;&#8984; + E (OS X / Safari) / &#8679;&#8984; + R (OS X / Chrome)'));
}
if (isset($_POST['beta']) && $_POST['beta'] != '')
{
$newStage = getConfig('main:update.stage', 'release') == 'release' ? 'beta' : 'release';
if ($newStage == 'release')
$tpl->msg('success', _t('Erfolgreich zur&uuml;ckgetreten'), _t('Du bist erfolgreich von Pi Control Beta zur&uuml;ckgetreten. Ab sofort erh&auml;ltst du ausschließlich stabile Aktualisierungen.'));
else
$tpl->msg('success', _t('Erfolgreich teilgenommen'), _t('Vielen Dank f&uuml;r deine Teilnahme an Pi Control Beta. Ab sofort erh&auml;ltst du Beta-Aktualisierungen.'));
setConfig('main:update.stage', $newStage);
$updateController->setStage($newStage);
$updateStatus = $updateController->getNextUpdate();
}
$filesFolders = fileFolderPermission();
$fileError = (array_search(true, array_column($filesFolders, 'error'))) ? true : false;
if ($fileError === true)
$tpl->msg('error', _t('Aktualisierung blockiert'), _t('Es wurde mindestens ein Fehler mit den Dateien oder Ordnern des Pi Control festgestellt! Bitte behebe zun&auml;chst das Problem mit Hilfe der <a href="%s">Problembehandlung</a>, ansonsten ist eine Aktualisierung nicht m&ouml;glich.', '?s=settings&amp;do=troubleshooting'), false);
$tpl->assign('updateError', $fileError);
$tpl->assign('updateStatus', $updateStatus);
$tpl->assign('updateStage', getConfig('main:update.stage', 'release'));
$tpl->assign('configVersion', $config['version']['version']);
$tpl->assign('configMailUrl', $config['url']['updateNotification'].getURLLangParam());
$tpl->draw('settings/update');
?>

View File

@@ -0,0 +1,163 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'user/user.function.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Einstellungen zum Benutzer'));
$showOverview = true;
if (isset($_GET['add']) && $_GET['add'] == '')
{
if (isset($_POST['submit']) && $_POST['submit'] != '')
{
if (isset($_POST['username'], $_POST['password'], $_POST['password2']) && ($pUsername = trim($_POST['username'])) != '' && ($pPassword = $_POST['password']) != '' && ($pPassword2 = $_POST['password2']) != '')
{
if (preg_match('/^[a-z][a-z0-9\-_]{1,31}$/i', $pUsername) === 1)
{
$lowerUsername = strtolower($pUsername);
if (getConfig('user:user_'.$lowerUsername.'.username', '') == '')
{
if (preg_match('/^[a-z0-9_\-\+\*\/\#.\!\?@\(\)\[\]\{\}\<\>\=\$%&,\|\:~§;]{4,64}$/i', $pPassword) === 1)
{
if ($pPassword === $pPassword2)
{
setConfig('user:user_'.$lowerUsername.'.username', $pUsername);
setConfig('user:user_'.$lowerUsername.'.created', time());
setConfig('user:user_'.$lowerUsername.'.password', password_hash($pPassword, PASSWORD_BCRYPT));
setConfig('user:user_'.$lowerUsername.'.last_login', 0);
$tpl->msg('success', _t('Benutzer angelegt'), _t('Der Benutzer "%s" wurder erfolgreich angelegt.', $pUsername));
}
else
$tpl->msg('error', _t('Fehler'), _t('Die angegebenen Passw&ouml;rter stimmen nicht &uuml;berein!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist das Passwort ung&uuml;ltig! Das Passwort muss aus 4 bis 64 Zeichen bestehen und darf nur folgende Zeichen beinhalten: A-Z 0-9 - _ + * / # . ! ? @ ( ) [ ] { } < > = $ %% & , | : ~ § ;'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist der Benutzername bereits vergeben! Bitte w&auml;hle einen anderen.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist der Benutzername ung&uuml;ltig! Der Benutzername muss aus 2 bis 32 Zeichen bestehen. Das erste Zeichen muss ein Buchstabe sein und es sind nur folgende Zeichen erlaubt: A-Z 0-9 - _'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte alle Felder ausf&uuml;llen.'));
}
$showOverview = false;
$tpl->draw('settings/user_add');
}
elseif (isset($_GET['delete']) && $_GET['delete'] != '')
{
$lowerUsername = $_GET['delete'];
$username = getConfig('user:user_'.$lowerUsername.'.username', '');
if ($username != '')
{
$showDelete = true;
if (isset($_POST['submit']))
{
if (isset($_POST['password']) && ($pPassword = $_POST['password']) != '')
{
$password = getConfig('user:user_'.$lowerUsername.'.password', '');
if (password_verify($pPassword, $password) === true)
{
removeConfig('user:user_'.$lowerUsername);
$loggedInUsers = getConfig('login');
foreach ($loggedInUsers as $key => $user)
{
if ($user['username'] == $lowerUsername)
removeConfig('login:'.$key);
}
$showDelete = false;
$tpl->msg('success', _t('Benutzer gel&ouml;scht'), _t('Der Benutzer wurde erfolgreich gel&ouml;scht!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Das Passwort ist nicht korrekt!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte alle Felder ausf&uuml;llen.'));
}
if ($showDelete === true)
{
$tpl->assign('lowerUsername', $lowerUsername);
$tpl->assign('username', $username);
$showOverview = false;
$tpl->draw('settings/user_delete');
}
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider existiert der Benutzer nicht!'));
}
elseif (isset($_GET['edit']) && $_GET['edit'] != '')
{
$lowerUsername = $_GET['edit'];
$username = getConfig('user:user_'.$lowerUsername.'.username', '');
if ($username != '')
{
if (isset($_POST['submit']))
{
if (isset($_POST['passwordOld'], $_POST['passwordNew'], $_POST['passwordNew2']) && ($pPasswordOld = $_POST['passwordOld']) != '' && ($pPasswordNew = $_POST['passwordNew']) != '' && ($pPasswordNew2 = $_POST['passwordNew2']) != '')
{
if (preg_match('/^[a-z0-9_\-\+\*\/\#.\!\?@\(\)\[\]\{\}\<\>\=\$%&,\|\:~§;]{4,64}$/i', $pPasswordNew) === 1)
{
$passwordOld = getConfig('user:user_'.$lowerUsername.'.password', '');
if (password_verify($pPasswordOld, $passwordOld) === true)
{
if ($pPasswordNew === $pPasswordNew2)
{
setConfig('user:user_'.$lowerUsername.'.password', password_hash($pPasswordNew, PASSWORD_BCRYPT));
$tpl->msg('success', _t('Benutzer bearbeitet'), _t('Der Benutzer "%s" wurde erfolgreich bearbeitet und gespeichert.', $username));
}
else
$tpl->msg('error', _t('Fehler'), _t('Das neue Passwort stimmt nicht mit der Wiederholung &uuml;berein!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Das alte Passwort ist nicht korrekt!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider ist das Passwort ung&uuml;ltig! Das Passwort muss aus 4 bis 64 Zeichen bestehen und darf nur folgende Zeichen beinhalten: A-Z 0-9 - _ + * / # . ! ? @ ( ) [ ] { } < > = $ %% & , | : ~ § ;'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte alle Felder ausf&uuml;llen.'));
}
$tpl->assign('lowerUsername', $lowerUsername);
$tpl->assign('username', $username);
$showOverview = false;
$tpl->draw('settings/user_edit');
}
else
$tpl->msg('error', _t('Fehler'), _t('Leider existiert der Benutzer nicht!'));
}
if ($showOverview === true)
{
if (isset($_POST['logout']) && $_POST['logout'] != '' && strlen($_POST['logout']) == 32)
{
removeConfig('login:token_'.$_POST['logout']);
$tpl->msg('success', _t('Benutzer abgemeldet'), _t('Der Benutzer wurde erfolgreich abgemeldet.'));
}
$allUsers = getConfig('user');
$loggedInUsers = getConfig('login');
unset($loggedInUsers['login']);
array_walk($loggedInUsers, 'loggedInUsers', $allUsers);
$loggedInUsers = array_sort($loggedInUsers, 'created', SORT_DESC);
$tpl->assign('allUsers', $allUsers);
$tpl->assign('loggedInUsers', $loggedInUsers);
$tpl->draw('settings/user');
}
?>

View File

@@ -0,0 +1,36 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->assign('overviewUrl', '?s=overview');
if (isset($_GET['restart']) && $_GET['restart'] == '')
{
$tpl->setHeaderTitle(_t('Neu starten'));
list ($SSHReturn, $SSHError, $SSHExitStatus) = $tpl->executeSSH('sudo /sbin/shutdown -r now', true);
if (!empty($SSHError))
$tpl->msg('error', _t('Neu starten nicht m&ouml;glich'), nl2br($SSHError));
else
{
$jsTranslations = array();
$jsTranslations[] = 'Online - Du wirst sofort weitergeleitet';
$jsTranslations[] = 'Offline';
$tpl->assign('jsTranslations', $jsTranslations);
$tpl->draw('restart');
}
}
else
{
$tpl->setHeaderTitle(_t('Herunterfahren'));
list ($SSHReturn, $SSHError, $SSHExitStatus) = $tpl->executeSSH('sudo /sbin/shutdown -h now', true);
if (!empty($SSHError))
$tpl->msg('error', _t('Herunterfahren nicht m&ouml;glich'), nl2br($SSHError));
else
$tpl->draw('shutdown');
}
?>

View File

@@ -0,0 +1,80 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle(_t('SSH-Login'));
// Anmelden
if (isset($_POST['submit'], $_POST['ssh-login']) && $_POST['submit'] != '' && in_array($_POST['ssh-login'], array('password', 'publickey')))
{
$pType = $_POST['ssh-login'];
if ($pType == 'password')
{
if (isset($_POST['port'], $_POST['username'], $_POST['password']) && ($pPort = intval(trim($_POST['port']))) != '' && ($pUsername = trim($_POST['username'])) != '' && ($pPassword = $_POST['password']) != '')
{
$pRememberMe = (isset($_POST['remember-me']) && $_POST['remember-me'] == 'checked') ? true : false;
if (is_numeric($pPort) && $pPort >= 0 && $pPort <= 65535)
{
if ($tpl->setSSHInfo($pType, $pPort, $pUsername, $pPassword, NULL, $pRememberMe) === true)
{
if ($tpl->getSSHResource() !== false)
$tpl->msg('success', _t('Verbindung hergestellt'), _t('Verbindung zum Raspberry Pi wurde hergestellt.'));
else
$tpl->msg('error', _t('Fehler'), _t('Verbindung zum Raspberry Pi war nicht erfolgreich!<br /><br />Bitte &uuml;berpr&uuml;fe die eingegebenen Daten. Schl&auml;gt ein erneuter Versuch mit korrekten Daten fehl, wende dich bitte unten unter "Feedback" an mich, ich werde dir so schnell wie m&ouml;glich weiterhelfen.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Fehler beim Speichern der Daten!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Ung&uuml;ltiger Port. Der Port muss zwischen 0 und 65535 liegen.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte alle Felder ausf&uuml;llen.'));
}
elseif ($pType == 'publickey')
{
if (isset($_POST['port_'], $_POST['username_'], $_POST['privatekey_']) && ($pPort = intval(trim($_POST['port_']))) != '' && ($pUsername = trim($_POST['username_'])) != '' && ($pPrivateKey = $_POST['privatekey_']) != '')
{
$pPassword = isset($_POST['password_']) ? $_POST['password_'] : '';
$pRememberMe = (isset($_POST['remember-me_']) && $_POST['remember-me_'] == 'checked') ? true : false;
if (is_numeric($pPort) && $pPort >= 0 && $pPort <= 65535)
{
if ($tpl->setSSHInfo($pType, $pPort, $pUsername, $pPassword, $pPrivateKey, $pRememberMe) === true)
{
if ($tpl->getSSHResource() !== false)
$tpl->msg('success', _t('Verbindung hergestellt'), _t('Verbindung zum Raspberry Pi wurde hergestellt.'));
else
$tpl->msg('error', _t('Fehler'), _t('Verbindung zum Raspberry Pi war nicht erfolgreich!<br /><br />Bitte &uuml;berpr&uuml;fe die eingegebenen Daten. Schl&auml;gt ein erneuter Versuch mit korrekten Daten fehl, wende dich bitte unten unter "Feedback" an mich, ich werde dir so schnell wie m&ouml;glich weiterhelfen.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Fehler beim Speichern der Daten!'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Ung&uuml;ltiger Port. Der Port muss zwischen 0 und 65535 liegen.'));
}
else
$tpl->msg('error', _t('Fehler'), _t('Bitte alle Felder ausf&uuml;llen.'));
}
}
// Abmelden
if (isset($_GET['logout']))
{
if ($tpl->logoutSSH() === true)
$tpl->msg('success', _t('Verbindung getrennt'), _t('Erfolgreich abgemeldet.'));
else
$tpl->msg('error', _t('Fehler'), _t('Beim Abmelden ist ein Fehler aufgetreten!'));
}
$SSHInfo = $tpl->getSSHInfo();
if (!is_array($SSHInfo))
$tpl->msg('error', _t('Fehler'), _t('Konnte SSH-Informationen nicht abrufen.'), false);
$tpl->assign('ssh_info', $SSHInfo);
$tpl->assign('logged_in', ($tpl->getSSHResource() !== false));
$tpl->draw('ssh_login');
?>

View File

@@ -0,0 +1,27 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'statistic/statistic.class.php') or die('Error: 0x0010');
$tpl->setHeaderTitle(_t('Statistik'));
$statistics = array();
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
$controller = new StatisticController($tpl);
$controller->loadStatistics('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, 'json' => $builder->getJSON());
}
$tpl->assign('statistics', $statistics);
$tpl->assign('msgInfo', (count($hiddenStatistics) == count($controller->getStatistics())) ? 'invisible' : ((count($controller->getStatistics()) == 0) ? 'empty' : ''));
$tpl->draw('statistic');
?>

View File

@@ -0,0 +1,70 @@
<?php
if (!defined('PICONTROL')) exit();
$tpl->setHeaderTitle('Terminal');
$jsTranslations = array();
$jsTranslations[] = 'Verbindung herstellen...';
$jsTranslations[] = 'Bitte gebe einen Befehl ein!';
$jsTranslations[] = 'Verbunden';
$jsTranslations[] = 'Verbindung getrennt';
$jsTranslations[] = 'Fehler aufgetreten!';
$jsTranslations[] = 'Verbindung erneut herstellen';
$jsTranslations[] = 'Verbindung getrennt<br />(Anmeldung an anderem Fenster)';
$jsTranslations[] = 'Verbindung getrennt<br />(Keine Berechtigung)';
$selectedPort = (isset($_GET['port'])) ? $_GET['port'] : 9001;
$ports = array();
if (isset($_GET['kill']) && $_GET['kill'])
{
if (($terminal = getConfig('terminal:port_'.$_GET['kill'], '')) != '')
{
removeConfig('terminal:port_'.$_GET['kill']);
exec('kill -9 '.$terminal['pid']);
$tpl->msg('success', _t('Terminal beendet'), _t('Das Terminal wurde erfolgreich beendet.'));
}
}
if ($tpl->getSSHResource(1) !== false)
{
$termials = getConfig('terminal', array());
$ports = array(
array('port' => 9001, 'active' => false),
array('port' => 9002, 'active' => false),
array('port' => 9003, 'active' => false),
array('port' => 9004, 'active' => false),
array('port' => 9005, 'active' => false)
);
foreach ($ports as $index => $port)
{
if (($terminal = getConfig('terminal:port_'.$port['port'], '')) != '')
{
if (shell_exec('netstat -atn | grep :'.$port['port']) == '')
{
removeConfig('terminal:port_'.$port['port']);
exec('kill -9 '.$terminal['pid']);
}
}
if (isset($termials['port_'.$port['port']]) && shell_exec('netstat -atn | grep :'.$port['port']) != '')
$ports[$index]['active'] = true;
}
}
// Vorkehrung aufgrund fehlendem HTTPS-Support
if (isset($_SERVER['HTTPS']))
{
$tpl->msg('info', _t('Terminal nicht verf&uuml;gbar'), _t('Das Terminal kann momentan noch nicht unter HTTPS verwendet werden.'));
}
$tpl->assign('port', $selectedPort);
$tpl->assign('ports', $ports);
$tpl->assign('cookie', substr($_COOKIE['_pi-control_login'], 0, 16));
$tpl->assign('jsTranslations', $jsTranslations);
$tpl->draw('terminal');
?>

View File

@@ -0,0 +1,16 @@
<?php
if (!defined('PICONTROL')) exit();
(include_once LIBRARY_PATH.'main/rpi.function.php') or die('Error: 0x0010');
(include_once LIBRARY_PATH.'cache/cache.class.php') or die('Error: 0x0011');
$tpl->setHeaderTitle(_t('Benutzer/Gruppen'));
$users = new Cache('users', 'rpi_getAllUsers');
$users->load();
$tpl->assign('all_users', $users->getContent());
$tpl->assign('users_cache_hint', $users->displayHint());
$tpl->draw('users_groups');
?>