grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 * @link http://www.regularlabs.com * @copyright Copyright © 2018 Regular Labs All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ namespace RegularLabs\Library; defined('_JEXEC') or die; use Joomla\CMS\Access\Access as JAccess; use Joomla\CMS\Factory as JFactory; jimport('joomla.filesystem.file'); /** * Class Protect * @package RegularLabs\Library */ class Protect { static $protect_start = ''; static $protect_tags_start = ''; static $html_safe_start = '___RL_PROTECTED___'; static $html_safe_end = '___/RL_PROTECTED___'; static $html_safe_tags_start = '___RL_PROTECTED_TAGS___'; static $html_safe_tags_end = '___/RL_PROTECTED_TAGS___'; static $sourcerer_tag = null; static $sourcerer_characters = '{.}'; /** * Check if page should be protected for given extension * * @param string $extension_alias * * @return bool */ public static function isDisabledByUrl($extension_alias = '') { // return if disabled via url if (($extension_alias && JFactory::getApplication()->input->get('disable_' . $extension_alias))) { return true; } } /** * Check if page should be protected for given extension * * @param bool $hastags * @param array $restricted_formats * * @return bool */ public static function isRestrictedPage($hastags = false, $restricted_formats = []) { $cache_id = 'isRestrictedPage_' . $hastags . '_' . json_encode($restricted_formats); if (Cache::has($cache_id)) { return Cache::get($cache_id); } $input = JFactory::getApplication()->input; // return if current page is in protected formats // return if current page is an image // return if current page is an installation page // return if current page is Regular Labs QuickPage // return if current page is a JoomFish or Josetta page $is_restricted = ( in_array($input->get('format'), $restricted_formats) || in_array($input->get('view'), ['image', 'img']) || in_array($input->get('type'), ['image', 'img']) || in_array($input->get('task'), ['install.install', 'install.ajax_upload']) || ($hastags && ( $input->getInt('rl_qp', 0) || in_array($input->get('option'), ['com_joomfishplus', 'com_josetta']) ) ) || (Document::isClient('administrator') && in_array($input->get('option'), ['com_jdownloads']) ) ); return Cache::set( $cache_id, $is_restricted ); } /** * @deprecated Use isDisabledByUrl() and isRestrictedPage() */ public static function isProtectedPage($extension_alias = '', $hastags = false, $exclude_formats = []) { if (self::isDisabledByUrl($extension_alias)) { return true; } return self::isRestrictedPage($hastags, $exclude_formats); } /** * Check if the page is a restricted component * * @param array $restricted_components * @param string $area * * @return bool */ public static function isRestrictedComponent($restricted_components, $area = 'component') { if ($area != 'component' && ! ($area == 'article' && JFactory::getApplication()->input->get('option') == 'com_content')) { return false; } $restricted_components = is_array($restricted_components) ? $restricted_components : explode(',', str_replace('|', ',', $restricted_components)); if (in_array(JFactory::getApplication()->input->get('option'), $restricted_components)) { return true; } if (JFactory::getApplication()->input->get('option') == 'com_acymailing' && ! in_array(JFactory::getApplication()->input->get('ctrl'), ['user', 'archive']) ) { return true; } return false; } /** * Check if the component is installed * * @param string $extension_alias * * @return bool */ public static function isComponentInstalled($extension_alias) { return file_exists(JPATH_ADMINISTRATOR . '/components/com_' . $extension_alias . '/' . $extension_alias . '.php'); } /** * Check if the component is installed * * @param string $extension_alias * * @return bool */ public static function isSystemPluginInstalled($extension_alias) { return file_exists(JPATH_PLUGINS . '/system/' . $extension_alias . '/' . $extension_alias . '.php'); } /** * Return the Regular Expressions string to match: * The edit form * * @param int $regex_format * * @return string */ public static function getFormRegex() { return '(
') === false) { return; } // Protect entire form if (empty($tags)) { $form_parts = explode('', $string, 2); $form_parts[0] = self::protectString($form_parts[0] . ''); $string = implode('', $form_parts); return; } $regex_tags = RegEx::quote($tags); if ( ! RegEx::match($regex_tags, $string)) { return; } $form_parts = explode('', $string, 2); // protect tags only inside form fields RegEx::matchAll( '(?: