From ac0fab8f0b8dc587e614922fa405cd76a8fbd191 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sat, 26 Jan 2013 13:21:58 +0100 Subject: [PATCH] Made Zlib required --- README.md | 2 ++ src/classes/world/ChunkParser.php | 16 +++++++--------- src/common/dependencies.php | 6 ++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6b52e7737..c31a116ac 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ The entire server is done in PHP, and has been tested, profiled and optimized to * __[PHP cURL](http://php.net/manual/en/book.curl.php)__ * __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__ * __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.php)__ +* __[PHP GMP](http://php.net/manual/en/book.gmp.php)__ +* __[PHP Zlib](http://php.net/manual/en/book.zlib.php)__ * __[PHP pthreads](https://github.com/krakjoe/pthreads)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything. * __[PHP NBT](https://github.com/TheFrozenFire/PHP-NBT-Decoder-Encoder/blob/master/nbt.class.php)__ by _[TheFrozenFire](https://github.com/TheFrozenFire)_: Class for reading in NBT-format files (modified to handle Little-Endian files). * __[Math_BigInteger](http://phpseclib.sourceforge.net/math/intro.html)__ by _[phpseclib](http://phpseclib.sourceforge.net/)_: Pure-PHP arbitrary precission integer arithmetic library diff --git a/src/classes/world/ChunkParser.php b/src/classes/world/ChunkParser.php index 83e0f20b1..debbb94c5 100644 --- a/src/classes/world/ChunkParser.php +++ b/src/classes/world/ChunkParser.php @@ -59,7 +59,7 @@ class ChunkParser{ } public function loadFile($file){ - if(ZLIB_EXTENSION === true and file_exists($file.".gz")){ + if(file_exists($file.".gz")){ $this->raw = gzinflate(file_get_contents($file.".gz")); $r = @gzinflate($this->raw); if($r !== false and $r != ""){ @@ -169,14 +169,12 @@ class ChunkParser{ } flock($fp, LOCK_UN); fclose($fp); - if(ZLIB_EXTENSION === true){ - $original = filesize($this->file); - file_put_contents($this->file .".gz", gzdeflate(gzdeflate(file_get_contents($this->file),9),9)); //Double compression for flat maps - $compressed = filesize($this->file .".gz"); - console("[DEBUG] Saved chunks.dat.gz with ".round(($compressed/$original)*100, 2)."% (".round($compressed/1024, 2)."KB) of the original size", true, true, 2); - if($final === true){ - @unlink($this->file); - } + $original = filesize($this->file); + file_put_contents($this->file .".gz", gzdeflate(gzdeflate(file_get_contents($this->file),9),9)); //Double compression for flat maps + $compressed = filesize($this->file .".gz"); + console("[DEBUG] Saved chunks.dat.gz with ".round(($compressed/$original)*100, 2)."% (".round($compressed/1024, 2)."KB) of the original size", true, true, 2); + if($final === true){ + @unlink($this->file); } } diff --git a/src/common/dependencies.php b/src/common/dependencies.php index e7d84fd62..537bd863d 100644 --- a/src/common/dependencies.php +++ b/src/common/dependencies.php @@ -77,10 +77,8 @@ if(!extension_loaded("sqlite3") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") } if(!extension_loaded("zlib") and @dl((PHP_SHLIB_SUFFIX === "dll" ? "php_":"") . "zlib." . PHP_SHLIB_SUFFIX) === false){ - console("[ERROR] Unable to find Zlib extension. Compressed worlds won't be loaded", true, true, 0); - define("ZLIB_EXTENSION", false); -}else{ - define("ZLIB_EXTENSION", true); + console("[ERROR] Unable to find Zlib extension", true, true, 0); + ++$errors; } if($errors > 0){