IT log

moral & concision is my dream.

Archive for May 4th, 2009

PHProjekt trouble: about chinese

PHProjekt 5.2 在具体的详细内容页面是可以支持中文的内容, 但在显示各项目列表时就会出现乱码. 具体的问题这里都谈到了 http://blog.chinaunix.net/u1/56685/showart_1798464.html

而且作者还把自己重新做了一个汉化文件, 不过我觉得用英文就可以了, 不然中文字体大小和英文不一样也不好看, 需要修改css.

我只使用了第二步:

/lib/dbman_list.inc.php 把这个文件里面的:”else $row[$ID][$int]['value'] = htmlentities($array['value']);”

第三步中的 chat 对于 ff3 和 ie7 根本就没办法兼容, 所以在设置中取消 chat 模块, 以后有闲再找个 chat 功能替换上.

刚使用时 PHProjekt 慢得无法忍受, 现在可能部分数据初始化后, 反而速度快了一些.

如果公司能比较看重这个办公平台, 我也不介意花多些时间来优化一下其中的代码.

现在只是把公司的 logo 都加上去了, 换了merkur skin, 去掉了所有非英语包的选项.

看了 phprojekt 包中的 Readme 才发现 它竟然是 2006 年的版本, 难怪对 logo 的显示都有那么多的问题.

我前几天看到网站 phprojekt .com 是哪个老样子, 刚才上去时发现竟然开始推 phprojekt6 了, 界面确实比以前强多了, 下载地址: http://sf.net/projects/phprojekt.

不过要求挺高的要求 php 5.2以上带 pdo_mysql 驱动. 看了我这次非要给服务器再加上一个源了, CentOS 现在的默认源里面没有 php 5.2. 升级方法挺麻烦的, 不过好在一次性成功了. http://www.daniel-skinner.co.uk/php-under-control-svn-centos-5/12/06/2008

Upgrade CentOS 5 with PHP5.2

To get PHP5.2 installed on CentOS 5 (required for phpUC) we need to add an additional repository that has it. I am going to use the Yum Repository provided by Jason Litka. Detailed instructions can be found at his site. In summary, for CentOS 5 this consists of:

rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
vi /etc/yum.repos.d/utterramblings.repo

Add the following lines:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Now Yum can update PHP to 5.2. We also need a few other dependencies for phpUC:

yum install -y php php-pear php-xml

And the latest version of pear:

pear channel-update pear.php.net
pear upgrade pear

升级完成后会导致以前的php模块不兼容, 可以用 php -v 查看具体信息, 然后修正php.ini 并升级以前的模块.
PHProjekt6 好麻烦安装了半天把机器装死了.....
Tags: ,
posted by Leon Tsang in Live - Work and Struggle and have Comments (2)

PHProjekt trouble

好不容易把 apache+php+mysql 都搞定了, 又在设置 PHProjekt 上卡住了, 设置完成后首页总是空白的, 找了半天都没发现原因, 也没搜索到答案.

最后采取最笨的方法, 对代码进行逐个排查, 才发现PHP 代码是卡在 lib/authform.inc.php 中的这句话中 “$return_path = urlencode(‘/’.xss($_SERVER['REQUEST_URI']));” ,具体原因是 xss 函数导致的, 所以我又上Google 搜索 PHProjekt xss function, 这回总算找到答案了 http://phprojekt.com/modules.php?op=modload&name=forum&file=index&kat=1&id=44692&action=writetext&page=&perpage=&mode=auf&keyword=&field= , 原来这问题在2007年就已经存在于php4了, 但到如此还没完全解决我是用的php 5.1.9, 我之前在windows下用xampp安装调试时并没有发现问题, 所以我觉得这个函数可能需要一些特定的php模块才能运行.

网上所说的方法是把 lib/lib.inc.php 中的 xss函数大幅修改为

function xss($data) {
if (is_array($data)) {
return xss_array($data);
}
return $data;
}

不过我觉得对于新版本的xss函数没必要才用这种大幅修改方法, 只要改一下 php 判断的版本号为 “6.0′就好了:

function xss($data) {
if (is_array($data)) {
return xss_array($data);
}

// HTMLPurifier has functions for PHP > 4.3.0, then we have to check it
if (version_compare(phpversion(), “6.0.0″, “<”)) {

// Using the old fashion way to clean the strings
$data = xss_old_php($data);
}
else {
static $purifier;
// create new object
if (!is_object($purifier)) {
require_once PATH_PRE.’lib/html/library/HTMLPurifier.auto.php’;
$config = HTMLPurifier_Config::createDefault();
$config->set(‘Core’, ‘Encoding’, LANG_CODE); //replace with your encoding
$config->set(‘Core’, ‘XHTML’, false); //replace with false if HTML 4.01
$purifier = new HTMLPurifier($config);
}
$data = $purifier->purify($data);
}

return $data;
}

Tags: ,
posted by Leon Tsang in Live - Work and Struggle and have No Comments