Init Repo
This commit is contained in:
45
resources/content/settings/cache.php
Normal file
45
resources/content/settings/cache.php
Normal 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ür die Speicherzeit eine gü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');
|
||||
?>
|
||||
142
resources/content/settings/notification.php
Normal file
142
resources/content/settings/notification.php
Normal 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ü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ü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ü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ülle alle nötigen Felder aus und wä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');
|
||||
?>
|
||||
107
resources/content/settings/overview.php
Normal file
107
resources/content/settings/overview.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
if (!defined('PICONTROL')) exit();
|
||||
|
||||
$tpl->setHeaderTitle(_t('Einstellungen zur Ü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ü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ü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ü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ü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ü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ü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ülle alle benö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');
|
||||
?>
|
||||
251
resources/content/settings/pi-control.php
Normal file
251
resources/content/settings/pi-control.php
Normal 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-Änderung wirksam zu machen, leere deinen Browser-Cache mit Strg + F5 (Windows) / ⌥⌘ + E (OS X / Safari) / ⇧⌘ + 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ü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ü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ü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ü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ä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überwachung aktiviert'), _t('Die Temperaturüberwachung wurde aktiviert.'));
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Konnte die Temperaturüberwachung nicht aktivieren!'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($cron->isExists() === true)
|
||||
{
|
||||
//$cron->readFile();
|
||||
$cron->setInterval($cron->getInterval());
|
||||
if ($cron->delete() === true)
|
||||
$tpl->msg('success', _t('Temperaturüberwachung deaktiviert'), _t('Die Temperaturüberwachung wurde deaktiviert.'));
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Konnte die Temperaturü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ätigungslink wurde an <strong>%s</strong> versandt. In der E-Mail ist ein Link, der angeklickt bzw. geöffnet werden muss. Sollte die E-Mail nach spä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&i=8'.getURLLangParam());
|
||||
|
||||
$tpl->draw('settings/pi-control');
|
||||
?>
|
||||
24
resources/content/settings/plugins.php
Normal file
24
resources/content/settings/plugins.php
Normal 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');
|
||||
}
|
||||
?>
|
||||
23
resources/content/settings/plugins_delete.php
Normal file
23
resources/content/settings/plugins_delete.php
Normal 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öscht'), _t('Das Plugin "%s" wurde erfolgreich gelöscht.', _t($plugin['name'])));
|
||||
$showList = true;
|
||||
}
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Das Plugin "%s" konnte nicht gelöscht werden.', _t($plugin['name'])));
|
||||
}
|
||||
|
||||
if ($showList == false)
|
||||
{
|
||||
$tpl->assign('plugin', $plugin);
|
||||
|
||||
$tpl->draw('settings/plugin_delete');
|
||||
}
|
||||
?>
|
||||
20
resources/content/settings/plugins_status.php
Normal file
20
resources/content/settings/plugins_status.php
Normal 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']));
|
||||
}
|
||||
?>
|
||||
73
resources/content/settings/statistic.php
Normal file
73
resources/content/settings/statistic.php
Normal 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ückgesetzt'), _t('Verlauf wurde erfolgreich zurückgesetzt.'));
|
||||
fclose($logFile);
|
||||
}
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Verlauf konnte nicht zurü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']);
|
||||
?>
|
||||
55
resources/content/settings/troubleshooting.php
Normal file
55
resources/content/settings/troubleshooting.php
Normal 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&i=1'.getURLLangParam());
|
||||
$tpl->assign('configHelpCron', $config['url']['help'].'?s=view&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');
|
||||
?>
|
||||
52
resources/content/settings/update.php
Normal file
52
resources/content/settings/update.php
Normal 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) / ⌥⌘ + E (OS X / Safari) / ⇧⌘ + 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ückgetreten'), _t('Du bist erfolgreich von Pi Control Beta zurückgetreten. Ab sofort erhältst du ausschließlich stabile Aktualisierungen.'));
|
||||
else
|
||||
$tpl->msg('success', _t('Erfolgreich teilgenommen'), _t('Vielen Dank für deine Teilnahme an Pi Control Beta. Ab sofort erhä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ächst das Problem mit Hilfe der <a href="%s">Problembehandlung</a>, ansonsten ist eine Aktualisierung nicht möglich.', '?s=settings&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');
|
||||
?>
|
||||
163
resources/content/settings/user.php
Normal file
163
resources/content/settings/user.php
Normal 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örter stimmen nicht überein!'));
|
||||
}
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Leider ist das Passwort ungü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ähle einen anderen.'));
|
||||
}
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Leider ist der Benutzername ungü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ü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öscht'), _t('Der Benutzer wurde erfolgreich gelöscht!'));
|
||||
}
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Das Passwort ist nicht korrekt!'));
|
||||
}
|
||||
else
|
||||
$tpl->msg('error', _t('Fehler'), _t('Bitte alle Felder ausfü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 ü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ü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ü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');
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user