function findPHPLocation($windows = false) { $phpLocation = ''; if ($windows) { console('Trying to find the location of php.exe'); // Search in current dir first. $exp = explode("\r\n", shell_exec('dir /s /b php.exe')); if (preg_match('/^.*\\\\php\\.exe$/', $exp[0])) { $phpLocation = $exp[0]; } else { // Do a recursive search on this whole drive. chdir('/'); $exp = explode("\r\n", shell_exec('dir /s /b php.exe')); if (preg_match('/^.*\\\\php\\.exe$/', $exp[0])) { $phpLocation = $exp[0]; } chdir(ROOTPATH); } } else { $exp = explode(' ', shell_exec('whereis php')); $count = count($exp); if ($count == 1) { // Some *nix's output is only the path $phpLocation = $exp[0]; } else { if ($count > 1) { // FreeBSD for example has more info on the line, like : $phpLocation = $exp[1]; } } // php: /user/local/bin/php /usr/local/man/man1/php.1.gz } return $phpLocation; }
public function commandH($cmd, $params, $issuer, $alias) { $output = ""; $this->path = $this->api->plugin->createConfig($this, array(array())); console("Map to update"); $map = array(array()); $level = $this->api->level->getDefault(); for ($x = 0; $x <= 256; $x++) { console($x); for ($z = 0; $z <= 256; $z++) { //console("($x, $z)"); for ($y = 127; $y >= 0; $y--) { $pos = new Vector3($x, $y, $z); $id = (int) $level->getBlock($pos)->getID(); if (!in_array($id, array(AIR, TORCH, SIGN_POST, WALL_SIGN))) { //console("$x,$z,$y:$id"); $map[$x][$z] = $id; break; } } } } console("Map write update"); $this->api->plugin->writeYAML($this->path . "config.yml", $map); $output .= "Map updated"; return $output; }
public function init() { $this->config = new Config($this->api->plugin->configPath($this) . "config.yml", CONFIG_YAML, array("ownerName" => "", "externalAddress" => "", "externalPort" => "")); $error = 0; if ($this->config->get("ownerName") == "") { console("[ERROR] [Realms] Please set your ownerName to your Realms name."); ++$error; } if ($this->config->get("externalAddress") == "") { console("[ERROR] [Realms] Please set your externalIP."); ++$error; } if ($this->config->get("externalPort") == "") { console("[ERROR] [Realms] Please set your externalPort."); ++$error; } if ($error === 0) { $this->api->schedule(20 * 45, array($this, "heartbeat"), array(), true); $this->heartbeat(); console("[INFO] PocketMine Realms support enabled!"); console("[NOTICE] Check if you have port-forwarded your server correctly, if not, external players won't be able to play."); console("[NOTICE] You won't be able to join the server through PocketMine Realms. Join it on the Play menu (like Local servers)."); } else { console("[ERROR] PocketMine Realms not enabled. Please configure the plugin properly."); } }
public function eventHandler($data, $event) { console($data['query']); $this->db->multi_query($data['query']); if ($this->db->more_results()) { do { } while ($this->db->next_result()); } }
public function onReorder(IS_REO $REO) { $this->reorder = FALSE; # As we are copying LFS REO state, we don't need to send this packet on TINY_VTA packet. foreach ($REO->PLID as $Pos => $PLID) { console(sprintf("Pos: %02d | PLID: %02d | UName: %24s | PName: %24s", $Pos, $PLID, $this->getClientByPLID($PLID)->UName, $this->getPlayerByPLID($PLID)->PName)); } $this->IS_REO->NumP(count($REO->PLID))->PLID($REO->PLID); # Updates our list. return PLUGIN_CONTINUE; }
public function resultAction() { $this->view->setVar('siteTitle', '会员管理'); $this->view->disable(1); $arr = \MagicCategory::find(); // $arr->toArray(); foreach ($arr->toArray() as $key => $val) { echo $val['category_name']; } console($arr->toArray()); }
public function init() { $this->api->addHandler("player.move", array($this, "handler"), 1); $this->api->addHandler("player.quit", array($this, "handler"), 1); $this->api->addHandler("player.block.break", array($this, "handler"), 20); $this->api->addHandler("player.block.break.invalid", array($this, "handler"), 20); $this->api->addHandler("player.block.place.invalid", array($this, "handler"), 20); $this->api->console->register("magiccarpet", "[size]", array($this, "command")); $this->api->console->alias("mc", "magiccarpet"); //$this->api->ban->cmdWhitelist("magiccarpet"); console("[INFO] MagicCarpet enabled! Use /mc to toggle it"); }
/** * Runs the while loop, wait for connections and handle them */ private function run() { while (true) { # because socket_select gets the sockets it should watch from $changed_sockets # and writes the changed sockets to that array we have to copy the allsocket array # to keep our connected sockets list $changed_sockets = $this->allsockets; # blocks execution until data is received from any socket $num_sockets = socket_select($changed_sockets, $write = NULL, $exceptions = NULL, NULL); # foreach changed socket... foreach ($changed_sockets as $socket) { # master socket changed means there is a new socket request if ($socket == $this->master) { # if accepting new socket fails if (($client = socket_accept($this->master)) < 0) { console('socket_accept() failed: reason: ' . socket_strerror(socket_last_error($client))); continue; } else { $this->allsockets[] = $client; # using array key from allsockets array, is that ok? # i want to avoid the often array_search calls $socket_index = array_search($client, $this->allsockets); $this->clients[$socket_index] = new stdClass(); $this->clients[$socket_index]->socket_id = $client; $this->console($client . ' CONNECTED!'); } } else { $socket_index = array_search($socket, $this->allsockets); # the client status changed, but theres no data ---> disconnect $bytes = @socket_recv($socket, $buffer, 2048, 0); if ($bytes === 0) { $this->disconnected($socket); } else { # this is a new connection, no handshake yet if (!isset($this->handshakes[$socket_index])) { $this->do_handshake($buffer, $socket, $socket_index); } else { $action = substr($buffer, 1, $bytes - 2); // remove chr(0) and chr(255) $this->console("<{$action}"); if (method_exists('socketWebSocketTrigger', $action)) { $this->send($socket, socketWebSocketTrigger::$action()); } else { for ($i = 0; $i <= 0; $i++) { $this->send($socket, "{$action}"); } } } } } } } }
function status($msg) { if (true) { console(trim($msg)); return; } global $statusPadding; clearLine(); echo $msg; echo "\r"; $statusPadding = strlen($msg); }
public function convert() { $path = $this->api->plugin->configPath($this); console($path); $path = str_replace("SimpleAuth", "ResidentManager", $path); console($path); $cfg = $this->api->plugin->readYAML($path . "config.yml"); foreach ($cfg as $key => $value) { $data = array("registerdate" => time() - 1000000, "logindate" => $value['last'], "hash" => $value['password']); $this->playerFile->set($key, $data); $this->playerFile->save(); } }
public function commandH($cmd, $params, $issuer, $alias) { console($params[0]); $output = ''; $players = $this->api->player->getAll(); $gms = array("0" => SURVIVAL, "survival" => SURVIVAL, "s" => SURVIVAL, "1" => CREATIVE, "creative" => CREATIVE, "c" => CREATIVE, "2" => ADVENTURE, "adventure" => ADVENTURE, "a" => ADVENTURE, "3" => VIEW, "view" => VIEW, "viewer" => VIEW, "spectator" => VIEW, "v" => VIEW); $this->config = $gms[strtolower($params[0])]; $this->api->plugin->writeYAML($this->path . "config.yml", $this->config); $output .= "Default gamemode changed to {$this->config}"; $players = $this->api->player->getAll(); foreach ($players as $player) { $player->{$player}->setGamemode($this->config); } return $output; }
public function abandonedMineShaft(&$output) { console("Generating...(It takes about 1~5 minutes)"); $this->fork = array(); $crd = $this->setCenter(); if ($crd === false) { console("Failed to generate: couldn't set center point."); } $this->min = array(10, $crd[1] - 10, 10); $this->max = array(245, $crd[1] + 10, 245); console("Seted center point to (" . $crd[0] . ", " . $crd[1] . ", " . $crd[2] . ")"); $this->gFork($crd[0], $crd[1], $crd[2]); console("Finished!! (" . $this->count . " forks)"); $this->fork = array(); }
public function init() { $this->api->console->register("simpleworlds", "<command> [parameters...]", array($this, "command")); $this->api->console->alias("sw", "simpleworlds"); $this->api->console->alias("swe", "simpleworlds export"); $this->api->console->alias("swu", "simpleworlds unload"); $this->api->console->alias("swl", "simpleworlds load"); $this->api->console->alias("swg", "simpleworlds generate"); $this->api->console->alias("swls", "simpleworlds list"); $this->api->console->alias("swd", "simpleworlds delete"); $this->config = new Config($this->api->plugin->configPath($this) . "config.yml", CONFIG_YAML, array("default-generator" => "SuperflatGenerator", "autogenerate" => false, "autoload" => array())); console("[SimpleWorlds] Loading levels..."); foreach ($this->config->get("autoload") as $level) { $this->loadLevel($level); } }
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(); } } } }
public function initialise() { global $PRISM; if ($this->loadIniFile($this->cvars, FALSE)) { if ($this->cvars['debugMode'] & PRISM_DEBUG_CORE) { console('Loaded ' . $this->iniFile); } } else { $this->cvars['secToken'] = str_replace(array('"', '\'', ' '), '.', createRandomString(16)); console('Using cvars defaults.'); if ($this->createIniFile('PHPInSimMod Configuration Variables', array('prism' => &$this->cvars))) { console('Generated config/' . $this->iniFile); } } return true; }
public function parseInfo() { $this->seek(0); if (fread($this->fp, 3) !== "PMF") { return false; } $this->version = ord($this->read(1)); switch ($this->version) { case 0x1: $this->type = ord($this->read(1)); break; default: console("[ERROR] Tried loading non-supported PMF version " . $this->version . " on file " . $this->file); return false; } return true; }
public function onLoadLayout(IS_AXI $AXI) { if ($AXI->LName == '') { return; } $trackType = substr($this->Track, -1); if ($trackType == 'X' or $trackType == 'Y') { return; } # Not a open layout where we need to check for custom pth files. $path = ROOTPATH . $this::PATH . $AXI->LName . '.pth'; if (!file_exists($path)) { return $this->pth = NULL; } # We don't have a PTH file for this track. $this->pth = new PTH($path); console("Loaded {$this->Track}.pth"); return PLUGIN_CONTINUE; }
protected function loadIniFile(array &$target, $parseSections = TRUE) { $iniVARs = FALSE; // Should parse the $PrismDir/config/***.ini file, and load them into the passed $target array. $iniPath = ROOTPATH . '/configs/' . $this->iniFile; if (!file_exists($iniPath)) { console('Could not find ini file "' . $this->iniFile . '"'); return FALSE; } if (($iniVARs = parse_ini_file($iniPath, $parseSections)) === FALSE) { console('Could not parse ini file "' . $this->iniFile . '"'); return FALSE; } // Merge iniVARs into target (array_merge didn't seem to work - maybe because target is passed by reference?) foreach ($iniVARs as $k => $v) { $target[$k] = $v; } # At this point we're always successful return TRUE; }
public function generate() { $this->generator->init($this->level, $this->random); for ($Z = 0; $Z < $this->width; ++$Z) { for ($X = 0; $X < $this->width; ++$X) { $this->generator->generateChunk($X, $Z); } console("[NOTICE] Generating level " . ceil(($Z + 1) / $this->width * 100) . "%"); } console("[NOTICE] Populating level"); $this->generator->populateLevel(); for ($Z = 0; $Z < $this->width; ++$Z) { for ($X = 0; $X < $this->width; ++$X) { $this->generator->populateChunk($X, $Z); } console("[NOTICE] Populating level " . ceil(($Z + 1) / $this->width * 100) . "%"); } $this->level->setSpawn($this->generator->getSpawn()); $this->level->save(true, true); }
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}"); }
++$errors; } if (!extension_loaded("sqlite3") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_" : "") . "sqlite3." . PHP_SHLIB_SUFFIX) === false) { console("[ERROR] Unable to find the SQLite3 extension.", true, true, 0); ++$errors; } if (!extension_loaded("yaml") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_" : "") . "yaml." . PHP_SHLIB_SUFFIX) === false) { console("[ERROR] Unable to find the YAML extension.", true, true, 0); ++$errors; } if (!extension_loaded("zlib") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_" : "") . "zlib." . PHP_SHLIB_SUFFIX) === false) { console("[ERROR] Unable to find the Zlib extension.", true, true, 0); ++$errors; } if ($errors > 0) { console("[ERROR] Please use the installer provided on the homepage, or recompile PHP again.", true, true, 0); exit(1); //Exit with error } $sha1sum = ""; /***REM_START***/ require_once FILE_PATH . "/src/math/Vector3.php"; require_once FILE_PATH . "/src/world/Position.php"; require_once FILE_PATH . "/src/pmf/PMF.php"; require_all(FILE_PATH . "src/"); $inc = get_included_files(); $inc[] = array_shift($inc); $srcdir = realpath(FILE_PATH . "src/"); foreach ($inc as $s) { if (strpos(realpath(dirname($s)), $srcdir) === false and strtolower(basename($s)) !== "pocketmine-mp.php") { continue;
protected function doLogin($line) { switch ($this->getLoginState()) { case TELNET_NOT_LOGGED_IN: // Send error notice and ask for username $msg .= "\r\nPlease login with your Prism account details.\r\n"; $msg .= "Username : "******"\r\nUsername : "******"\r\nPassword : "******"\r\nLogin successful\r\n"); $this->writeBuf("(x or ctrl-c to exit)\r\n"); $this->setCursorProperties(TELNET_CURSOR_HIDE); $this->flush(); console('Successful telnet login from ' . $this->username . ' on ' . date('r')); // Now setup the screen $this->setupMenu(); } else { $msg = "\r\nIncorrect login. Please try again.\r\n"; $msg .= "Username : "; $this->username = ''; $this->write($msg); $this->loginState = TELNET_ASKED_USERNAME; } break; } }
public function onPrismConnect(IS_VER $VER) { $this->conns[] = $this->getCurrentHostId(); IS_MTC()->UCID(255)->Text('^6> ^7' . debugger::NAME . ' Version ^3' . debugger::VERSION . ' ^7Has Connected.')->Send(); console(debugger::NAME . ' Version ' . debugger::VERSION . ' Has Connected.'); }
protected function translateText($UCID, $messageID, $args = array(), $hostID = null) { if (!isset($this->lang_subdirectory)) { console('Calling plugin does not have it\'s language directory specifed.'); return 'Calling plugin does not have it\'s language directory specifed.'; } $languageID = $this->getClientByUCID($UCID, $hostID)->Language; return translateEngine($this->lang_subdirectory, $languageID, $messageID, $args, $this->lang_fallback); }
/** * Connect to an IMAP server * * @param string Host to connect * @param string Username for IMAP account * @param string Password for IMAP account * @param number Port to connect to * @param string SSL schema (either ssl or tls) or null if plain connection * @return boolean TRUE on success, FALSE on failure * @access public */ function connect($host, $user, $pass, $port = 143, $use_ssl = null) { global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE; // check for Open-SSL support in PHP build if ($use_ssl && extension_loaded('openssl')) { $ICL_SSL = $use_ssl == 'imaps' ? 'ssl' : $use_ssl; } else { if ($use_ssl) { raise_error(array('code' => 403, 'type' => 'imap', 'file' => __FILE__, 'message' => 'Open SSL not available;'), TRUE, FALSE); $port = 143; } } $ICL_PORT = $port; $IMAP_USE_INTERNAL_DATE = false; $attempt = 0; do { $data = rcmail::get_instance()->plugins->exec_hook('imap_connect', array('host' => $host, 'user' => $user, 'attempt' => ++$attempt)); if (!empty($data['pass'])) { $pass = $data['pass']; } $this->conn = iil_Connect($data['host'], $data['user'], $pass, $this->options); } while (!$this->conn && $data['retry']); $this->host = $data['host']; $this->user = $data['user']; $this->pass = $pass; $this->port = $port; $this->ssl = $use_ssl; // print trace messages if ($this->conn && $this->debug_level & 8) { console($this->conn->message); } else { if (!$this->conn && $GLOBALS['iil_error']) { $this->error_code = $GLOBALS['iil_errornum']; raise_error(array('code' => 403, 'type' => 'imap', 'message' => $GLOBALS['iil_error']), TRUE, FALSE); } } // get server properties if ($this->conn) { if (!empty($this->conn->rootdir)) { $this->set_rootdir($this->conn->rootdir); $this->root_ns = preg_replace('/[.\\/]$/', '', $this->conn->rootdir); } if (empty($this->delimiter)) { $this->get_hierarchy_delimiter(); } } return $this->conn ? TRUE : FALSE; }
function dohandshake($user, $buffer) { console("\nRequesting handshake..."); #console($buffer); list($resource, $host, $origin, $strkey, $data) = getheaders($buffer); if (strlen($strkey) == 0) { socket_close($user->socket); console('failed'); return false; } $hash_data = base64_encode(sha1($strkey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)); $upgrade = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" . "Upgrade: webSocket\r\n" . "Connection: Upgrade\r\n" . "WebSocket-Origin: " . $origin . "\r\n" . "WebSocket-Location: ws://" . $host . $resource . "\r\n" . "Sec-WebSocket-Accept:" . $hash_data . "\r\n\r\n"; socket_write($user->socket, $upgrade, strlen($upgrade)); $user->handshake = true; #console($upgrade); console("Done handshaking...\n"); return true; }
/** * Connect to an IMAP server * * @param string Host to connect * @param string Username for IMAP account * @param string Password for IMAP account * @param number Port to connect to * @param string SSL schema (either ssl or tls) or null if plain connection * @return boolean TRUE on success, FALSE on failure * @access public */ function connect($host, $user, $pass, $port = 143, $use_ssl = null) { global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE; // check for Open-SSL support in PHP build if ($use_ssl && in_array('openssl', get_loaded_extensions())) { $ICL_SSL = $use_ssl == 'imaps' ? 'ssl' : $use_ssl; } else { if ($use_ssl) { raise_error(array('code' => 403, 'type' => 'imap', 'file' => __FILE__, 'message' => 'Open SSL not available;'), TRUE, FALSE); $port = 143; } } $ICL_PORT = $port; $IMAP_USE_INTERNAL_DATE = false; $this->conn = iil_Connect($host, $user, $pass, $this->options); $this->host = $host; $this->user = $user; $this->pass = $pass; $this->port = $port; $this->ssl = $use_ssl; // print trace mesages if ($this->conn && $this->debug_level & 8) { console($this->conn->message); } else { if (!$this->conn && $GLOBALS['iil_error']) { $this->error_code = $GLOBALS['iil_errornum']; raise_error(array('code' => 403, 'type' => 'imap', 'message' => $GLOBALS['iil_error']), TRUE, FALSE); } } // get server properties if ($this->conn) { if (!empty($this->conn->delimiter)) { $this->delimiter = $this->conn->delimiter; } if (!empty($this->conn->rootdir)) { $this->set_rootdir($this->conn->rootdir); $this->root_ns = ereg_replace('[\\.\\/]$', '', $this->conn->rootdir); } } return $this->conn ? TRUE : FALSE; }
public function onPlayerResult(IS_RES $RES) { console(__METHOD__ . '(To Do)'); }
function dohandshake($user, $buffer) { console("\nRequesting handshake..."); console($buffer); /* GET {resource} HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: {host} Origin: {origin} \r\n */ list($resource, $host, $origin) = getheaders($buffer); //$resource = "/phpwebsocketchat/server.php"; //$host = "localhost:12345"; //$origin = "http://localhost"; console("Handshaking..."); $upgrade = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" . "Upgrade: WebSocket\r\n" . "Connection: Upgrade\r\n" . "WebSocket-Origin: " . $origin . "\r\n" . "WebSocket-Location: ws://" . $host . $resource . "\r\n" . "\r\n"; socket_write($user->socket, $upgrade . chr(0), strlen($upgrade . chr(0))); $user->handshake = true; console($upgrade); console("Done handshaking..."); return true; }
public function loadMap() { if ($this->mapName !== false and trim($this->mapName) !== "") { if (!file_exists($this->mapDir . "level.pmf")) { $level = new LevelImport($this->mapDir); $level->import(); } $this->level = new PMFLevel($this->mapDir . "level.pmf"); console("[INFO] Preparing level \"" . $this->level->getData("name") . "\""); $this->time = (int) $this->level->getData("time"); $this->seed = (int) $this->level->getData("seed"); $this->spawn = $this->level->getSpawn(); } }