From caeee06f85491133252e939e6dfd57c03d4ae480 Mon Sep 17 00:00:00 2001 From: Gabor Hojtsy Date: Sat, 3 May 2003 20:07:23 +0000 Subject: [PATCH] Add a function to count mirrors in a given country --- include/site.inc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/site.inc b/include/site.inc index 60bc4e266..8fd87f512 100644 --- a/include/site.inc +++ b/include/site.inc @@ -108,6 +108,25 @@ function mirror_status($site = FALSE) return $MIRRORS[$site][7]; } +// Count all mirrors or mirrors in a given country +function count_mirrors($country = FALSE) +{ + global $MIRRORS; + + // This is a non-identified country + if ($country == "NA") { return 0; } + + // Count all mirror sites + elseif ($country === FALSE) { return count($MIRRORS); } + + // Count only the ones in the same country + $count = 0; + foreach ($MIRRORS as $murl => $mirror) { + if (mirror_country($murl) == $country) { $count++; } + } + return $count; +} + // Redirect to an URI on this mirror // site or outside this site function mirror_redirect($absoluteURI, $remote = FALSE)