mirror of
https://github.com/Froxlor/Froxlor.git
synced 2024-09-21 18:37:30 +00:00
merge branch '0.11-dev' of github.com:Froxlor/Froxlor into 0.11-dev
This commit is contained in:
commit
1557482d17
@ -43,6 +43,11 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
// get distro from URL param
|
||||
$distribution = Request::get('distribution');
|
||||
|
||||
// check for possible setting
|
||||
if (empty($distribution)) {
|
||||
$distribution = Settings::Get('system.distribution') ?? "";
|
||||
}
|
||||
|
||||
$distributions_select = [];
|
||||
|
||||
$services = [];
|
||||
@ -53,6 +58,11 @@ if ($userinfo['change_serversettings'] == '1') {
|
||||
Response::dynamicError("Unknown distribution");
|
||||
}
|
||||
|
||||
// update setting if different
|
||||
if ($distribution != Settings::Get('system.distribution')) {
|
||||
Settings::Set('system.distribution', $distribution);
|
||||
}
|
||||
|
||||
// create configparser object
|
||||
$configfiles = new ConfigParser($config_dir . '/' . $distribution . ".xml");
|
||||
|
||||
|
@ -699,6 +699,7 @@ opcache.validate_timestamps'),
|
||||
('system', 'froxlorusergroup', ''),
|
||||
('system', 'froxlorusergroup_gid', ''),
|
||||
('system', 'acmeshpath', '/root/.acme.sh/acme.sh'),
|
||||
('system', 'distribution', ''),
|
||||
('api', 'enabled', '0'),
|
||||
('2fa', 'enabled', '1'),
|
||||
('panel', 'decimal_places', '4'),
|
||||
|
@ -126,6 +126,8 @@ if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
Update::showUpdateStep("Adding new settings");
|
||||
$panel_settings_mode = isset($_POST['panel_settings_mode']) ? (int) $_POST['panel_settings_mode'] : 0;
|
||||
Settings::AddNew("panel.settings_mode", $panel_settings_mode);
|
||||
$system_distribution = isset($_POST['system_distribution']) ? $_POST['system_distribution'] : '';
|
||||
Settings::AddNew("system.distribution", $system_distribution);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Update::showUpdateStep("Adjusting existing settings");
|
||||
|
@ -15,6 +15,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\Config\ConfigParser;
|
||||
|
||||
/**
|
||||
* checks if the new-version has some updating to do
|
||||
*
|
||||
@ -29,7 +33,6 @@
|
||||
*/
|
||||
function parseAndOutputPreconfig011(&$has_preconfig, &$return, $current_version, $current_db_version)
|
||||
{
|
||||
global $lng;
|
||||
|
||||
if (versionInUpdate($current_version, '0.10.99')) {
|
||||
$has_preconfig = true;
|
||||
@ -45,5 +48,28 @@ function parseAndOutputPreconfig011(&$has_preconfig, &$return, $current_version,
|
||||
'selected' => 1,
|
||||
'label' => $question
|
||||
];
|
||||
|
||||
$description = 'The configuration page now can preselect a distribution, please select your current distribution';
|
||||
$return['system_distribution_note'] = ['type' => 'infotext', 'value' => $description];
|
||||
$question = '<strong>Select distribution</strong>';
|
||||
$config_dir = FileDir::makeCorrectDir(Froxlor::getInstallDir() . '/lib/configfiles/');
|
||||
// show list of available distro's
|
||||
$distros = glob($config_dir . '*.xml');
|
||||
$distributions_select[''] = '-';
|
||||
// read in all the distros
|
||||
foreach ($distros as $_distribution) {
|
||||
// get configparser object
|
||||
$dist = new ConfigParser($_distribution);
|
||||
// store in tmp array
|
||||
$distributions_select[str_replace(".xml", "", strtolower(basename($_distribution)))] = $dist->getCompleteDistroName();
|
||||
}
|
||||
// sort by distribution name
|
||||
asort($distributions_select);
|
||||
$return['system_distribution'] = [
|
||||
'type' => 'select',
|
||||
'select_var' => $distributions_select,
|
||||
'selected' => '',
|
||||
'label' => $question
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
namespace Froxlor\Api\Commands;
|
||||
|
||||
use Froxlor\Api\ApiCommand;
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
class ApiKeys extends ApiCommand
|
||||
{
|
||||
|
||||
public function listing()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function listingCount()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -296,6 +296,8 @@ class Froxlor extends ApiCommand
|
||||
*
|
||||
* @param string $module
|
||||
* optional, return list of functions for a specific module
|
||||
* @param string $function
|
||||
* optional, return parameter information for a specific module and function
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
@ -304,6 +306,7 @@ class Froxlor extends ApiCommand
|
||||
public function listFunctions()
|
||||
{
|
||||
$module = $this->getParam('module', true, '');
|
||||
$function = $this->getParam('function', true, '');
|
||||
|
||||
$functions = [];
|
||||
if ($module != null) {
|
||||
@ -313,11 +316,13 @@ class Froxlor extends ApiCommand
|
||||
$reflection = new ReflectionClass(__NAMESPACE__ . '\\' . $module);
|
||||
$_functions = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||
foreach ($_functions as $func) {
|
||||
if ($func->class == __NAMESPACE__ . '\\' . $module && $func->isPublic()) {
|
||||
array_push($functions, array_merge([
|
||||
'module' => $module,
|
||||
'function' => $func->name
|
||||
], $this->getParamListFromDoc($module, $func->name)));
|
||||
if (empty($function) || ($function != null && $func->name == $function)) {
|
||||
if ($func->class == __NAMESPACE__ . '\\' . $module && $func->isPublic()) {
|
||||
array_push($functions, array_merge([
|
||||
'module' => $module,
|
||||
'function' => $func->name
|
||||
], $this->getParamListFromDoc($module, $func->name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -29,7 +29,9 @@ use Exception;
|
||||
use PDO;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Froxlor\Database\Database;
|
||||
|
||||
final class RunApiCommand extends CliCommand
|
||||
@ -42,6 +44,7 @@ final class RunApiCommand extends CliCommand
|
||||
$this->addArgument('user', InputArgument::REQUIRED, 'Loginname of the user you want to run the command as')
|
||||
->addArgument('api-command', InputArgument::REQUIRED, 'The command to execute in the form "Module.function"')
|
||||
->addArgument('parameters', InputArgument::OPTIONAL, 'Paramaters to pass to the command as JSON array');
|
||||
$this->addOption('show-params', 's', InputOption::VALUE_NONE, 'Show possible parameters for given api-command (given command will *not* be called)');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
@ -50,26 +53,54 @@ final class RunApiCommand extends CliCommand
|
||||
|
||||
$result = $this->validateRequirements($input, $output);
|
||||
|
||||
try {
|
||||
$loginname = $input->getArgument('user');
|
||||
$userinfo = $this->getUserByName($loginname);
|
||||
$command = $input->getArgument('api-command');
|
||||
$apicmd = $this->validateCommand($command);
|
||||
$module = "\\Froxlor\\Api\\Commands\\" . $apicmd['class'];
|
||||
$function = $apicmd['function'];
|
||||
$params_json = $input->getArgument('parameters');
|
||||
$params = json_decode($params_json ?? '', true);
|
||||
$json_result = $module::getLocal($userinfo, $params)->{$function}();
|
||||
$output->write($json_result);
|
||||
$result = self::SUCCESS;
|
||||
} catch (Exception $e) {
|
||||
$output->writeln('<error>' . $e->getMessage() . '</>');
|
||||
$result = self::FAILURE;
|
||||
if ($result == self::SUCCESS) {
|
||||
try {
|
||||
$loginname = $input->getArgument('user');
|
||||
$userinfo = $this->getUserByName($loginname);
|
||||
$command = $input->getArgument('api-command');
|
||||
$apicmd = $this->validateCommand($command);
|
||||
$module = "\\Froxlor\\Api\\Commands\\" . $apicmd['class'];
|
||||
$function = $apicmd['function'];
|
||||
if ($input->getOption('show-params') !== false) {
|
||||
$json_result = \Froxlor\Api\Commands\Froxlor::getLocal($userinfo, ['module' => $apicmd['class'], 'function' => $function])->listFunctions();
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$result = $this->outputParamsList($json_result, $io);
|
||||
} else {
|
||||
$params_json = $input->getArgument('parameters');
|
||||
$params = json_decode($params_json ?? '', true);
|
||||
$json_result = $module::getLocal($userinfo, $params)->{$function}();
|
||||
$output->write($json_result);
|
||||
$result = self::SUCCESS;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$output->writeln('<error>' . $e->getMessage() . '</>');
|
||||
$result = self::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function outputParamsList(string $json, SymfonyStyle $io): int
|
||||
{
|
||||
$docs = json_decode($json, true);
|
||||
$docs = array_shift($docs['data']);
|
||||
if (!isset($docs['params'])) {
|
||||
$io->warning(($docs['head'] ?? "unknown return"));
|
||||
return self::INVALID;
|
||||
}
|
||||
if (empty($docs['params'])) {
|
||||
$io->success("No parameters required");
|
||||
} else {
|
||||
$rows = [];
|
||||
foreach ($docs['params'] as $param) {
|
||||
$rows[] = [$param['type'], '<options=bold>' . $param['parameter'] . '</>', $param['desc'] ?? ""];
|
||||
}
|
||||
$io->table(['Type', 'Name', 'Description'], $rows);
|
||||
}
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function validateCommand(string $command): array
|
||||
{
|
||||
$command = explode(".", $command);
|
||||
|
@ -108,6 +108,7 @@ return [
|
||||
'skipconfig' => 'Nicht (erneut) konfigurieren',
|
||||
'recommendednote' => 'Empfohlene/benötigte Dienste anhand der aktuellen Systemeinstellungen',
|
||||
'selectrecommended' => 'Empfohlene wählen',
|
||||
'downloadselected' => 'Auswahl exportieren',
|
||||
],
|
||||
'templates' => [
|
||||
'templates' => 'E-Mail-Vorlagen',
|
||||
|
@ -110,6 +110,7 @@ return [
|
||||
'skipconfig' => 'Don\'t (re)configure',
|
||||
'recommendednote' => 'Recommended/required services based on current system settings',
|
||||
'selectrecommended' => 'Select recommended',
|
||||
'downloadselected' => 'Export selected',
|
||||
],
|
||||
'templates' => [
|
||||
'templates' => 'Email-templates',
|
||||
@ -1353,6 +1354,9 @@ Yours sincerely, your administrator',
|
||||
'maintitle' => 'PHP Configurations',
|
||||
'fpmdaemons' => 'PHP-FPM versions',
|
||||
],
|
||||
'logger' => [
|
||||
'logger' => 'System log',
|
||||
],
|
||||
],
|
||||
'message' => [
|
||||
'norecipients' => 'No e-mail has been sent because there are no recipients in the database',
|
||||
|
Loading…
Reference in New Issue
Block a user