wp post 时500错误重要更新

Posted on 05月 10, 2008 - Filed Under php | Leave a Comment

应该有些人用了我修改过的db.php文件,发现一bug,请尽快更新。
详情链接:http://www.nimab.org/2008/05/01/39.html

Read More..>>

Wordpress 2.5.1 500 错误解决方法

Posted on 05月 1, 2008 - Filed Under php | 10 Comments

随时听人讲有500错误。
今天在楚云blog上重现了。
抓住机会debug。
结果很快出来:
当你第二次用同样的标题并且标题中含有多字节文字时,有很大机会触发wp一个死循环,然后服务器cpu直接到100%,当运行时间超过max_execution_time时候出现500错误。
死循环在这里:wp-include/post.php
<?php
......
if ( 'draft' != $post_status ) {
$post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $post_name, $post_type, $post_ID, $post_parent));

if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) {
[...]

Read More..>>

Leopard 编译 universal php5

Posted on 12月 11, 2007 - Filed Under Bsd, MacosX, Unix, bash, php | 1 Comment

因为自带的php没有gd所以要重编
因为服务器用的是x86_64 httpd+php5所以要编 x86_64
因为自带的httpd+php是 universal ,所以要这样做
自带的httpd很好,所以不搞它了
参考:
ppc就不要了

export MACOSX_DEPLOYMENT_TARGET=10.5
export ARCHFLAGS='-arch i386 -arch x86_64'
export CFLAGS='-arch i386 -arch x86_64 -O3 -pipe'
export CXXFLAGS='-arch i386 -arch x86_64 -O3 -pipe'
export LDFLAGS='-arch i386 -arch x86_64 -bind_at_load'

make时候可能出现这样的提示:
gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
在 configure 的时候加上 --disable-dependency-tracking

'./configure' \
'--prefix=/usr' \
'--with-config-file-path=/private/etc' \
'--sysconfdir=/private/etc' \
'--with-apxs2=/usr/sbin/apxs' \
'--with-iconv=/usr/local' \
'--with-mhash=/usr/local' \
'--with-gettext=/usr/local' \
'--with-mysql=/usr/local' \
'--with-mysqli=/usr/local/bin/mysql_config' \
'--with-pdo-mysql=/usr/local' \
'--with-openssl=/usr' \
'--with-zlib=/usr' [...]

Read More..>>

iPhone的通讯录以拼音排序

Posted on 10月 6, 2007 - Filed Under MacosX, php, shell | 1 Comment

在iphone中安装php
将代码保存为py.php
ssh 登陆iphone或者在iphone安装Term-vt100
执行 php py.php 等待重启完成
结束
支持的中文貌似很有限,拼音表的处理看来要自己搞一个了,这个在网上找的。
py.php
<?php
/**
* @desc 将iPhone的通讯录以拼音排序, 需要安装PHP
* @author Kafeifei <http://www.nimab.org>
* @version 0.2beta
*/
error_reporting(0);
$sqlite_file = '/private/var/root/Library/AddressBook/AddressBook.sqlitedb'; // 1.1.3 以前的版本
$sqlite_file = '/private/var/mobile/Library/AddressBook/AddressBook.sqlitedb'; // 1.1.3 以后的版本
if (!file_exists($sqlite_file)) {
println("SQLiteDB:File Notfound.");
die;
}
$dsn = "sqlite:{$sqlite_file}";
try {
$dbh = new PDO($dsn);
println("Open {$dsn} OK.");
} catch (Exception $e) {
[...]

Read More..>>

再谈 jre / ZendStudio 中文字体问题

Posted on 01月 23, 2007 - Filed Under Linux, Zend, bash, java, php, shell | Leave a Comment

找了若干资料,终于有了结果
原来如此简单:
把 Courier New 的几个字体文件 copy 到 jre/lib/fonts/

cd xxx/jre/lib/fonts
mkfontscale
cp fonts.scale fonts.dir
cd ../
cp fontconfig.properties.src fontconfig.properties
vi fontconfig.properties

修改相关位置:

monospaced.plain.latin-1=-monotype-courier new-medium-r-normal--0-0-0-0-m-0-iso8859-1
monospaced.bold.latin-1=-monotype-courier new-bold-r-normal--0-0-0-0-m-0-iso8859-1
monospaced.italic.latin-1=-monotype-courier new-medium-i-normal--0-0-0-0-m-0-iso8859-1
monospaced.bolditalic.latin-1=-monotype-courier new-bold-i-normal--0-0-0-0-m-0-iso8859-1

最后再 cp 一个你喜欢的中文字体到 xxx/jre/fonts/fallback/
打开 ZDE,设置字体为 monospaced
这下爽了,我顶你个肺!
注意:此方法只在 Ubuntu 下测试通过,另外 Windows 是不适用的,如果是suse或者redhat之类的系统,主意看 xxx/jre/lib 下面的fontconfig.xxxx 文件,与当前系统相关做相应的修改就可以(没试过)
相关网址:http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html

Read More..>>

再说关于jre的字体问题

Posted on 01月 22, 2007 - Filed Under Linux, MacosX, Zend, java, php | Leave a Comment

其实最简单的解决ZendStudio中文问题方法就是:
(ZDE自带了JRE)
Zendxxx/jre/lib/fonts/
目录下面建一个叫 fallback 的目录,然后 ln 或干脆 cp 一个中文字体进去就OK了,以前还去改什么字体配置文件,真傻B了!
同样sun-jre也是一样的,建立 fallback 目录。
这种方法对 jre1.5 一上版本有效,其他版本据说要修改 lib 下面某个 font开头的文件。
另外说一下,jre1.6 对文字的处理看上去好像调用了操作系统的东西,例如平滑效果。
不知道有没有高人能把 ZendStudio 里的文字效果做成和平果一样的,Courier New 的英文,黑体中文,平滑处理。平果唯一让我怀念的就是这个东西,写代码的时候心情高很多。

Read More..>>

Ubuntu 6.10 Edgy 下ZendStudio不能运行的问题。

Posted on 10月 29, 2006 - Filed Under Linux, php | 3 Comments

升级完发现系统速度居然比6.06更快!
其他都还不错,只是ZDE不能运行了,出现以下错误信息:
Configuring the installer for this system's environment...
nawk: error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory
dirname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/ls: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
basename: [...]

Read More..>>

一个常见的xml解析错误解决方法

Posted on 10月 9, 2006 - Filed Under php | Leave a Comment

反正就是莫名其妙的错误,特别是utf-8的页面,出现这种情况的原因大概因为utf-8的编码格式是变长的,规则比较烦,中途少了一个字节或者多了一个字节就容易出现这类问题,后来用ultraedit查看,发现很诡异,都是那种单字节的字符引起的,一些控制码,反正不管怎样,替换掉这些东西就可以了,这些字符本来也不是用来看的。

$xml = preg_replace('#[\x00-\x08\x0e-\x1f\x7f]+#', ", $xml);

Read More..>>