__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ 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
/**
 * @package         Regular Labs Library
 * @version         23.12.10783
 * 
 * @author          Peter van Westen <[email protected]>
 * @link            https://regularlabs.com
 * @copyright       Copyright © 2023 Regular Labs All Rights Reserved
 * @license         GNU General Public License version 2 or later
 */

namespace RegularLabs\Library;

defined('_JEXEC') or die;

class PluginTag
{
    /**
     * @var array
     */
    static $protected_characters = [
        '=' => '[[:EQUAL:]]',
        '"' => '[[:QUOTE:]]',
        ',' => '[[:COMMA:]]',
        '|' => '[[:BAR:]]',
        ':' => '[[:COLON:]]',
    ];

    /**
     * Cleans the given tag word
     *
     * @param string $string
     *
     * @return string
     */
    public static function clean($string = '')
    {
        return RegEx::replace('[^a-z0-9-_]', '', $string);
    }

    /**
     * Get the attributes from  plugin style string
     *
     * @param string $string
     * @param string $main_key
     * @param array  $known_boolean_keys
     * @param string $key_format (empty, 'underscore', 'dash')
     * @param array  $keep_escaped_chars
     *
     * @return object
     */
    public static function getAttributesFromString(
        $string = '',
        $main_key = 'title',
        $known_boolean_keys = [],
        $key_format = '',
        $keep_escaped_chars = null,
        $convert_numerals = null
    )
    {
        if (empty($string))
        {
            return (object) [];
        }

        if (is_object($string))
        {
            return $string;
        }

        if (is_array($string))
        {
            return (object) $string;
        }

        // Replace html entity quotes to normal quotes
        if ( ! str_contains($string, '"'))
        {
            $string = str_replace('&quot;', '"', $string);
        }

        self::protectSpecialChars($string);

        // replace weird whitespace
        $string = str_replace(chr(194) . chr(160), ' ', $string);

        // Replace html entity spaces between attributes to normal spaces
        $string = RegEx::replace('((?:^|")\s*)&nbsp;(\s*(?:[a-z]|$))', '\1 \2', $string);

        // Only one value, so return simple key/value object
        if ( ! str_contains($string, '|') && ! RegEx::match('=\s*["\']', $string))
        {
            self::unprotectSpecialChars($string, $keep_escaped_chars);

            return (object) [$main_key => $string];
        }

        // Cannot find right syntax, so return simple key/value object
        if ( ! RegEx::matchAll('(?:^|\s)(?<key>[a-z0-9-_\:]+)\s*(?<not>\!?)=\s*(["\'])(?<value>.*?)\3', $string, $matches))
        {
            self::unprotectSpecialChars($string, $keep_escaped_chars);

            return (object) [$main_key => $string];
        }

        $tag = (object) [];

        foreach ($matches as $match)
        {
            $key         = StringHelper::toCase($match['key'], $key_format);
            $tag->{$key} = self::getAttributeValueFromMatch($match, $known_boolean_keys, $keep_escaped_chars, $convert_numerals);
        }

        return $tag;
    }

    /**
     * Extract the plugin style div tags with the possible attributes. like:
     * {div width:100|float:left}...{/div}
     *
     * @param string $start_tag
     * @param string $end_tag
     * @param string $tag_start
     * @param string $tag_end
     *
     * @return array
     */
    public static function getDivTags(
        $start_tag = '',
        $end_tag = '',
        $tag_start = '{',
        $tag_end = '}'
    )
    {
        $tag_start = RegEx::quote($tag_start);
        $tag_end   = RegEx::quote($tag_end);

        $start_div = ['pre' => '', 'tag' => '', 'post' => ''];
        $end_div   = ['pre' => '', 'tag' => '', 'post' => ''];

        if ( ! empty($start_tag)
            && RegEx::match(
                '^(?<pre>.*?)(?<tag>' . $tag_start . 'div(?: .*?)?' . $tag_end . ')(?<post>.*)$',
                $start_tag,
                $match
            )
        )
        {
            $start_div = $match;
        }

        if ( ! empty($end_tag)
            && RegEx::match(
                '^(?<pre>.*?)(?<tag>' . $tag_start . '/div' . $tag_end . ')(?<post>.*)$',
                $end_tag,
                $match
            )
        )
        {
            $end_div = $match;
        }

        if (empty($start_div['tag']) || empty($end_div['tag']))
        {
            return [$start_div, $end_div];
        }

        $attribs = trim(RegEx::replace($tag_start . 'div(.*)' . $tag_end, '\1', $start_div['tag']));

        $start_div['tag'] = '<div>';
        $end_div['tag']   = '</div>';

        if (empty($attribs))
        {
            return [$start_div, $end_div];
        }

        $attribs = self::getDivAttributes($attribs);

        $style = [];

        if (isset($attribs->width))
        {
            if (is_numeric($attribs->width))
            {
                $attribs->width .= 'px';
            }

            $style[] = 'width:' . $attribs->width;
        }

        if (isset($attribs->height))
        {
            if (is_numeric($attribs->height))
            {
                $attribs->height .= 'px';
            }

            $style[] = 'height:' . $attribs->height;
        }

        if (isset($attribs->align))
        {
            $style[] = 'float:' . $attribs->align;
        }

        if ( ! isset($attribs->align) && isset($attribs->float))
        {
            $style[] = 'float:' . $attribs->float;
        }

        $attribs = isset($attribs->class) ? 'class="' . $attribs->class . '"' : '';

        if ( ! empty($style))
        {
            $attribs .= ' style="' . implode(';', $style) . ';"';
        }

        $start_div['tag'] = trim('<div ' . trim($attribs)) . '>';

        return [$start_div, $end_div];
    }

    /**
     * Return the Regular Expressions string to match:
     * Plugin type tags inside others
     *
     * @return string
     */
    public static function getRegexInsideTag($start_character = '{', $end_character = '}')
    {
        $s = RegEx::quote($start_character);
        $e = RegEx::quote($end_character);

        return '(?:[^' . $s . $e . ']*' . $s . '[^' . $e . ']*' . $e . ')*.*?';
    }

    /**
     * Return the Regular Expressions string to match:
     * html before plugin tag
     *
     * @param string $group_id
     *
     * @return string
     */
    public static function getRegexLeadingHtml($group_id = '')
    {
        $group          = 'leading_block_element';
        $html_tag_group = 'html_tag';

        if ($group_id)
        {
            $group          .= '_' . $group_id;
            $html_tag_group .= '_' . $group_id;
        }

        $block_elements = Html::getBlockElements(['div']);
        $block_element  = '(?<' . $group . '>' . implode('|', $block_elements) . ')';

        $other_html = '[^<]*(<(?<' . $html_tag_group . '>[a-z][a-z0-9_-]*)[\s>]([^<]*</(?P=' . $html_tag_group . ')>)?[^<]*)*';

        // Grab starting block element tag and any html after it (that is not the same block element starting/ending tag).
        return '(?:'
            . '<' . $block_element . '(?: [^>]*)?>'
            . $other_html
            . ')?';
    }

    /**
     * Return the Regular Expressions string to match:
     * Different types of spaces
     *
     * @param string $modifier
     *
     * @return string
     */
    public static function getRegexSpaces($modifier = '+')
    {
        return '(?:\s|&nbsp;|&\#160;)' . $modifier;
    }

    /**
     * Return the Regular Expressions string to match:
     * Trailing html tag
     *
     * @param array $elements
     *
     * @return string
     */
    public static function getRegexSurroundingTagPost($elements = [])
    {
        $elements = ($elements ?? null) ?: [...Html::getBlockElements(), 'span'];

        return '(?:(?:\s*<br ?/?>)*\s*<\/(?:' . implode('|', $elements) . ')>)?';
    }

    /**
     * Return the Regular Expressions string to match:
     * Leading html tag
     *
     * @param array $elements
     *
     * @return string
     */
    public static function getRegexSurroundingTagPre($elements = [])
    {
        $elements = ($elements ?? null) ?: [...Html::getBlockElements(), 'span'];

        return '(?:<(?:' . implode('|', $elements) . ')(?: [^>]*)?>\s*(?:<br ?/?>\s*)*)?';
    }

    /**
     * Return the Regular Expressions string to match:
     * Closing html tags
     *
     * @param array $block_elements
     * @param array $inline_elements
     * @param array $excluded_block_elements
     *
     * @return string
     */
    public static function getRegexSurroundingTagsPost(
        $block_elements = [],
        $inline_elements = ['span'],
        $excluded_block_elements = []
    )
    {
        $block_elements = ($block_elements ?? null) ?: Html::getBlockElements($excluded_block_elements);

        $regex = '';

        if ( ! empty($inline_elements))
        {
            $regex .= '(?:(?:\s*<br ?/?>)*\s*<\/(?:' . implode('|', $inline_elements) . ')>){0,3}';
        }

        $regex .= '(?:(?:\s*<br ?/?>)*\s*<\/(?:' . implode('|', $block_elements) . ')>)?';

        return $regex;
    }

    /**
     * Return the Regular Expressions string to match:
     * Opening html tags
     *
     * @param array $block_elements
     * @param array $inline_elements
     * @param array $excluded_block_elements
     *
     * @return string
     */
    public static function getRegexSurroundingTagsPre(
        $block_elements = [],
        $inline_elements = ['span'],
        $excluded_block_elements = []
    )
    {
        $block_elements = ($block_elements ?? null) ?: Html::getBlockElements($excluded_block_elements);

        $regex = '(?:<(?:' . implode('|', $block_elements) . ')(?: [^>]*)?>\s*(?:<br ?/?>\s*)*)?';

        if ( ! empty($inline_elements))
        {
            $regex .= '(?:<(?:' . implode('|', $inline_elements) . ')(?: [^>]*)?>\s*(?:<br ?/?>\s*)*){0,3}';
        }

        return $regex;
    }

    /**
     * Return the Regular Expressions string to match:
     * Plugin style tags
     *
     * @param array|string $tags
     * @param bool         $include_no_attributes
     * @param bool         $include_ending
     * @param array        $required_attributes
     *
     * @return string
     */
    public static function getRegexTags(
        $tags,
        $include_no_attributes = true,
        $include_ending = true,
        $required_attributes = []
    )
    {
        $tags = ArrayHelper::toArray($tags);
        $tags = count($tags) > 1 ? '(?:' . implode('|', $tags) . ')' : $tags[0];

        $value      = '(?:\s*=\s*(?:"[^"]*"|\'[^\']*\'|[a-z0-9-_]+))?';
        $attributes = '(?:\s+[a-z0-9-_]+' . $value . ')+';

        $required_attributes = ArrayHelper::toArray($required_attributes);

        if ( ! empty($required_attributes))
        {
            $attributes = '(?:' . $attributes . ')?' . '(?:\s+' . implode('|', $required_attributes) . ')' . $value . '(?:' . $attributes . ')?';
        }

        if ($include_no_attributes)
        {
            $attributes = '\s*(?:' . $attributes . ')?';
        }

        if ( ! $include_ending)
        {
            return '<' . $tags . $attributes . '\s*/?>';
        }

        return '<(?:\/' . $tags . '|' . $tags . $attributes . '\s*/?)\s*/?>';
    }

    /**
     * Return the Regular Expressions string to match:
     * html after plugin tag
     *
     * @param string $group_id
     *
     * @return string
     */
    public static function getRegexTrailingHtml($group_id = '')
    {
        $group = 'leading_block_element';

        if ($group_id)
        {
            $group .= '_' . $group_id;
        }

        // If the grouped name is found, then grab all content till ending html tag is found. Otherwise grab nothing.
        return '(?(<' . $group . '>)'
            . '(?:.*?</(?P=' . $group . ')>)?'
            . ')';
    }

    /**
     * Replace special characters in the string with the protected versions
     *
     * @param string $string
     */
    public static function protectSpecialChars(&$string)
    {
        $unescaped_chars = array_keys(self::$protected_characters);

        array_walk($unescaped_chars, function (&$char) {
            $char = '\\' . $char;
        });

        // replace escaped characters with special markup
        $string = str_replace(
            $unescaped_chars,
            array_values(self::$protected_characters),
            $string
        );

        if ( ! RegEx::matchAll(
            '(<[a-z][a-z0-9-_]*(?: [a-z0-9-_]*=".*?")* ?/?>|{.*?}|\[.*?\])',
            $string,
            $tags,
            null,
            PREG_PATTERN_ORDER
        )
        )
        {
            return;
        }

        foreach ($tags[0] as $tag)
        {
            // replace unescaped characters with special markup
            $protected = str_replace(
                ['=', '"'],
                [self::$protected_characters['='], self::$protected_characters['"']],
                $tag
            );

            $string = str_replace($tag, $protected, $string);
        }
    }

    /**
     * Replace keys aliases with the main key names in an object
     *
     * @param object|string $attributes
     * @param array         $key_aliases
     * @param bool          $handle_plurals
     *
     * @deprecated Use ObjectHelper::replaceKeys()
     */
    public static function replaceKeyAliases(
        &$attributes,
        $key_aliases = [],
        $handle_plurals = false
    )
    {
        return ObjectHelper::replaceKeys($attributes, $key_aliases);
    }

    /**
     * Replace protected characters in the string with the original special versions
     *
     * @param string $string
     * @param array  $keep_escaped_chars
     */
    public static function unprotectSpecialChars(&$string, $keep_escaped_chars = null)
    {
        $unescaped_chars    = array_keys(self::$protected_characters);
        $keep_escaped_chars = ! is_null($keep_escaped_chars)
            ? ArrayHelper::toArray($keep_escaped_chars)
            : [];

        if ( ! empty($keep_escaped_chars))
        {
            array_walk($unescaped_chars, function (&$char, $key, $keep_escaped_chars) {
                if (is_array($keep_escaped_chars) && ! in_array($char, $keep_escaped_chars, true))
                {
                    return;
                }

                $char = '\\' . $char;
            }, $keep_escaped_chars);
        }

        // replace special markup with unescaped characters
        $string = str_replace(
            array_values(self::$protected_characters),
            $unescaped_chars,
            $string
        );
    }

    /**
     * Get the value from a found attribute match
     *
     * @param array $match
     * @param array $known_boolean_keys
     * @param array $keep_escaped_chars
     *
     * @return bool|int|string
     */
    private static function getAttributeValueFromMatch(
        $match,
        $known_boolean_keys = [],
        $keep_escaped_chars = [','],
        $convert_numerals = true
    )
    {
        $value = $match['value'];

        self::unprotectSpecialChars($value, $keep_escaped_chars);

        if (
            is_numeric($value)
            && (
                in_array($match['key'], $known_boolean_keys, true)
                || in_array(strtolower($match['key']), $known_boolean_keys, true)
            )
        )
        {
            $value = $value ? 'true' : 'false';
        }

        // Convert numeric values to ints/floats
        if ($convert_numerals && is_numeric($value) && RegEx::match('^[0-9\.]+$', $value))
        {
            $value = $value + 0;
        }

        // Convert boolean values to actual booleans
        if ($value === 'true' || $value === true)
        {
            return $match['not'] ? false : true;
        }

        if ($value === 'false' || $value === false)
        {
            return $match['not'] ? true : false;
        }

        return $match['not'] ? '!NOT!' . $value : $value;
    }

    /**
     * Get the attributes from a plugin style div tag
     */
    private static function getDivAttributes(string $string): object
    {
        if (str_contains($string, '="'))
        {
            return self::getAttributesFromString($string);
        }

        $parts      = explode('|', $string);
        $attributes = (object) [];

        foreach ($parts as $e)
        {
            if ( ! str_contains($e, ':'))
            {
                continue;
            }

            [$key, $val] = explode(':', $e, 2);
            $attributes->{$key} = $val;
        }

        return $attributes;
    }
}

Filemanager

Name Type Size Permission Actions
Form Folder 0775
ActionLogPlugin.php File 8.29 KB 0664
Alias.php File 3.22 KB 0664
ArrayHelper.php File 14.13 KB 0664
Article.php File 10.14 KB 0664
Cache.php File 4.69 KB 0664
Color.php File 1.85 KB 0664
DB.php File 15.25 KB 0664
Date.php File 5.25 KB 0664
Document.php File 13.21 KB 0664
DownloadKey.php File 3.92 KB 0664
EditorButtonPlugin.php File 5.9 KB 0664
EditorButtonPopup.php File 5.53 KB 0664
Extension.php File 14.81 KB 0664
FieldsPlugin.php File 1001 B 0664
File.php File 14.92 KB 0664
Html.php File 22.41 KB 0664
HtmlTag.php File 4.84 KB 0664
Http.php File 4.54 KB 0664
Image.php File 29.04 KB 0664
Input.php File 4.64 KB 0664
Language.php File 985 B 0664
License.php File 1.78 KB 0664
MobileDetect.php File 748 B 0664
ObjectHelper.php File 2.92 KB 0664
Parameters.php File 7.27 KB 0664
Php.php File 6.81 KB 0664
PluginTag.php File 16.31 KB 0664
Protect.php File 27.82 KB 0664
RegEx.php File 8.02 KB 0664
ShowOn.php File 1.44 KB 0664
SimpleCategory.php File 1.7 KB 0664
StringHelper.php File 22.9 KB 0664
StringReplacer.php File 13.66 KB 0664
SystemPlugin.php File 15.4 KB 0664
Title.php File 2.8 KB 0664
Uri.php File 6.06 KB 0664
Variables.php File 11.55 KB 0664
Version.php File 8.32 KB 0664
Xml.php File 1.53 KB 0664
Filemanager