extra->source; } $registry = DataSourceRegistry::getInstance(); if (is_null($source)) { $source = $registry->getCurrentSource(); } else { $source = $registry->getSource($source); } if ($source) { return $source->getShortLabel(); } return 'Unknown'; } /** * Get client IP (even if it is behind a reverse proxy) * For security reasons, the reverse proxy usage has to be enabled on the settings page. * * @return string Client Ip (IPv4 or IPv6) * * @since 2.0.0 */ function geoip_detect2_get_client_ip() { _geoip_maybe_disable_pagecache(); static $helper = null; if (is_null($helper) || defined('GEOIP_DETECT_DOING_UNIT_TESTS')) { $helper = new GetClientIp(); // TODO: Expose option to UI. comma-seperated list of IPv4 and v6 adresses. $trusted_proxies = explode(',', (string) get_option('geoip-detect-trusted_proxy_ips', '')); $helper->addProxiesToWhitelist($trusted_proxies); } $useReverseProxy = get_option('geoip-detect-has_reverse_proxy', 0); return $helper->getIp( $useReverseProxy ); } /** * Sometimes we can only see an local IP adress (local development environment.) * In this case we need to ask an internet server which IP adress our internet connection has. * * @param boolean $unfiltered If true, do not check the options for an external adress. (Default: false) * @return string The detected IPv4 Adress. If none is found, '0.0.0.0' is returned instead. * * @since 2.0.0 * @since 2.4.3 Reading option 'external_ip' first. * @since 2.5.2 New param $unfiltered that can bypass the option. */ function geoip_detect2_get_external_ip_adress($unfiltered = false) { $ip_cache = ''; if (!$unfiltered) $ip_cache = get_option('geoip-detect-external_ip'); if (!$ip_cache) $ip_cache = get_transient('geoip_detect_external_ip'); if (!$ip_cache) { $ip_cache = _geoip_detect_get_external_ip_adress_without_cache(); $expiryTime = GEOIP_DETECT_IP_CACHE_TIME; if (empty($ip_cache) || $ip_cache === '0.0.0.0') $expiryTime = GEOIP_DETECT_IP_EMPTY_CACHE_TIME; set_transient('geoip_detect_external_ip', $ip_cache, $expiryTime); } $ip_cache = apply_filters('geoip_detect_get_external_ip_adress', $ip_cache); return $ip_cache; }