major refactoring of almost all files
This commit is contained in:
@@ -4,30 +4,40 @@
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Panel
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* @since 0.9.34
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you can also view it online at
|
||||
* https://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright the authors
|
||||
* @author Froxlor team <team@froxlor.org>
|
||||
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||
*/
|
||||
|
||||
const AREA = 'admin';
|
||||
require __DIR__ . '/lib/init.php';
|
||||
|
||||
use Froxlor\Config\ConfigParser;
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
use Froxlor\UI\Response;
|
||||
|
||||
if ($userinfo['change_serversettings'] == '1') {
|
||||
|
||||
if ($action == 'setconfigured') {
|
||||
Settings::Set('panel.is_configured', '1', true);
|
||||
\Froxlor\UI\Response::redirectTo('admin_configfiles.php');
|
||||
Response::redirectTo('admin_configfiles.php');
|
||||
}
|
||||
|
||||
// get distro from URL param
|
||||
@@ -36,15 +46,15 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
$distributions_select = [];
|
||||
|
||||
$services = [];
|
||||
$config_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/');
|
||||
$config_dir = FileDir::makeCorrectDir(Froxlor::getInstallDir() . '/lib/configfiles/');
|
||||
|
||||
if (!empty($distribution)) {
|
||||
if (!file_exists($config_dir . '/' . $distribution . ".xml")) {
|
||||
\Froxlor\UI\Response::dynamic_error("Unknown distribution");
|
||||
Response::dynamicError("Unknown distribution");
|
||||
}
|
||||
|
||||
// create configparser object
|
||||
$configfiles = new \Froxlor\Config\ConfigParser($config_dir . '/' . $distribution . ".xml");
|
||||
$configfiles = new ConfigParser($config_dir . '/' . $distribution . ".xml");
|
||||
|
||||
// get distro-info
|
||||
$dist_display = $configfiles->getCompleteDistroName();
|
||||
@@ -52,13 +62,12 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
// get all the services from the distro
|
||||
$services = $configfiles->getServices();
|
||||
} else {
|
||||
|
||||
// show list of available distro's
|
||||
$distros = glob($config_dir . '*.xml');
|
||||
// read in all the distros
|
||||
foreach ($distros as $_distribution) {
|
||||
// get configparser object
|
||||
$dist = new \Froxlor\Config\ConfigParser($_distribution);
|
||||
$dist = new ConfigParser($_distribution);
|
||||
// store in tmp array
|
||||
$distributions_select[str_replace(".xml", "", strtolower(basename($_distribution)))] = $dist->getCompleteDistroName();
|
||||
}
|
||||
@@ -68,7 +77,6 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
}
|
||||
|
||||
if ($distribution != "" && isset($_POST['finish'])) {
|
||||
|
||||
unset($_POST['finish']);
|
||||
$params = $_POST;
|
||||
$params['distro'] = $distribution;
|
||||
@@ -77,19 +85,18 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
$params['system'][] = $sysdaemon;
|
||||
}
|
||||
$params_content = json_encode($params);
|
||||
$params_filename = \Froxlor\FileDir::makeCorrectFile(\Froxlor\Froxlor::getInstallDir() . 'install/' . \Froxlor\Froxlor::genSessionId() . '.json');
|
||||
$params_filename = FileDir::makeCorrectFile(Froxlor::getInstallDir() . 'install/' . Froxlor::genSessionId() . '.json');
|
||||
file_put_contents($params_filename, $params_content);
|
||||
|
||||
UI::twigBuffer('settings/configuration-final.html.twig', [
|
||||
'distribution' => $distribution,
|
||||
// alert
|
||||
'type' => 'info',
|
||||
'alert_msg' => $lng['admin']['configfiles']['finishnote'],
|
||||
'basedir' => \Froxlor\Froxlor::getInstallDir(),
|
||||
'alert_msg' => lng('admin.configfiles.finishnote'),
|
||||
'basedir' => Froxlor::getInstallDir(),
|
||||
'params_filename' => $params_filename
|
||||
]);
|
||||
} else {
|
||||
|
||||
if (!empty($distribution)) {
|
||||
// show available services to configure
|
||||
$fields = $services;
|
||||
@@ -104,46 +111,56 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
|
||||
$cfg_formfield = [
|
||||
'config' => [
|
||||
'title' => $lng['admin']['configfiles']['serverconfiguration'],
|
||||
'title' => lng('admin.configfiles.serverconfiguration'),
|
||||
'image' => 'fa-solid fa-wrench',
|
||||
'description' => $lng['admin']['configfiles']['description'],
|
||||
'description' => lng('admin.configfiles.description'),
|
||||
'sections' => [
|
||||
'section_config' => [
|
||||
'fields' => [
|
||||
'distribution' => ['type' => 'select', 'select_var' => $distributions_select, 'label' => $lng['admin']['configfiles']['distribution']]
|
||||
'distribution' => [
|
||||
'type' => 'select',
|
||||
'select_var' => $distributions_select,
|
||||
'label' => lng('admin.configfiles.distribution')
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'buttons' => [
|
||||
[
|
||||
'class' => 'btn-outline-secondary',
|
||||
'label' => $lng['panel']['cancel'],
|
||||
'label' => lng('panel.cancel'),
|
||||
'type' => 'reset'
|
||||
],
|
||||
[
|
||||
'label' => $lng['update']['proceed']
|
||||
'label' => lng('update.proceed')
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
UI::twigBuffer('user/form-note.html.twig', [
|
||||
'formaction' => $linker->getLink(array('section' => 'configfiles')),
|
||||
'formaction' => $linker->getLink(['section' => 'configfiles']),
|
||||
'formdata' => $cfg_formfield['config'],
|
||||
'actions_links' => (int) Settings::Get('panel.is_configured') == 0 ? [[
|
||||
'href' => $linker->getLink(['section' => 'configfiles', 'page' => 'overview', 'action' => 'setconfigured']),
|
||||
'label' => $lng['panel']['ihave_configured'],
|
||||
'class' => 'btn-outline-warning',
|
||||
'icon' => 'fa fa-circle-check'
|
||||
]] : [],
|
||||
'actions_links' => (int)Settings::Get('panel.is_configured') == 0 ? [
|
||||
[
|
||||
'href' => $linker->getLink([
|
||||
'section' => 'configfiles',
|
||||
'page' => 'overview',
|
||||
'action' => 'setconfigured'
|
||||
]),
|
||||
'label' => lng('panel.ihave_configured'),
|
||||
'class' => 'btn-outline-warning',
|
||||
'icon' => 'fa fa-circle-check'
|
||||
]
|
||||
] : [],
|
||||
// alert
|
||||
'type' => 'warning',
|
||||
'alert_msg' => $lng['panel']['settings_before_configuration'] . ((int)Settings::Get('panel.is_configured') == 1 ? '<br><br>' . $lng['panel']['system_is_configured'] : '')
|
||||
'alert_msg' => lng('panel.settings_before_configuration') . ((int)Settings::Get('panel.is_configured') == 1 ? '<br><br>' . lng('panel.system_is_configured') : '')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
UI::twigOutputBuffer();
|
||||
} else {
|
||||
\Froxlor\UI\Response::redirectTo('admin_index.php');
|
||||
Response::redirectTo('admin_index.php');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user