instances.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. require_once "misc/header.php";
  3. require_once "misc/tools.php";
  4. $instances_json = json_decode(file_get_contents("instances.json"), true);
  5. $librey_instances = array_filter($instances_json['instances'], fn($n) => $n['librey']);
  6. $librex_instances = array_filter($instances_json['instances'], fn($n) => !$n['librey']);
  7. function list_instances($instances)
  8. {
  9. echo "<table><tr>";
  10. echo "<th>Clearnet</th>";
  11. echo "<th>Tor</th>";
  12. echo "<th>I2P</th>";
  13. echo "<th>Country</th>";
  14. echo "</tr>";
  15. foreach($instances as $instance) {
  16. $hostname = parse_url($instance["clearnet"])["host"];
  17. $country = get_country_emote($instance["country"]) . $instance["country"];
  18. $is_tor = !is_null($instance["tor"]);
  19. $is_i2p = !is_null($instance["i2p"]);
  20. echo "<tr>";
  21. echo "<td><a href=\"" . $instance["clearnet"] . "\">" . $hostname . "</a></td>";
  22. echo $is_tor
  23. ? "<td><a href=\"" . $instance["tor"] . "\">\u{2705}</a></td>"
  24. : "<td>\u{274C}</td>";
  25. echo $is_i2p
  26. ? "<td><a href=\"" . $instance["i2p"] . "\">\u{2705}</a></td>"
  27. :"<td>\u{274C}</td>";
  28. echo "<td>$country</td>";
  29. echo "</tr>";
  30. }
  31. echo "</table>";
  32. }
  33. ?>
  34. <title>LibreY - instances</title>
  35. </head>
  36. <body>
  37. <div class="misc-container">
  38. <center>
  39. <h2>Libre<span class="Y">Y</span> instances</h2>
  40. <?php
  41. list_instances($librey_instances);
  42. ?>
  43. <p><?php printftext("instances_librex", "<a href=\"https://github.com/hnhx/librex\">LibreX</a>")?>:</p>
  44. <?php
  45. list_instances($librex_instances);
  46. ?>
  47. </center>
  48. </div>
  49. <?php require_once "misc/footer.php"; ?>