public function run() { foreach ($this->loadPaths as $name => $path) { if (!class_exists($name, false) and !interface_exists($name, false)) { require $path; } } $this->loader->register(true); Terminal::init(); $server = new \Wrench\Server('ws://' . $this->host . ':' . $this->port, array("logger" => function ($msg, $pri) { })); $server->registerApplication("app", new PDCApp($this, $this->password)); $server->addListener(\Wrench\Server::EVENT_SOCKET_CONNECT, function ($data, $other) { $header = $other->getSocket()->receive(); if ($this->isHTTP($header)) { $other->getSocket()->send("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" . $this->data); $other->close(200); } else { $other->onData($header); } }); $server->run(); }
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl"); $autoloader->register(\true); \set_time_limit(0); //Who set it to 30 seconds?!?! \gc_enable(); \error_reporting(-1); \ini_set("allow_url_fopen", 1); \ini_set("display_errors", 1); \ini_set("display_startup_errors", 1); \ini_set("default_charset", "utf-8"); \ini_set("memory_limit", -1); \define("pocketmine\\START_TIME", \microtime(\true)); $opts = \getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]); \define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); \define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); Terminal::init(); \define("pocketmine\\ANSI", Terminal::hasFormattingCodes()); if (!\file_exists(\pocketmine\DATA)) { \mkdir(\pocketmine\DATA, 0777, \true); } //Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone. \date_default_timezone_set("UTC"); $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); if (!\ini_get("date.timezone")) { if ($timezone = detect_system_timezone() and \date_default_timezone_set($timezone)) { //Success! Timezone has already been set and validated in the if statement. //This here is just for redundancy just in case some program wants to read timezone data from the ini. \ini_set("date.timezone", $timezone); } else { //If system timezone detection fails or timezone is an invalid value. if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = \json_decode($response, \true) and $ip_geolocation_data['status'] != 'fail' and \date_default_timezone_set($ip_geolocation_data['timezone'])) {