summaryrefslogtreecommitdiff
path: root/mirrors/index.php
blob: 85ec4e060b99a5f288ba954df95a152645c16c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php

include "lib/mysql.php";
include "lib/style.php";

$cutoff = 3600;

mysql_run_query(
  "CREATE TEMPORARY TABLE `ls` (`id` BIGINT NOT NULL, PRIMARY KEY (`id`))"
);

mysql_run_query(
  "INSERT INTO `ls` (`id`)" .
  " SELECT `ms`.`id`" .
  " FROM `mirror_statuses` AS `ms`" .
  " WHERE NOT EXISTS (" .
    "SELECT 1 FROM `mirror_statuses` AS `n_ms`" .
    " WHERE `n_ms`.`url`=`ms`.`url`" .
    " AND `n_ms`.`start`>`ms`.`start`" .
  ") AND `ms`.`start` > UNIX_TIMESTAMP(NOW())-" . $cutoff
);

$result = mysql_run_query(
  "SELECT " .
  "GROUP_CONCAT(`l_ms`.`protocol`) AS `protocols`," .
  "SUBSTRING(`l_ms`.`url`,LENGTH(`l_ms`.`protocol`)+4) AS `url`," .
  "`l_ms`.`country`," .
  "`l_ms`.`country_code`," .
  "`l_ms`.`isos`," .
  "`l_ms`.`ipv4`," .
  "`l_ms`.`ipv6`" .
  " FROM `ls`" .
  " JOIN `mirror_statuses` AS `l_ms` ON `ls`.`id`=`l_ms`.`id`" .
  " GROUP BY SUBSTRING(`l_ms`.`url`,LENGTH(`l_ms`.`protocol`)+4)"
);

$last_check = 0;
$max_count = 0;

while($row = $result->fetch_assoc())
  $rows[] = $row;

print_header("Mirror Overview");

?>
      <div id="dev-mirrorlist" class="box">
        <h2>Mirror Overview</h2>
        <table class="results">
          <thead>
            <tr>
              <th>Server</th>
              <th>Country</th>
              <th>ISOs</th>
              <th>Protocols</th>
            </tr>
          </thead>
          <tbody>
<?php

$oddity = "odd";
foreach ($rows as $row) {
  print "            <tr class=\"" . $oddity ."\">\n";
  print "              <td>\n";
  print "                " . $row["url"] . "\n";
  print "              </td>\n";
  print "              <td class=\"country\">\n";
  print "                <span class=\"fam-flag fam-flag-" . $row["country_code"] . "\" title=\"" . $row["country"] . "\">\n";
  print "                </span>\n";
  print "                  " . $row["country"] . "\n";
  print "              </td>\n";
  print "              <td>\n";
  if ($row["isos"])
    print "                Yes\n";
  else
    print "                No\n";
  print "              </td>\n";
  print "              <td class=\"wrap\">\n";
  print "                " . $row["protocols"] . "\n";
  print "              </td>\n";
  print "            </tr>\n";
  if ($oddity == "odd")
    $oddity = "even";
  else
    $oddity = "odd";
}

?>
          </tbody>
        </table>
      </div>
<?php

  print_footer();