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>
Ubuntu 配置 vsftp+mysql
1、安装vsftpd
sudo apt-get install vsftpd
2、安装pam的mysql验证模块"pam_mysql.so"
sudo apt-get install libpam-mysql
3、配置vsftpd的PAM验证文件
vim /etc/pam.d/vsftpd
Here is an example,注释掉原有的,添加最下面两行
# Standard behaviour for ftpd(8).
# auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
# Note: vsftpd handles anonymous logins on its own. Do not enable
# pam_ftp.so.
# Standard blurb.
#@include common-session
#@include common-auth
#auth required pam_shells.so
#红色部分请根据自己的实际情况修改
# auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
# Note: vsftpd handles anonymous logins on its own. Do not enable
# pam_ftp.so.
# Standard blurb.
#@include common-session
#@include common-auth
#auth required pam_shells.so
auth required pam_mysql.so user=yoursqluser passwd= host=localhost db=vsftpd table=user usercolumn=name passwdcolumn=passwd crypt=0 sqllog=1 logtable=log logmsgcolumn=msg logusercolumn=user logpidcolumn=pid loghostcolumn=host logtimecolumn=time verbose=1
account required pam_mysql.so user=yoursqluser passwd=p@ssw0rd host=localhost db=vsftpd table=user usercolumn=name passwdcolumn=passwd crypt=0 sqllog=1 logtable=log logmsgcolumn=msg logusercolumn=user logpidcolumn=pid loghostcolumn=host logtimecolumn=time verbose=1p@ssw0rd
account required pam_mysql.so user=yoursqluser passwd=p@ssw0rd host=localhost db=vsftpd table=user usercolumn=name passwdcolumn=passwd crypt=0 sqllog=1 logtable=log logmsgcolumn=msg logusercolumn=user logpidcolumn=pid loghostcolumn=host logtimecolumn=time verbose=1p@ssw0rd
#红色部分请根据自己的实际情况修改
4、修改vsftpd的配置文件
vim vim /etc/vsftpd.conf
Here is an example,开启了ipv6的监听。
#去掉了所有的注释行
# listen=YES 这里注释掉是因为此项与listen_ipv6只能选一项,开启ipv6后自动侦听ipv4
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
guest_enable=YES
guest_username=ftp
anon_world_readable_only=NO
virtual_use_local_privs=YES
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
# listen=YES 这里注释掉是因为此项与listen_ipv6只能选一项,开启ipv6后自动侦听ipv4
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
guest_enable=YES
guest_username=ftp
anon_world_readable_only=NO
virtual_use_local_privs=YES
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
5、确定你对ftp目录的写权限
sudo chown -R ftp\: /home/ftp/
6、最后重启vsftpd服务,看看服务器好没好用?
sudo /etc/init.d/vsftpd restart
好了,可以看看你的服务器是不是好了?
root@www:/home# ftp localhost
Connected to localhost.
220 (vsFTPd 2.0.7)
Name (localhost:ado): admin
331 Please specify the password.
Password: //这里输入密码但看不见
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r-- 1 109 1001 76 May 07 02:07 2.txt
drwxr-xr-x 2 109 1001 4096 May 07 01:10 a directory
-rwxr-xr-x 1 109 1001 1482 May 07 02:07 bridge
drwxr-xr-x 3 109 1001 4096 May 07 02:07 icc32
-rwx------ 1 109 1001 78771302 May 07 02:08 l_fc_p_10.1.015.tar.gz
-rw-r--r-- 1 109 1001 323 May 07 01:36 ls.txt
226 Directory send OK.
ftp> mkdir test
257 "/test" created
ftp> rm test
250 Remove directory operation successful.
ftp>exit
root@www:/home#
Connected to localhost.
220 (vsFTPd 2.0.7)
Name (localhost:ado): admin
331 Please specify the password.
Password: //这里输入密码但看不见
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r-- 1 109 1001 76 May 07 02:07 2.txt
drwxr-xr-x 2 109 1001 4096 May 07 01:10 a directory
-rwxr-xr-x 1 109 1001 1482 May 07 02:07 bridge
drwxr-xr-x 3 109 1001 4096 May 07 02:07 icc32
-rwx------ 1 109 1001 78771302 May 07 02:08 l_fc_p_10.1.015.tar.gz
-rw-r--r-- 1 109 1001 323 May 07 01:36 ls.txt
226 Directory send OK.
ftp> mkdir test
257 "/test" created
ftp> rm test
250 Remove directory operation successful.
ftp>exit
root@www:/home#
P.S.
mysql 数据库的建立
#创建管理vsftpd用户的数据库和表,并插入测试帐号
#mysql -u root -p123456
CREATE DATABASE ftp;
USE ftp;
CREATE TABLE user(name CHAR(20) BINARY,passwd CHAR(20) BINARY);
INSERT INTO user (name,passwd) VALUES ('test1','12345');
INSERT INTO user (name,passwd) VALUES ('test2','54321');
GRANT SELECT on ftp.user to ftp@localhost identified BY '123456';
flush PRIVILEGES;
quit
#mysql -u root -p123456
CREATE DATABASE ftp;
USE ftp;
CREATE TABLE user(name CHAR(20) BINARY,passwd CHAR(20) BINARY);
INSERT INTO user (name,passwd) VALUES ('test1','12345');
INSERT INTO user (name,passwd) VALUES ('test2','54321');
GRANT SELECT on ftp.user to ftp@localhost identified BY '123456';
flush PRIVILEGES;
quit
配置过程参考:菜鸟ubuntu8.04桌面版配置vsftp+mysql+pam 无法使用,Ubuntu 8.04 Desktop上的vsftp+mysql+pam_mysql