) { if ( empty($string) || ( strpos($string, 'exists()) { return $cache->get(); } foreach ($tags as $i => $tag) { if (StringHelper::is_alphanumeric($tag[0])) { $tag = '{' . $tag; } $tags[$i] = $tag; if ($include_closing_tags) { $tags[] = RegEx::replace('^([^a-z0-9]+)', '\1/', $tag); } } return $cache->set([$tags, self::protectArray($tags, 1)]); } /** * Protect the input fields in the string * * @param string $string */ private static function protectFieldsInputFields(&$string) { if (strpos($string, '' . '|' . ')\s*)+' ); } /** * Protect the fields in the string * * @param string $string */ private static function protectFieldsPart(&$string) { self::protectFieldsTextAreas($string); self::protectFieldsInputFields($string); } /** * Protect the textarea fields in the string * * @param string $string */ private static function protectFieldsTextAreas(&$string) { if (strpos($string, ']*)?)>(\s*)', '<' . $temp_tag . '\1>\2', $string ); self::protectByRegex( $string, '(?:' . '' . '\s*)+' ); // Replace back the temporarily replaced empty textareas $string = str_replace($temp_tag, 'textarea', $string); } /** * Protect part of the AdminForm * * @param string $string * @param array $tags * @param array $protected_tags */ private static function protectFormPart(&$string, $tags = [], $protected_tags = []) { if (strpos($string, '') === 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( '(?:]*>.*?<\/textarea>|]*>)', $form_parts[0], $matches, null, PREG_PATTERN_ORDER ); if (empty($matches)) { return; } $matches = array_unique($matches[0]); foreach ($matches as $match) { $field = str_replace($tags, $protected_tags, $match); $form_parts[0] = str_replace($match, $field, $form_parts[0]); } $string = implode('', $form_parts); } /** * @param string $string * @param array $delimiters */ private static function unprotectByDelimiters(&$string, $delimiters) { if ( ! StringHelper::contains($string, $delimiters)) { return; } $regex = RegEx::preparePattern(RegEx::quote($delimiters), 's', $string); $parts = preg_split($regex, $string); foreach ($parts as $i => &$part) { if ($i % 2 == 0) { continue; } $part = base64_decode($part); } $string = implode('', $parts); } } Error