2007 年 5 月

bbpress发送的注册邮件收不到怎么办

最近试着在dreamhost上搭了一个bbpress的论坛程序,它的注册流程的最后是需要邮件确认,在确认邮件里发送用户名和密码。这个过程本来算的上是相当经典的注册流程,可惜国内大部分邮箱死活收不到确认邮件,因此注册没法成功。
在bbpress的Troubleshooting支持论坛上提到一个解决办法,需要修改bbpress的代码,暂时没法以插件形式解决这个问题。解决思路是直接在屏幕上打出用户名和密码,不再发送邮件:)
修正patch

评论 (15)

使用php的五个小技巧

php的一些小技巧,比较基础,总结一下,老鸟换个姿势飘过去就是。
1. str_replace
str_replace是非常常常常常用的php函数,用于字符串替换,经常看到某些php新人为了替换一批字符串,写了好多行str_replace,实在是惨不忍睹。
比如这个例子:
PLAIN TEXT
PHP:

$str = '某人的栖息地 --- www.ooso.net';

$str = str_replace('某人', '坏人', $str);

$str = str_replace('的', 'di', $str);

$str = str_replace('栖息地', '猪窝窝', $str);

$str = str_replace('www.ooso.net', 'ooso.net', $str);

以上,替换了4次字符串,实际只要换个写法,一行就搞定了:
PLAIN TEXT
PHP:

$str = '某人的栖息地 --- www.ooso.net';

$str = str_replace(array('某人', '的', '栖息地', 'www.ooso.net'), array('坏人', 'di', '猪窝窝', 'ooso.net'), $str);

评论 (15)

在dreamhost上使用imagemagick

Dreamhost的主机上,据说已经安装了imagemagick,但是在phpinfo里面没能找到相关信息。在dreamhost的support forum上找找帮助,imagemagick的信息还真不少。
dreamhost上的imagemagick的位置安装在
/usr/bin/convert
版本是
Version: ImageMagick 6.2.4 09/16/06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2005 ImageMagick Studio LLC
在php中使用imagemagick命令行转换图片的例子
PLAIN TEXT
PHP:

<?php

$location='/usr/bin/convert';

$command='-thumbnail 150';

$name='glass.';

$extfrm='jpg';

$extto='png';

$output="{$name}{$extto}";

$convert=$location . ' ' .$command . ' ' . $name . $extfrm . ' ' . $name . $extto;

exec ($convert);

print "<img src=" . $output . ">";

?>

评论

gooogle reader一个小中转服务

使用google reader好些日子,才发现它也有一些小的接口,比如下面这个url,能缓存一些rss源:
http://www.google.com/reader/atom/feed/http://www.ooso.net/index.php/feed/?r=n&c=CM6R9t3xnIsC&n=100&ck=1175983111269&client=scroll
如果把后面的feed替换掉,改成你自己的rss,也可以使用。url里面的n参数表示一次取多少个结果,这里成功取到了100条记录,俺测试成功取1000条记录:))
我认为这个接口是google reader长期以来抓取的结果,因此,可以算是一个历史记录,某些人可能用的上吧。

评论

使用php apc模块需要注意的几点

在maillist中看到Rasmus的一段对于php APC模块的发言。作为APC的作者,他的见解应该是很有参考价值的。
APC will probably be 20-30% faster, but if you are writing to it frequently it can cause problems. The APC cache is best for things that change very rarely. And by very rarely I mean days, not hours or minutes.
Because of the way APC does an anonymous file-backed mmap where I unlink the file [...]

评论

greasemonkey内置了ajax管理器

greasemonkey这工具,就好像web开发人员的作弊器一样,好玩。经常去的网站,若是看着不顺眼,就祭出greasemonkey对它页面元素的位置调整一番,把主题内容字体搞大,把广告隐藏不见,别人的网站我做主,倒也有一番小小乐趣(我可没有hack它的站点哦)。这些天看看文档,原来人家已经内置了xmlhttpRequest的api,不用费牛劲去外部导入一些js来搞这些基础工程了。
Description
GM_xmlhttpRequest makes an arbitrary HTTP request. The details argument is an object that can contain up to seven fields.
一个greasemonkey的ajax调用
PLAIN TEXT
CODE:

GM_xmlhttpRequest({

    method: 'GET',

    url: 'http://greaseblog.blogspot.com/atom.xml',

    headers: {

        'User-agent': 'Mozilla/4.0 (compatible)

Greasemonkey',

        'Accept':

 

'application/atom+xml,application/xml,text/xml',

    },

    onload: function(responseDetails) {

        alert('Request for Atom feed [...]

评论

参加中国网络侠客行工程师大会

今天在杭州参加阿里巴巴举办的中国网络侠客行工程师大会,首日上午有php创始人Rasmus Lerdorf以及牛人Jeremy Zawodny,议题是PHP on hormones和Web Service APIs: From Mashups to new Businesses。
下午继续听了Rasmus Lerdorf的Performance and Security,他这次用cachegrind来做后端模块的性能分析,php方面直接使用xdebug+kcachegrind,这个组合相当之好,只可惜cachegrind一直没有freebsd下的版本,比较不爽。这期间因为语言不通,听的很累,同声翻译不是专业人士,翻译的也让人是很难受,好在幻灯早就看过,和最早的getting rich from php5很相似,有一些了解。
BTW:与会的学生那是相当之多:)

评论 (6)