// === УЛУЧШЕННЫЙ ПОИСК ФАЙЛОВ === function getLatestVersionInfo() { $cacheFile = __DIR__ . '/github_cache.json'; $repo = "UnrealKaraulov/EasyCheatDetector"; $currentVersion = "v2.66"; // Проверка кэша if (file_exists($cacheFile) && (time() - filemtime($cacheFile)) < CACHE_TIME) { $cachedData = json_decode(file_get_contents($cacheFile), true); if (json_last_error() === JSON_ERROR_NONE && is_array($cachedData)) { $cachedData['updateAvailable'] = ($cachedData['latestVersion'] !== $currentVersion); $cachedData['cached'] = true; return $cachedData; } } // Запрос к GitHub API $apiUrl = "https://api.github.com/repos/$repo/releases/latest"; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $apiUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => 'ECD-Version-Check', CURLOPT_TIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_FOLLOWLOCATION => true ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Данные по умолчанию с fallback ссылками $data = [ 'latestVersion' => $currentVersion, 'downloadUrl' => 'https://github.com/UnrealKaraulov/EasyCheatDetector/releases/latest', 'zipUrl' => 'https://github.com/UnrealKaraulov/EasyCheatDetector/releases/latest/download/EasyCheatDetector.zip', 'exeUrl' => 'https://github.com/UnrealKaraulov/EasyCheatDetector/releases/latest/download/EasyCheatDetector.exe', 'updateAvailable' => false, 'cached' => false, 'assets' => [] ]; if ($httpCode === 200 && $response) { $githubData = json_decode($response, true); if (json_last_error() === JSON_ERROR_NONE && isset($githubData['tag_name'])) { $latestVersion = $githubData['tag_name']; $assets = $githubData['assets'] ?? []; $releaseUrl = $githubData['html_url'] ?? $data['downloadUrl']; // Умный поиск файлов $foundFiles = [ 'zip' => null, 'exe' => null, 'other' => [] ]; foreach ($assets as $asset) { $name = strtolower($asset['name'] ?? ''); $browserUrl = $asset['browser_download_url'] ?? '#'; if (strpos($name, '.zip') !== false) { $foundFiles['zip'] = $browserUrl; } elseif (strpos($name, '.exe') !== false) { $foundFiles['exe'] = $browserUrl; } else { $foundFiles['other'][] = $browserUrl; } } // Определение итоговых ссылок $zipUrl = $foundFiles['zip'] ?? ($foundFiles['exe'] ?? ($foundFiles['other'][0] ?? $data['zipUrl'])); $exeUrl = $foundFiles['exe'] ?? ($foundFiles['zip'] ?? ($foundFiles['other'][0] ?? $data['exeUrl'])); $downloadUrl = $foundFiles['zip'] ?? $foundFiles['exe'] ?? ($foundFiles['other'][0] ?? $releaseUrl); $data = [ 'latestVersion' => $latestVersion, 'downloadUrl' => $downloadUrl, 'zipUrl' => $zipUrl, 'exeUrl' => $exeUrl, 'updateAvailable' => ($latestVersion !== $currentVersion), 'cached' => false, 'assets' => $assets ]; // Сохранение в кэш file_put_contents($cacheFile, json_encode([ 'latestVersion' => $data['latestVersion'], 'downloadUrl' => $data['downloadUrl'], 'zipUrl' => $data['zipUrl'], 'exeUrl' => $data['exeUrl'], 'assets' => $data['assets'] ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), LOCK_EX); } } return $data; }