WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_Geo_IP::_setup_segments() private WC 1.0

Setup segments.

{} Это метод класса: WC_Geo_IP{}

Хуков нет.

Возвращает

WC_Geo_IP. instance

Использование

// private - только в коде основоного (родительского) класса
$result = $this->_setup_segments();

Код WC_Geo_IP::_setup_segments() WC 4.7.1

<?php
private function _setup_segments() {
	$this->databaseType  = self::GEOIP_COUNTRY_EDITION;
	$this->record_length = self::STANDARD_RECORD_LENGTH;

	if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
		$offset = @shmop_size( $this->shmid ) - 3;

		for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) {
			$delim   = @shmop_read( $this->shmid, $offset, 3 );
			$offset += 3;

			if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) {
				$this->databaseType = ord( @shmop_read( $this->shmid, $offset, 1 ) );

				if ( $this->databaseType >= 106 ) {
					$this->databaseType -= 105;
				}

				$offset++;

				if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) {
					$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
				} elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) {
					$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
				} elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
					|| ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType )
					|| ( self::GEOIP_ORG_EDITION == $this->databaseType )
					|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
					|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
					|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_USERTYPE_EDITION == $this->databaseType )
					|| ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType )
					|| ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType )
					|| ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType )
					|| ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType )
					|| ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType )
					|| ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType )
					|| ( self::GEOIP_ASNUM_EDITION == $this->databaseType )
					|| ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType )
				) {
					$this->databaseSegments = 0;
					$buf                    = @shmop_read( $this->shmid, $offset, self::SEGMENT_RECORD_LENGTH );

					for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) {
						$this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) );
					}

					if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
						|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
						|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
						|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
						|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
						|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
					) {
						$this->record_length = self::ORG_RECORD_LENGTH;
					}
				}

				break;
			} else {
				$offset -= 4;
			}
		}
		if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType )
			|| ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType )
			|| ( self::GEOIP_PROXY_EDITION == $this->databaseType )
			|| ( self::GEOIP_NETSPEED_EDITION == $this->databaseType )
		) {
			$this->databaseSegments = self::GEOIP_COUNTRY_BEGIN;
		}
	} else {
		$filepos = ftell( $this->filehandle );
		fseek( $this->filehandle, -3, SEEK_END );

		for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) {

			$delim = fread( $this->filehandle, 3 );
			if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) {

				$this->databaseType = ord( fread( $this->filehandle, 1 ) );
				if ( $this->databaseType >= 106 ) {
					$this->databaseType -= 105;
				}

				if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) {
					$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
				} elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) {
					$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
				} elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
					|| ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType )
					|| ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType )
					|| ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType )
					|| ( self::GEOIP_ORG_EDITION == $this->databaseType )
					|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
					|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
					|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType )
					|| ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType )
					|| ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType )
					|| ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType )
					|| ( self::GEOIP_USERTYPE_EDITION == $this->databaseType )
					|| ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType )
					|| ( self::GEOIP_ASNUM_EDITION == $this->databaseType )
					|| ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType )
				) {
					$this->databaseSegments = 0;
					$buf = fread( $this->filehandle, self::SEGMENT_RECORD_LENGTH );

					for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) {
						$this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) );
					}

					if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
						|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
						|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
						|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
						|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
						|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
					) {
						$this->record_length = self::ORG_RECORD_LENGTH;
					}
				}

				break;
			} else {
				fseek( $this->filehandle, -4, SEEK_CUR );
			}
		}

		if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType )
			|| ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType )
			|| ( self::GEOIP_PROXY_EDITION == $this->databaseType )
			|| ( self::GEOIP_NETSPEED_EDITION == $this->databaseType )
		) {
			$this->databaseSegments = self::GEOIP_COUNTRY_BEGIN;
		}

		fseek( $this->filehandle, $filepos, SEEK_SET );
	}

	return $this;
}