Make a website for your PocketMine server fully free !
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

handler.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /*
  3. Copyright (C) Ad5001 2016 All rights reserved.
  4. @link http://ad5001.ga
  5. Do not attemped to modify this file if you're not sure on how it works.
  6. This file process 404, 403 requests, custom index and some other stuff.
  7. */
  8. // Definitions
  9. $cfg = yaml_parse(file_get_contents(__DIR__ . "/../config.yml"));
  10. $args = json_decode(file_get_contents(__DIR__ . "/args"), true);
  11. $_POCKETMINE = $args["POCKETMINE"];
  12. $_PLUGINS = $args["PLUGINS"];
  13. $_PLAYERS = $args["PLAYERS"];
  14. $_LEVELS = $args["LEVELS"];
  15. // Calling handlers.
  16. foreach($args["HANDLERS"] as $handler) {
  17. // echo $handler;
  18. if((include $handler) == false) {
  19. return true;
  20. }
  21. }
  22. // Domains parsing
  23. $host = $_SERVER["HTTP_HOST"];
  24. if(isset($cfg["Parked domains"][$host])) {
  25. $host = $cfg["Parked domains"][$host];
  26. }
  27. if(in_array($host, $cfg["Domains"])) {
  28. $_SERVER["REQUEST_URI"] = $host . $_SERVER["REQUEST_URI"];
  29. } else {
  30. unallowedDomain();
  31. return true;
  32. }
  33. // Removing GET from the request
  34. $uri = $_SERVER["REQUEST_URI"];
  35. if(strpos($uri, "?") !== false) {
  36. $uri = explode("?", $uri)[0];
  37. }
  38. // Getting the file & output it if possible.
  39. if(!file_exists(__DIR__ . "/../" . $uri)) {
  40. echo file_get_contents(__DIR__ . "/../" . $host . "/" . $cfg[404]);
  41. } elseif(in_array($uri, $cfg["denied-pages"])) {
  42. echo file_get_contents(__DIR__ . "/../" . $host . "/" . $cfg[403]);
  43. } elseif(is_dir(__DIR__ . "/../" .$uri)) {
  44. if(file_exists(__DIR__ . "/../" . $uri . "index.html")) {
  45. include(__DIR__ . "/../" . $uri . "index.html");
  46. } elseif(file_exists(__DIR__ . "/../" . $uri . "index.php")) {
  47. include(__DIR__ . "/../" . $uri . "index.php");
  48. } elseif(file_exists(__DIR__ . "/../" . $uri . $cfg["index"])) {
  49. include(__DIR__ . "/../" . $uri . $cfg["index"]);
  50. }
  51. } else {
  52. include(__DIR__ . "/" . $uri);
  53. }
  54. function unallowedDomain() {
  55. echo <<<A
  56. <html>
  57. <head>
  58. <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300" rel="stylesheet">
  59. <style>
  60. body {
  61. padding: 60px;
  62. }
  63. div.container {
  64. padding: 40px;
  65. border: 3px solid lightgray;
  66. border-radius: 8px;
  67. background: linear-gradient(45deg, gray, grey);
  68. height: 70%;
  69. }
  70. h1, h2, h3, p {
  71. font-family: 'Roboto Condensed', sans-serif;
  72. }
  73. </style>
  74. <link rel="icon" src="http://serveur.cf/Online/icon.ico" href="http://serveur.cf/Online/icon.ico" />
  75. </head>
  76. <body>
  77. <div class="container">
  78. <h1><img src="http://serveur.cf/Online/icon.png" style="width: 30px; height: 30px;"></img>Unallowed domain</h1><hr>
  79. <p>This IP does not have any domain on this machine. Please refer to your server administartor if you think it's an error.</p>
  80. <h2 style="float: right;">Online 1.6 - Eclipse edition</a></h2>
  81. </body>
  82. </style>
  83. A;
  84. }