<?php
session_start();
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Card Checker - Website Version</title>
    <style>
        :root {
            --primary: #2c3e50;
            --secondary: #3498db;
            --success: #27ae60;
            --danger: #e74c3c;
            --warning: #f39c12;
            --light: #ecf0f1;
            --dark: #2c3e50;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        header {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 20px 0;
            border-radius: 8px;
            margin-bottom: 30px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }
        
        .logo {
            display: flex;
            align-items: center;
        }
        
        .logo h1 {
            font-size: 24px;
            margin-left: 10px;
        }
        
        .logo-icon {
            font-size: 28px;
        }
        
        .user-info {
            text-align: right;
        }
        
        .card {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            padding: 20px;
            margin-bottom: 20px;
        }
        
        .card h2 {
            color: var(--primary);
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }
        
        .form-group {
            margin-bottom: 15px;
        }
        
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: 600;
        }
        
        input, select {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
        }
        
        button {
            background-color: var(--secondary);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            transition: background-color 0.3s;
        }
        
        button:hover {
            background-color: #2980b9;
        }
        
        .btn-success {
            background-color: var(--success);
        }
        
        .btn-success:hover {
            background-color: #219653;
        }
        
        .btn-danger {
            background-color: var(--danger);
        }
        
        .btn-danger:hover {
            background-color: #c0392b;
        }
        
        .result {
            margin-top: 20px;
            padding: 15px;
            border-radius: 4px;
            display: none;
        }
        
        .success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        
        .error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        
        .warning {
            background-color: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
        }
        
        .info {
            background-color: #d1ecf1;
            color: #0c5460;
            border: 1px solid #bee5eb;
        }
        
        .result-content {
            white-space: pre-line;
        }
        
        .tabs {
            display: flex;
            margin-bottom: 20px;
            border-bottom: 1px solid #ddd;
        }
        
        .tab {
            padding: 10px 20px;
            cursor: pointer;
            border-bottom: 3px solid transparent;
        }
        
        .tab.active {
            border-bottom: 3px solid var(--secondary);
            color: var(--secondary);
            font-weight: 600;
        }
        
        .tab-content {
            display: none;
        }
        
        .tab-content.active {
            display: block;
        }
        
        .command-list {
            list-style-type: none;
        }
        
        .command-list li {
            padding: 8px 0;
            border-bottom: 1px solid #eee;
        }
        
        .command-list li:last-child {
            border-bottom: none;
        }
        
        .command {
            font-weight: 600;
            color: var(--primary);
        }
        
        .description {
            color: #666;
        }
        
        footer {
            text-align: center;
            margin-top: 40px;
            padding: 20px;
            color: #7f8c8d;
            border-top: 1px solid #eee;
        }
        
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                text-align: center;
            }
            
            .user-info {
                margin-top: 10px;
                text-align: center;
            }
            
            .tabs {
                flex-wrap: wrap;
            }
            
            .tab {
                flex: 1 0 50%;
            }
        }
        
        .loading {
            display: none;
            text-align: center;
            padding: 10px;
        }
        
        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #3498db;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 2s linear infinite;
            margin: 0 auto;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .bin-info {
            background: #f8f9fa;
            border-left: 4px solid var(--secondary);
            padding: 10px;
            margin: 10px 0;
            border-radius: 4px;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <div class="header-content">
                <div class="logo">
                    <span class="logo-icon">💳</span>
                    <h1>Card Checker</h1>
                </div>
                <div class="user-info">
                    <p>Welcome, <span id="username">Guest</span></p>
                    <p>Session ID: <span id="session-id"><?php echo session_id(); ?></span></p>
                </div>
            </div>
        </header>
        
        <div class="tabs">
            <div class="tab active" data-tab="checker">Card Checker</div>
            <div class="tab" data-tab="bin">BIN Lookup</div>
            <div class="tab" data-tab="sk">SK Check</div>
            <div class="tab" data-tab="commands">Commands</div>
            <div class="tab" data-tab="info">Info</div>
        </div>
        
        <!-- Card Checker Tab -->
        <div class="tab-content active" id="checker-tab">
            <div class="card">
                <h2>Card Checker</h2>
                <form id="checker-form">
                    <div class="form-group">
                        <label for="amount">Amount (USD/INR)</label>
                        <input type="number" id="amount" name="amount" placeholder="Enter amount" value="1" required>
                    </div>
                    <div class="form-group">
                        <label for="card-number">Card Number</label>
                        <input type="text" id="card-number" name="card_number" placeholder="Enter card number" required>
                    </div>
                    <div class="form-row" style="display: flex; gap: 10px;">
                        <div class="form-group" style="flex: 1;">
                            <label for="exp-month">Expiration Month</label>
                            <input type="text" id="exp-month" name="exp_month" placeholder="MM" required>
                        </div>
                        <div class="form-group" style="flex: 1;">
                            <label for="exp-year">Expiration Year</label>
                            <input type="text" id="exp-year" name="exp_year" placeholder="YY" required>
                        </div>
                        <div class="form-group" style="flex: 1;">
                            <label for="cvv">CVV</label>
                            <input type="text" id="cvv" name="cvv" placeholder="CVV" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="currency">Currency</label>
                        <select id="currency" name="currency">
                            <option value="usd">USD ($)</option>
                            <option value="inr">INR (₹)</option>
                        </select>
                    </div>
                    <button type="submit" id="check-card" class="btn-success">Check Card</button>
                </form>
                
                <div class="loading" id="checker-loading">
                    <div class="spinner"></div>
                    <p>Processing your request...</p>
                </div>
                
                <div id="checker-result" class="result"></div>
            </div>
        </div>
        
        <!-- BIN Lookup Tab -->
        <div class="tab-content" id="bin-tab">
            <div class="card">
                <h2>BIN Lookup</h2>
                <form id="bin-form">
                    <div class="form-group">
                        <label for="bin">BIN (First 6 digits)</label>
                        <input type="text" id="bin" name="bin" placeholder="Enter BIN" required>
                    </div>
                    <button type="submit" id="lookup-bin">Lookup BIN</button>
                </form>
                
                <div class="loading" id="bin-loading">
                    <div class="spinner"></div>
                    <p>Looking up BIN information...</p>
                </div>
                
                <div id="bin-result" class="result"></div>
            </div>
        </div>
        
        <!-- SK Check Tab -->
        <div class="tab-content" id="sk-tab">
            <div class="card">
                <h2>SK Check</h2>
                <form id="sk-form">
                    <div class="form-group">
                        <label for="sk">Stripe Secret Key</label>
                        <input type="text" id="sk" name="sk" placeholder="Enter SK (sk_live_...)" required>
                    </div>
                    <button type="submit" id="check-sk">Check SK</button>
                </form>
                
                <div class="loading" id="sk-loading">
                    <div class="spinner"></div>
                    <p>Checking SK validity...</p>
                </div>
                
                <div id="sk-result" class="result"></div>
            </div>
        </div>
        
        <!-- Commands Tab -->
        <div class="tab-content" id="commands-tab">
            <div class="card">
                <h2>Available Commands</h2>
                <ul class="command-list">
                    <li>
                        <span class="command">STRIPE CUSTOM CHARGE:</span>
                        <div class="description">/chk{Amount In $} - xxxxxxxxxxxxxxxx|xx|xx|xxx</div>
                        <div class="description">/inr{Amount In ₹} - xxxxxxxxxxxxxxxx|xx|xx|xxx</div>
                    </li>
                    <li>
                        <span class="command">BIN LOOKUP:</span>
                        <div class="description">/bin - xxxxxx</div>
                    </li>
                    <li>
                        <span class="command">SK CHECK:</span>
                        <div class="description">/sk - sk_live_xxxxxxxxxx</div>
                    </li>
                    <li>
                        <span class="command">TELEGRAM ID/GROUP ID:</span>
                        <div class="description">/id</div>
                    </li>
                </ul>
            </div>
        </div>
        
        <!-- Info Tab -->
        <div class="tab-content" id="info-tab">
            <div class="card">
                <h2>System Information</h2>
                <div class="form-group">
                    <p><strong>Server Time:</strong> <span id="server-time"><?php echo date('Y-m-d H:i:s'); ?></span></p>
                    <p><strong>PHP Version:</strong> <span id="php-version"><?php echo phpversion(); ?></span></p>
                    <p><strong>Session ID:</strong> <span id="info-session-id"><?php echo session_id(); ?></span></p>
                    <p><strong>User IP:</strong> <span id="user-ip"><?php echo $_SERVER['REMOTE_ADDR']; ?></span></p>
                </div>
            </div>
        </div>
        
        <footer>
            <p>Bot By: @CarderAdminBot</p>
            <p>Website Version | Fully Functional PHP Backend</p>
        </footer>
    </div>

    <script>
        // Tab switching functionality
        document.querySelectorAll('.tab').forEach(tab => {
            tab.addEventListener('click', () => {
                // Remove active class from all tabs and contents
                document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
                document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
                
                // Add active class to clicked tab and corresponding content
                tab.classList.add('active');
                const tabId = tab.getAttribute('data-tab');
                document.getElementById(`${tabId}-tab`).classList.add('active');
            });
        });
        
        // Set user info
        document.getElementById('username').textContent = 'User';
        
        // Card Checker functionality
        document.getElementById('checker-form').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const formData = new FormData(this);
            formData.append('action', 'check_card');
            
            showLoading('checker-loading', true);
            showResult('checker-result', '', '');
            
            fetch('process.php', {
                method: 'POST',
                body: formData
            })
            .then(response => response.json())
            .then(data => {
                showLoading('checker-loading', false);
                if (data.status) {
                    showResult('checker-result', data.status, data.message);
                } else {
                    showResult('checker-result', 'error', 'Error: ' + data.message);
                }
            })
            .catch(error => {
                showLoading('checker-loading', false);
                showResult('checker-result', 'error', 'Network error: ' + error);
            });
        });
        
        // BIN Lookup functionality
        document.getElementById('bin-form').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const formData = new FormData(this);
            formData.append('action', 'bin_lookup');
            
            showLoading('bin-loading', true);
            showResult('bin-result', '', '');
            
            fetch('process.php', {
                method: 'POST',
                body: formData
            })
            .then(response => response.json())
            .then(data => {
                showLoading('bin-loading', false);
                if (data.status) {
                    showResult('bin-result', data.status, data.message);
                } else {
                    showResult('bin-result', 'error', 'Error: ' + data.message);
                }
            })
            .catch(error => {
                showLoading('bin-loading', false);
                showResult('bin-result', 'error', 'Network error: ' + error);
            });
        });
        
        // SK Check functionality
        document.getElementById('sk-form').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const formData = new FormData(this);
            formData.append('action', 'sk_check');
            
            showLoading('sk-loading', true);
            showResult('sk-result', '', '');
            
            fetch('process.php', {
                method: 'POST',
                body: formData
            })
            .then(response => response.json())
            .then(data => {
                showLoading('sk-loading', false);
                if (data.status) {
                    showResult('sk-result', data.status, data.message);
                } else {
                    showResult('sk-result', 'error', 'Error: ' + data.message);
                }
            })
            .catch(error => {
                showLoading('sk-loading', false);
                showResult('sk-result', 'error', 'Network error: ' + error);
            });
        });
        
        // Helper function to display results
        function showResult(elementId, type, message) {
            const resultElement = document.getElementById(elementId);
            resultElement.innerHTML = message;
            resultElement.className = 'result ' + type;
            resultElement.style.display = 'block';
        }
        
        // Helper function to show/hide loading
        function showLoading(elementId, show) {
            const loadingElement = document.getElementById(elementId);
            loadingElement.style.display = show ? 'block' : 'none';
        }
    </script>
</body>
</html>