示例#1
0
<?php

global $USER;
session_start();
//$site = "tvguru.com";
$site = "megatv.su";
$host = $_SERVER['SERVER_NAME'];
if (strpos($host, "http://") === false && strpos($host, "https://") === false) {
    $host = "http://" . $host;
}
//city change
if (isset($_POST["city-id"]) && intval($_POST["city-id"]) > 0 && check_bitrix_sessid()) {
    $arGeo = \Hawkart\Megatv\CityTable::setGeoCity(intval($_POST["city-id"]));
    header("Location: " . $APPLICATION->GetCurPage());
} else {
    if (isset($_POST["lang-id"]) && intval($_POST["lang-id"]) > 0 && check_bitrix_sessid()) {
        $arGeo = \Hawkart\Megatv\CountryTable::setCountry(intval($_POST["lang-id"]));
        if (strtoupper($arGeo["COUNTRY_ISO"]) == LANGUAGE_DEFAULT) {
            $redirect_url = "http://" . $site;
        } else {
            $redirect_url = "http://" . strtolower($arGeo["COUNTRY_ISO"]) . "." . $site;
        }
        if (strtolower(LANGUAGE_ID) != strtolower($arGeo["COUNTRY_ISO"])) {
            LocalRedirect($redirect_url . $APPLICATION->GetCurPage());
            die;
        }
    } else {
        $arGeo = \Hawkart\Megatv\CityTable::getGeoCity();
        if (strtolower(LANGUAGE_ID) != strtolower($arGeo["COUNTRY_ISO"])) {
            \Hawkart\Megatv\CountryTable::setCountryByIso(LANGUAGE_ID);
        }