PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/mytube.pm/wp-content/plugins/wp-simple-firewall/src/lib/src/Modules/GeoIp/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/mytube.pm/wp-content/plugins/wp-simple-firewall/src/lib/src/Modules/GeoIp/Lookup.php

<?php

namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\GeoIp;

use FernleafSystems\Wordpress\Plugin\Shield\Databases;
use FernleafSystems\Wordpress\Plugin\Shield\Modules\IPs\Components\IpAddressConsumer;
use FernleafSystems\Wordpress\Services\Services;

class Lookup {

	const URL_REDIRECTLI = 'https://api.redirect.li/v1/ip/';
	use Databases\Base\HandlerConsumer;
	use IpAddressConsumer;

	private $ips = [];

	/**
	 * @return Databases\GeoIp\EntryVO|null
	 */
	public function lookupIp() {
		$ip = $this->getIP();
		// Small optimization so we don't SQL it every time.
		if ( isset( $this->ips[ $ip ] ) ) {
			return $this->ips[ $ip ];
		}

		/** @var Databases\GeoIp\Handler $dbh */
		$dbh = $this->getDbHandler();
		/** @var Databases\GeoIp\Select $select */
		$select = $dbh->getQuerySelector();
		$IP = $select->byIp( $ip );

		/**
		 * We look up the IP and if the request fails, we store it anyway so that we don't repeatedly
		 * bombard the API. The address will eventually be expired over time and lookup will process
		 * again at a later date, as required
		 */
		if ( empty( $IP ) ) {
			$IP = new Databases\GeoIp\EntryVO();
			$IP->ip = $ip;
			$IP->meta = $this->redirectliIpLookup();
			$dbh->getQueryInserter()->insert( $IP );
		}

		$this->ips[ $ip ] = $IP;
		return $IP;
	}

	private function redirectliIpLookup() :array {
		$oHttp = Services::HttpRequest();
		$aIpData = @json_decode( $oHttp->getContent( self::URL_REDIRECTLI.$this->getIP() ), true );
		if ( empty( $aIpData ) || !is_array( $aIpData ) ) {
			$aIpData = [];
		}

		return array_intersect_key(
			$aIpData,
			[
				'countryCode' => '',
				'countryName' => '',
				'timeZone'    => '',
				'latitude'    => '',
				'longitude'   => '',
			]
		);
	}
}