<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <title>Bot & Sistem Bağlantı Durumu - Aurea Crypto</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-6 bg-[#05070c] text-gray-100 font-sans">
    <div class="max-w-7xl mx-auto space-y-6">
        
        <!-- Header -->
        <header class="flex flex-col md:flex-row justify-between items-start md:items-center pb-4 border-b border-gray-800 gap-4">
            <div>
                <h1 class="text-xl font-black text-yellow-500 flex items-center gap-2">
                    <span>📡</span> Bot & Sistem Bağlantı Durumu Terminali
                </h1>
                <p class="text-xs text-gray-400 mt-1">
                    Binance API Endpoint, Sunucu NTP Saat Senkronizasyonu, Veritabanı ve Otomatik Bot Taraması Canlı Teşhis Paneli
                </p>
            </div>
            
            <div class="flex items-center gap-2 bg-gray-950/80 p-1 rounded-xl border border-gray-800 flex-wrap">
                <a href="index.php?tab=aurea" class="px-3.5 py-2 rounded-lg text-xs font-bold tracking-wider uppercase transition flex items-center gap-1.5 text-gray-400 hover:text-white hover:bg-gray-900/40">
                    🧭 Dipler
                </a>
                <a href="index.php?tab=yield" class="px-3.5 py-2 rounded-lg text-xs font-bold tracking-wider uppercase transition flex items-center gap-1.5 text-gray-400 hover:text-white hover:bg-gray-900/40">
                    ⚡ Simülatör
                </a>
                <a href="index.php?tab=binance" class="px-3.5 py-2 rounded-lg text-xs font-bold tracking-wider uppercase transition flex items-center gap-1.5 text-gray-400 hover:text-white hover:bg-gray-900/40">
                    💼 Binance Terminali
                </a>
                <a href="wallet.php" class="px-3.5 py-2 rounded-lg text-xs font-bold tracking-wider uppercase transition flex items-center gap-1.5 text-gray-400 hover:text-white hover:bg-gray-900/40">
                    📊 Cüzdan
                </a>
                <a href="status.php" class="px-3.5 py-2 rounded-lg text-xs font-bold tracking-wider uppercase transition flex items-center gap-1.5 bg-yellow-500 text-gray-950 font-black shadow-lg shadow-yellow-500/10">
                    📡 Bağlantı
                </a>
                <a href="tests.php?run=1" class="px-3.5 py-2 rounded-lg text-xs font-bold tracking-wider uppercase transition flex items-center gap-1.5 text-yellow-400 border border-yellow-500/30 hover:bg-yellow-500/10">
                    🧪 Bütün Testler
                </a>
                <a href="status.php?action=test" class="px-3.5 py-2 bg-yellow-500/20 text-yellow-400 border border-yellow-500/40 hover:bg-yellow-500 hover:text-gray-950 font-black rounded-lg text-xs transition flex items-center gap-1 ml-1">
                    ⚡ Teşhis
                </a>
            </div>
        </header>

        <!-- General Health Badge -->
        <div class="p-4 bg-gray-900/80 border border-gray-800 rounded-2xl flex items-center justify-between font-mono text-xs">
            <div class="flex items-center gap-3">
                <span class="h-3 w-3 rounded-full bg-emerald-500 animate-pulse"></span>
                <div>
                    <span class="text-gray-400 block text-[10px]">GENEL SİSTEM SAĞLIK DURUMU</span>
                    <strong class="text-emerald-400 text-sm font-black">
                        🟢 TÜM BAĞLANTILAR AKTİF VE SAĞLIKLI                    </strong>
                </div>
            </div>

            <div class="text-right">
                <span class="text-gray-500 block text-[10px]">ÇALIŞMA MODU</span>
                <span class="text-yellow-400 font-bold">
                    🌐 Binance Global Canlı Borsa                </span>
            </div>
        </div>

        <!-- Diagnostic Test Result Overlay if triggered -->
                    <div class="p-5 bg-yellow-500/10 border border-yellow-500/30 rounded-2xl space-y-3 font-mono text-xs">
                <div class="flex justify-between items-center pb-2 border-b border-yellow-500/20">
                    <h3 class="font-black text-yellow-400 text-sm">🧪 Canlı Teşhis Test Raporu (Tamamlanma Süresi: 4835ms)</h3>
                    <a href="status.php" class="text-gray-400 hover:text-white text-[11px]">Kapat ✕</a>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-3 text-[11px]">
                    <div class="p-3 bg-gray-950/60 border border-gray-800 rounded-xl">
                        <span class="text-gray-400 block">1. MySQL Veritabanı Bağlantısı:</span>
                        <strong class="text-emerald-400">
                            ✅ BAŞARILI                        </strong>
                        <p class="text-[10px] text-gray-500 mt-0.5">MySQL veritabanı bağlantısı başarılı ve tepki veriyor.</p>
                    </div>

                    <div class="p-3 bg-gray-950/60 border border-gray-800 rounded-xl">
                        <span class="text-gray-400 block">2. Binance API Public Ping & NTP Saati:</span>
                        <strong class="text-emerald-400">
                            ✅ BAŞARILI (488ms)                        </strong>
                        <p class="text-[10px] text-gray-500 mt-0.5">Binance API sunucusuna 488ms sürede ulaşıldı. Saat farkı: 763ms.</p>
                    </div>

                    <div class="p-3 bg-gray-950/60 border border-gray-800 rounded-xl">
                        <span class="text-gray-400 block">3. API Key & Ticaret Yetkisi:</span>
                        <strong class="text-emerald-400">
                            ✅ DOĞRULANDI                        </strong>
                        <p class="text-[10px] text-gray-500 mt-0.5">API Anahtarı doğrulandı. Borsa bakiyelerine erişim aktif.</p>
                    </div>

                    <div class="p-3 bg-gray-950/60 border border-gray-800 rounded-xl">
                        <span class="text-gray-400 block">4. Bot Konfigürasyon Taraması:</span>
                        <strong class="text-emerald-400">
                            ✅ SİSTEM HAZIR                        </strong>
                        <p class="text-[10px] text-gray-500 mt-0.5">Bot ayarları okundu. Durum: Aktif, Alım Skoru: &gt;=80</p>
                    </div>
                </div>
            </div>
        
        <!-- 4 Core Layers Grid -->
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 font-mono text-xs">
            
            <!-- Layer 1 -->
            <div class="p-4 bg-gray-900 border border-gray-800 rounded-2xl space-y-2">
                <span class="text-amber-500 text-[10px] tracking-wider uppercase font-bold block">1. Borsa API Katmanı</span>
                <h3 class="text-sm font-black text-white">Binance Exchange</h3>
                <div class="space-y-1 text-gray-300 text-[11px]">
                    <div class="flex justify-between"><span class="text-gray-500">Domain:</span> <span class="font-bold">api.binance.com</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">Gecikme (Ping):</span> <span class="text-emerald-400 font-bold">39 ms</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">API Key:</span> <span>b50b20...</span></div>
                </div>
            </div>

            <!-- Layer 2 -->
            <div class="p-4 bg-gray-900 border border-gray-800 rounded-2xl space-y-2">
                <span class="text-amber-500 text-[10px] tracking-wider uppercase font-bold block">2. Sunucu Saati (NTP)</span>
                <h3 class="text-sm font-black text-white">Timestamp Sync</h3>
                <div class="space-y-1 text-gray-300 text-[11px]">
                    <div class="flex justify-between"><span class="text-gray-500">Offset Farkı:</span> <span class="text-emerald-400 font-bold">±0 ms (Dinamik)</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">-1021 Koruması:</span> <span class="text-emerald-400 font-bold">AKTİF</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">recvWindow:</span> <span>60000 ms</span></div>
                </div>
            </div>

            <!-- Layer 3 -->
            <div class="p-4 bg-gray-900 border border-gray-800 rounded-2xl space-y-2">
                <span class="text-amber-500 text-[10px] tracking-wider uppercase font-bold block">3. Bot Algoritma Motoru</span>
                <h3 class="text-sm font-black text-white">Otomatik Al-Sat Botu</h3>
                <div class="space-y-1 text-gray-300 text-[11px]">
                    <div class="flex justify-between"><span class="text-gray-500">Bot Durumu:</span> <span class="text-emerald-400 font-bold">🟢 AKTİF TARAMADA</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">İşlem Başında:</span> <span>$250</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">Alım Skoru:</span> <span>>= 80/100</span></div>
                </div>
            </div>

            <!-- Layer 4 -->
            <div class="p-4 bg-gray-900 border border-gray-800 rounded-2xl space-y-2">
                <span class="text-amber-500 text-[10px] tracking-wider uppercase font-bold block">4. Veritabanı & Sistem</span>
                <h3 class="text-sm font-black text-white">MySQL & PHP Engine</h3>
                <div class="space-y-1 text-gray-300 text-[11px]">
                    <div class="flex justify-between"><span class="text-gray-500">Veritabanı:</span> <span class="text-emerald-400 font-bold">MySQL 8.0 (PDO)</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">HTTP Status:</span> <span class="text-emerald-400 font-bold">200 OK</span></div>
                    <div class="flex justify-between"><span class="text-gray-500">Uptime:</span> <span>%99.98</span></div>
                </div>
            </div>

        </div>

        <!-- Technical Guide & Cron Configuration Panel -->
        <div class="bg-gray-900 border border-gray-800 rounded-2xl p-6 space-y-4">
            <h2 class="text-base font-black text-yellow-500 flex items-center gap-2">
                <span>⚙️</span> Sunucu Yapılandırma & Kesintisiz Çalışma Rehberi
            </h2>
            
            <div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-xs font-mono">
                <div class="p-4 bg-gray-950 border border-gray-850 rounded-xl space-y-2">
                    <strong class="text-white font-bold block">1. Cron Job İle 7/24 Kesintisiz Bot:</strong>
                    <p class="text-gray-400 text-[11px] leading-relaxed">
                        Tarayıcı isteklerinde oluşan 30 saniyelik <code class="text-yellow-400">max_execution_time</code> zaman aşımını önlemek için botu sunucu arkaplanında Cron Job ile her dakika çalıştırabilirsiniz:
                    </p>
                    <div class="p-2 bg-black border border-gray-800 rounded text-[10px] text-emerald-400 font-mono select-all overflow-x-auto">
                        * * * * * php /var/www/html/php-backend/cron_runner.php >> /dev/null 2>&1
                    </div>
                </div>

                <div class="p-4 bg-gray-950 border border-gray-850 rounded-xl space-y-2">
                    <strong class="text-white font-bold block">2. Sunucu NTP Saati Senkronizasyonu:</strong>
                    <p class="text-gray-400 text-[11px] leading-relaxed">
                        Binance API timestamp (-1021) hatalarını engellemek için sunucu saatinizi NTP protokolü ile güncel tutun:
                    </p>
                    <div class="p-2 bg-black border border-gray-800 rounded text-[10px] text-emerald-400 font-mono select-all overflow-x-auto">
                        sudo ntpdate -u time.google.com
                    </div>
                </div>

                <div class="p-4 bg-gray-950 border border-gray-850 rounded-xl space-y-2">
                    <strong class="text-white font-bold block">3. Dinamik LOT_SIZE Filtresi:</strong>
                    <p class="text-gray-400 text-[11px] leading-relaxed">
                        Her coin için Binance <code class="text-yellow-400">exchangeInfo</code> endpoint'inden stepSize hassasiyeti çekilerek miktar küsüratı otomatik formatlanır.
                    </p>
                    <span class="inline-block px-2 py-0.5 bg-emerald-500/10 text-emerald-400 border border-emerald-500/30 rounded text-[10px]">✅ Dinamik Küsürat Aktif</span>
                </div>
            </div>
        </div>

    </div>
</body>
</html>
