Example #1
0
 public function verify()
 {
     $serverAPI = new ServerAPI("25wehl3uwk9bw", "o50nPHUuRaanG");
     $result = array("status" => "-999", "message" => "", "startPath" => "", "data" => "");
     $username = isset($_POST["username"]) ? $_POST["username"] : "";
     $password = isset($_POST["password"]) ? $_POST["password"] : "";
     if ($username == '' || $password == '') {
         $result["message"] = "登入請確實填寫";
     } else {
         $user = $this->Lmodel->verify($username, $password);
         $token = $serverAPI->getToken($user, $username, "1");
         $getdecode = json_decode($token, true);
         $gettoken = $getdecode['token'];
         $this->Lmodel->writetoken($gettoken, $username);
         if ($user != "-1") {
             @session_start();
             $_SESSION["user"] = $user;
             $result["message"] = $gettoken;
             $result["status"] = "1";
             $result["startPath"] = "index.php/table";
             $result["data"] = $this->Lmodel->get_edit($username);
         } else {
             if ($user == "-1") {
                 $result["status"] = "-1";
                 $result["message"] = "資料不正確";
             } else {
                 $reult["message"] = "帳號審核中";
             }
         }
     }
     echo json_encode($result);
 }
 public function doLogin()
 {
     import('Class.ServerAPI', APP_PATH);
     $mobile = I('mobile');
     //手机号码
     $password = I('password', '', 'md5');
     //密码
     //验证手机号码格式
     if (!isMobile($mobile)) {
         $this->ajaxReturn(0, "手机号码格式错误", -1);
     }
     //判断该手机号码是否存在
     if (M('user')->where(array('mobile' => $mobile))->count('id') == 0) {
         $this->ajaxReturn(0, "手机号码不存在", -2);
     }
     //判断密码是否正确
     if (M('user')->where(array('mobile' => $mobile, 'password' => $password))->count('id') == 0) {
         $this->ajaxReturn(0, "密码错误", -3);
     }
     $info = M('user')->where(array('mobile' => $mobile))->find();
     $uid = $info['id'];
     //登录用户ID
     $islock = M('user')->where(array('id' => $uid))->getField('islock');
     if ($islock == 1) {
         $this->ajaxReturn(0, "该用户被锁定,无法进行登录,请与管理员进行联系", -103);
     }
     $allMessage = 0;
     //查找用户新赞数和新评论数
     $userinfo = M('user')->field('headicon,newsupportNum,newcommentNum')->where(array('id' => $uid))->find();
     $dialoginfo = M('dialog')->field('newLetterNum')->where("sendId={$uid} or receiveId={$uid}")->select();
     for ($i = 0; $i < count($dialoginfo); $i++) {
         $allMessage += intval($dialoginfo[$i]['newLetterNum']);
     }
     $allMessage += intval($userinfo['newsupportNum']);
     $allMessage += intval($userinfo['newcommentNum']);
     $returninfo = array();
     $returninfo['uid'] = $uid;
     $returninfo['headicon'] = headiconUrl($userinfo['headicon'], 60);
     $returninfo['allMessage'] = $allMessage;
     //appKey :
     //AppSecret :
     //此处的AppKey  AppSecret 为融云SDK
     $p = new ServerAPI('', '');
     $r = $p->getToken($uid, $info['username'], $returninfo['headicon']);
     //print_r($r);
     $returninfo['token'] = $r;
     $returninfo['userRefresh'] = $p->userRefresh($uid, $info['username'], $returninfo['headicon']);
     $returninfo['username'] = $info['username'];
     session('uid', $uid);
     $this->ajaxReturn($returninfo, "登录成功", 1);
 }
Example #3
0
 public function onUpdate($type)
 {
     if ($type === BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent === true) {
             //Replace with common break method
             ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
             $this->level->setBlock($this, new AirBlock(), false, false, true);
             return BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === BLOCK_UPDATE_RANDOM) {
         //Growth
         if (mt_rand(1, 7) === 1) {
             if (($this->meta & 0x8) === 0x8) {
                 TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x3);
             } else {
                 $this->meta |= 0x8;
                 $this->level->setBlock($this, $this, true, false, true);
                 return BLOCK_UPDATE_RANDOM;
             }
         } else {
             return BLOCK_UPDATE_RANDOM;
         }
     }
     return false;
 }
Example #4
0
 public function onUpdate($type)
 {
     if ($type === BLOCK_UPDATE_NORMAL) {
         $down = $this->getSide(0);
         if ($down->getID() !== SAND and $down->getID() !== CACTUS) {
             //Replace with common break method
             $this->level->setBlock($this, new AirBlock(), false);
             ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
             return BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === BLOCK_UPDATE_RANDOM) {
         if ($this->getSide(0)->getID() !== CACTUS) {
             if ($this->meta == 0xf) {
                 for ($y = 1; $y < 3; ++$y) {
                     $b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                     if ($b->getID() === AIR) {
                         $this->level->setBlock($b, new CactusBlock(), true, false, true);
                         break;
                     }
                 }
                 $this->meta = 0;
                 $this->level->setBlock($this, $this, false);
             } else {
                 ++$this->meta;
                 $this->level->setBlock($this, $this, false);
             }
             return BLOCK_UPDATE_RANDOM;
         }
     }
     return false;
 }
 public function __construct(ServerAPI $api, $server = false)
 {
     $this->api = $api;
     $this->server = ServerAPI::request();
     $this->sessions = array();
     SimpleAuthAPI::set($this);
 }
Example #6
0
 public function onUpdate($type)
 {
     if ($type === BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent === true) {
             //Replace with common break method
             ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
             $this->level->setBlock($this, new AirBlock(), false, false, true);
             return BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === BLOCK_UPDATE_RANDOM) {
         if (mt_rand(0, 2) == 1) {
             if ($this->meta < 0x7) {
                 ++$this->meta;
                 $this->level->setBlock($this, $this, true, false, true);
                 return BLOCK_UPDATE_RANDOM;
             } else {
                 for ($side = 2; $side <= 5; ++$side) {
                     $b = $this->getSide($side);
                     if ($b->getID() === MELON_BLOCK) {
                         return BLOCK_UPDATE_RANDOM;
                     }
                 }
                 $side = $this->getSide(mt_rand(2, 5));
                 $d = $side->getSide(0);
                 if ($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)) {
                     $this->level->setBlock($side, new MelonBlock(), true, false, true);
                 }
             }
         }
         return BLOCK_UPDATE_RANDOM;
     }
     return false;
 }
 public function dumpError()
 {
     if ($this->stop === true) {
         return;
     }
     console("[SEVERE] An unrecovereable has ocurred and the server has crashed. Creating an error dump");
     $dump = "```\r\n# PocketMine-MP Error Dump " . date("D M j H:i:s T Y") . "\r\n";
     $er = error_get_last();
     $errorConversion = array(E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_PARSE => "E_PARSE", E_NOTICE => "E_NOTICE", E_CORE_ERROR => "E_CORE_ERROR", E_CORE_WARNING => "E_CORE_WARNING", E_COMPILE_ERROR => "E_COMPILE_ERROR", E_COMPILE_WARNING => "E_COMPILE_WARNING", E_USER_ERROR => "E_USER_ERROR", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_STRICT => "E_STRICT", E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", E_DEPRECATED => "E_DEPRECATED", E_USER_DEPRECATED => "E_USER_DEPRECATED");
     $er["type"] = isset($errorConversion[$er["type"]]) ? $errorConversion[$er["type"]] : $er["type"];
     $dump .= "Error: " . var_export($er, true) . "\r\n\r\n";
     if (stripos($er["file"], "plugin") !== false) {
         $dump .= "THIS ERROR WAS CAUSED BY A PLUGIN. REPORT IT TO THE PLUGIN DEVELOPER.\r\n";
     }
     $dump .= "Code: \r\n";
     $file = @file($er["file"], FILE_IGNORE_NEW_LINES);
     for ($l = max(0, $er["line"] - 10); $l < $er["line"] + 10; ++$l) {
         $dump .= "[" . ($l + 1) . "] " . @$file[$l] . "\r\n";
     }
     $dump .= "\r\n\r\n";
     $version = new VersionString();
     $dump .= "PocketMine-MP version: " . $version . " #" . $version->getNumber() . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "; API " . CURRENT_API_VERSION . "]\r\n";
     $dump .= "Git commit: " . GIT_COMMIT . "\r\n";
     $dump .= "Source SHA1 sum: " . SOURCE_SHA1SUM . "\r\n";
     $dump .= "uname -a: " . php_uname("a") . "\r\n";
     $dump .= "PHP Version: " . phpversion() . "\r\n";
     $dump .= "Zend version: " . zend_version() . "\r\n";
     $dump .= "OS : " . PHP_OS . ", " . Utils::getOS() . "\r\n";
     $dump .= "Debug Info: " . var_export($this->debugInfo(false), true) . "\r\n\r\n\r\n";
     global $arguments;
     $dump .= "Parameters: " . var_export($arguments, true) . "\r\n\r\n\r\n";
     $p = $this->api->getProperties();
     if ($p["rcon.password"] != "") {
         $p["rcon.password"] = "******";
     }
     $dump .= "server.properties: " . var_export($p, true) . "\r\n\r\n\r\n";
     if ($this->api->plugin instanceof PluginAPI) {
         $plist = $this->api->plugin->getList();
         $dump .= "Loaded plugins:\r\n";
         foreach ($plist as $p) {
             $dump .= $p["name"] . " " . $p["version"] . " by " . $p["author"] . "\r\n";
         }
         $dump .= "\r\n\r\n";
     }
     $extensions = array();
     foreach (get_loaded_extensions() as $ext) {
         $extensions[$ext] = phpversion($ext);
     }
     $dump .= "Loaded Modules: " . var_export($extensions, true) . "\r\n";
     $dump .= "Memory Usage Tracking: \r\n" . chunk_split(base64_encode(gzdeflate(implode(";", $this->memoryStats), 9))) . "\r\n";
     ob_start();
     phpinfo();
     $dump .= "\r\nphpinfo(): \r\n" . chunk_split(base64_encode(gzdeflate(ob_get_contents(), 9))) . "\r\n";
     ob_end_clean();
     $dump .= "\r\n```";
     $name = "Error_Dump_" . date("D_M_j-H.i.s-T_Y");
     logg($dump, $name, true, 0, true);
     console("[SEVERE] Please submit the \"{$name}.log\" file to the Bug Reporting page. Give as much info as you can.", true, true, 0);
 }
Example #8
0
 public function __construct($config = [])
 {
     if (!empty($config)) {
         $this->configure($config);
     }
     parent::__construct($this->AppKey, $this->AppSecret, $this->Format);
     $this->init();
 }
Example #9
0
 function __construct()
 {
     $this->help = array();
     $this->cmds = array();
     $this->alias = array();
     $this->server = ServerAPI::request();
     $this->last = microtime(true);
 }
Example #10
0
 public function onUpdate($type)
 {
     if ($type === BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent === true) {
             //Replace with common break method
             ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
             $this->level->setBlock($this, new AirBlock(), false);
             return BLOCK_UPDATE_NORMAL;
         }
     }
     return false;
 }
Example #11
0
 public function onActivate(Item $item, Player $player)
 {
     if ($item->getID() === FLINT_STEEL) {
         if (($player->gamemode & 0x1) === 0) {
             $item->useOn($this);
         }
         $data = array("x" => $this->x + 0.5, "y" => $this->y + 0.5, "z" => $this->z + 0.5, "power" => 4, "fuse" => 20 * 4);
         $this->level->setBlock($this, new AirBlock(), false, false, true);
         $e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
         ServerAPI::request()->api->entity->spawnToAll($e);
         return true;
     }
     return false;
 }
Example #12
0
 public function onUpdate($type)
 {
     if ($type === BLOCK_UPDATE_NORMAL) {
         $side = $this->getMetadata();
         $faces = array(1 => 4, 2 => 5, 3 => 2, 4 => 3, 5 => 0, 6 => 0, 0 => 0);
         if ($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)) {
             //Replace with common break method
             ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
             $this->level->setBlock($this, new AirBlock(), true, false, true);
             return BLOCK_UPDATE_NORMAL;
         }
     }
     return false;
 }
Example #13
0
 public function check()
 {
     for ($n = 0; $n < $this->threads; ++$n) {
         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 !== "") {
                 console($this->workers[$n]->response);
                 $this->workers[$n]->notify();
             } else {
                 $this->workers[$n]->response = ServerAPI::request()->api->console->run($this->workers[$n]->cmd, "rcon");
                 $this->workers[$n]->notify();
             }
         }
     }
 }
Example #14
0
 /**
  * @param integer $type
  *
  * @return boolean
  */
 public function onUpdate($type)
 {
     if ($this->hasPhysics === true and $type === BLOCK_UPDATE_NORMAL) {
         $down = $this->getSide(0);
         if ($down->getID() === AIR or $down instanceof LiquidBlock) {
             $data = array("x" => $this->x + 0.5, "y" => $this->y + 0.5, "z" => $this->z + 0.5, "Tile" => $this->id);
             $server = ServerAPI::request();
             $this->level->setBlock($this, new AirBlock(), false, false, true);
             $e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data);
             $server->api->entity->spawnToAll($e);
             $server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1);
         }
         return false;
     }
     return false;
 }
Example #15
0
 public function getDrops(Item $item, Player $player)
 {
     $drops = array();
     if ($item->isPickaxe() >= 1) {
         $drops[] = array(FURNACE, 0, 1);
     }
     $t = ServerAPI::request()->api->tile->get($this);
     if ($t !== false and $t->class === TILE_FURNACE) {
         for ($s = 0; $s < FURNACE_SLOTS; ++$s) {
             $slot = $t->getSlot($s);
             if ($slot->getID() > AIR and $slot->count > 0) {
                 $drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
             }
         }
     }
     return $drops;
 }
Example #16
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($target->isTransparent === false and $face > 1 and $block->isSolid === false) {
         $server = ServerAPI::request();
         $faces = array(2 => 1, 3 => 3, 4 => 0, 5 => 2);
         $motives = array(array("Kebab", 1, 1), array("Aztec", 1, 1), array("Alban", 1, 1), array("Aztec2", 1, 1), array("Bomb", 1, 1), array("Plant", 1, 1), array("Wasteland", 1, 1), array("Wanderer", 1, 2), array("Graham", 1, 2), array("Pool", 2, 1), array("Courbet", 2, 1), array("Sunset", 2, 1), array("Sea", 2, 1), array("Creebet", 2, 1), array("Match", 2, 2), array("Bust", 2, 2), array("Stage", 2, 2), array("Void", 2, 2), array("SkullAndRoses", 2, 2), array("Fighters", 4, 2), array("Skeleton", 4, 3), array("DonkeyKong", 4, 3), array("Pointer", 4, 4), array("Pigscene", 4, 4), array("Flaming Skull", 4, 4));
         $motive = $motives[mt_rand(0, count($motives) - 1)];
         $data = array("x" => $target->x, "y" => $target->y, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]);
         $e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
         $server->api->entity->spawnToAll($e);
         if (($player->gamemode & 0x1) === 0x0) {
             $player->removeItem($this->getID(), $this->getMetadata(), 1, false);
         }
         return true;
     }
     return false;
 }
Example #17
0
 public function indexAction()
 {
     $token = $this->gettoken();
     echo $token;
     die;
     $serverapi = new \ServerAPI($this->appKey, $this->appSecret);
     //刷新用户信息
     $serverapi->userRefresh($userId, $name = '', $portraitUri = '');
     //检查用户在线状态
     $serverapi->userCheckOnline($userId);
     //封禁用户   $minute,封禁时长,单位为分钟,最大值为43200分钟
     $serverapi->userBlock($userId, $minute);
     //解除用户封禁
     $serverapi->userUnBlock($userId);
     //获取被封禁用户信息
     $serverapi->userBlockQuery();
     //添加用户到黑名单  $blackUserId,被加黑的用户Id
     $serverapi->userBlacklistAdd($userId, $blackUserId = array());
     //获取某个用户的黑名单列表
     $serverapi->userBlacklistQuery($userId);
     //移除黑名单
     $serverapi->userBlacklistRemove($userId, $blackUserId = array());
 }
Example #18
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     switch ($this->meta) {
         case MOB_CHICKEN:
         case MOB_SHEEP:
         case MOB_COW:
         case MOB_PIG:
             $data = array("x" => $block->x + 0.5, "y" => $block->y, "z" => $block->z + 0.5);
             $e = ServerAPI::request()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data);
             ServerAPI::request()->api->entity->spawnToAll($e);
             if (($player->gamemode & 0x1) === 0) {
                 --$this->count;
             }
             return true;
             break;
     }
     return false;
 }
Example #19
0
 public static function grantAchievement(Player $player, $achievementId)
 {
     if (isset(self::$achievements[$achievementId]) and !self::hasAchievement($player, $achievementId)) {
         foreach (self::$achievements[$achievementId]["requires"] as $requerimentId) {
             if (!self::hasAchievement($player, $requerimentId)) {
                 return false;
             }
         }
         if (ServerAPI::request()->api->dhandle("achievement.grant", array("player" => $player, "achievementId" => $achievementId)) !== false) {
             $player->achievements[$achievementId] = true;
             self::broadcastAchievement($player, $achievementId);
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
Example #20
0
 public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name)
 {
     $this->server = ServerAPI::request();
     $this->level = $level;
     $this->level->level = $this;
     $this->entities = $entities;
     $this->tiles = $tiles;
     $this->blockUpdates = $blockUpdates;
     $this->startTime = $this->time = (int) $this->level->getData("time");
     $this->nextSave = $this->startCheck = microtime(true);
     $this->nextSave += 90;
     $this->stopTime = false;
     $this->server->schedule(15, array($this, "checkThings"), array(), true);
     $this->server->schedule(20 * 13, array($this, "checkTime"), array(), true);
     $this->name = $name;
     $this->usedChunks = array();
     $this->changedBlocks = array();
     $this->changedCount = array();
 }
Example #21
0
 function __construct(Level $level, $id, $class, $x, $y, $z, $data = array())
 {
     $this->server = ServerAPI::request();
     $this->level = $level;
     $this->normal = true;
     $this->class = $class;
     $this->data = $data;
     $this->closed = false;
     if ($class === false) {
         $this->closed = true;
     }
     $this->name = "";
     $this->lastUpdate = microtime(true);
     $this->scheduledUpdate = false;
     $this->id = (int) $id;
     $this->x = (int) $x;
     $this->y = (int) $y;
     $this->z = (int) $z;
     $this->server->query("INSERT OR REPLACE INTO tiles (ID, level, class, x, y, z) VALUES (" . $this->id . ", '" . $this->level->getName() . "', '" . $this->class . "', " . $this->x . ", " . $this->y . ", " . $this->z . ");");
     switch ($this->class) {
         case TILE_CHEST:
         case TILE_SIGN:
             $this->server->query("UPDATE tiles SET spawnable = 1 WHERE ID = " . $this->id . ";");
             break;
         case TILE_FURNACE:
             if (!isset($this->data["BurnTime"]) or $this->data["BurnTime"] < 0) {
                 $this->data["BurnTime"] = 0;
             }
             if (!isset($this->data["CookTime"]) or $this->data["CookTime"] < 0 or $this->data["BurnTime"] === 0 and $this->data["CookTime"] > 0) {
                 $this->data["CookTime"] = 0;
             }
             if (!isset($this->data["MaxTime"])) {
                 $this->data["MaxTime"] = $this->data["BurnTime"];
                 $this->data["BurnTicks"] = 0;
             }
             if ($this->data["BurnTime"] > 0) {
                 $this->update();
             }
             break;
     }
 }
Example #22
0
 public function __construct()
 {
     console("[INFO] Starting GS4 status listener");
     $this->server = ServerAPI::request();
     $addr = ($ip = $this->server->api->getProperty("server-ip")) != "" ? $ip : "0.0.0.0";
     $port = $this->server->api->getProperty("server-port");
     console("[INFO] Setting query port to {$port}");
     /*
     The Query protocol is built on top of the existing Minecraft PE UDP network stack.
     Because the 0xFE packet does not exist in the MCPE protocol,
     we can identify	Query packets and remove them from the packet queue.
     
     Then, the Query class handles itself sending the packets in raw form, because
     packets can conflict with the MCPE ones.
     */
     $this->server->schedule(20 * 30, array($this, "regenerateToken"), array(), true);
     $this->regenerateToken();
     $this->lastToken = $this->token;
     $this->regenerateInfo();
     console("[INFO] Query running on {$addr}:{$port}");
 }
Example #23
0
 public function onActivate(Item $item, Player $player)
 {
     if (ServerAPI::request()->api->time->getPhase($player->level) !== "night") {
         $pk = new ChatPacket();
         $pk->message = "You can only sleep at night";
         $player->dataPacket($pk);
         return true;
     }
     $blockNorth = $this->getSide(2);
     //Gets the blocks around them
     $blockSouth = $this->getSide(3);
     $blockEast = $this->getSide(5);
     $blockWest = $this->getSide(4);
     if (($this->meta & 0x8) === 0x8) {
         //This is the Top part of bed
         $b = $this;
     } else {
         //Bottom Part of Bed
         if ($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x8) === 0x8) {
             $b = $blockNorth;
         } elseif ($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x8) === 0x8) {
             $b = $blockSouth;
         } elseif ($blockEast->getID() === $this->id and ($blockEast->meta & 0x8) === 0x8) {
             $b = $blockEast;
         } elseif ($blockWest->getID() === $this->id and ($blockWest->meta & 0x8) === 0x8) {
             $b = $blockWest;
         } else {
             $pk = new ChatPacket();
             $pk->message = "This bed is incomplete";
             $player->dataPacket($pk);
             return true;
         }
     }
     if ($player->sleepOn($b) === false) {
         $pk = new ChatPacket();
         $pk->message = "This bed is occupied";
         $player->dataPacket($pk);
     }
     return true;
 }
 public function packetDispatcher(&$packet, $event)
 {
     if ($event !== "server.noauthpacket") {
         return;
     }
     switch ($packet["pid"]) {
         case 0x2:
             //Ping External
             foreach ($this->config->get("servers") as $server) {
                 ServerAPI::request()->send(0x1d, array($packet["data"][0], Utils::readLong("13p13p"), RAKNET_MAGIC, $packet["ip"] . ";" . $packet["port"]), false, $server["server"], $server["port"]);
             }
             break;
         case 0x1d:
             //Ping Internal
             if ($packet["data"][1] !== Utils::readLong("13p13p")) {
                 break;
             }
             $data = explode(";", $packet["data"][3]);
             ServerAPI::request()->packetHandler(array("pid" => 0x2, "data" => array(0 => $data[0], 1 => RAKNET_MAGIC), "raw" => "", "ip" => $data[0], "port" => (int) $data[1]));
             return false;
     }
 }
Example #25
0
 public function onUpdate($type)
 {
     if ($type === BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent === true) {
             //Replace with common break method
             ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(BEETROOT_SEEDS, 0, 1));
             $this->level->setBlock($this, new AirBlock(), false, false, true);
             return BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === BLOCK_UPDATE_RANDOM) {
         if (mt_rand(0, 2) == 1) {
             if ($this->meta < 0x7) {
                 ++$this->meta;
                 $this->level->setBlock($this, $this, true, false, true);
                 return BLOCK_UPDATE_RANDOM;
             }
         } else {
             return BLOCK_UPDATE_RANDOM;
         }
     }
     return false;
 }
Example #26
0
 public function getToken()
 {
     $p = new ServerAPI('0vnjpoadnw2uz', 'hg0BUlbxV8a1');
     $r = $p->getToken($this->member_id, $this->member_info['member_name'], getMemberAvatarForID($this->member_id));
     print_r($r);
 }
 public function __construct(ServerAPI $api, $server = false)
 {
     $this->api = $api;
     $this->interval = array();
     $this->server = ServerAPI::request();
 }
Example #28
0
 /**
  * @param Item $item
  * @param Player $player
  *
  * @return boolean
  */
 public function onActivate(Item $item, Player $player)
 {
     if (($this->meta & 0x8) === 0x8) {
         //Top
         $down = $this->getSide(0);
         if ($down->getID() === $this->id) {
             $meta = $down->getMetadata() ^ 0x4;
             $this->level->setBlock($down, BlockAPI::get($this->id, $meta), true, false, true);
             $players = ServerAPI::request()->api->player->getAll($this->level);
             unset($players[$player->CID]);
             $pk = new LevelEventPacket();
             $pk->x = $this->x;
             $pk->y = $this->y;
             $pk->z = $this->z;
             $pk->evid = 1003;
             $pk->data = 0;
             ServerAPI::request()->api->player->broadcastPacket($players, $pk);
             return true;
         }
         return false;
     } else {
         $this->meta ^= 0x4;
         $this->level->setBlock($this, $this, true, false, true);
         $players = ServerAPI::request()->api->player->getAll($this->level);
         unset($players[$player->CID]);
         $pk = new LevelEventPacket();
         $pk->x = $this->x;
         $pk->y = $this->y;
         $pk->z = $this->z;
         $pk->evid = 1003;
         $pk->data = 0;
         ServerAPI::request()->api->player->broadcastPacket($players, $pk);
     }
     return true;
 }
Example #29
0
$params = array();
$name = $_GET['name'];
$version = $_GET['version'];
$hostname = $_GET['hostname'];
if (!empty($_GET['uuid'])) {
    $uuid = $_GET['uuid'];
} else {
    $uuid = null;
}
if (!empty($_GET['gid'])) {
    $gid = $_GET['gid'];
} else {
    $gid = null;
}
$pid = $_GET['pid'];
$p_api = new ServerAPI();
$p_api->fromURI($_GET["papi"]);
$cible = $hostname;
if ($gid) {
    $group = new Group($_GET['gid'], true);
    $cible = $group->getName();
}
$params["papi"] = $p_api;
$params["name"] = $hostname;
$params["hostname"] = $hostname;
$params["uuid"] = $uuid;
$params["gid"] = $gid;
$params["from"] = $from;
$params["pid"] = $pid;
$params["ltitle"] = get_def_package_label($name, $version);
$params["create_directory"] = 'on';
Example #30
0
<?php

/**
* 融云server API 接口 新版 1.0
* Class ServerAPI
* @author  caolong
* @date    2014-12-10  15:30
* @modify  2015-02-02  10:21
*
//使用
$p = new ServerAPI('appKey','AppSecret');
$r = $p->getToken('11','22','33');
print_r($r);
*/
$p = new ServerAPI('pgyu6atqylmeu', 'llja3dGCy9M3');
$r = $p->getToken('44', '55', '66');
print_r($r);
class ServerAPI
{
    private $appKey;
    //appKey
    private $appSecret;
    //secret
    const SERVERAPIURL = 'https://api.cn.ronghub.com';
    //请求服务地址
    private $format;
    //数据格式 json/xml
    /**
     * 参数初始化
     * @param $appKey
     * @param $appSecret