!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/uploads/script/vendor/composer/composer/src/Composer/Command/   drwxr-xr-x
Free 13.28 GB of 57.97 GB (22.9%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     LicensesCommand.php (6.67 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of Composer.
 *
 * (c) Nils Adermann <naderman@naderman.de>
 *     Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Command;

use 
Composer\Json\JsonFile;
use 
Composer\Plugin\CommandEvent;
use 
Composer\Plugin\PluginEvents;
use 
Composer\Package\PackageInterface;
use 
Composer\Repository\RepositoryInterface;
use 
Symfony\Component\Console\Helper\Table;
use 
Symfony\Component\Console\Input\InputInterface;
use 
Symfony\Component\Console\Input\InputOption;
use 
Symfony\Component\Console\Output\OutputInterface;
use 
Symfony\Component\Console\Style\SymfonyStyle;

/**
 * @author BenoĆ®t Merlet <benoit.merlet@gmail.com>
 */
class LicensesCommand extends BaseCommand
{
    protected function 
configure()
    {
        
$this
            
->setName('licenses')
            ->
setDescription('Shows information about licenses of dependencies.')
            ->
setDefinition(array(
                new 
InputOption('format''f'InputOption::VALUE_REQUIRED'Format of the output: text, json or summary''text'),
                new 
InputOption('no-dev'nullInputOption::VALUE_NONE'Disables search in require-dev packages.'),
            ))
            ->
setHelp(
                <<<EOT
The license command displays detailed information about the licenses of
the installed dependencies.

Read more at https://getcomposer.org/doc/03-cli.md#licenses
EOT
            )
        ;
    }

    protected function 
execute(InputInterface $inputOutputInterface $output)
    {
        
$composer $this->getComposer();

        
$commandEvent = new CommandEvent(PluginEvents::COMMAND'licenses'$input$output);
        
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);

        
$root $composer->getPackage();
        
$repo $composer->getRepositoryManager()->getLocalRepository();

        if (
$input->getOption('no-dev')) {
            
$packages $this->filterRequiredPackages($repo$root);
        } else {
            
$packages $this->appendPackages($repo->getPackages(), array());
        }

        
ksort($packages);
        
$io $this->getIO();

        switch (
$format $input->getOption('format')) {
            case 
'text':
                
$io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
                
$io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
                
$io->write('Licenses: <comment>'.(implode(', '$root->getLicense()) ?: 'none').'</comment>');
                
$io->write('Dependencies:');
                
$io->write('');

                
$table = new Table($output);
                
$table->setStyle('compact');
                
$tableStyle $table->getStyle();
                if (
method_exists($tableStyle'setVerticalBorderChars')) {
                    
$tableStyle->setVerticalBorderChars('');
                } else {
                    
$tableStyle->setVerticalBorderChar('');
                }
                
$tableStyle->setCellRowContentFormat('%s  ');
                
$table->setHeaders(array('Name''Version''License'));
                foreach (
$packages as $package) {
                    
$table->addRow(array(
                        
$package->getPrettyName(),
                        
$package->getFullPrettyVersion(),
                        
implode(', '$package->getLicense()) ?: 'none',
                    ));
                }
                
$table->render();
                break;

            case 
'json':
                
$dependencies = array();
                foreach (
$packages as $package) {
                    
$dependencies[$package->getPrettyName()] = array(
                        
'version' => $package->getFullPrettyVersion(),
                        
'license' => $package->getLicense(),
                    );
                }

                
$io->write(JsonFile::encode(array(
                    
'name' => $root->getPrettyName(),
                    
'version' => $root->getFullPrettyVersion(),
                    
'license' => $root->getLicense(),
                    
'dependencies' => $dependencies,
                )));
                break;

            case 
'summary':
                
$usedLicenses = array();
                foreach (
$packages as $package) {
                    
$license $package->getLicense();
                    
$licenseName $license[0];
                    if (!isset(
$usedLicenses[$licenseName])) {
                        
$usedLicenses[$licenseName] = 0;
                    }
                    
$usedLicenses[$licenseName]++;
                }

                
// Sort licenses so that the most used license will appear first
                
arsort($usedLicensesSORT_NUMERIC);

                
$rows = array();
                foreach (
$usedLicenses as $usedLicense => $numberOfDependencies) {
                    
$rows[] = array($usedLicense$numberOfDependencies);
                }

                
$symfonyIo = new SymfonyStyle($input$output);
                
$symfonyIo->table(
                    array(
'License''Number of dependencies'),
                    
$rows
                
);
                break;
            default:
                throw new 
\RuntimeException(sprintf('Unsupported format "%s".  See help for supported formats.'$format));
        }

        return 
0;
    }

    
/**
     * Find package requires and child requires
     *
     * @param  RepositoryInterface $repo
     * @param  PackageInterface    $package
     * @param  array               $bucket
     * @return array
     */
    
private function filterRequiredPackages(RepositoryInterface $repoPackageInterface $package$bucket = array())
    {
        
$requires array_keys($package->getRequires());

        
$packageListNames array_keys($bucket);
        
$packages array_filter(
            
$repo->getPackages(),
            function (
$package) use ($requires$packageListNames) {
                return 
in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
            }
        );

        
$bucket $this->appendPackages($packages$bucket);

        foreach (
$packages as $package) {
            
$bucket $this->filterRequiredPackages($repo$package$bucket);
        }

        return 
$bucket;
    }

    
/**
     * Adds packages to the package list
     *
     * @param  array $packages the list of packages to add
     * @param  array $bucket   the list to add packages to
     * @return array
     */
    
public function appendPackages(array $packages, array $bucket)
    {
        foreach (
$packages as $package) {
            
$bucket[$package->getName()] = $package;
        }

        return 
$bucket;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0136 ]--