diff --git a/.gitignore b/.gitignore index 7b8cce590..fd7fa6bac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ players/* worlds/* plugins/* +logs/* *.log server.properties white-list.txt banned-ips.txt -console.in ################# ## Eclipse diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index 16d208702..866504bd5 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -30,7 +30,7 @@ class ConsoleAPI{ function __construct(PocketMinecraftServer $server){ $this->help = array(); $this->server = $server; - $this->input = fopen(FILE_PATH."src/console.in", "w+b"); + $this->input = fopen(FILE_PATH."logs/console.in", "w+b"); $this->last = microtime(true); } diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 5bff0f626..e21934ac5 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -30,9 +30,14 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run private $server, $config, $apiList = array(); function __construct(){ console("[INFO] Starting ServerAPI server handler..."); - file_put_contents(FILE_PATH."packets.log", ""); - file_put_contents(FILE_PATH."console.in", ""); - if(!file_exists(FILE_PATH."test.bin.log") or md5_file(FILE_PATH."test.bin.log") !== TEST_MD5){ + console("[DEBUG] Checking data folders...", true, true, 2); + @mkdir(FILE_PATH."logs/", 0777, true); + @mkdir(FILE_PATH."players/", 0777); + @mkdir(FILE_PATH."worlds/", 0777); + @mkdir(FILE_PATH."plugins/", 0777); + file_put_contents(FILE_PATH."logs/packets.log", ""); + file_put_contents(FILE_PATH."logs/console.in", ""); + if(!file_exists(FILE_PATH."logs/test.bin.log") or md5_file(FILE_PATH."logs/test.bin.log") !== TEST_MD5){ console("[NOTICE] Executing integrity tests..."); console("[INFO] OS: ".PHP_OS.", ".Utils::getOS()); console("[INFO] uname -a: ".php_uname("a")); @@ -60,7 +65,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run $test .= Utils::writeLong($str->hashCode()); $test .= Utils::writeDataArray(array("a", "b", "c", "\xff\xff\xff\xff")); $test .= Utils::hexToStr("012334567890"); - file_put_contents(FILE_PATH."test.bin.log", $test); + file_put_contents(FILE_PATH."logs/test.bin.log", $test); if(md5($test) !== TEST_MD5){ console("[ERROR] Test error, please send your console.log + test.bin.log to the Github repo"); die(); @@ -82,11 +87,6 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run copy(FILE_PATH."src/common/default.properties", FILE_PATH."server.properties"); } - console("[DEBUG] Checking data folders...", true, true, 2); - @mkdir(FILE_PATH."players/", 0777, true); - @mkdir(FILE_PATH."worlds/", 0777); - @mkdir(FILE_PATH."plugins/", 0777); - console("[DEBUG] Loading server.properties...", true, true, 2); $this->parseProperties(); define("DEBUG", $this->config["debug"]); diff --git a/src/classes/PocketMinecraftServer.class.php b/src/classes/PocketMinecraftServer.class.php index 30cdcdaa9..a660a737a 100644 --- a/src/classes/PocketMinecraftServer.class.php +++ b/src/classes/PocketMinecraftServer.class.php @@ -30,7 +30,7 @@ class PocketMinecraftServer extends stdClass{ private $database, $interface, $evCnt, $handCnt, $events, $handlers, $version, $serverType, $lastTick; function __construct($name, $gamemode = 1, $seed = false, $protocol = CURRENT_PROTOCOL, $port = 19132, $serverID = false, $version = CURRENT_VERSION){ $this->port = (int) $port; //19132 - 19135 - console("[INFO] PocketMine-MP ".MAJOR_VERSION." by @shoghicp, LGPL License. http://bit.ly/TbrimG", true, true, 0); + console("[INFO] PocketMine-MP ".MAJOR_VERSION." by @shoghicp, LGPL License", true, true, 0); console("[INFO] Starting Minecraft PE Server at *:".$this->port); if($this->port < 19132 or $this->port > 19135){ console("[WARNING] You've selected a not-standard port. Normal port range is from 19132 to 19135 included"); diff --git a/src/common/functions.php b/src/common/functions.php index 3380213e7..ce9d05630 100644 --- a/src/common/functions.php +++ b/src/common/functions.php @@ -170,7 +170,7 @@ function logg($message, $name, $EOL = true, $level = 2, $close = false){ $fpointers = array(); } if(!isset($fpointers[$name])){ - $fpointers[$name] = fopen(FILE_PATH."/".$name.".log", "ab"); + $fpointers[$name] = fopen(FILE_PATH."logs/".$name.".log", "ab"); } fwrite($fpointers[$name], $message); if($close === true){ diff --git a/src/input.php b/src/common/input.php similarity index 91% rename from src/input.php rename to src/common/input.php index 1e9107a84..9e1f2aaad 100644 --- a/src/input.php +++ b/src/common/input.php @@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or */ -$fp = fopen(dirname(__FILE__)."/console.in","wb"); +$fp = fopen(dirname(__FILE__)."/../../logs/console.in","wb"); while(true){ $l = fgets(STDIN); fwrite($fp, $l); diff --git a/start.cmd b/start.cmd index abdd99898..8e15e3e23 100644 --- a/start.cmd +++ b/start.cmd @@ -27,6 +27,6 @@ echo [ERROR] Couldn't find PHP binary in PATH. ping 127.0.0.1 -n 3 -w 1000>nul ) else ( START /B CMD /C CALL php PocketMine-MP.php -START /B /WAIT php src/input.php 1 +START /B /WAIT php src/common/input.php 1 ping 127.0.0.1 -n 5 -w 1000>nul ) \ No newline at end of file