Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Geo_IP::_geoip_seek_country( int $ipnum )
Seek country.
Description Description
Parameters Parameters
- $ipnum
-
(Required)
Return Return
(string)
Source Source
File: includes/class-wc-geo-ip.php
private function _geoip_seek_country( $ipnum ) { $offset = 0; for ( $depth = 31; $depth >= 0; --$depth ) { if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { $buf = $this->_safe_substr( $this->memory_buffer, 2 * $this->record_length * $offset, 2 * $this->record_length ); } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { $buf = @shmop_read( $this->shmid, 2 * $this->record_length * $offset, 2 * $this->record_length ); } else { if ( 0 != fseek( $this->filehandle, 2 * $this->record_length * $offset, SEEK_SET ) ) { break; } $buf = fread( $this->filehandle, 2 * $this->record_length ); } $x = array( 0, 0 ); for ( $i = 0; $i < 2; ++$i ) { for ( $j = 0; $j < $this->record_length; ++$j ) { $x[ $i ] += ord( $buf[ $this->record_length * $i + $j ] ) << ( $j * 8 ); } } if ( $ipnum & ( 1 << $depth ) ) { if ( $x[1] >= $this->databaseSegments ) { return $x[1]; } $offset = $x[1]; } else { if ( $x[0] >= $this->databaseSegments ) { return $x[0]; } $offset = $x[0]; } } $this->log( 'GeoIP API: Error traversing database - perhaps it is corrupt?', 'error' ); return false; }