query( 'SELECT timezone, lat, lon FROM regions WHERE timezone IS NOT NULL AND timezone <> ""' ); $regions = $stmt->fetchAll(PDO::FETCH_ASSOC); if (!$regions) return null; $closest = null; $min = PHP_FLOAT_MAX; foreach ($regions as $r) { $dLat = $lat - (float)$r['lat']; $dLon = $lon - (float)$r['lon']; $dist = $dLat * $dLat + $dLon * $dLon; if ($dist < $min) { $min = $dist; $closest = $r['timezone']; } } return $closest; } $clientTz = isset($_GET['tz']) ? (string) $_GET['tz'] : null; if ($clientTz && in_array($clientTz, timezone_identifiers_list(), true)) { date_default_timezone_set($clientTz); } else { $fallback = 'UTC'; if (isset($_GET['lat'], $_GET['lon'])) { $lat = (float) $_GET['lat']; $lon = (float) $_GET['lon']; $closestTz = findClosestRegionTimezone(db(), $lat, $lon); if ($closestTz && in_array($closestTz, timezone_identifiers_list(), true)) { $fallback = $closestTz; } } date_default_timezone_set($fallback); } function checkSite(string $region, string $url, int $rankGroup, string $timezone): array { $start = microtime(true); $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 15, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_USERAGENT => "XoStatusChecker/1.0", CURLOPT_SSL_VERIFYPEER => true, ]); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); $latency = (int) ((microtime(true) - $start) * 1000); curl_close($ch); $up = false; $note = null; if ($error) { $up = false; $note = 'cannot_fetch_web'; } else { if ($code >= 200 && $code < 500) { $up = true; if ($code === 403) { $note = 'blocked_by_protection'; } elseif ($code === 429) { $note = 'too_many_requests'; } } elseif ($code >= 500 && $code <= 599) { $up = false; $note = 'cloudflare_origin_error'; } } try { $dt = new DateTime('now', new DateTimeZone($timezone)); } catch (Exception $e) { $dt = new DateTime('now', new DateTimeZone('UTC')); } return [ 'region' => $region, 'url' => $url, 'rank_group' => $rankGroup, 'up' => $up, 'http' => $code ?: null, 'latency' => $latency, 'error' => $note, 'date' => $dt->format('Y-m-d'), 'time' => $dt->format('H:i:s'), ]; } function haversineDistance(float $lat1, float $lon1, float $lat2, float $lon2): float { $earthRadius = 6371.0; $lat1Rad = deg2rad($lat1); $lon1Rad = deg2rad($lon1); $lat2Rad = deg2rad($lat2); $lat2Rad = deg2rad($lat2); $lon2Rad = deg2rad($lon2); $dLat = $lat2Rad - $lat1Rad; $dLon = $lon2Rad - $lon1Rad; $a = sin($dLat / 2) ** 2 + cos($lat1Rad) * cos($lat2Rad) * sin($dLon / 2) ** 2; $c = 2 * asin(min(1.0, sqrt($a))); return $earthRadius * $c; } $geoStatus = isset($_GET['geo']) ? (string) $_GET['geo'] : null; $userLat = isset($_GET['lat']) ? (float) $_GET['lat'] : null; $userLon = isset($_GET['lon']) ? (float) $_GET['lon'] : null; $hasUserLocation = ($geoStatus === '1' && $userLat !== 0.0 && $userLon !== 0.0); $maxRank = isset($_GET['max_rank']) ? (int) $_GET['max_rank'] : 1; if ($maxRank < 1) $maxRank = 1; if ($maxRank > 6) $maxRank = 6; $allStmt = db()->prepare(" SELECT id, region, url, rank_group, sort_order, rank_points, lat, lon, timezone FROM regions ORDER BY id ASC "); $allStmt->execute(); $allRows = $allStmt->fetchAll(); foreach ($allRows as $i => $row) { $allRows[$i]['user_distance'] = null; } $closestThree = []; if ($hasUserLocation && !empty($allRows)) { $distanceList = []; foreach ($allRows as $i => $row) { if ($row['lat'] === null || $row['lon'] === null) { continue; } $distKm = haversineDistance( $userLat, $userLon, (float) $row['lat'], (float) $row['lon'] ); $allRows[$i]['user_distance'] = $distKm; $distanceList[] = [ 'idx' => $i, 'dist' => $distKm, ]; } if (!empty($distanceList)) { usort($distanceList, fn($a, $b) => $a['dist'] <=> $b['dist']); $top3 = array_slice($distanceList, 0, 3); $updateStmt = db()->prepare(" UPDATE regions SET rank_points = rank_points + :points WHERE id = :id "); foreach ($top3 as $pos => $item) { $points = 0; if ($pos === 0) { $points = 1; } elseif ($pos === 1) { $points = 1; } elseif ($pos === 2) { $points = 1; } $idx = $item['idx']; $allRows[$idx]['rank_points'] = (int) $allRows[$idx]['rank_points'] + $points; $updateStmt->execute([ ':points' => $points, ':id' => $allRows[$idx]['id'], ]); $row = $allRows[$idx]; $tz = (string) $row['timezone']; $check = checkSite($row['region'], $row['url'], (int) $row['rank_group'], $tz); $check['user_distance'] = $row['user_distance']; $check['rank_points'] = $row['rank_points']; $check['id'] = $row['id']; $check['timezone'] = $tz; $closestThree[] = $check; } } } $dynamicTiers = []; if (!empty($allRows)) { $sortedByPoints = $allRows; usort($sortedByPoints, function (array $a, array $b): int { $cmp = (int) $b['rank_points'] <=> (int) $a['rank_points']; if ($cmp !== 0) { return $cmp; } $cmp = (int) $a['rank_group'] <=> (int) $b['rank_group']; if ($cmp !== 0) { return $cmp; } return (int) $a['sort_order'] <=> (int) $b['sort_order']; }); foreach ($sortedByPoints as $index => $row) { $rankPosition = $index + 1; $tier = intdiv($rankPosition - 1, 10) + 1; if ($tier > 6) { $tier = 6; } $dynamicTiers[$row['id']] = $tier; } } foreach ($closestThree as &$r) { $id = $r['id'] ?? null; if ($id !== null && isset($dynamicTiers[$id])) { $r['tier'] = $dynamicTiers[$id]; } else { $r['tier'] = 6; } } unset($r); $rows = $allRows; foreach ($rows as &$row) { $id = $row['id']; $row['tier'] = $dynamicTiers[$id] ?? 6; } unset($row); usort($rows, function (array $a, array $b): int { $cmp = (int) $b['rank_points'] <=> (int) $a['rank_points']; if ($cmp !== 0) { return $cmp; } $cmp = (int) $a['rank_group'] <=> (int) $b['rank_group']; if ($cmp !== 0) { return $cmp; } return (int) $a['sort_order'] <=> (int) $b['sort_order']; }); $allUp = true; $totalChecked = 0; $checks = []; foreach ($rows as $row) { if ($row['tier'] > $maxRank) { continue; } $tz = (string) $row['timezone']; $check = checkSite($row['region'], $row['url'], (int) $row['rank_group'], $tz); $check['user_distance'] = null; $check['rank_points'] = $row['rank_points']; $check['tier'] = $row['tier']; $check['timezone'] = $tz; $checks[] = $check; if (!$check['up']) { $allUp = false; } $totalChecked++; } ?>
What if DownDetector goes down? Bro, you're supposed to detect outages, not join them. Well, that’s why this detector exists isdowndetectordown.rf.gd :)
| Country/Region | Domain | Status | HTTP | Latency | Date | Time |
|---|---|---|---|---|---|---|
| T= (int) $r['tier'] ?> = htmlspecialchars($r['region'], ENT_QUOTES, 'UTF-8') ?> | = htmlspecialchars(parse_url($r['url'], PHP_URL_HOST) ?? $r['url'], ENT_QUOTES, 'UTF-8') ?> | UP blocked by protection'; } elseif ($r['error'] === 'too_many_requests') { echo 'too many requests'; } elseif ($r['error'] === null) { echo 'no protection found'; } ?> DOWN cloudflare origin error cann't fetch web | = $r['http'] !== null ? (int) $r['http'] : '-' ?> | = $r['latency'] ?: '-' ?> | = htmlspecialchars($r['date']) ?> | = htmlspecialchars($r['time']) ?> |
| Country/Region | Domain | Status | HTTP | Latency | Date | Time |
|---|---|---|---|---|---|---|
| T= (int) $r['tier'] ?> = htmlspecialchars($r['region'], ENT_QUOTES, 'UTF-8') ?> | = htmlspecialchars(parse_url($r['url'], PHP_URL_HOST) ?? $r['url'], ENT_QUOTES, 'UTF-8') ?> | UP blocked by protection'; } elseif ($r['error'] === 'too_many_requests') { echo 'too many requests'; } elseif ($r['error'] === null) { echo 'no protection found'; } ?> DOWN cloudflare origin error cann't fetch web | = $r['http'] !== null ? (int) $r['http'] : '-' ?> | = $r['latency'] ?: '-' ?> | = htmlspecialchars($r['date']) ?> | = htmlspecialchars($r['time']) ?> |
Response Codes > 200–299 OK. 300–399 redirects. 403 = protected, 429 = too many requests. 500–599 = Cloudflare's origin error.
Protection > Uses standard HEAD checks only; no bypassing of Cloudflare, WAF, or rate-limits. Some protected sites may return 403, but this means they are still fully operational.
Latency > Includes DNS, SSL/TLS handshake, and server response. Distance + routing can affect timing.