getCountryByIp

@param string $clientIp to detect country
@return string
516777
public static function getCountryByIp(string $clientIp): string
    {
        $clientCountryCode = '';
        if (function_exists('geoip_country_code_by_name')) {
            $clientCountryCode = geoip_country_code_by_name($clientIp);
        }

        return $clientCountryCode;
    }
217358
public function getClientDetails($client_id)
    {
        $result = $this->getObjectByType('client_table',$client_id);

        return is_null($result) ? false : $result;
    }
1005072
public static function getClientIp($safe = true) {
		if (!$safe && env('HTTP_X_FORWARDED_FOR')) {
			$ipaddr = preg_replace('/(?:,.*)/', '', env('HTTP_X_FORWARDED_FOR'));
		} elseif (!$safe && env('HTTP_CLIENT_IP')) {
			$ipaddr = env('HTTP_CLIENT_IP');
		} else {
			$ipaddr = env('REMOTE_ADDR');
		}
		return trim($ipaddr);
	}
967995
public function getClientId($clientId = null)
    {

        // Return given parameter
        if ($clientId) {
            return $clientId;
        }

        // If clientId is null and no clientId has previously been set
        if (!$this->clientId) {
            throw new RequestRequiresClientIdException();
        }

        // Return clientId that has previously been set
        return $this->clientId;
    }
1213982
public static function clientIP() : string
    {
        if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
            return $_SERVER['HTTP_CF_CONNECTING_IP'];
        } elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            return $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            return $_SERVER['HTTP_X_FORWARDED_FOR'];
        }

        return $_SERVER['REMOTE_ADDR'];
    }
1096782
private function getClientIP()
    {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
            $clientIpAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR']) {
            $clientIpAddress = $_SERVER['REMOTE_ADDR'];
        } else {
            $clientIpAddress = '';
        }

        return $clientIpAddress;
    }
1084760
public static function checkIP($UserIP = false)
    {
        // Check if IP present
        if ($UserIP === false)
        {
            if (\Environment::get('ip'))
            {
                if (strpos(\Environment::get('ip'), ',') !== false) //first IP
                {
                    $UserIP =  trim(substr(\Environment::get('ip'), 0, strpos(\Environment::get('ip'), ',')));
                }
                else
                {
                    $UserIP = trim(\Environment::get('ip'));
                }
            }
            else
            {
                return false; // No IP, no search.
            }
            //Test for private IPs
            if ( true === static::checkPrivateIP($UserIP) &&
                false === empty($_SERVER['HTTP_X_FORWARDED_FOR'])
            )
            {
                //second try
                $HTTPXFF = $_SERVER['HTTP_X_FORWARDED_FOR'];
                $_SERVER['HTTP_X_FORWARDED_FOR'] = '';
            
                $UserIP = \Environment::get('ip');
                if (strpos($UserIP, ',') !== false) //first IP
                {
                    $UserIP = trim( substr($UserIP, 0, strpos($UserIP, ',') ) );
                }
                $_SERVER['HTTP_X_FORWARDED_FOR'] = $HTTPXFF;
            }
        }
        // IPv4 or IPv6 ?
        switch (static::getIpVersion($UserIP))
        {
        	case "IPv4":
        	    if ( static::checkBotIPv4($UserIP, static::getBotIpv4List()) === true) { return true; }
        	    break;
        	case "IPv6":
        	    if ( static::checkBotIPv6($UserIP, static::getBotIpv6List()) === true) { return true; }
        	    break;
        	default:
        	    return false;
        	    break;
        }
        return false;
    }
986636
private function find($ip = null)
    {
        if ($this->config('cache.mode', 'none') !== 'none' && $location = $this->cache()->get($ip)) {
            $location->setAttribute('cached', true);

            return $location;
        }

        $ip = $ip ?: $this->remoteIp;

        if (IpValidator::validate($ip)) {
            try {
                $location = $this->driver()->locate($ip);

                if (is_null($location->currency)) {
                    $location->setAttribute('currency', $this->getCurrency($location->iso_code));
                }

                $location->setAttribute('default', false);

                return $location;
            }
            catch (\Exception $e) {
                GeoIPLogger::log($e);
            }
        }

        return new Location($this->defaultLocation);
    }
38445
public function getCountry(IdentifierInterface $identifier)
    {
        $identifierFull = $identifier->getFull();
        return isset($this->countries[$identifierFull]) ? $this->countries[$identifierFull] : null;
    }
901738
public function clientIp()
    {
        $keys = [
            'REMOTE_ADDR',
            'HTTP_CLIENT_IP',
            'HTTP_X_FORWARDED_FOR',
        ];

        foreach ($keys as $offset) {
            if ($this->server->has($offset)) {
                return $this->server->get($offset);
            }
        }

        return null;
    }
647747
private function find($ip = null)
    {
        // If IP not set, user remote IP
        $ip = $ip ?: $this->remote_ip;

        // Check cache for location
        if ($this->config('cache', 'none') !== 'none' && $location = $this->getCache()->get($ip)) {
            $location->cached = true;

            return $location;
        }

        // Check if the ip is not local or empty
        if ($this->isValid($ip)) {
            try {
                // Find location
                $location = $this->getService()->locate($ip);

                // Set currency if not already set by the service
                if (!$location->currency) {
                    $location->currency = $this->getCurrency($location->iso_code);
                }

                // Set default
                $location->default = false;

                return $location;
            }
            catch (\Exception $e) {
                if ($this->config('log_failures', true) === true) {
                    $log = new Logger('geoip');
                    $log->pushHandler(new StreamHandler(storage_path('logs/geoip.log'), Logger::ERROR));
                    $log->addError($e);
                }
            }
        }

        return $this->getService()->hydrate($this->default_location);
    }
649635
public function getInfo($ip = null)
    {
        if ($ip == null) {
            $ip = $this->getIpAdress();
        }

        $url = str_replace('{IP}', $ip, $this->api_adress);
        $hex = $this->ipToHex($ip);
        $me = $this;

        // Check if the IP is in the cache
        if (Cache::has($hex)) {
            $this->isCached = true;
        }
        // Use the IP info stored in cache or store it
        $ipInfo = Cache::remember($hex, 10080, function () use ($me, $url) {
            return $me->fetchInfo($url);
        });

        $ipInfo->geoplugin_cached = $this->isCached;

        return $ipInfo;
    }
1328142
static public function getClientIp()
    {
        /*
         $headers = function_exists('apache_request_headers')
         ? apache_request_headers()
         : $_SERVER;
         
         return isset($headers['REMOTE_ADDR']) ? $headers['REMOTE_ADDR'] : '0.0.0.0';
         */
        
        if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
            $ip = getenv('HTTP_CLIENT_IP');
        } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
            $ip = getenv('HTTP_X_FORWARDED_FOR');
        } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
            $ip = getenv('REMOTE_ADDR');
        } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
            $ip = $_SERVER['REMOTE_ADDR'];
        } else {
            return '0.0.0.0';
        }
        
        return preg_match ( '/[\d\.]{7,15}/', $ip, $matches ) ? $matches [0] : '0.0.0.0';
    }
1241709
public function getClientIp()
    {
        if (isset($_SERVER['HTTP_CLIENT_IP'])) {
            $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
            $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
        } elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
            $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
        } elseif (isset($_SERVER['HTTP_FORWARDED'])) {
            $ipaddress = $_SERVER['HTTP_FORWARDED'];
        } elseif (isset($_SERVER['REMOTE_ADDR'])) {
            $ipaddress = $_SERVER['REMOTE_ADDR'];
        } else {
            $ipaddress = '';
        }

        return $ipaddress;
    }
178672
public static function getClientIp()
	{
		$ip = '';
		if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
			$ip = $_SERVER['HTTP_CLIENT_IP'];
		} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
			$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
		} elseif ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) {
			$ip = $_SERVER['HTTP_X_FORWARDED'];
		} elseif ( isset( $_SERVER['HTTP_FORWARDED_FOR'] ) ) {
			$ip = $_SERVER['HTTP_FORWARDED_FOR'];
		} elseif ( isset( $_SERVER['HTTP_FORWARDED'] ) ) {
			$ip = $_SERVER['HTTP_FORWARDED'];
		} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
			$ip = $_SERVER['REMOTE_ADDR'];
		}

		return $ip;
	}
228598
public function verify($response, $clientIp = null)
    {
        return $this->response = $this->sendVerifyRequest([
            'secret'   => $this->secret,
            'response' => $response,
            'remoteip' => $clientIp
        ]);
    }
910420
public function getIpInfo()
    {
        $request = $this->requestStack->getCurrentRequest();

        $ipInfo = [];
        $ipInfo['country'] = $request->server->get('GEOIP_COUNTRY_CODE', null);
        $ipInfo['city'] = $request->server->get('GEOIP_CITY', null);
        $ipInfo['region'] = $request->server->get('GEOIP_REGION_NAME', null);
        $ipInfo['ip'] = $request->getClientIp();

        return $ipInfo;
    }