• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WooCommerce a2z

WooCommerce a2z

WooCommerce

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Reader::findAddressInTree() –

You appear to be a bot. Output may be restricted

Description

Usage

Reader::findAddressInTree( $ipAddress );

Parameters

$ipAddress
( mixed ) required –

Returns

void

Source

File name: woocommerce/vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php
Lines:

1 to 42 of 42
    private function findAddressInTree($ipAddress)
    {
        $rawAddress = unpack('C*', inet_pton($ipAddress));

        $bitCount = \count($rawAddress) * 8;

        // The first node of the tree is always node 0, at the beginning of the
        // value
        $node = 0;

        $metadata = $this->metadata;

        // Check if we are looking up an IPv4 address in an IPv6 tree. If this
        // is the case, we can skip over the first 96 nodes.
        if ($metadata->ipVersion === 6) {
            if ($bitCount === 32) {
                $node = $this->ipV4Start;
            }
        } elseif ($metadata->ipVersion === 4 && $bitCount === 128) {
            throw new InvalidArgumentException(
                "Error looking up $ipAddress. You attempted to look up an"
                . ' IPv6 address in an IPv4-only database.'
            );
        }

        $nodeCount = $metadata->nodeCount;

        for ($i = 0; $i < $bitCount && $node < $nodeCount; ++$i) {
            $tempBit = 0xFF & $rawAddress[($i >> 3) + 1];
            $bit = 1 & ($tempBit >> 7 - ($i % 8));

            $node = $this->readNode($node, $bit);
        }
        if ($node === $nodeCount) {
            // Record is empty
            return [0, $i];
        } elseif ($node > $nodeCount) {
            // Record is a data pointer
            return [$node, $i];
        }
        throw new InvalidDatabaseException('Something bad happened');
    }
 

 View on GitHub View on Trac

Published: 8th February 2020 | Last updated: 8th February 2020

Primary Sidebar

Information

Function name: Reader::findAddressInTree
Class ref: Reader
Plugin ref: WooCommerce
Version: 4.8.0
Sourcefile: vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php
File ref: vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php
Deprecated?: No
API Letters: F,R

Footer

WooCommerce a2z
WooCommerce a2z
WooCommerce
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites