index.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. if (isset($_GET["command"])) {
  3. switch ($_GET["command"]) {
  4. case "official_channels.list":
  5. require("../.htconfig.php");
  6. global $dblink;
  7. $chanList = $dblink->query("SELECT channel, default_join FROM knacki_official;");
  8. $chanList->setFetchMode(PDO::FETCH_OBJ);
  9. $result = array();
  10. while ($i = $chanList->fetch())
  11. array_push($result, $i);
  12. echo json_encode($result);
  13. break;
  14. case "version":
  15. $fic = substr(file_get_contents("../.git/HEAD"), 5);
  16. if ($fic === FALSE) {
  17. header("HTTP/1.1 500 Server error");
  18. break;
  19. }
  20. $fic = file_get_contents("../.git/".trim($fic));
  21. if ($fic === FALSE) {
  22. header("HTTP/1.1 500 Server error");
  23. break;
  24. }
  25. echo json_encode(trim($fic));
  26. break;
  27. case "servers":
  28. echo json_encode(array(
  29. "irc.knacki.info" => array(
  30. "ports" => array(
  31. "6667" => false,
  32. "6697" => true
  33. )
  34. ),
  35. "mirror.knacki.info" => array(
  36. "ports" => array(
  37. "6667" => false,
  38. "6697" => true
  39. )
  40. )
  41. ));
  42. }
  43. }
  44. ?>