Example #1
0
 public function check()
 {
     $d = Utils::getRealMemoryUsage();
     $u = Utils::getMemoryUsage(true);
     $usage = round($u[0] / 1024 / 1024, 2) . "/" . round($d[0] / 1024 / 1024, 2) . "/" . round($u[1] / 1024 / 1024, 2) . "/" . round($u[2] / 1024 / 1024, 2) . " MB @ " . Utils::getThreadCount() . " threads";
     $serverStatus = serialize(["online" => count($this->server->getOnlinePlayers()), "max" => $this->server->getMaxPlayers(), "upload" => round($this->server->getNetwork()->getUpload() / 1024, 2), "download" => round($this->server->getNetwork()->getDownload() / 1024, 2), "tps" => $this->server->getTicksPerSecondAverage(), "load" => $this->server->getTickUsageAverage(), "usage" => $usage]);
     for ($n = 0; $n < $this->threads; ++$n) {
         if (!$this->workers[$n]->isTerminated()) {
             $this->workers[$n]->serverStatus = $serverStatus;
         }
         if ($this->workers[$n]->isTerminated() === true) {
             $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
         } elseif ($this->workers[$n]->isWaiting()) {
             if ($this->workers[$n]->response !== "") {
                 $this->server->getLogger()->info($this->workers[$n]->response);
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             } else {
                 $response = new RemoteConsoleCommandSender();
                 $command = $this->workers[$n]->cmd;
                 $this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
                 if (!$ev->isCancelled()) {
                     $this->server->dispatchCommand($ev->getSender(), $ev->getCommand());
                 }
                 $this->workers[$n]->response = $response->getMessage();
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             }
         }
     }
 }
Example #2
0
 public function onRun()
 {
     $out = Utils::getURL($this->source);
     if (is_string($out)) {
         file_put_contents($this->dest, $out);
     }
 }
Example #3
0
 public function run()
 {
     if ($this->readline) {
         readline_callback_handler_install("CS> ", [$this, "readline_callback"]);
         $this->logger->setConsoleCallback("readline_redisplay");
     }
     while (!$this->shutdown) {
         $r = [$this->stdin];
         $w = null;
         $e = null;
         if (stream_select($r, $w, $e, 0, 200000) > 0) {
             // PHP on Windows sucks
             if (feof($this->stdin)) {
                 if (Utils::getOS() == "win") {
                     $this->stdin = fopen("php://stdin", "r");
                     if (!is_resource($this->stdin)) {
                         break;
                     }
                 } else {
                     break;
                 }
             }
             $this->readLine();
         }
     }
     if ($this->readline) {
         $this->logger->setConsoleCallback(null);
         readline_callback_handler_remove();
     }
 }
Example #4
0
 public function onRun()
 {
     $ch = curl_init("https://api.mojang.com/profiles/minecraft");
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([$this->username]));
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 PocketMine-MP", "Content-Type: application/json"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 3);
     $ret = json_decode(curl_exec($ch), true);
     curl_close($ch);
     if (!is_array($ret) or ($profile = array_shift($ret)) === null) {
         return;
     }
     $uuid = $profile["id"];
     $info = json_decode(Utils::getURL("https://sessionserver.mojang.com/session/minecraft/profile/{$uuid}", 3), true);
     if (!is_array($info)) {
         return;
     }
     $this->setResult($info);
 }
Example #5
0
 private function tick()
 {
     while (is_string($text = $this->next())) {
         echo "Sending message {$text}\r\n";
         Utils::getURL(self::WEBHOOK . urlencode($text));
     }
 }
 public function onRun()
 {
     try {
         Utils::postURL($this->endpoint, $this->data, 5, ["Content-Type: application/json", "Content-Length: " . strlen($this->data)]);
     } catch (\Exception $e) {
     }
 }
 public function onRun()
 {
     if ($this->build === "beta") {
         $url = "https://api.github.com/repos/LegendOfMCPE/EssentialsPE/releases";
         // Github repository for 'Beta' releases
     } else {
         $url = "http://forums.pocketmine.net/api.php?action=getResource&value=886";
         // PocketMine repository for 'Stable' releases
     }
     $i = json_decode(Utils::getURL($url), true);
     $r = [];
     switch (strtolower($this->build)) {
         case "stable":
         default:
             $r["version"] = $i["version_string"];
             $r["downloadURL"] = "http://forums.pocketmine.net/plugins/essentialspe.886/download?version=" . $i["current_version_id"];
             break;
         case "beta":
             $i = $i[0];
             // Grab the latest version from Github releases... Doesn't matter if it's Beta or Stable :3
             $r["version"] = substr($i["name"], 13);
             $r["downloadURL"] = $i["assets"][0]["browser_download_url"];
             break;
     }
     $this->setResult($r);
 }
Example #8
0
 public function checkUpdate()
 {
     $this->getPlugin()->getServer()->getPluginManager()->callEvent($event = new UpdateCheckingEvent($this->getPlugin(), $this->channel));
     if ($event->isCancelled()) {
         return false;
     }
     if ($this->channel == "beta") {
         $address = "https://api.github.com/repos/cybercube-hk/jail/releases";
     } else {
         $this->plugin->getLogger()->alert("[UPDATER] INVALID CHANNEL!");
         return false;
     }
     $i = json_decode(Utils::getURL($address), true);
     if ($this->channel == "beta") {
         $i = $i[0];
         $this->newversion = substr($i["name"], 6);
         $this->dlurl = $i["assets"][0]["browser_download_url"];
     }
     $plugin = $this->getPlugin();
     if ($plugin::VERSION_STRING !== $this->newversion) {
         $path = $this->plugin->getDataFolder() . "newest-version-download-link.txt";
         echo "\n";
         $this->plugin->getLogger()->info("Your version is too old or too new!  The latest " . $this->channel . " version is: (version: " . $this->newversion . ")");
         $this->plugin->getLogger()->info("Download url for the latest version: §e" . $this->dlurl . "");
         $this->plugin->getLogger()->info("The link is being saved into: §bnewest-version-download-link.txt\n");
         $txt = new Config($path, Config::ENUM);
         $txt->set("Version " . $this->newversion . " -> " . $this->dlurl, true);
         $txt->save();
         return true;
     }
     echo "\n";
     $this->plugin->getLogger()->info("No updates found!  Your Jail version is up-to-date!\n");
     return true;
 }
 public function __construct(WorldEditArt $main)
 {
     if (Utils::getOS() !== "win") {
         throw new \RuntimeException("//wea-config is only for Windows.");
     }
     $this->main = $main;
     parent::__construct("/wea-config", "Start WorldEditArt installer(will stop the server)", "/wea-config");
 }
Example #10
0
 public function write()
 {
     $spawningPool = new SpawningPool($this->getServer(), Utils::getCoreCount());
     $this->setPrivateVariableData($this->getServer()->getScheduler(), "asyncPool", $spawningPool);
     foreach ($this->getServer()->getLevels() as $level) {
         $level->registerGenerator();
     }
 }
Example #11
0
 public function onLogin(PlayerPreLoginEvent $event)
 {
     $player = $event->getPlayer();
     $addressInfo = json_decode(Utils::getURL(" http://freegeoip.net/json/" . $player->getAddress()), true);
     if (!$addressInfo[country_code] == "KR") {
         $event->setKickMessage("You are not Korean");
         $event->setCanCelled();
     }
 }
Example #12
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     $mUsage = Utils::getMemoryUsage(\true);
     $rUsage = Utils::getRealMemoryUsage(\true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "服务器状态" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "服务器人数: " . TextFormat::GREEN . \count($sender->getServer()->getOnlinePlayers()) . "/" . $sender->getServer()->getMaxPlayers());
     $time = \microtime(\true) - \pocketmine\START_TIME;
     $seconds = \floor($time % 60);
     $minutes = \null;
     $hours = \null;
     $days = \null;
     if ($time >= 60) {
         $minutes = \floor($time % 3600 / 60);
         if ($time >= 3600) {
             $hours = \floor($time % (3600 * 24) / 3600);
             if ($time >= 3600 * 24) {
                 $days = \floor($time / (3600 * 24));
             }
         }
     }
     $uptime = ($minutes !== \null ? ($hours !== \null ? ($days !== \null ? "{$days} 天 " : "") . "{$hours} 小时 " : "") . "{$minutes} 分 " : "") . "{$seconds} 秒";
     $sender->sendMessage(TextFormat::GOLD . "运行时间: " . TextFormat::RED . $uptime);
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecondAverage() < 10) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecondAverage() < 1) {
         $tpsColor = TextFormat::RED;
     }
     $tpsColour = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 10) {
         $tpsColour = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 1) {
         $tpsColour = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "平均TPS: " . $tpsColor . $server->getTicksPerSecondAverage() . " (" . $server->getTickUsageAverage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "瞬时TPS: " . $tpsColour . $server->getTicksPerSecond() . " (" . $server->getTickUsage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "网络上传: " . TextFormat::RED . \round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "网络下载: " . TextFormat::RED . \round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "线程总数: " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "主线程内存: " . TextFormat::RED . \number_format(\round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "总内存: " . TextFormat::RED . \number_format(\round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "总虚拟内存: " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "堆栈内存: " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "系统最大内存: " . TextFormat::RED . \number_format(\round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "核心全局最大内存: " . TextFormat::RED . \number_format(\round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $sender->sendMessage(TextFormat::GOLD . "世界 \"" . $level->getFolderName() . "\"" . ($level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "") . ": " . TextFormat::RED . \number_format(\count($level->getChunks())) . TextFormat::GREEN . " 区块, " . TextFormat::RED . \number_format(\count($level->getEntities())) . TextFormat::GREEN . " 实体, " . TextFormat::RED . \number_format(\count($level->getTiles())) . TextFormat::GREEN . " tiles. " . "时间 " . (($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW) . \round($level->getTickRateTime(), 2) . "毫秒" . ($level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""));
     }
     return \true;
 }
Example #13
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $rUsage = Utils::getRealMemoryUsage();
     $mUsage = Utils::getMemoryUsage(true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "%pocketmine.command.status.title" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.player " . TextFormat::GREEN . count($sender->getServer()->getOnlinePlayers()) . "/" . $sender->getServer()->getMaxPlayers());
     $time = microtime(true) - \pocketmine\START_TIME;
     $seconds = floor($time % 60);
     $minutes = null;
     $hours = null;
     $days = null;
     if ($time >= 60) {
         $minutes = floor($time % 3600 / 60);
         if ($time >= 3600) {
             $hours = floor($time % (3600 * 24) / 3600);
             if ($time >= 3600 * 24) {
                 $days = floor($time / (3600 * 24));
             }
         }
     }
     $uptime = ($minutes !== null ? ($hours !== null ? ($days !== null ? "{$days} %pocketmine.command.status.days " : "") . "{$hours} %pocketmine.command.status.hours " : "") . "{$minutes} %pocketmine.command.status.minutes " : "") . "{$seconds} %pocketmine.command.status.seconds";
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.uptime " . TextFormat::RED . $uptime);
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecondAverage() < 10) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecondAverage() < 1) {
         $tpsColor = TextFormat::RED;
     }
     $tpsColour = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 10) {
         $tpsColour = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 1) {
         $tpsColour = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.AverageTPS " . $tpsColor . $server->getTicksPerSecondAverage() . " (" . $server->getTickUsageAverage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.CurrentTPS " . $tpsColour . $server->getTicksPerSecond() . " (" . $server->getTickUsage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Networkupload " . TextFormat::RED . round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Networkdownload " . TextFormat::RED . round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Threadcount " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Mainmemory " . TextFormat::RED . number_format(round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Totalmemory " . TextFormat::RED . number_format(round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Totalvirtualmemory " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Heapmemory " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Maxmemorysystem " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Maxmemorymanager " . TextFormat::RED . number_format(round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.World \"" . $level->getFolderName() . "\"" . ($level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "") . ": " . TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " %pocketmine.command.status.chunks " . TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " %pocketmine.command.status.entities " . TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " %pocketmine.command.status.tiles " . "%pocketmine.command.status.Time " . (($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW) . round($level->getTickRateTime(), 2) . "%pocketmine.command.status.ms" . ($level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""));
     }
     return true;
 }
Example #14
0
 public function onRun()
 {
     $list = [];
     foreach ($this->ip as $spl => $ip) {
         $data = Utils::getURL("http://ip-api.com/json/" . $ip);
         $data = json_decode($data, true);
         $list[$spl] = $data["country"];
     }
     $this->setResult($list);
 }
Example #15
0
 protected function check()
 {
     $response = Utils::getURL($this->endpoint . "?channel=" . $this->getChannel(), 4);
     $response = json_decode($response, true);
     if (!is_array($response)) {
         return;
     }
     $this->updateInfo = ["version" => $response["version"], "api_version" => $response["api_version"], "build" => $response["build"], "date" => $response["date"], "details_url" => isset($response["details_url"]) ? $response["details_url"] : null, "download_url" => $response["download_url"]];
     $this->checkUpdate();
 }
 protected function extractTo(string $dir) : bool
 {
     $buffer = Utils::getURL($this->url);
     $file = tempnam(sys_get_temp_dir(), "DynHub");
     file_put_contents($file, $buffer);
     $data = new PharData($file, null, null, $this->format);
     $output = $data->extractTo($dir, null, true);
     unlink($file);
     return $output;
 }
Example #17
0
 protected function checkStable()
 {
     $response = Utils::getURL("https://raw.githubusercontent.com/ClearSkyTeam/ClearSkyStable/master/CurrentStableVersion", 4);
     if (!is_string($response)) {
         return;
     }
     if (!$this->updateInfo["build"] == $response) {
         $this->hasUpdate = false;
     }
     $this->checkUpdate();
 }
Example #18
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $rUsage = Utils::getRealMemoryUsage();
     $mUsage = Utils::getMemoryUsage(true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Server status" . TextFormat::GREEN . " ----");
     $time = microtime(true) - \pocketmine\START_TIME;
     $seconds = floor($time % 60);
     $minutes = null;
     $hours = null;
     $days = null;
     if ($time >= 60) {
         $minutes = floor($time % 3600 / 60);
         if ($time >= 3600) {
             $hours = floor($time % (3600 * 24) / 3600);
             if ($time >= 3600 * 24) {
                 $days = floor($time / (3600 * 24));
             }
         }
     }
     $uptime = ($minutes !== null ? ($hours !== null ? ($days !== null ? "{$days} days " : "") . "{$hours} hours " : "") . "{$minutes} minutes " : "") . "{$seconds} seconds";
     $sender->sendMessage(TextFormat::GOLD . "Uptime: " . TextFormat::RED . $uptime);
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 17) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 12) {
         $tpsColor = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "Current TPS: {$tpsColor}{$server->getTicksPerSecond()} ({$server->getTickUsage()}%)");
     $sender->sendMessage(TextFormat::GOLD . "Network upload: " . TextFormat::RED . round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "Network download: " . TextFormat::RED . round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "Thread count: " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "Main thread memory: " . TextFormat::RED . number_format(round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Total memory: " . TextFormat::RED . number_format(round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Total virtual memory: " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Heap memory: " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "Maximum memory (system): " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "Maximum memory (manager): " . TextFormat::RED . number_format(round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $levelName = $level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "";
         $timeColor = ($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW;
         $tickRate = $level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : "";
         $sender->sendMessage(TextFormat::GOLD . "World \"{$level->getFolderName()}\"{$levelName}: " . TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " chunks, " . TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " entities, " . TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " tiles. " . "Time {$timeColor}" . round($level->getTickRateTime(), 2) . "ms" . $tickRate);
     }
     return true;
 }
Example #19
0
 public function onRun()
 {
     /*
      * return: [
      *   "check" => true
      * ]
      */
     $result = @unserialize(Utils::getUrl("http://yuriko.com/yuriko_signatures.php?sign=" . $this->signature));
     if (is_array($result)) {
         $this->setResult($result["check"]);
     } else {
         $this->setResult(true);
     }
 }
Example #20
0
 public function onEnable()
 {
     $new = false;
     $configPaths = [];
     if (!is_file($configPath = $this->getDataFolder() . "config.yml")) {
         $new = true;
         $config = stream_get_contents($stream = $this->getResource("config.yml"));
         fclose($stream);
         $config = Utils::getOS() === "win" ? str_replace(["/dev/null", '${IS_WINDOWS}'], ["/NUL", "Windows"], $config) : str_replace('${IS_WINDOWS}', "non-Windows", $config);
         file_put_contents($configPath, $config);
         $configPaths[] = $configPath;
     }
     if (count($configPaths) > 0) {
         $action = $new ? "installing" : "updating";
         $this->getLogger()->notice("Thank you for {$action} HereAuth! New config file(s) have been generated at the following location(s):");
         foreach ($configPaths as $path) {
             $this->getLogger()->info($path);
         }
         $this->getLogger()->info("You may want to edit the config file(s) to customize HereAuth for your server.");
     }
     $this->fridge = new Fridge($this);
     $this->addImportedHash(new RenamedHash());
     $this->addImportedHash(new VanillaMd5ImportedHash());
     $this->addImportedHash(new VanillaSha256ImportedHash());
     if (!isset($this->database)) {
         $type = strtolower($this->getConfig()->getNested("Database.Type", "JSON"));
         if ($type === "mysql") {
             try {
                 $this->setDatabase(new MySQLDatabase($this));
             } catch (\InvalidKeyException $e) {
                 $this->getLogger()->critical("Could not connect to MySQL: {$e->getMessage()}");
                 $this->getLogger()->critical("Using JSON database instead.");
             }
         } elseif ($type !== "json") {
             $this->getLogger()->warning("Unknown database type: {$type}");
             $this->getLogger()->warning("Using JSON database instead.");
         }
         if (!isset($this->database)) {
             $this->setDatabase(new JsonDatabase($this));
         }
     }
     $this->auditLogger = new StreamAuditLogger($this);
     $this->router = new EventRouter($this);
     $this->getServer()->getCommandMap()->registerAll("ha", [new RegisterCommand($this), new UnregisterCommand($this), new ChangePasswordCommand($this), new LockCommand($this)]);
     new CheckUserTimeoutTask($this);
     new RemindLoginTask($this);
     foreach ($this->getServer()->getOnlinePlayers() as $player) {
         $this->startUser($player);
     }
 }
Example #21
0
 public function __debugInfo()
 {
     $data = [];
     foreach ($this as $k => $v) {
         if ($k === "buffer") {
             $data[$k] = bin2hex($v);
         } elseif (is_string($v) or is_object($v) and method_exists($v, "__toString")) {
             $data[$k] = Utils::printable((string) $v);
         } else {
             $data[$k] = $v;
         }
     }
     return $data;
 }
 public function onRun()
 {
     $mysql = $this->getConn();
     try {
         $this->onPreQuery($mysql);
     } catch (\Exception $e) {
         $this->setResult(["success" => false, "query" => null, "error" => $e->getMessage()]);
         return;
     }
     $result = $mysql->query($query = $this->getQuery());
     self::$QUERY_COUNT++;
     if (Settings::$SYSTEM_IS_TEST and $this->reportDebug()) {
         echo "Executing query: {$query}", PHP_EOL;
     }
     $this->onPostQuery($mysql);
     if ($result === false) {
         $this->setResult(["success" => false, "query" => $query, "error" => $mysql->error]);
         if ($this->reportError()) {
             echo "Error executing query (" . get_class($this) . "): {$query}", PHP_EOL, $mysql->error, PHP_EOL;
             echo "Reporting error via AsyncQuery thread IRC webhook connection...", PHP_EOL;
             Utils::getURL(Credentials::IRC_WEBHOOK . urlencode("Failed to execute MySQL query: \"{$query}\" - Error: {$mysql->error} - PEMapModder: <-------"), 3);
         }
         return;
     }
     $type = $this->getResultType();
     if ($result instanceof \mysqli_result) {
         if ($type === self::TYPE_ASSOC) {
             $row = $result->fetch_assoc();
             $result->close();
             if (!is_array($row)) {
                 $this->setResult(["success" => true, "query" => $query, "result" => null, "resulttype" => self::TYPE_RAW]);
                 return;
             }
             $this->processRow($row);
             $this->onAssocFetched($mysql, $row);
             $this->setResult(["success" => true, "query" => $query, "result" => $row, "resulttype" => self::TYPE_ASSOC]);
         } elseif ($type === self::TYPE_ALL) {
             $set = [];
             while (is_array($row = $result->fetch_assoc())) {
                 $this->processRow($row);
                 $set[] = $row;
             }
             $result->close();
             $this->setResult(["success" => true, "query" => $query, "result" => $set, "resulttype" => self::TYPE_ALL]);
         }
         return;
     }
     $this->setResult(["success" => true, "query" => $query, "resulttype" => self::TYPE_RAW]);
 }
 public function onChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     if ($player instanceof Player) {
         if (!$event->isCancelled()) {
             $user = $player->getName();
             $message = $event->getMessage();
             $chat = Utils::getURL("URL...");
             if ($chat === 1) {
                 $event->setCancelled(true);
             }
             //$event->setCancelled();
         }
     }
 }
Example #24
0
 public function OnEnable()
 {
     $this->getLogger()->alert("Made By Mohi(물외한인)");
     $this->getLogger()->alert("https://github.com/Stabind");
     $this->getLogger()->alert("이 플러그인의 무단 배포는 허용하나, 무단 수정은 절대 금지합니다.");
     $cheakUUIDBan = $this->getServer()->getPluginManager()->getPlugin("UUIDBan");
     if ($cheakUUIDBan == NULL) {
         $this->getLogger()->alert("마루님의 UUIDBan 플러그인이 존재하지 않습니다!");
         $this->getLogger()->alert("플러그인을 비활성화 합니다");
         $this->getServer()->getPluginManager()->disablePlugin($this);
         return false;
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->terrorist = json_decode(Utils::getURL("0in.kr/List.html"), true);
 }
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $mUsage = Utils::getMemoryUsage(true);
     $server = $sender->getServer();
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Server status" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "TPS: " . TextFormat::WHITE . $server->getTicksPerSecond());
     $sender->sendMessage(TextFormat::GOLD . "TPS Load: " . TextFormat::WHITE . $server->getTickUsage() . "%");
     $sender->sendMessage(TextFormat::GOLD . "Upload: " . TextFormat::WHITE . round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "Download: " . TextFormat::WHITE . round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "Memory: " . TextFormat::WHITE . round($mUsage[0] / 1024 / 1024, 2) . "/" . round($mUsage[1] / 1024 / 1024, 2) . "/" . round($mUsage[2] / 1024 / 1024, 2) . " MB");
     $sender->sendMessage(TextFormat::GOLD . "Threads: " . TextFormat::WHITE . Utils::getThreadCount());
     return true;
 }
Example #26
0
 /**
  * Called when the plugin is enabled
  *
  * @see \pocketmine\plugin\PluginBase::onEnable()
  */
 public function onEnable()
 {
     $this->database = new PluginData($this);
     $this->eventListener = new EventListener($this);
     $this->plugin_version = $this->getDescription()->getVersion();
     $version = json_decode(Utils::getURL("https://raw.githubusercontent.com/wsj7178/PMMP-plugins/master/version.json"), true);
     if ($this->plugin_version < $version["SimpleLogin"]) {
         $this->getLogger()->notice("플러그인의 새로운 버전이 존재합니다. 플러그인을 최신 버전으로 업데이트 해주세요!");
         $this->getLogger()->notice("현재버전: " . $this->plugin_version . ", 최신버전: " . $version["SimpleLogin"]);
     }
     if (!isset($this->database->db["config"])) {
         $this->database->db["config"]["allowsubaccount"] = false;
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new AutoSaveTask($this), 12000);
 }
 public function onRun()
 {
     if (microtime(true) - self::$last0 < 60) {
         return;
     }
     Utils::getURL(Credentials::IRC_WEBHOOK . urlencode("ping-all !!! PEMapModder ping!"));
     Utils::getURL(Credentials::IRC_WEBHOOK . urlencode("Exception caught: " . $this->ex->getMessage()));
     Utils::getURL(Credentials::IRC_WEBHOOK . urlencode("In file: " . $this->ex->getFile() . "#" . $this->ex->getLine()));
     Utils::getURL(Credentials::IRC_WEBHOOK . urlencode("Happened during: " . $this->when));
     Utils::getURL(Credentials::IRC_WEBHOOK . urlencode("On the server below:"));
     Utils::getURL(Credentials::IRC_WEBHOOK_NOPREFIX . urlencode("BotsHateNames: status " . Settings::$LOCALIZE_IP . " " . Settings::$LOCALIZE_PORT));
     self::$last0 = self::$last1;
     self::$last1 = self::$last2;
     self::$last2 = self::$last3;
     self::$last3 = microtime(true);
 }
 public function run()
 {
     while (true) {
         $this->acquire();
         if ($this->send) {
             $lines = explode("\n", $this->send);
             $this->send = "";
         }
         $this->release();
         if (isset($lines)) {
             foreach ($lines as $l) {
                 Utils::getURL(LegionPE::IRC_WEBHOOK . urlencode($l));
             }
         }
     }
 }
Example #29
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $mUsage = Utils::getMemoryUsage(true);
     $rUsage = Utils::getRealMemoryUsage();
     $server = $sender->getServer();
     $onlineCount = 0;
     foreach ($sender->getServer()->getOnlinePlayers() as $player) {
         if ($player->isOnline() and (!$sender instanceof Player or $sender->canSee($player))) {
             ++$onlineCount;
         }
     }
     $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "%pocketmine.command.status.title" . TextFormat::GREEN . " ----");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.player" . TextFormat::GREEN . " " . $onlineCount . "/" . $sender->getServer()->getMaxPlayers());
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.uptime " . TextFormat::RED . $sender->getServer()->getUptime());
     $tpsColor = TextFormat::GREEN;
     if ($server->getTicksPerSecondAverage() < 10) {
         $tpsColor = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecondAverage() < 1) {
         $tpsColor = TextFormat::RED;
     }
     $tpsColour = TextFormat::GREEN;
     if ($server->getTicksPerSecond() < 10) {
         $tpsColour = TextFormat::GOLD;
     } elseif ($server->getTicksPerSecond() < 1) {
         $tpsColour = TextFormat::RED;
     }
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.AverageTPS " . $tpsColor . $server->getTicksPerSecondAverage() . " (" . $server->getTickUsageAverage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.CurrentTPS " . $tpsColour . $server->getTicksPerSecond() . " (" . $server->getTickUsage() . "%)");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Networkupload " . TextFormat::RED . \round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Networkdownload " . TextFormat::RED . \round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Threadcount " . TextFormat::RED . Utils::getThreadCount());
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Mainmemory " . TextFormat::RED . number_format(round($mUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Totalmemory " . TextFormat::RED . number_format(round($mUsage[1] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Totalvirtualmemory " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Heapmemory " . TextFormat::RED . number_format(round($rUsage[0] / 1024 / 1024, 2)) . " MB.");
     $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Maxmemorysystem " . TextFormat::RED . number_format(round($mUsage[2] / 1024 / 1024, 2)) . " MB.");
     if ($server->getProperty("memory.global-limit") > 0) {
         $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.Maxmemorymanager " . TextFormat::RED . number_format(round($server->getProperty("memory.global-limit"), 2)) . " MB.");
     }
     foreach ($server->getLevels() as $level) {
         $sender->sendMessage(TextFormat::GOLD . "%pocketmine.command.status.World \"" . $level->getFolderName() . "\"" . ($level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : "") . ": " . TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " %pocketmine.command.status.chunks " . TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " %pocketmine.command.status.entities " . TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " %pocketmine.command.status.tiles " . "%pocketmine.command.status.Time " . (($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW) . round($level->getTickRateTime(), 2) . "%pocketmine.command.status.ms" . ($level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""));
     }
     return true;
 }
Example #30
0
 public static function RemovePortForward($port)
 {
     if (Utils::$online === false) {
         return false;
     }
     if (Utils::getOS() != "win" or !class_exists("COM")) {
         return false;
     }
     $port = (int) $port;
     try {
         $com = new \COM("HNetCfg.NATUPnP") or false;
         if ($com === false or !is_object($com->StaticPortMappingCollection)) {
             return false;
         }
         $com->StaticPortMappingCollection->Remove($port, "UDP");
     } catch (\Throwable $e) {
         return false;
     }
     return true;
 }