/** * @return bool */ public static function IsViewingThroughProxy() { $bRet = false; $strProxyIP = Config::inst()->get('ContinentalContent', 'proxy_ip'); if ($strProxyIP != '0.0.0.0') { $bRet = $strProxyIP == ContinentalContentUtils::IPAddress(); } return $bRet; }
/** * @return int|string */ public static function CurrentContinent() { if (self::$current_continent) { return self::$current_continent; } self::$current_continent = CONTINENTAL_DEFAULT; if (!self::IsViewingThroughProxy() && Session::get('SESSION_MAP_LOCATION')) { self::$current_continent = strtolower(trim(Session::get('SESSION_MAP_LOCATION'))); } else { if ($forwarder = ForwardedIP::get()->filter('IP', ContinentalContentUtils::IPAddress())->first()) { $countryToCode = array_flip(self::$country_codes); foreach (self::GetContinents() as $strCode => $arrContinents) { foreach ($arrContinents as $strContinent) { $strCountryCode = isset($countryToCode[$strContinent]) ? $countryToCode[$strContinent] : null; if ($strCountryCode == $forwarder->Continent) { self::$current_continent = $strCode; if (isset($_REQUEST['debug_location'])) { echo "<p style='display: block; padding: 10px 40px; background: white; color: black; position: absolute; top: 43px; left: 0; z-index: 999999;'>{$forwarder->Continent}</p>"; } break 2; } } } } else { if ($location = ContinentalContentUtils::GetLocation()) { $countryToCode = array_flip(self::$country_codes); foreach (self::GetContinents() as $strCode => $arrContinents) { foreach ($arrContinents as $strContinent) { $strCountryCode = isset($countryToCode[$strContinent]) ? $countryToCode[$strContinent] : null; if (strtolower(trim($location->Country)) == strtolower(trim($strContinent)) || strtolower(trim($location->Region)) == strtolower(trim($strContinent)) || strtolower(trim($location->City)) == strtolower(trim($strContinent)) || strtolower(trim($location->Country)) == strtolower(trim($strCode)) || strtolower(trim($location->Region)) == strtolower(trim($strCode)) || strtolower(trim($location->City)) == strtolower(trim($strCode)) || !is_null($strCountryCode) && strtolower(trim($location->Country)) == strtolower(trim($strCountryCode))) { if (isset($_REQUEST['debug_location'])) { echo "<p style='display: block; padding: 10px 40px; background: white; color: black; position: absolute; top: 43px; left: 0; z-index: 999999;'>{$strCode}</p>"; } self::$current_continent = $strCode; break 2; } } } } } } return self::$current_continent; }