XiZi's Blog
Gallery3 On Windows with Apache Server.
1.We need to patch some files to make gallery3 run on windows with apache web server. This is the path, but it's not stronge. you can not use this patch when you use linux etc.
2.This patch mainly fixed errors when you use none utf8 encode system. it convert the utf8 encoded filenames to locale encoded ones.
diff --git a/index.php b/index.php index e6636cf..70aeb3d 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,8 @@ version_compare(PHP_VERSION, "5.2.3", "<") and // Gallery is not supported on Windows. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - exit("Gallery is not supported on Windows (PHP reports that you're using: " . PHP_OS . ")"); +define("WIN",true); +// exit("Gallery is not supported on Windows (PHP reports that you're using: " . PHP_OS . ")"); } // PHP 5.4 requires a timezone - if one isn't set date functions aren't going to work properly. diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index f0879d6..2c34d11 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -48,7 +48,11 @@ class system_Core { foreach ($paths as $path) { $path = rtrim($path, "/"); - $candidate = "$path/$binary"; + if (!preg_match("/^win/i", PHP_OS)) { + $candidate = "$path/$binary"; + }else{ + $candidate = "$path/$binary.exe"; + } // @suppress errors below to avoid open_basedir issues if (@file_exists($candidate)) { if (!@is_executable($candidate) && diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index c446eea..cfc75f8 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -167,7 +167,7 @@ class Item_Model_Core extends ORM_MPTT { * movie: /usr/home/www/gallery3/var/albums/Bobs Wedding/First-Dance.mp4 */ public function file_path() { - return VARPATH . "albums/" . urldecode($this->relative_path()); + return VARPATH . "albums/" . iconv("UTF-8","GBK",urldecode($this->relative_path())); } /** @@ -194,7 +194,7 @@ class Item_Model_Core extends ORM_MPTT { * movie: /usr/home/www/gallery3/var/thumbs/Bobs Wedding/First-Dance.jpg */ public function thumb_path() { - $base = VARPATH . "thumbs/" . urldecode($this->relative_path()); + $base = VARPATH . "thumbs/" . iconv("UTF-8","GBK",urldecode($this->relative_path())); if ($this->is_photo()) { return $base; } else if ($this->is_album()) { @@ -245,7 +245,7 @@ class Item_Model_Core extends ORM_MPTT { * (*) Since only photos have resizes, album and movie paths are fictitious. */ public function resize_path() { - return VARPATH . "resizes/" . urldecode($this->relative_path()) . + return VARPATH . "resizes/" . iconv("UTF-8","GBK",urldecode($this->relative_path())) . ($this->is_album() ? "/.album.jpg" : ""); } diff --git a/modules/gallery/views/admin_block_platform.html.php b/modules/gallery/views/admin_block_platform.html.php index 9a594fa..76fb0a2 100644 --- a/modules/gallery/views/admin_block_platform.html.php +++ b/modules/gallery/views/admin_block_platform.html.php @@ -15,9 +15,11 @@ <li> <?= t("MySQL: %mysql_version", array("mysql_version" => Database::instance()->query("SELECT version() as v")->current()->v)) ?> </li> + <?php if (function_exists("sys_getloadavg")): ?> <li> <?= t("Server load: %load_average", array("load_average" => join(" ", sys_getloadavg()))) ?> </li> + <?php endif; ?> <li> <?= t("Graphics toolkit: %toolkit", array("toolkit" => module::get_var("gallery", "graphics_toolkit"))) ?> </li>