没事看看开源的项目,也能有些收获。比如有些模块几乎是所有项目都要用到的,如反SQL注入处理等。

今天看EasyTalk的源码,这是他们的处理方式,可以参考一下

//addslashes() 函数在指定的预定义字符前添加反斜杠
function daddslashes($string) {
    $string=str_replace(”‘”,’”‘,$string);
    !defined(’MAGIC_QUOTES_GPC’) && define(’MAGIC_QUOTES_GPC’, get_magic_quotes_gpc());
    if(!MAGIC_QUOTES_GPC) {
        if(is_array($string)) {
            foreach($string as $key => $val) {
                $string[$key] = daddslashes($val);
            }
        } else {
            $string = addslashes($string);
        }
    }
 return $string;
}

其实就是addslashes转义’ 引号。此外,htmlspecialchar经常被用来防止用户输入恶意script脚本

Posted in 未分类 at 07月 15th, 2009. No Comments.

nginx+php_ini模式下,安装Zend和apache下差不多,下载Zend合适的版本,解压, ./install.sh 选择php_cgi的php.ini所在的目录,有一点需要注意的,是服务器不要选apache,一路next。完毕!

Posted in 未分类 at 01月 17th, 2009. No Comments.

$mbox  = imap_open(…);

$MC = imap_check($mbox);

die(var_dump($MC->Nmsgs));

 

// Fetch an overview for all messages in INBOX

$result = imap_fetch_overview($mbox,”1:{$MC->Nmsgs}”,0);

foreach ($result as $overview) {

   echo “#{$overview->msgno} ({$overview->date}) - From: {$overview->from}

   {$overview->subject}\n”;

}

imap_close($mbox);
这是一段常用的代码,在我这去不工作 ,imap_check可以,但是imap_fetch_overview不可以。郁闷,算了,绕道!

Posted in 未分类 at 12月 13th, 2008. No Comments.

imap,一个类似pop3,优于pop3的东东。

简单记录一下安装过程

1. 下载imap_2007 (ftp.cac.washington.edu 可以下载到)

2. tar -zxf imap-xxxxx.tar.Z

cd imap-xxxxx
make slx
ln -sf c-client include
ln -sf c-client lib
进入php安装程序目录
./configure –with-openssl=/usr/local/ssl –with-imap-ssl=/usr/local/ssl –with-imap=../imap-xxxxx  (imap路径可以自己换)

注意,没有 enable ssl,编译不会报错,但是,执行php函数时,可能会导致一个 remote什么的错误

有些机器编译时,还会出现一个ext/imap/.libs/php_imap.o(.text+0×2b8d): In function `zif_imap_expunge’:

: undefined reference to `mail_expunge_full’的错误。

解决方法:在php安装目录找到 ext/imap/php_imap.c 增加以下代码
long mail_expunge_full (MAILSTREAM *stream,char *sequence,long options)
{
                    /* do the driver’s action */
return stream->dtb ? (*stream->dtb->expunge) (stream,sequence,options) : NIL;
}
重新编译即可。
Posted in 未分类 at 12月 12th, 2008. No Comments.