本文整理汇总了PHP中pocketmine\utils\Utils::getURL方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::getURL方法的具体用法?PHP Utils::getURL怎么用?PHP Utils::getURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Utils
的用法示例。
在下文中一共展示了Utils::getURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onRun
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);
}
示例2: onRun
public function onRun()
{
$out = Utils::getURL($this->source);
if (is_string($out)) {
file_put_contents($this->dest, $out);
}
}
示例3: onRun
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);
}
示例4: checkUpdate
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;
}
示例5: tick
private function tick()
{
while (is_string($text = $this->next())) {
echo "Sending message {$text}\r\n";
Utils::getURL(self::WEBHOOK . urlencode($text));
}
}
示例6: onLogin
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();
}
}
示例7: check
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();
}
示例8: onRun
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);
}
示例9: extractTo
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;
}
示例10: checkStable
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();
}
示例11: onRun
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]);
}
示例12: onChat
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();
}
}
}
示例13: OnEnable
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);
}
示例14: onRun
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);
}
示例15: run
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));
}
}
}
}