🚀 Speedtest Sonuç Çekici

Geçersiz Speedtest.net URL\'si!
'; } else { echo '
Veriler çekiliyor...
'; // PHP ile veri çekme $result = fetchSpeedtestData($url); if ($result['success']) { echo '
'; echo '
'; echo '

Test Sonuçları

'; if (isset($result['data']['download'])) { echo '
'; echo '⬇️ İndirme Hızı:'; echo '' . $result['data']['download'] . ''; echo '
'; } if (isset($result['data']['upload'])) { echo '
'; echo '⬆️ Yükleme Hızı:'; echo '' . $result['data']['upload'] . ''; echo '
'; } if (isset($result['data']['ping'])) { echo '
'; echo '📡 Ping:'; echo '' . $result['data']['ping'] . ''; echo '
'; } if (isset($result['data']['jitter'])) { echo '
'; echo '📊 Jitter:'; echo '' . $result['data']['jitter'] . ''; echo '
'; } if (isset($result['data']['server'])) { echo '
'; echo '🖥️ Sunucu:'; echo '' . htmlspecialchars($result['data']['server']) . ''; echo '
'; } if (isset($result['data']['location'])) { echo '
'; echo '📍 Konum:'; echo '' . htmlspecialchars($result['data']['location']) . ''; echo '
'; } if (isset($result['data']['date'])) { echo '
'; echo '📅 Tarih:'; echo '' . htmlspecialchars($result['data']['date']) . ''; echo '
'; } if (isset($result['data']['isp'])) { echo '
'; echo '🌐 ISP:'; echo '' . htmlspecialchars($result['data']['isp']) . ''; echo '
'; } // Yeni eklenen alanlar if (isset($result['data']['id'])) { echo '
'; echo '🆔 Test ID:'; echo '' . htmlspecialchars($result['data']['id']) . ''; echo '
'; } if (isset($result['data']['server_name'])) { echo '
'; echo '🖥️ Sunucu Adı:'; echo '' . htmlspecialchars($result['data']['server_name']) . ''; echo '
'; } if (isset($result['data']['sponsor_name'])) { echo '
'; echo '🏢 Sponsor:'; echo '' . htmlspecialchars($result['data']['sponsor_name']) . ''; echo '
'; } if (isset($result['data']['isp_name'])) { echo '
'; echo '🌐 ISP Adı:'; echo '' . htmlspecialchars($result['data']['isp_name']) . ''; echo '
'; } if (isset($result['data']['display_provider_name'])) { echo '
'; echo '📡 Sağlayıcı:'; echo '' . htmlspecialchars($result['data']['display_provider_name']) . ''; echo '
'; } if (isset($result['data']['connection_icon'])) { $iconText = $result['data']['connection_icon'] === 'wireless' ? 'Kablosuz' : ($result['data']['connection_icon'] === 'wired' ? 'Kablolu' : ucfirst($result['data']['connection_icon'])); echo '
'; echo '📶 Bağlantı Tipi:'; echo '' . htmlspecialchars($iconText) . ''; echo '
'; } if (isset($result['data']['connection_mode'])) { echo '
'; echo '🔌 Bağlantı Modu:'; echo '' . htmlspecialchars($result['data']['connection_mode']) . ''; echo '
'; } if (isset($result['data']['idle_latency'])) { echo '
'; echo '⏱️ Boşta Latency:'; echo '' . htmlspecialchars($result['data']['idle_latency']) . ''; echo '
'; } if (isset($result['data']['download_latency'])) { echo '
'; echo '⬇️ İndirme Latency:'; echo '' . htmlspecialchars($result['data']['download_latency']) . ''; echo '
'; } if (isset($result['data']['upload_latency'])) { echo '
'; echo '⬆️ Yükleme Latency:'; echo '' . htmlspecialchars($result['data']['upload_latency']) . ''; echo '
'; } if (isset($result['data']['hasSecondary'])) { echo '
'; echo '🔄 İkincil Test:'; echo '' . htmlspecialchars($result['data']['hasSecondary']) . ''; echo '
'; } if (isset($result['data']['path'])) { echo '
'; echo '🔗 Path:'; echo '' . htmlspecialchars($result['data']['path']) . ''; echo '
'; } // Ek sunucular if (isset($result['data']['additional_servers']) && is_array($result['data']['additional_servers']) && !empty($result['data']['additional_servers'])) { echo '
'; echo '🌍 Ek Sunucular:'; echo '
'; foreach ($result['data']['additional_servers'] as $index => $server) { echo '
'; if (isset($server['server_name'])) { echo '' . htmlspecialchars($server['server_name']) . ''; } if (isset($server['sponsor_name'])) { echo ' - ' . htmlspecialchars($server['sponsor_name']); } if (isset($server['server_id'])) { echo ' (ID: ' . htmlspecialchars($server['server_id']) . ')'; } echo '
'; } echo '
'; echo '
'; } echo '
'; echo '
'; } else { echo '
Hata: ' . htmlspecialchars($result['error']) . '
'; } } } function fetchSpeedtestData($url) { // URL'den result ID'yi çıkar if (!preg_match('/\/result\/(\d+)/', $url, $urlMatches)) { return ['success' => false, 'error' => 'Geçersiz Speedtest URL formatı!']; } $resultId = $urlMatches[1]; $data = []; // Method 1: Speedtest.net API endpoint'ini dene (en güvenilir yöntem) $apiUrls = [ "https://www.speedtest.net/api/results/{$resultId}", "https://www.speedtest.net/api/js/result/{$resultId}", "https://www.speedtest.net/api/v2/results/{$resultId}" ]; foreach ($apiUrls as $apiUrl) { $apiCh = curl_init(); curl_setopt($apiCh, CURLOPT_URL, $apiUrl); curl_setopt($apiCh, CURLOPT_RETURNTRANSFER, true); curl_setopt($apiCh, CURLOPT_FOLLOWLOCATION, true); curl_setopt($apiCh, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'); curl_setopt($apiCh, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($apiCh, CURLOPT_TIMEOUT, 15); curl_setopt($apiCh, CURLOPT_HTTPHEADER, [ 'Accept: application/json, text/plain, */*', 'Referer: https://www.speedtest.net/', 'Origin: https://www.speedtest.net' ]); $apiResponse = curl_exec($apiCh); $apiHttpCode = curl_getinfo($apiCh, CURLINFO_HTTP_CODE); curl_close($apiCh); if ($apiHttpCode === 200 && $apiResponse) { $apiData = json_decode($apiResponse, true); if ($apiData && is_array($apiData)) { // Farklı API response formatlarını kontrol et $result = $apiData; // Nested result objesi varsa if (isset($apiData['result'])) { $result = $apiData['result']; } // Download speed (bytes per second) if (isset($result['download'])) { $data['download'] = formatSpeed($result['download']); } elseif (isset($result['downloadSpeed'])) { $data['download'] = formatSpeed($result['downloadSpeed']); } elseif (isset($result['downloadBandwidth'])) { $data['download'] = formatSpeed($result['downloadBandwidth']); } // Upload speed if (isset($result['upload'])) { $data['upload'] = formatSpeed($result['upload']); } elseif (isset($result['uploadSpeed'])) { $data['upload'] = formatSpeed($result['uploadSpeed']); } elseif (isset($result['uploadBandwidth'])) { $data['upload'] = formatSpeed($result['uploadBandwidth']); } // Ping if (isset($result['ping'])) { $data['ping'] = round($result['ping']) . ' ms'; } elseif (isset($result['latency'])) { $data['ping'] = round($result['latency']) . ' ms'; } // Jitter if (isset($result['jitter'])) { $data['jitter'] = round($result['jitter'], 2) . ' ms'; } // Server bilgileri if (isset($result['server'])) { if (is_array($result['server'])) { if (isset($result['server']['name'])) { $data['server'] = $result['server']['name']; } if (isset($result['server']['location'])) { $data['location'] = $result['server']['location']; } elseif (isset($result['server']['city']) && isset($result['server']['country'])) { $data['location'] = $result['server']['city'] . ', ' . $result['server']['country']; } } } // Tarih if (isset($result['date'])) { $timestamp = is_numeric($result['date']) ? $result['date'] : strtotime($result['date']); $data['date'] = date('d.m.Y H:i', $timestamp); } elseif (isset($result['timestamp'])) { $timestamp = is_numeric($result['timestamp']) ? $result['timestamp'] : strtotime($result['timestamp']); $data['date'] = date('d.m.Y H:i', $timestamp); } // ISP if (isset($result['isp'])) { $data['isp'] = $result['isp']; } elseif (isset($result['client']['isp'])) { $data['isp'] = $result['client']['isp']; } if (!empty($data)) { return ['success' => true, 'data' => $data]; } } } } // Method 2: HTML sayfasını çek ve parse et $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $html = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode !== 200 || !$html) { return ['success' => false, 'error' => 'Sayfa yüklenemedi. HTTP Kodu: ' . $httpCode]; } // JSON-LD script tag'lerini ara if (preg_match_all('/]*type=["\']application\/ld\+json["\'][^>]*>(.*?)<\/script>/is', $html, $matches)) { foreach ($matches[1] as $jsonStr) { $jsonData = json_decode($jsonStr, true); if ($jsonData && isset($jsonData['@type']) && $jsonData['@type'] === 'WebPage') { if (isset($jsonData['about']['result'])) { $result = $jsonData['about']['result']; if (isset($result['downloadSpeed'])) { $data['download'] = formatSpeed($result['downloadSpeed']); } if (isset($result['uploadSpeed'])) { $data['upload'] = formatSpeed($result['uploadSpeed']); } if (isset($result['latency'])) { $data['ping'] = round($result['latency']) . ' ms'; } } } } } // JavaScript değişkenlerini ara - window.OOKLA.INIT_DATA // window.OOKLA.INIT_DATA = {...}; formatını yakala if (preg_match('/window\.OOKLA\.INIT_DATA\s*=\s*(\{.*?\});/s', $html, $matches)) { $jsonStr = $matches[1]; // JSON string'ini temizle (escape karakterlerini düzelt) $jsonStr = str_replace(['\u002F'], ['/'], $jsonStr); // JSON decode dene $initData = json_decode($jsonStr, true); // Eğer decode başarısız olduysa, manuel olarak düzeltmeyi dene if (json_last_error() !== JSON_ERROR_NONE) { // Başlangıç ve bitiş pozisyonlarını bul $startPos = strpos($html, 'window.OOKLA.INIT_DATA'); if ($startPos !== false) { $startPos = strpos($html, '{', $startPos); if ($startPos !== false) { $braceCount = 0; $endPos = $startPos; $inString = false; $escapeNext = false; // JSON'un sonunu bul for ($i = $startPos; $i < strlen($html); $i++) { $char = $html[$i]; if ($escapeNext) { $escapeNext = false; continue; } if ($char === '\\') { $escapeNext = true; continue; } if ($char === '"' && !$escapeNext) { $inString = !$inString; continue; } if (!$inString) { if ($char === '{') { $braceCount++; } elseif ($char === '}') { $braceCount--; if ($braceCount === 0) { $endPos = $i; break; } } } } if ($braceCount === 0) { $jsonStr = substr($html, $startPos, $endPos - $startPos + 1); $jsonStr = str_replace(['\u002F'], ['/'], $jsonStr); $initData = json_decode($jsonStr, true); } } } } if ($initData && isset($initData['result'])) { $result = $initData['result']; // Temel hız verileri // window.OOKLA.INIT_DATA'daki değerler bits per second cinsindendir if (isset($result['download'])) { $data['download'] = formatSpeedFromBits($result['download']); } if (isset($result['upload'])) { $data['upload'] = formatSpeedFromBits($result['upload']); } if (isset($result['latency'])) { $data['ping'] = round($result['latency']) . ' ms'; } if (isset($result['jitter'])) { $data['jitter'] = round($result['jitter'], 2) . ' ms'; } // Tarih if (isset($result['date'])) { $timestamp = is_numeric($result['date']) ? $result['date'] : strtotime($result['date']); $data['date'] = date('d.m.Y H:i:s', $timestamp); } // ID if (isset($result['id'])) { $data['id'] = $result['id']; } // Sunucu bilgileri if (isset($result['server_name'])) { $data['server_name'] = $result['server_name']; } if (isset($result['sponsor_name'])) { $data['sponsor_name'] = $result['sponsor_name']; } if (isset($result['sponsor_url'])) { $data['sponsor_url'] = $result['sponsor_url']; } // ISP ve Provider if (isset($result['isp_name'])) { $data['isp_name'] = $result['isp_name']; } if (isset($result['display_provider_name'])) { $data['display_provider_name'] = $result['display_provider_name']; } // Bağlantı bilgileri if (isset($result['connection_icon'])) { $data['connection_icon'] = $result['connection_icon']; } if (isset($result['connection_mode'])) { $data['connection_mode'] = $result['connection_mode']; } // Latency detayları if (isset($result['idle_latency'])) { $data['idle_latency'] = $result['idle_latency'] . ' ms'; } if (isset($result['download_latency'])) { $data['download_latency'] = $result['download_latency'] . ' ms'; } if (isset($result['upload_latency'])) { $data['upload_latency'] = $result['upload_latency'] . ' ms'; } // Path if (isset($result['path'])) { $data['path'] = $result['path']; } // HasSecondary if (isset($result['hasSecondary'])) { $data['hasSecondary'] = $result['hasSecondary'] ? 'Evet' : 'Hayır'; } // Ek sunucular if (isset($result['additional_servers']) && is_array($result['additional_servers'])) { $data['additional_servers'] = $result['additional_servers']; } } } // HTML'den regex ile veri çek (son çare) if (empty($data)) { // Download speed - çeşitli formatları dene if (preg_match('/download["\']?\s*[:=]\s*["\']?(\d+(?:\.\d+)?)\s*(?:mbps|mb\/s)?/i', $html, $matches)) { $data['download'] = number_format((float)$matches[1], 2) . ' Mbps'; } // Upload speed if (preg_match('/upload["\']?\s*[:=]\s*["\']?(\d+(?:\.\d+)?)\s*(?:mbps|mb\/s)?/i', $html, $matches)) { $data['upload'] = number_format((float)$matches[1], 2) . ' Mbps'; } // Ping if (preg_match('/ping["\']?\s*[:=]\s*["\']?(\d+(?:\.\d+)?)\s*ms?/i', $html, $matches)) { $data['ping'] = round((float)$matches[1]) . ' ms'; } } if (empty($data)) { return ['success' => false, 'error' => 'Veriler sayfadan çıkarılamadı. Sayfa yapısı değişmiş olabilir veya sayfa JavaScript ile yükleniyor olabilir.']; } return ['success' => true, 'data' => $data]; } function formatSpeed($bytesPerSecond) { // Bytes per second'u Mbps'e çevir $mbps = $bytesPerSecond / 1000000; if ($mbps >= 1000) { return number_format($mbps / 1000, 2) . ' Gbps'; } else { return number_format($mbps, 2) . ' Mbps'; } } function formatSpeedFromBits($value) { // Speedtest.net'teki window.OOKLA.INIT_DATA değerleri bits per second cinsindendir // Ancak gerçek hız değerleri için 1000'e bölmek gerekiyor // Örnek: download: 90849 -> 90.849 Mbps (1000'e bölünür) // Bu muhtemelen Speedtest.net'in internal formatından kaynaklanıyor // Değeri 1000'e bölerek Mbps'e çevir $mbps = $value / 1000; if ($mbps >= 1000) { return number_format($mbps / 1000, 2) . ' Gbps'; } else { return number_format($mbps, 2) . ' Mbps'; } } ?>